Skip to content

Type-Check the Carried hub_fetch_run.py Strictly in the Hub - #4280

Merged
ptr727 merged 4 commits into
developfrom
fix/4266-hub-fetch-run-strict-types
Nov 19, 2026
Merged

ptr727 merged 4 commits into
developfrom
fix/4266-hub-fetch-run-strict-types

Conversation

@ptr727

@ptr727 ptr727 commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

Refs #4266.

Every fleet repository carries catalog/snippets/hub_fetch_run.py at its root, where a carrier's own strict type checker can reach it and the carrier may not edit it. mypy --strict failed it with no-any-return, because typeshed types urlopen(...).read() as Any. That body is now annotated as bytes.

The hub now gates the snippet with the real strict checkers:

  • A Type-check the carried hub_fetch_run.py strictly step in the hub's validate action runs mypy --strict with no config, and pyright, on the snippet. Neither hub type check reached catalog/ before. The root's Python leg runs only mypy, never pyright, since its mypy section outranks pyright.
  • A # pyright: strict line in the snippet keeps pyright strict wherever the file is checked, the step and every carrier included.

A per-module strict = true mypy override was tried first. It made every hub module strict, with 4,167 errors.

Verification

  • mypy --strict and strict pyright on the snippet pass. With the old line restored, mypy fails at hub_fetch_run.py:90. With an unannotated-parameter probe, strict pyright fails, with no config entry.
  • tests/test_hub_fetch_run.py, plus test_cli_usage, test_python_directories, test_pre_commit_hook, test_release_guards, test_prose_lint, and test_audit_helpers, all pass.
  • The hub's own mypy reports no issues.

Local strict review

Three passes before the opening push. Round 1 replaced a hand-copied mypy flag list with the step. Round 2 moved pyright's strictness into the file. Round 3 raised the finding below, after the edit budget for this push was spent.

Introduced findings, fixed in this pull request

  • .github/actions/validate/action.yml, introduced: the step checked the snippet as Linux only. Fixed in f19e7ac, which runs both checkers as Linux, macOS, and Windows code. An unguarded os.killpg(pid, signal.SIGKILL) probe passed on Linux and Darwin and failed both checkers on win32. A fourth local pass over the fix raised nothing.

The pull request carries the comments label for the one pragma line.

🤖 Generated with Claude Code

ptr727 and others added 3 commits November 19, 2026 07:19
`resolve_main_commit` returned the decoded `urlopen` body, which typeshed types as Any. So `mypy --strict` failed the root copy every carrier holds and may not edit. The body is now annotated as bytes.

The hub's own mypy and pyright configs now include the snippet and check it strictly, so a regression fails here first. A per-module `strict = true` makes every module strict, so the override names the per-module flags `--strict` enables. `warn_redundant_casts` is global-only and is left out.

Closes #4266

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The local review found two gaps. The mypy override hand-copied the flags `--strict` enables, so it drifted whenever mypy added one. And no hub gate ran pyright, which the root's mypy section always outranks. So a pyright-strict-only regression merged green.

The hub's validate action now runs `mypy --strict` with no config and pyright on the snippet, and pyright reads the strict entry. The override and the mypy `files` entry are gone, since the step covers them.

Refs #4266

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The second local review found that the step's pyright run was strict only through a `pyproject.toml` entry nothing tied to the step. A root `pyrightconfig.json` would also have displaced that entry. A `# pyright: strict` line in the snippet keeps the mode with the file, in the hub's step and in every carrier's own pyright run. So the `pyproject.toml` changes are reverted.

Refs #4266

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings November 19, 2026 15:33
@ptr727 ptr727 added the comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses label Nov 19, 2026
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@ptr727

ptr727 commented Nov 19, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 1207bfd786e85d3f4c573340d45350a117dec601, the content this pull request carries at that commit against develop, and it recorded 1 finding.

The step checked the snippet as Linux only, while carriers check it on Windows and macOS hosts too. An unguarded `os.killpg(pid, signal.SIGKILL)` probe passed both checkers on Linux and Darwin. It failed them only on win32, so the old step would have let it reach a carrier's Windows checker. Each checker now runs once per platform.

Refs #4266

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The validation hook still runs only on Linux, leaving platform-specific type and import issues on supported Windows and macOS runners unchecked.

1 open issue
What changed in this PR

This pull request makes the carried hub_fetch_run.py pass strict type checking and adds hub validation to prevent regressions.

Changes:

  • Annotates the HTTP response body as bytes for strict mypy compatibility.
  • Enables strict pyright checking within the carried helper.
  • Adds strict mypy and pyright checks to the hub validation action.
  • The validation currently runs only on Linux, leaving Windows and macOS platform-specific behavior unchecked.
File Description
catalog/​snippets/​hub_fetch_run.py Adds strict pyright mode and explicitly annotates the fetched response body as bytes.
.github/​actions/​validate/​action.yml Adds strict mypy and pyright validation for the carried helper, currently running only on Ubuntu.

Review effort: Lite

Comment thread .github/actions/validate/action.yml Resolved
@ptr727

ptr727 commented Nov 19, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head f19e7ac8442542c9bf0fcb28968354565467578a, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.21%. Comparing base (5d07823) to head (f19e7ac).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4280   +/-   ##
========================================
  Coverage    79.21%   79.21%           
========================================
  Files           42       42           
  Lines        15502    15502           
========================================
  Hits         12280    12280           
  Misses        3222     3222           
Flag Coverage Δ
python-3.13 79.21% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ptr727

ptr727 commented Nov 19, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@ptr727

ptr727 commented Nov 19, 2026

Copy link
Copy Markdown
Owner Author

/review

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Action not completed

Pull request is closed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ptr727
ptr727 merged commit 5a58f67 into develop Nov 19, 2026
13 checks passed
@ptr727
ptr727 deleted the fix/4266-hub-fetch-run-strict-types branch November 19, 2026 15:56
ptr727 added a commit that referenced this pull request Nov 19, 2026
…n secrets_sync Tests as Root (#4282)

## Summary

Promotes `develop` to `main`. It carries these changes:

- [#4280](#4280) makes the
carried `hub_fetch_run.py` pass every carrier's strict checker.
- **The fix.** The `urlopen` body is annotated as `bytes`, which clears
`mypy --strict`'s `no-any-return`. Every carrier holds this file at its
root and may not edit it.
- **The gate.** The hub's validate action now runs `mypy --strict` with
no config, and pyright, on the snippet, once each as Linux, macOS, and
Windows code. A `# pyright: strict` line keeps pyright strict wherever
the file is checked.
- [#4281](#4281) keeps
`tests/test_secrets_sync.py` meaningful under a root runner. Root used
to give 170 failures and 1 error. Under root the base case now stubs the
script's root refusal, the refusal case restores it, and the interrupt
driver stubs it too. Only the mode-000 listing case skips, through a
shared `RUNNING_AS_ROOT` in `tests/host_capability.py`.

Closes #4266
Closes #4262

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Tests**
* Test coverage now accounts for root-level environments, including
cases where root access changes how filesystem permissions behave.
* Root-refusal behavior remains explicitly covered, and interruption
scenarios are less affected by root restrictions.
* **Chores**
* Automated validation now checks Python types across Linux, macOS, and
Windows.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
ptr727 added a commit that referenced this pull request Nov 20, 2026
## Summary

`pr_review.py merge` could land a pull request in the gap after a hosted
reviewer was asked and before its check registered. Until the check
registers the rollup holds nothing of the review, so a head whose other
checks have passed reads ready. This adds the registration grace the
maintainer chose on #3814 and refined on #3806: option 1, anchored on
the head's push, its last check settling, and its newest review ask,
with G = 90s.

- **Settle stamp.** `check_nodes` now records when each check settled.
For a CheckRun that is `completedAt`, which the held query now reads.
For a StatusContext it is `createdAt` once the context is no longer
pending.
- **The grace.** `pr_review_hold.hosted_grace` anchors on the latest of
three things: the head's push (its earliest suite or check), its last
non-hosted check settling, and its newest trusted review ask
(`@coderabbitai review`, `@coderabbitai full review`, or `/review` from
an owner, member, or collaborator). It runs `HOSTED_GRACE` = 90 seconds
from that anchor.
- A hosted reviewer's own check, Copilot's included, is left out of the
settling, so a finished review never restarts the window.
- The grace ends early once a CodeRabbit or Qodo check that did not
conclude `SKIPPED` and that began at or after the newest ask is on the
head. From then on, that check's existing hold decides. A check older
than the ask answered an earlier request, so a re-ask still waits for
its own check. A `SKIPPED` check is CodeRabbit's "automatic reviews are
disabled" placeholder, which every head here carries about 10s after the
push.
- **wait.** On an attested head, the held poll judges the grace only
after `wait` sends its after-checks asks. Where it sent one, it reads
the pull request again, because the ask moves the anchor. The
`CHECKS_PENDING` line adds `(registration grace until: <time>)`. A
`wait` that returns `0` with no hosted check on the head prints a note.
The note says either that the grace released the merge without a hosted
check, or, on a head no local pass covers, that the grace still holds
and `merge` refuses until it ends.
- **merge.** The fresh read's `unmet` refuses an open grace as
`CHECKS_PENDING`, on a line of its own that names when the grace ends.
This is separate from the "a hosted review of the head is running" line.
- **Layout.** `pr_review.py` was at 2198 of its 2200-line ceiling,
`pr_review_checks.py` at 449 of 450, and `pr_review_side.py` at 347 of
350. So the grace, its note, and the `CHECKS_PENDING` line builder (with
`_unmet_note`) live in a new pure reader, `scripts/pr_review_hold.py`,
which has a 200-line ceiling.
- The pure helpers `side_command`, `side_asks`, `head_arrived`, and
`hosted_check` moved there from `pr_review_side.py`, which imports them
back.
- The new module is listed among the readers in the import contract
test.
  - No ceiling was raised.
- **Accepted trade-off.** The grace is judged apart from
`held_checks_open`'s stuck-check read. So on an attested head, a
`BLOCKED` merge with a required check stuck reports `30` for at most the
grace's 90 seconds before `44`. `scripts/README.md` says so in the
`wait` paragraph and on the `44` exit row.

## Measurement

Read-only reads of the 150 most recently updated merged pull requests in
this repository (#4038 to #4300):

- CodeRabbit posts a `SKIPPED` "Review skipped: automatic reviews are
disabled" check on every head, about 10s after the push (p90 30s). Its
check for an actual review appears only after an ask. 89 heads carried
such a run: 26 finished, 50 rate limited (an instant neutral), and 13
cancelled. Qodo posts no check in this repository.
- **Ask to registration:** 10 to 33s across all 89 asked runs, mostly 12
to 17s.
- **Later of push and last non-hosted check settling, to registration:**
3 to 146s on 86 heads (p50 91s, p90 133s). The other 3 were 278s, 1566s,
and 1963s, where a later `wait` sent the ask minutes after the checks
settled. That is why the anchor includes the ask.
- **The failure, measured:** 7 merges landed 1 to 6s before CodeRabbit's
run registered (#4280, #4281, #4244, #4130, #4129, #4105, #4109). Each
run was then cancelled with "Pull request is closed", and each merge
came 10 to 20s after the ask.
- **Chosen value:** `HOSTED_GRACE` = 90s, about 2.7 times the largest
measured delay from ask to registration. On a head nobody asks a hosted
reviewer to review, the fixed cost is 90s after the checks settle.

## Verification

- `python -m unittest discover -s tests`: see the CI run. Locally,
`tests/test_pr_*.py` (979 tests) and `tests/test_backlog*.py` pass, the
size ceiling test included.
- New cases in `TestRegistrationGrace` cover:
- the anchor's three sources, with an untrusted ask and a hosted
conclusion moving nothing;
  - a `SKIPPED` check versus any other hosted conclusion;
  - a StatusContext's settle stamp;
  - the open and released notes;
  - the `CHECKS_PENDING` line;
  - `merge`'s separate refusal line.
- `TestCli` cases cover the hold and its release on a held head, and the
extra read after a sent ask, which happens only when an ask was sent.
Three existing `wait` fixtures now date their head past the grace.
- ruff format, ruff check, mypy, and the prose gate are clean. The full
`unittest discover -s tests` run passed locally on the first commit
(4559 tests).

## Local review

There were three recorded `local-strict-review` passes. The first raised
seven findings and the second raised two, and both rounds' fixes are in
this branch. The third raised none. The declined findings are these:

- **Grace ignores the review policy** (`introduced`, declined). On #3814
the maintainer chose a grace that reads no reviewer configuration, with
its fixed, bounded delay accepted. A policy can also understate a
reviewer that is installed, and reading it would then drop the hold.
- **`ASK_BODIES` repeats `pr_review_policy.COMMANDS`** (`introduced`,
declined). `pr_review_policy` imports `subprocess`, which the reader
contract test forbids a pure reader to load.
- **`stamp()` repeats the formatter in `secrets_sync.py`**
(`introduced`, declined). The same reader contract rules that import
out.
- **Skill drift** (`introduced`, reported to the backlog-burndown
orchestrator, outside this pull request's files). Two skills still
describe the old refusal:
- `.agents/skills/pr-review-conduct/SKILL.md` "Merge Gate" item 2 names
only a running hosted check as a `CHECKS_PENDING` refusal.
- `.agents/skills/drive-pr/SKILL.md` step 4 `next=redrive` says a
`CHECKS_PENDING` refusal clears by `gh pr checks --watch`, which returns
at once for a grace refusal.

  The refusal line itself now names the time to run `merge` again.

Closes on promotion: #3806

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants