Skip to content

ci: wider PR checks (Windows units on PR, blast-radius slice, lazy CLI imports, linter cache, shard file lists, mutation floors, receipts gate) - #4150

Merged
Daniel Meppiel (danielmeppiel) merged 76 commits into
mainfrom
p1-ci-topology
Nov 21, 2026

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Integration PR for the 0.37.0 "P1: CI topology" stream. Widens PR checks and makes them cheaper:

Worker lanes land on this branch as merge commits; status per lane is tracked below and updated as they merge.

Lane Issue Branch Status
P-2 #4115 p1-windows-units-on-pr pending
P-4 #4117 p1-blast-radius pending
P-5a #4118 p1-lazy-cli-imports pending
P-5b #4119 p1-linter-cache pending
P-5c #4120 p1-shard-file-lists pending
P-6 #4121 p1-mutation-floors pending
P-7 #4122 p1-receipts-gate separate PR after T1

Session-cache gating (not a timing ratio)

The architecture-linter session cache (#4119) is gated by deterministic checks only:

  • tests/integration/test_architecture_linter_session_cache.py covers parse-once (each (path, content) built once, one tree walk, cached mutated runs still fail) and cached-vs-cold byte-equal findings. It runs in Integration Tests (Linux) (ci-integration.yml, integration-tests-shard). That job is required by merge-gate.yml on merge_group and on full-integration-labeled PRs, and it also runs in the main and nightly integration lanes.
  • The linter rules contracts-tooling-linter-cache-content-key and contracts-tooling-linter-cache-parse-once run in scripts/lint_architecture_boundaries.py (ci.yml Lint job, every PR). Their teeth are proven by MutationCase entries in test_architecture_owner_rule_mutations.py.
  • The full-matrix cached-vs-cold byte-equality replay (test_session_cache_findings_match_uncached_runs_full_matrix, ~15 min) runs on demand with PYTEST_PERF=1 -m benchmark. CI keeps the full-matrix parse-once guard and the per-group byte-equality sample.
  • The 2.2x wall-clock ratio (test_session_cached_mutation_matrix_scales_within_2_2x_from_n_to_2n) is not in CI. It is non-gating by owner ruling and runs locally with PYTEST_PERF=1 -m benchmark.

Issue and approved scope

Issue:
Fixes #4115
Refs #4117 (blast-radius slice follows in its own PR)
Fixes #4118
Fixes #4119
Fixes #4120
Refs #4121 (mutation floors follow in their own PR)

Human scope-approval comments:

Does this PR complete the issue, or what remains? Completes #4115 #4117 #4118 #4119 #4120 #4121 once every lane is merged; #4122 ships in its own PR after T1. Out of scope (per records): removing Windows units from main push, merge queue (#4116, separate PR), test deletion/moves, rule-semantics changes, ruleset changes, obligation set / cells.json changes.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Red-before / green-after evidence per guard, collect-only diffs, import counts, linter cache diff, kill-rate table and negative controls are added here as lanes merge.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md:
    user-visible effect first, 25 words or fewer, ending with (#PR);
    breaking changes only under upgrade notes; no Highlights; see
    .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json} regenerated
  • N/A -- this PR does not change OpenAPM-observable behaviour.

apm-spec-waiver: deps/init.py PEP 562 lazy exports are a startup perf rewrite with identical public names and no observable behaviour delta (#4118)

Integration branch for issues #4115 #4117 #4118 #4119 #4120 #4121 #4122.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
The PR Windows Compatibility Gate ran only `-m windows_compat` while
main push ran the full Windows unit suite, so Windows-only unit
regressions reached main (11 of 21 red main pushes, 2026-11-05..19).

- scripts/ci_selections.py owns the Windows unit selection (new
  architecture owner ci-validation-topology); the PR gate shards and
  the build-release push/full Windows unit steps all run it.
- Each of the 3 gate shards runs its unit slice (-n 4, windows-unit
  seed) then its windows_compat integration slice; the aggregate check
  name and fail-closed aggregation are unchanged.
- Guard: tests/quality/test_ci_topology.py::
  test_pr_windows_gate_runs_every_windows_unit_node (red on main) plus
  drift mutations; lexical rule contracts-tooling-ci-validation-topology
  with its own MutationCase; bug-ledger row (PERF-H2).

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…led-CLI import budget (#4118)

apm --help imported every command module and GitPython (767 modules,
37 git modules, ~440 ms). Every root verb now registers as a _LazyCommand
stub carrying its exact summary source, and apm_cli.deps resolves its
public names lazily (PEP 562), so --help imports 332 modules and no
GitPython. Help output and exit codes are byte-identical for apm --help
and all 87 subcommand --help invocations.

New owner cli-startup-import-budget: installed-CLI -X importtime guard
(count budget + must-not-import list), static rule
registry_delegation.cli_startup_imports, and one mutation case.
Bug-ledger row PERF-H5.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Resolve build-release.yml: the 3 Windows push shards (#4032) run
through scripts/ci_selections.py; recompute the tests.instructions.md
lock hash; reuse RELEASE_WORKFLOW in test_ci_topology.py.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…4119)

LinterSession reuses one inventory walk, one owner-registry validation and
one parse per (path, content sha256, linter-source sha256, collectors)
across run_selected_rules calls inside linter_session(); per-case
source_overrides apply on top. Outside a session every run gets a private
session, so single runs are unchanged.

New owner architecture-linter-performance with two closed-world guards
(content key, parse once), one MutationCase each, plus runtime guards:
byte-equal findings cached vs cold (always-on per-group sample, full
matrix under benchmark in the nightly lane) and a parse-once counter over
the full matrix. N vs 2N ratio added to Architecture Scaling.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…#4118)

apm --version still seeds config.json through the experimental-flag read;
strict xfail until H3 lands the pure read.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…ts; drift guard

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
USER_ROOT_ROUTING_MUTATIONS repeats guard ids, so the full-matrix byte-equal
guard compared cases against another case's cold report.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…terally (#4118)

cli.py stays selected by process-interrupt-signals; the
cli-startup-import-budget rule reads it by path. A literal __all__ lets
ruff see the TYPE_CHECKING re-exports.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…dius slice, lazy CLI imports, linter cache, shard file lists, mutation floors, receipts gate)

Co-authored-by: Copilot App <[email protected]>
…nder signal

- Drop the session-cache 2.2x wall-clock ratio from the Architecture Scaling
  job: timing asserts flake (2.83x on a busy runner); the deterministic
  parse-once guard gates the cache, per the owner ruling.
- AQ003: the parse-once guard asserts each cached mutated run still fails;
  the startup budget helper is an assertion helper; the ratio benchmark
  asserts its commands succeed.
- Lifecycle concurrency: lazy CLI imports no longer spawn git version at
  startup, so the contender's start is now its own lock acquire (engine) or
  its first git call once the holder is parked (binary).

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…dius slice, lazy CLI imports, linter cache, shard file lists, mutation floors, receipts gate)

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
cli.py defined its lazy _check_and_notify_updates wrapper, so tests that
patch apm_cli.cli._check_and_notify_updates patched an owner they import
(AQ004). The wrapper now lives in apm_cli/update_notice.py; cli.py imports
it under the same name, so the patch target and startup budget are kept.

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…dius slice, lazy CLI imports, linter cache, shard file lists, mutation floors, receipts gate)

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
… shards

CI's integration lanes pass an explicit -m expression, which overrides the
default benchmark deselection, so the ~15-minute full-matrix replay ran in a
25-minute shard and timed it out. Gate it on PYTEST_PERF=1; the per-group
transparency sample and the full-matrix parse-once guard stay always-on.

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…dius slice, lazy CLI imports, linter cache, shard file lists, mutation floors, receipts gate)

Co-authored-by: Copilot App <[email protected]>
The PYTEST_PERF-gated full-matrix byte-equality replay now runs in its own
job in lifecycle-journeys.yml (nightly cron and ref dispatch), and the
tracking-issue signal waits for it. test_ci_topology pins the job, its env,
its node and the signal dependency.

Co-authored-by: Copilot App <[email protected]>
…st fails

Diagnostic for an order-dependent CI-only failure; the oracle is unchanged.

Co-authored-by: Copilot App <[email protected]>
…e ref resolver

GitHubPackageDownloader imports git_reference_resolver on first construction.
With lazy CLI imports and per-shard file lists, that first import can happen
inside test_install_pipeline_orchestration_logic's patch of
apm_cli.utils.github_host.is_github_hostname (return_value=False), so the
resolver keeps the mock for the rest of the xdist worker and later tests see
github.com as a generic host. Load the resolver at module import instead.
Reverts the temporary diagnostic in test_list_remote_refs_io.

Co-authored-by: Copilot App <[email protected]>
A session-finish hook (xdist workers report to the controller) names every
apm_cli module global that is a unittest.mock object: a patch at a source
module captured by a module first imported inside it. The preflight polluter
now pre-imports the whole lazily imported downloader stack.

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…dius slice, lazy CLI imports, linter cache, shard file lists, mutation floors, receipts gate)

Co-authored-by: Copilot App <[email protected]>

# Conflicts:
#	tests/quality/test_ci_topology.py
H3's experimental-flag pure read landed on main, so the strict xfail turned
into XPASS on the merged tree.

Co-authored-by: Copilot App <[email protected]>
…start

The lazy CLI imports each verb (and the downloader, plugin-phase, marketplace
and policy modules) on first use, so a test that patched a source module and
then exercised one left the consumer bound to the mock for the worker. Load
them once at session start; the session-finish check fails on any new case.
Replaces the per-file pre-import in the preflight test.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 16c39c6 into main Nov 21, 2026
3 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the p1-ci-topology branch November 21, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-integration Run the full integration suite (ci-integration.yml) on this PR before merge

Projects

None yet

2 participants