Skip to content

Promote Develop to Main: Strict-Check the Carried Fetch Helper and Run secrets_sync Tests as Root - #4282

Merged
ptr727 merged 2 commits into
mainfrom
develop
Nov 19, 2026
Merged

ptr727 merged 2 commits into
mainfrom
develop

Conversation

@ptr727

@ptr727 ptr727 commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

Promotes develop to main. It carries these changes:

  • #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 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

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.

ptr727 and others added 2 commits November 19, 2026 07:50
## Summary

Refs #4262.

`scripts/secrets_sync.py` refuses root before any call. So under a root
test runner almost every case in `tests/test_secrets_sync.py` failed at
that refusal: 170 failures and 1 error in a root container.

- Under real root, the base case patches `refuse_root` to a no-op rather
than faking the euid. The euid stays 0, consistent with the owner of the
files the runner creates, so the ownership check reads them as owned.
- `test_root_is_refused_before_any_call` restores the real function and
runs as root.
- The interrupt cases' subprocess driver stubs `refuse_root` as it
already stubs `ask`.
- A shared `RUNNING_AS_ROOT` in `tests/host_capability.py` skips the one
case root genuinely changes: root lists a mode-000 directory.

## Verification

In `python:3.13-slim`, with a copy of the tree:

- As uid 0: 163 tests OK, 1 skipped, with both interrupt cases running.
On `develop`: 170 failures, 1 error.
- As uid 1234: OK.
- The root-refusal case fails as root when the real function is not
restored.

On this host as a normal user: OK. No stub process survived.

## Local strict review

Three passes. Round 1 replaced a faked euid, which caused 11 avoidable
skips, with the `refuse_root` stub and a shared predicate. Round 2 moved
the interrupt cases onto the same stub. Round 3 raised nothing.

### Dropped findings

- Inline euid-0 predicates in `tests/test_restore_secrets.py`,
`test_secrets_sh.py`, `test_install_agents.py`,
`test_skills_install.py`, `test_bootstrap.py`, and `test_build_dist.py`,
`consolidation` on text this change did not touch. `RUNNING_AS_ROOT` is
the primitive they can move onto.

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
## 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](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings November 19, 2026 15:56
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

This PR adds strict CI type-checking for catalog/snippets/hub_fetch_run.py, makes a small typing change in that script, and updates secrets_sync test support and cases so the test module behaves correctly when the test runner runs as root.

Changes: hub_fetch_run strict type-checking

Layer / File(s) Summary
Strict checker coverage and script typing
catalog/snippets/hub_fetch_run.py, .github/actions/validate/action.yml
hub_fetch_run.py now enables Pyright strict mode and uses a typed bytes local before decoding the commit response. The validate action description now mentions this check, and CI runs mypy --strict and pyright for Python 3.13 on Linux, macOS, and Windows for that script.

secrets_sync root-runner test handling

Layer / File(s) Summary
Root detection and default test patching
tests/host_capability.py, tests/test_secrets_sync.py
tests/host_capability.py adds RUNNING_AS_ROOT. tests/test_secrets_sync.py imports it, saves the real ss.refuse_root as REAL_REFUSE_ROOT, and patches ss.refuse_root to a no-op in Case.setUp when the runner is root.
Case-specific root behavior coverage
tests/test_secrets_sync.py
One dry-run test stops forcing a non-root geteuid override. The root-refusal test restores the real ss.refuse_root while forcing geteuid() to 0. The unlistable-directory push test now skips under root. The interrupt-test subprocess driver also overrides module.refuse_root to a no-op.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Severity of issue fixed: Low

Possibly related issues

Merge Risk: Minimal · up to 5a58f

This change adds strict type-checking coverage for the carried fetch helper and makes the secrets sync tests work when run as root. No production behavior changes are expected, and no merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names two changes: the strict type check of the carried hub_fetch_run.py helper and the secrets_sync tests run as root. Both appear in the changeset summaries and the PR objectives. The phra…
Linked Issues check Passed Stack objectives, assessed from the current PR (#4282) with stack member #4283 not credited (uncertain, no review evidence).

**Objective A [#4266]: catalog/snippets/hub_fetch_run.py passes `mypy --…
Out of Scope Changes check Passed The PR changes four files, and each supports an objective of #4266 or #4262:
- catalog/snippets/hub_fetch_run.py: bytes annotation and # pyright: strict directive for #4266 objective A.
- `.gith…
Full details: Title check

Explanation

The title names two changes: the strict type check of the carried hub_fetch_run.py helper and the secrets_sync tests run as root. Both appear in the changeset summaries and the PR objectives. The phrase 'Promote Develop to Main' describes the branch promotion, which the objectives also state. The title is specific and matches the main changes, though it is long at 97 characters.

Full details: Linked Issues check

Explanation

Stack objectives, assessed from the current PR (#4282) with stack member #4283 not credited (uncertain, no review evidence).

Objective A [#4266]: catalog/snippets/hub_fetch_run.py passes mypy --strict and strict pyright. Addressed (PR #4282). Verified at head: resolve_main_commit reads the urlopen body into body: bytes before decoding, which addresses the no-any-return error named in #4266. The file starts with # pyright: strict. Behavior of commit resolution and fallback is unchanged.

Objective B [#4266]: the hub gates the check so regressions fail in the hub. Addressed (PR #4282). Verified at head: .github/actions/validate/action.yml adds the step 'Type-check the carried hub_fetch_run.py strictly'. It runs mypy --strict --python-version 3.13 --config-file= and pyright --pythonversion 3.13 on the snippet for Linux, Darwin, and Windows platforms, under set -Eeuo pipefail. This is the alternative the issue allowed, and the PR chose the check-the-snippet option.

Objective C [#4262]: tests/test_secrets_sync.py stays meaningful under a root runner. Addressed (PR #4282). Supported by the attested change summary and the PR description, not by a direct diff read (blob diffs were unavailable). The summary reports: Case.setUp stubs ss.refuse_root when RUNNING_AS_ROOT; the root-refusal test restores REAL_REFUSE_ROOT while forcing geteuid to 0; the interrupt driver stubs refuse_root; only the mode-000 listing push test skips under root. RUNNING_AS_ROOT is defined in tests/host_capability.py. The author reports 163 passed and 1 skipped under root, and the suite passes as uid 1234 and as a normal user. The approach differs from the issue's proposed os.geteuid stub for all cases, but it keeps the root-refusal case running as root, as the issue requires.

No unrelated stack work is required for these objectives. The fix for objective A and the gate for objective B are present at the reviewed head.

Full details: Out of Scope Changes check

Explanation

The PR changes four files, and each supports an objective of #4266 or #4262:

  • catalog/snippets/hub_fetch_run.py: bytes annotation and # pyright: strict directive for #4266 objective A.
  • .github/actions/validate/action.yml: new strict type-check step and description update for #4266 objective B.
  • tests/host_capability.py: new RUNNING_AS_ROOT constant for #4262.
  • tests/test_secrets_sync.py: root-aware stubbing, restored root-refusal case, and mode-000 skip for #4262.

No change was found that is unconnected to the linked issues. The tests/test_secrets_sync.py change was assessed from its attested summary, since diff blobs were unavailable. This does not change the verdict, because the summary describes changes that map directly to #4262.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6199c6c and 5a58f67.

Files selected for processing: 4

  • .github/actions/validate/action.yml
  • catalog/snippets/hub_fetch_run.py
  • tests/host_capability.py
  • tests/test_secrets_sync.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

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.

🟢 Approval recommended

No active review issues remain, and the changes include strict cross-platform type validation plus targeted root-aware test adjustments.

No open issues 🎉

What changed in this PR

This promotion hardens the carried fetch helper with strict type validation and keeps secrets_sync tests meaningful when executed as root.

Changes:

  • Adds strict mypy and pyright checks for Linux, macOS, and Windows targets.
  • Annotates the fetched response body and enables strict pyright checking in the carried helper.
  • Adapts root-sensitive tests while preserving root-refusal coverage and skipping the root-incompatible permission case.
File Description
tests/​test_secrets_sync.py Adapts test setup and interrupt coverage for root execution while preserving root-specific assertions.
tests/​host_capability.py Adds the shared root-detection capability used by the tests.
catalog/​snippets/​hub_fetch_run.py Enables strict pyright checking and annotates the HTTP response body as bytes.
.github/​actions/​validate/​action.yml Adds cross-platform strict mypy and pyright validation for the carried helper.

Review effort: Lite

@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 (5a58f67).
⚠️ Report is 511 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4282   +/-   ##
=======================================
  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 performed

Review finished.

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 aa8e40d into main Nov 19, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type-Check the Carried hub_fetch_run.py So It Passes a Carrier's Strict Checker Keep the secrets_sync Tests Meaningful Under a Root Test Runner

2 participants