Skip to content

ci: make the merge queue the live merge-time gate (#4116) - #4149

Merged
Daniel Meppiel (danielmeppiel) merged 16 commits into
mainfrom
danielmeppiel-fantastic-robot
Nov 20, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 16 commits into
mainfrom
danielmeppiel-fantastic-robot

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

The main ruleset declares a merge queue, and ci.yml, ci-integration.yml and merge-gate.yml describe merge_group as the merge-time gate: full integration, binary build, release validation and the global 80% coverage floor. In practice no merge_group run has happened since 2026-09-09 (last run). Nothing failed, so regressions outside lifecycle smoke surfaced only in the 04:00 UTC nightly, and the coverage floor gated no merge.

This PR does the in-repo side. A maintainer applies the ruleset change after it lands green (remove the admin bypass, merge_method: MERGE).

  • ci-integration.yml:
    • Hermetic integration is sharded by the build-release planner (scripts/ci_sharding.py, nightly durations or the committed seed). It replaces the fixed --splits 4 layout. Those durations are measured without --cov, and coverage slows the in-process tests/integration/test_architecture* suites about 3x, so their weights are tripled before planning (merge-queue.json, --shard-target-seconds 300 --shard-max 16, which gives 16 shards).
    • Network tests run in their own retrying lane, as in build-release.yml. Both lanes reuse the build-release HERMETIC_MARK_EXPR / NETWORK_MARK_EXPR partition.
    • Release validation now runs in parallel with integration instead of after it.
    • workflow_dispatch and the full-integration PR label came from ci: allow manual dispatch of full integration #4177, merged here. Every job is label-gated, and pull_request_target / push stay forbidden by the topology guard and the architecture rule.
  • merge-gate.yml: the merge_group EXPECTED_CHECKS names are unchanged. A guard now proves each one is produced by exactly one merge_group job. The comments now describe the real gate, the guard and the new poll budget.
  • ci.yml: corrects four comments that said ci-integration.yml enforces the 80% floor. Coverage Combine (Linux) is the floor authority, and merge-gate.yml requires it on merge_group.
  • merge-queue-freshness.yml + scripts/merge_queue_freshness.py: a daily alarm (05:30 UTC, also dispatchable). It fails when main received commits but no merge_group run of ci-integration.yml completed in the last 3 days. The failure output names the last merge_group run (id, URL, date) and lists the main SHAs pushed since then. Against main today it fails and names run 34349326054, as intended. It turns green once the queue is enforced.
  • Owner ci-validation-topology (steward-approved) has two guards, each with its own MutationCase and frozen rule id:
    • contracts-tooling-ci-merge-time-topology
    • contracts-tooling-ci-merge-queue-freshness
  • Bug-ledger row for Make the merge queue the live merge-time gate with full integration and the coverage floor #4116 covering PERF-H1 and PERF-H9, plus docs (cicd.instructions.md, integration-testing.md) and one CHANGELOG line.

Merge-time wall clock, measured:

  • 8 shards (first dispatch, 44705559047): shard 1 hit the 20-min cap at 33%.
  • 12 shards (dispatch 44719321796): 24 min end to end, with shards at 10-17.5 min of test time. Coverage costs ~1.6x on top of the 3x architecture weighting.
  • 16 shards (this head): planned for ~16-18 min. The label run on this PR measures it.

Note: live-marked integration tests (26) no longer run at merge time, matching the build-release.yml lanes. auth-acceptance.yml owns live runs.

Issue and approved scope

Issue: Fixes #4116

Human scope-approval comment: #4116 (comment)

Does this PR complete the issue, or what remains? The in-repo side is complete. What remains belongs to the issue's done-when: after the maintainer applies the ruleset change, the first landing through the queue must produce a green merge_group run, and its link goes on #4116.

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 (main @ 27eb7b3, new guards only): uv run pytest tests/quality/test_ci_topology.py -k "merge_group or merge_time or merge_queue or global_coverage or pr_time" -> 7 failed, 15 passed, including test_merge_time_integration_uses_the_release_planner and test_merge_queue_freshness_alarm_is_scheduled.

Green after (merged with main @ 74a9dd6):

  • uv run pytest -n 4 tests/quality/test_ci_topology.py tests/quality/test_lifecycle_bug_ledger.py tests/unit/scripts/test_merge_queue_freshness.py tests/unit/scripts/test_architecture_runner.py tests/unit/test_windows_compat_gate_workflow.py tests/unit/test_security_workflow_contracts.py tests/unit/test_push_ci_gates.py tests/unit/test_platform_contract_workflow.py tests/quality/test_test_taxonomy.py -> 468 passed
  • uv run pytest tests/integration/test_architecture_owner_rule_mutations.py tests/unit/scripts/test_architecture_runner.py -k "ci-merge or ci_merge or matrix or inventory or registered or case_order" -> 26 passed (both new mutation cases are caught by their rule)
  • Lint chain from ci.yml (ruff check, ruff format --check, complexity ratchet, pylint R0801, lint-auth-signals.sh, lint-architecture-boundaries.sh, file-length, relative_to): all pass
  • uv run apm audit --ci: 11/11 pass (deployed cicd.instructions.md hash updated)
  • REPOSITORY=microsoft/apm python3 scripts/merge_queue_freshness.py -> exit 1, names run 34349326054 and lists the main SHAs since then (expected while the queue is bypassed)
  • Local planner: --shard-target-seconds 420 --shard-workers 4 --shard-max 8 on .github/ci-durations/linux-x86_64.json -> 8 shards x 1675 s serial (~7 min each at 4 workers)

workflow_dispatch of ci-integration.yml: the latest is https://github.com/microsoft/apm/actions/runs/44719321796 (12 shards). Planner, build, smoke, release validation, scaling guards and the network lane are green; the shards are red only on main regressions present without this PR (this PR has no src/ changes), and those are routed to their owners. A green dispatch link goes here once main is green.

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: docs/src/content/docs/specs/openapm-v0.1.md updated
    (new/changed <a id="req-XXX"></a> anchor + prose + Appendix C
    row).
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml
    updated.
  • Test edit: a @pytest.mark.req("req-XXX") test under
    tests/spec_conformance/ added or extended.
  • CONFORMANCE.{md,json} regenerated via
    uv run --extra dev python -m tests.spec_conformance.gen_statement
    and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour.

- ci-integration.yml: build-release planner (scripts/ci_sharding.py, up to
  8 shards) for hermetic integration, a retrying network lane, release
  validation in parallel, and a workflow_dispatch rehearsal trigger.
- merge-gate.yml / ci.yml: correct the comments that describe the gate;
  ci.yml Coverage Combine stays the global 80% floor, required on
  merge_group.
- tests/quality/test_ci_topology.py: every merge_group EXPECTED_CHECKS name
  has exactly one merge_group producer; planner, trigger, floor and
  freshness guards with mutation tests.
- merge-queue-freshness.yml + scripts/merge_queue_freshness.py: daily alarm
  that fails when main moves without a merge_group run in 3 days.
- Owner ci-validation-topology with guards
  contracts-tooling-ci-merge-time-topology and
  contracts-tooling-ci-merge-queue-freshness, mutation cases, frozen ids.
- Ledger row #4116 (PERF-H1, PERF-H9); docs; changelog.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
Copilot AI balanced review requested due to automatic review settings November 20, 2026 08:48
Co-authored-by: copilot-swe-agent[bot] <[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

Critical gaps allow an always-false required producer to pass topology validation and skipped checks to pass the runtime gate, while architecture contract failures can leave the required gate successful because their aggregate is not required.

2 open issues
What changed in this PR

Updates APM’s in-repository merge-time validation for #4116. Repository ruleset enforcement remains a separate maintainer action.

Changes:

  • Uses duration-planned integration shards, a retrying network lane, parallel release validation, and manual rehearsal runs.
  • Adds a daily alarm for activity on main without recent merge-queue validation.
  • Adds topology guards and regression coverage, and clarifies the existing coverage-floor authority.
File Description
tests/​unit/​scripts/​test_merge_queue_freshness.py Tests freshness decisions and diagnostic output.
tests/​unit/​scripts/​test_architecture_runner.py Registers two new frozen rule identifiers.
tests/​quality/​test_ci_topology.py Adds merge-time topology and freshness contracts.
tests/​integration/​test_architecture_owner_rule_mutations.py Adds mutation cases for both guards.
tests/​fixtures/​lifecycle_bug_ledger.json Records #4116 and its regression checks.
scripts/​merge_queue_freshness.py Evaluates queue activity and reports stale validation.
scripts/​architecture_linter/​groups/​contracts_tests.py Includes the new topology rules.
scripts/​architecture_linter/​checks/​contracts_ci_topology.py Adds structural topology and freshness guards.
docs/​src/​content/​docs/​contributing/​integration-testing.md Documents integration lanes and coverage enforcement.
CHANGELOG.md Records the CI changes.
apm.lock.yaml Refreshes deployed CI instruction hashes.
.github/​workflows/​merge-queue-freshness.yml Schedules and exposes the freshness alarm.
.github/​workflows/​merge-gate.yml Updates comments explaining checks and polling budget.
.github/​workflows/​ci.yml Corrects comments about coverage authority and integration selection.
.github/​workflows/​ci-integration.yml Adds planned shards, network retries, parallel validation, and dispatch.
.github/​instructions/​cicd.instructions.md Updates deployed CI guidance.
.apm/​instructions/​cicd.instructions.md Updates canonical CI guidance.
.apm/​architecture/​owners/​contracts-tooling.json Declares topology ownership and its guards.

Review effort: Balanced

Comment thread tests/quality/test_ci_topology.py Resolved
Comment thread tests/quality/test_ci_topology.py Resolved
… shards

- ci-integration.yml: label-gated pull_request trigger on every job (from #4177); planner weights the in-process architecture suites 3x for --cov and plans up to 12 shards (target 300 s); shard cap 25 min.
- merge-gate.yml: three-context EXPECTED_CHECKS; poll budget 80 min.
- test_ci_topology.py and the merge-time-topology rule accept the label-gated pull_request trigger, still reject pull_request_target and push.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added the full-integration Run the full integration suite (ci-integration.yml) on this PR before merge label Nov 20, 2026
…gate additions)

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Measured on dispatch 44719321796: --cov costs ~1.6x beyond the 3x architecture weighting, so 12 shards ran 24 min end to end. 16 shards target ~16-18 min.

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

- test_ci_topology: a producer counts only with no condition, always(), the full-integration label gate, or always() && (label gate); ${{ false }} and unknown conditions are rejected (mutation test).
- merge-gate.yml: 'Test Architecture Ratchets' is required at PR time (labeled and unlabeled) and on merge_group, so the tests/quality guards, including the merge-time topology checks, block the merge.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
The steward keeps the wall-clock scaling ratio non-required (timing asserts flake). Test Architecture Ratchets now needs only test-architecture-contracts; Architecture Scaling (Linux) stays its own non-required check. test_ci_topology pins it, with negative controls for re-adding the scaling dependency or result and for requiring the scaling check.

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

# Conflicts:
#	tests/fixtures/lifecycle_bug_ledger.json
# Conflicts:
#	tests/fixtures/lifecycle_bug_ledger.json
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit a93076a into main Nov 20, 2026
29 of 50 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-fantastic-robot branch November 20, 2026 14:31
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
Accept #4149's test consolidation; the consolidated copies carry #4143 wording (catalog sentences, stderr errors, #4184 local installed=0, null-logger adapter warnings). Ledger rebuilt as main's rows plus #4143's.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
… audit details on their header's stream

Failed-check details follow their header to stderr, so two checks with the same detail no longer print it as consecutive duplicate stdout lines (I9). New tests assert through check/expect helpers; pure hint tests move to the unit module; the console test patches rich's Table, not the owner.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
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

Development

Successfully merging this pull request may close these issues.

Make the merge queue the live merge-time gate with full integration and the coverage floor

2 participants