Skip to content

fix(ci): shard lifecycle smoke without weakening its gate - #3345

Merged
Daniel Meppiel (danielmeppiel) merged 1 commit into
mainfrom
danielmeppiel-ci-lifecycle-smoke-shards
Oct 22, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 1 commit into
mainfrom
danielmeppiel-ci-lifecycle-smoke-shards

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

fix(ci): shard lifecycle smoke without weakening its gate

Description

TL;DR

Split the existing required lifecycle selection into two affinity-preserving jobs, each retaining four loadgroup workers and its 10-minute whole-job limit. Keep the required check name Lifecycle Smoke (Linux) as an always-run aggregate that accepts only two explicit successful shard results. This is a scheduling-only correction; application behavior, selected tests, credentials, release triggers, and merge-gate requirements are unchanged.

Important

Hosted branch qualification is complete at the exact head below. This PR is not yet landed and does not establish repaired main CI or authorize any release, publication, deployment, or full release-validation dispatch.

Problem (WHY)

  • The actual lifecycle job on #3343 exceeded its 10-minute deadline: 606 seconds overall, with 581 seconds in its test step. Its printed 396 passed, 13 skipped in 577.92s was followed by cancellation, and the required aggregate correctly failed.
  • Independent review found a startup defect in the first scheduling draft: console pytest -p scripts.lifecycle_smoke_sharding cannot import the repository-only plugin in a clean environment. This was reproduced as ImportError: Error importing plugin "scripts.lifecycle_smoke_sharding": No module named 'scripts', then corrected to python -m pytest.

The evidence boundary follows "Read agent execution traces, not just final outputs.": a printed test summary is not a successful terminal job, and an observer's PYTHONPATH is not a clean-runner startup proof.

Approach (WHAT)

  • Keep the exact marker expression and tests/integration root.
  • Collapse complete composite xdist_group affinity units, delegate balancing to the existing pytest-split LeastDurationAlgorithm, then expand those units without reordering members.
  • Run two explicit jobs with shared setup steps, four workers, loadgroup, and a 10-minute limit per job.
  • Require each explicit result to equal success; reject missing, failed, cancelled, and skipped results.
  • Use python -m pytest and pin that entrypoint in the topology contract.

Implementation (HOW)

File Change
.github/workflows/ci.yml Two explicit shard jobs share a YAML steps anchor. The original required name becomes a strict aggregate; no merge-gate edit.
scripts/lifecycle_smoke_sharding.py Fixed two-way adapter around pytest-split; preserves xdist composite labels and rejects invalid partitions or competing split selectors.
tests/unit/scripts/test_lifecycle_smoke_sharding.py Canonical algorithm delegation, complete affinity, exact membership, invalid-output, and hook contracts.
tests/quality/test_ci_topology.py Real clean-environment collection, exact union/disjointness, per-shard topology negatives, and actual aggregate-shell truth table.
docs/src/content/docs/contributing/integration-testing.md Describes both shards, the unchanged budget, strict aggregate, and the local module-entry command.

Diagrams

The highlighted region shows the new parallel jobs and their explicit results feeding the unchanged required check name.

sequenceDiagram
    participant C as ci.yml
    participant A as lifecycle-smoke-shard-1
    participant B as lifecycle-smoke-shard-2
    participant G as Lifecycle Smoke (Linux)
    rect rgb(255, 247, 200)
        Note over A,B: NEW two shards, same selection and complete affinity groups
        par Shard 1
            C->>A: python -m pytest, lifecycle-shard 1
            A->>A: 4 workers, loadgroup, 10-minute job cap
        and Shard 2
            C->>B: python -m pytest, lifecycle-shard 2
            B->>B: 4 workers, loadgroup, 10-minute job cap
        end
        A-->>G: explicit shard 1 result
        B-->>G: explicit shard 2 result
        Note over G: always(), unchanged required check name
        alt Both results are success
            G->>G: Exit 0
        else Either result is not success or is absent
            G->>G: Exit 1
        end
    end
Loading

Trade-offs

  • Two runners repeat setup instead of increasing the timeout or removing cases.
  • Member counts are scheduling weights, not measured durations. The actual hosted results below, rather than node-count balance alone, establish that both shards fit the unchanged budget.
  • Explicit jobs permit independent result checks; a shared YAML steps anchor avoids duplicating setup and selection.
  • No application/spec change or release-note entry. I5, fix(tests): restore MCP and update-plan CI contracts #3343 test contracts, and fix(install): retain trustworthy rendered skill receipts #3344 rendered-skill receipts remain separate carriers.

Benefits

  1. The two local executions cover all 411 locally collected cases exactly once: 206 plus 205.
  2. All 17 home_env cases stay in one shard and one worker; composed affinity labels are also covered.
  3. The aggregate-shell contract accepts exactly one of 25 result pairs: success plus success.

Issue and approved scope

Issue: related tracking #3341, which remains OPEN.

Human scope-approval comment: no new public approval comment was created. The maintainer directly authorized these bounded CI fixes and explicitly waived a separate issue/public-approval-record prerequisite:

"you do it, and do not mandate for these fixes to require an issue and approval, it's not needed. get CI working ASAP"

This task-specific exception is not a fabricated accepted label or a claim that the earlier label-gated worker admission passed. Scope is the five-file scheduling correction only; public-main repair and full nonpublishing validation remain outstanding.

Type of change

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

Testing

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

Validation

Base: freshly fetched and composed 75bfa523954dabb3eb9bbd57f4b6bd4eacf3c389. Qualified head: f2cefd811a4cc3d8cbeca9a4849c5107d01c2239. Full repository suites and repaired-main/full-release validation are not claimed.

Hosted check Terminal result Whole-job duration
Lifecycle Smoke Shard 1 (Linux) SUCCESS 243s
Lifecycle Smoke Shard 2 (Linux) SUCCESS 385s
Lifecycle Smoke (Linux) SUCCESS 4s
Required merge gate SUCCESS 604s

Hosted pytest results: shard 1 200 passed, 5 skipped in 219.15s; shard 2 196 passed, 8 skipped in 319.11s. These account for all 409 hosted cases, distinct from the 411-case local selection.

The exact-head rollup is 22 SUCCESS, 2 NEUTRAL, 1 SKIPPED. The neutral CodeQL compatibility context is not a passed imposed-native CodeQL check; the actual Python/actions analyses succeeded separately. Deployment was skipped. GitHub still reports MERGEABLE/BLOCKED; landing remains the separate Merge Master decision.

Exact local commands and results

The shared two-slot validator serialized all pytest qualification. proof names the local evidence directory:

proof="$HOME/.copilot/session-state/067b35fc-52fb-4db4-b316-c606d23b4b34/files"
uv run --frozen --extra dev python -m pytest -p no:cacheprovider -q \
  tests/unit/scripts/test_lifecycle_smoke_sharding.py tests/quality \
  --basetemp="$proof/smoke-clean-quality-tmp" --junitxml="$proof/smoke-clean-quality.xml"
145 passed in 62.41s (0:01:02)

Each actual shard ran sequentially with the following command, for shard=1 then shard=2; neither PYTHONPATH nor an observer plugin was present:

env -u PYTHONPATH -u GITHUB_TOKEN -u GH_TOKEN -u GITHUB_APM_PAT -u ADO_APM_PAT \
  -u APM_RUN_INTEGRATION_TESTS -u APM_RUN_INFERENCE_TESTS APM_E2E_TESTS=1 \
  uv run --frozen --extra dev python -m pytest -p no:cacheprovider -q --strict-markers \
  -p scripts.lifecycle_smoke_sharding --lifecycle-shard "$shard" \
  -n 4 --dist loadgroup --durations=20 \
  -m "lifecycle_smoke and not lifecycle_merge_group" tests/integration \
  --basetemp="$proof/smoke-clean-shard$shard-tmp" --junitxml="$proof/smoke-clean-shard$shard.xml"
199 passed, 7 skipped in 268.55s (0:04:28)
195 passed, 10 skipped in 251.51s (0:04:11)

Skips: four case-insensitive-filesystem cases, twelve native-Windows-capability cases, and one explicitly network-gated marketplace case. All 411 local cases are accounted for; the older hosted Linux run had 409 cases, not 411.

Full current lint mirror, with the new script additionally included:

uv run --frozen --extra dev ruff check src/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.py scripts/lifecycle_smoke_sharding.py
uv run --frozen --extra dev ruff format --check src/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.py scripts/lifecycle_smoke_sharding.py
uv run --frozen --extra dev python -m pylint --disable=all --enable=R0801 --min-similarity-lines=10 --fail-on=R0801 src/apm_cli/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.py scripts/lifecycle_smoke_sharding.py
bash scripts/lint-auth-signals.sh
bash scripts/lint-architecture-boundaries.sh
uv run --frozen python scripts/check_test_assertions.py
uv run --frozen python scripts/check_exact_test_duplicates.py

All commands exited 0. Output excerpts:

All checks passed!
2088 files already formatted
Your code has been rated at 10.00/10
[+] auth-signal lint clean
[+] assertion-quality ratchet clean: AQ001=4, AQ002=12
[+] exact test duplicate ratchet clean: 1411 files, 0 allowed duplicate group(s)

The workflow-equivalent YAML-I/O, portable-relative-path, and 2100-line guards also passed: 507 source files and 592 length-covered files.

Finite in-memory mutations produced the intended failures: affinity removal 4 failed/15 passed; overlap acceptance 1 failed/18 passed; missing-node acceptance 1 failed/18 passed. Source bytes were never mutated; restoration initially passed 143 tests, then the final entrypoint correction passed 145. Historical mock-fixture failures and the clean-console startup failure are retained, not recast as successes.

The independently reviewed diff is 7b1e47993c3ecde210fcdc1521aa13d520127d6abfcaa80da40f0ac2e04ea2d8. Clean-execution reconciliation is 5a7e2986c62d7f0f2a879145fabded87b2b6c082d10ec2c930eb1f28c6cd4b1f: exact JUnit node multisets match the separately observed worker collections. Independent review used read-only file/Git inspection, not another validator.

Scenario Evidence

# Scenario (user promise) Principle(s) Test(s) proving it Type
1 Every required lifecycle case still runs once across the two jobs. Governed by policy tests/quality/test_ci_topology.py::test_lifecycle_shards_collect_exact_required_union; actual shard JUnit reconciliation (regression-trap for the #3341 recovery scheduling boundary) integration
2 HOME-mutating tests stay serialized rather than racing across workers. DevX (pragmatic as npm) tests/unit/scripts/test_lifecycle_smoke_sharding.py::test_partition_retains_every_node_once_and_whole_affinity_groups; actual 17-case home_env worker trace unit / integration
3 A failed, skipped, cancelled, or missing shard cannot produce a successful required gate. Governed by policy tests/quality/test_ci_topology.py::test_lifecycle_smoke_is_required_and_hermetic; test_lifecycle_aggregate_cannot_ignore_either_shard integration
4 A clean runner can load the plugin without hidden local import-path setup. OSS / community-driven tests/quality/test_ci_topology.py::test_lifecycle_shard_command_drift_fails; clean-environment collection and both actual module-entry shard runs integration

How to test

  • Run uv sync --frozen --extra dev, then the unit/quality command above; expect no failures.
  • Run both documented shard commands with APM_E2E_TESTS=1; retain the original marker expression and inspect platform/prerequisite skip reasons.
  • Confirm both hosted shard jobs finish successfully within their unchanged 10-minute budgets, then confirm Lifecycle Smoke (Linux) succeeds.
  • Confirm the required aggregate remains in the existing merge gate, and that no release/publication/deployment event was triggered.

Spec conformance (OpenAPM v0.1)

If this PR changes behaviour that an OpenAPM v0.1 req-XXX covers,
confirm the three-step ritual in the
development guide:

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

Co-authored-by: Copilot [email protected]

Delegate two-way balancing to pytest-split while retaining complete xdist affinity units, the existing marker selection, four workers and ten-minute job caps. Require both explicit shard results under the existing check name and use the clean Python-module pytest entrypoint.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 067b35fc-52fb-4db4-b316-c606d23b4b34

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.

🔵 Needs a closer look

Human review should confirm successful hosted runs of both shards within their unchanged 10-minute limits before approving this required-gate scheduling change.

No open issues 🎉

What changed in this PR

This PR addresses lifecycle smoke timeouts by splitting the existing required test selection into two parallel shards while preserving test coverage, worker affinity, and the required check name.

Changes:

  • Adds affinity-preserving two-way sharding, retaining four workers and a 10-minute limit per shard.
  • Converts Lifecycle Smoke (Linux) into an always-run aggregate that succeeds only when both shards succeed.
  • Adds partition, startup, and gate contracts, and documents the updated local commands.
File Description
tests/​unit/​scripts/​test_lifecycle_smoke_sharding.py Tests affinity preservation, partition validation, and selector handling.
tests/​quality/​test_ci_topology.py Verifies shard coverage, clean plugin loading, workflow constraints, and aggregate failure behavior.
scripts/​lifecycle_smoke_sharding.py Implements two-way balancing without splitting composite affinity groups.
docs/​src/​content/​docs/​contributing/​integration-testing.md Documents sharding, timeout limits, aggregate behavior, and local execution.
.github/​workflows/​ci.yml Adds two shard jobs with shared steps and preserves the required aggregate check.

Review effort: Balanced

@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

Docs sync advisory

Verdict: no_change * Pages affected: 0 * LLM calls: 1/15 * Took: not measured

No additional product-documentation changes indicated. At f2cefd811, all five changed paths match the docs index's L0 exclusions for CI, scripts, tests, and documentation; none touches a listed user-facing code surface. The contributor integration-testing page is already updated in this PR.

This is the deterministic path-gate result, not a whole-corpus audit or a documentation-panel review. No panel or companion PR was spawned; the advisory does not establish CI readiness.


Generated by docs-sync. This comment is AI-generated and may contain errors.

@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

Merge Master assessment

Recommendation: ship_now for exact head f2cefd811a4cc3d8cbeca9a4849c5107d01c2239 against actual main 75bfa523954dabb3eb9bbd57f4b6bd4eacf3c389, under the maintainer's explicit bounded CI-recovery mandate. This is a separate Merge Master delivery assessment, not a persona-panel or human-approval claim.

The five-path scheduling change preserves the full lifecycle selection, affinity groups, four workers per shard, unchanged ten-minute limits, and the strict required aggregate. Existing independent source review and entrypoint rereview have no outstanding findings. The current-head Copilot review has no inline defects; its request for successful hosted jobs below ten minutes is satisfied by both completed jobs.

Exact-head CI run 39747693143 and required gate 39747693381 succeeded. Lifecycle shards completed successfully in 243s and 385s; their strict aggregate succeeded in 4s. All 27 raw checks are terminal: 24 success, two neutral, one skipped deployment. Hosted evidence is 396 passed / 13 skipped; distinct clean local evidence is 394 passed / 17 classified skips across 411 unique identities. The actual full-selection union guard, 145 quality cases, causal failures/restorations, canonical lint/static evidence, and all 38 sealed artifacts remain source-bound and unchanged; no tests or reviewers were replayed merely for this handoff.

Canonical completion-schema and strict terminal owner-v2 evidence are verified, with zero detected registered-owner touches. Fresh actual-main composition matches the qualified head tree f7a898fcb319beec24e2e11911c7132414a11389. All author surfaces are released; this remains the sole scheduling carrier, with no closing issue references under the explicit issue-less CI exception. #3341 stays open.

Fresh API reads confirm restored ADMIN and applicable ruleset bypass eligibility always. Actual Python/actions analyses succeeded and the current PR alert query returned zero open alerts. The neutral compatibility check is not a passing imposed-native CodeQL analysis: that missing evidence remains disclosed under the user's narrow exception. No substantive failure, vulnerability, native consent, or observation requirement is waived.

Landing this scheduling prerequisite does not complete CI recovery or establish full actual-main validation. #3343, #3344, and #3346 need their own current-head qualification after consuming the actual public landing; source owners retain those duties. Full nonpublishing platform/integration/release validation remains open and belongs to the sole CI owner after the repaired public landings.


Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors.

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 2f1587b into main Oct 22, 2026
27 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-ci-lifecycle-smoke-shards branch October 22, 2026 10:17
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.

2 participants