Skip to content

[0.38] test(mutation): owner kill-rate floors and the 0.37 owners, wave A - #4585

Merged
Daniel Meppiel (danielmeppiel) merged 10 commits into
mainfrom
danielmeppiel-4121-owner-mutation
Nov 22, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 10 commits into
mainfrom
danielmeppiel-4121-owner-mutation

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

TL;DR

Wave A of #4121.

  • The nightly mutation pilot becomes per-owner mutation testing: each owner has a kill-rate floor and recorded survivors in tests/mutation/baseline.json.
  • The scheduled job runs one shard per owner, each with a built-in negative control.
  • Eight owners from the 0.37 owner moves are added and fully resolved: every mutant is killed by a new behavioral unit test or recorded as equivalent with a reason.
  • The nightly pilot had been red since 2026-11-20 because of stale test seams; this PR repairs it.

Kill-rate table (floors recorded in tests/mutation/baseline.json)

Owner Source Mutants Killed Survived Kill rate = floor Survivors resolved as
policy-outcome-routing policy/outcome_routing.py 338 336 2 0.9940 2 equivalent
executable-trust-context security/executables.py 233 233 0 1.0000 -
install-entry-routing install/pipeline_entry.py 107 107 0 1.0000 -
install-commit-order install/commit_gate.py 221 221 0 1.0000 -
lockfile-write-authority deps/lockfile_write_authority.py 123 118 5 0.9593 5 equivalent
apm-home-resolution (scope manifest path) core/scope.py 50 49 1 0.9800 1 equivalent
egress-route-policy deps/egress_route.py 13 13 0 1.0000 -
remediation-advice core/remediation.py 20 20 0 1.0000 -
legacy subset-selection models/dependency/subsets.py 148 127 21 0.8581 legacy allowlist (was 23)
legacy update-plan install/plan.py 210 199 11 0.9476 legacy allowlist (was 9; see below)
legacy policy-serialization policy/discovery.py 139 139 0 1.0000 -
legacy link-projection compilation/link_resolver.py 46 46 0 1.0000 -
legacy lockfile-normalization deps/lockfile.py 27 25 2 0.9259 legacy allowlist (unchanged)

Equivalent survivors (each recorded with this reason)

  • outcome_routing.classify_discovery_outcome__mutmut_15: getattr default None versus "". Both are falsy, so or "unknown" gives the same source.
  • outcome_routing._report_miss_neutrally__mutmut_6: getattr default None versus False. bool() of both is False.
  • scope.get_manifest_path__mutmut_5: the project branch runs only for a non-user scope, and get_source_root treats None exactly like any non-user scope.
  • lockfile_write_authority._scope__mutmut_7: _WriteScope.writer is stored but never read.
  • lockfile_write_authority._refused__mutmut_11: getattr default None versus False. Both are falsy.
  • lockfile_write_authority.remove_lockfile__mutmut_7: it only reorders a removal marker among pending writes. _commit writes nothing for a removal, so commit order and bytes are unchanged.
  • lockfile_write_authority.restore_lockfile_bytes__mutmut_9: normalize_line_endings=None versus False. atomic_write_text tests truthiness.
  • lockfile_write_authority.restore_lockfile_bytes__mutmut_15: codec names are case-insensitive.

What changed

  • scripts/run_mutation_pilot.py (baseline schema 2):

    • Per-owner kill_rate_floor, rounded down to 4 decimals, and equivalent_survivors with reasons.
    • accepted_survivors is allowed only for the five original pilot owners (LEGACY_OWNER_KEYS). Validation rejects it for any other owner.
    • A run fails on an unrecorded survivor, a kill rate below the floor, or any incomplete outcome (timeouts included).
    • --update-baseline keeps recorded reasons and refuses a new owner's survivor that has neither a test nor a reason.
    • New flags: --owner KEY (repeatable), --list-owners, --negative-control.
    • The negative control flips one killed mutant to a survivor, allows it as equivalent so that only the floor can object, and requires the floor check to fail.
    • run_owners(owners, ...) is the reusable entry point for Test impact analysis S0: offline selector recall harness (replay plus fault injection) #4514's fault injection: an Owner is a source file, its functions and its seams. It accepts registered owners only, because mutmut reads [tool.mutmut].
  • .github/workflows/mutation-pilot.yml:

    • An owners job lists the keys, then a fail-fast: false matrix runs --owner "$OWNER" --negative-control per owner, each uploading its own report.
    • No shared cache: each owner runs fresh in about a minute.
    • tests/quality/test_ci_topology.py pins the topology: schedule, dynamic matrix, the negative control, no soft shard and no baseline writes. Five mutation cases fail it.
  • Eight new unit seams, each marked unit and promise("P-OWN-<owner>"):

    • tests/unit/policy/test_outcome_routing.py
    • tests/unit/security/test_exec_trust_context.py
    • tests/unit/install/test_pipeline_entry.py
    • tests/unit/install/test_commit_gate.py
    • tests/unit/deps/test_lockfile_write_authority.py
    • tests/unit/core/test_apm_home_resolution.py
    • tests/unit/deps/test_egress_route.py
    • tests/unit/core/test_remediation.py

    Four P-OWN ids for registered owners were added to tests/quality/promise-catalog.json.

    The seams follow AQ004 with no new allowance:

    • Each seam runs its owner's own chain for real.
    • A collaborator in another module (policy discovery, console output, atomic_write_text, integrity, MCP collection) is replaced at its own dotted path.
    • Import-time and warn-once state (_STARTUP_CWD, the allowExecutables notice) comes from a fresh import of the owner module.
  • Legacy pilot repair:

    • test_link_resolver_phase3.py was consolidated away (011445b) and the policy-serializer tests moved to test_cache_merged_effective_logic.py, so the pilot's pytest selection failed at collection. Its nightly run has failed since 2026-11-20.
    • The seams now point at the surviving modules, and test_every_owner_seam_exists fails on a missing seam.
    • Two new tests in tests/unit/test_dep_targets_persistence.py kill new subset-selection survivors: an alias recorded as its canonical target, and the exact unknown-target message.
  • tests/unit/scripts/test_run_mutation_pilot.py:

    • 19 new tests: floors, equivalents, validation, negative control, owner selection, run_owners, --list-owners, refusing a partial --update-baseline, and checked-in baseline validity.
    • The module is reclassified unit (in-process tests of a script). Its AQ003 allowance (10) and its unclassified taxonomy entry are pruned; both are shrinks.

Findings for the owning lanes (not fixed here: product changes are out of this record's scope)

  • Latent, unreachable today: resolve_trust_policy(..., announce=True, raise_blocking_errors=False) would crash with AttributeError. route_discovery_outcome calls logger.warning(...) to preview a block, and _TrustReaderLog has no warning. Every current dry-run caller passes announce=False, so no command reaches it. Owner: policy-outcome-routing.
  • Legacy update-plan drift: build_update_plan changed on main while the pilot was red. Mutant IDs were renumbered and there are two more unexplained survivors (9 to 11): display_name and sort-key mutants of the same kind already accepted. They stay in the legacy allowlist for the update-plan wave.
  • mutmut limits:
    • mutmut 3.6.0 skips any function with a decorator other than staticmethod/classmethod. So lockfile_write_scope (a @contextmanager) is covered through _commits and _commit, and the Remediation dataclass methods through the module-level renderers.
    • Test seams must not chdir or fake os.getcwd, because mutmut's stats pass resolves src/ through the process working directory. The new seams patch Path.cwd and HOME.

Trade-offs

  • The floor equals the measured rate, so any lost kill fails the nightly. A real change that adds survivors needs a test or a recorded reason in the same PR.
  • Legacy owners keep their unexplained allowlists until their own wave; they now also have floors.

Issue and approved scope

Issue: Refs #4121 (wave A of the staged plan in #4121 (comment); the issue stays open until the last wave).

Merge order: no dependency. The main-red generator-citation fix (#4590) is already on main, and this branch is rebased on top of it.

Human scope-approval comment: #4121 (comment). Wave staging was ruled by the 0.38 PM.

Does this PR complete the issue, or what remains? It completes wave A: the tooling plus the 0.37 owners. The remaining owners follow by blast radius; owners not landed by the 0.38 cut move to 0.39.

Type of change

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

Testing

  • Tested locally
  • All existing tests pass: CI pending.
  • Added tests for new functionality (if applicable)

Local results:

  • Full mutation run, all 13 owners: 1675 mutants, 42 survivors, all recorded. --report-only --negative-control printed: "[+] Negative control: losing one killed mutant fails every owner (13)."
  • tests/quality, the runner tests, the new seams and tests/unit/{core,security}: 3543 passed. The 3 failures are environment-only and fail identically on main: a credential-helper test and two git-transport tests.
  • Lint mirror, architecture linter and the complexity ratchet are clean.
  • Mutation workflow dispatched on this branch: https://github.com/microsoft/apm/actions/runs/44892955581. All 13 owner shards are green. Each prints its kill_rate equal to its floor (table above) and "[+] Negative control: losing one killed mutant fails every owner (1)."
  • AQ004 rewrite of the five flagged seams and the Windows fix for test_staged_reads_are_keyed_by_absolute_path (no cross-drive relpath), rebased onto main 5337f2fb:
  • Review follow-ups in scripts/run_mutation_pilot.py, with a test for each:
    • --update-baseline keeps legacy owners' recorded equivalents.
    • run_owners refuses an unregistered owner.
    • A failed negative control is written to the report and makes its status a regression.
    • Runner tests: 54 passed. Head rebased onto main again; tests/quality/test_quality_baselines.py: 7 passed.
  • Earlier, rebased onto main e74759bc after [0.38] feat(marketplace): root apm.yml marketplaces: map and marketplace.allow policy #4006 changed core/remediation.py, security/executables.py and policy/discovery.py. The regenerated baseline is byte-identical; policy-serialization now has 146 mutants, all killed.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md (internal; required by the record).
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • N/A -- this PR does not change OpenAPM-observable behaviour.

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

Unresolved mutation-pilot defects can misreport acceptance, discard equivalence decisions, and ignore owner test seams, while misclassified filesystem-backed tests bypass component assertion checks.

5 open issues
What changed in this PR

This PR delivers wave A of #4121, expanding APM's mutation pilot to 13 owner modules with scheduled per-owner enforcement. It adds behavioral tests and repairs stale test selections without changing product behavior.

Changes:

  • Introduces per-owner kill-rate floors, documented equivalent survivors, owner selection and negative controls.
  • Replaces the shared-cache workflow with independent owner shards and report artifacts.
  • Adds eight owner-focused test modules, runner/topology coverage and contributor documentation.
File Description
tests/​unit/​test_dep_targets_persistence.py Adds canonical-target and exact-error assertions.
tests/​unit/​security/​test_exec_trust_context.py Adds executable-trust and approval coverage.
tests/​unit/​scripts/​test_run_mutation_pilot.py Tests floors, baselines, controls and owner selection.
tests/​unit/​policy/​test_outcome_routing.py Tests policy classification and trust-reader routing.
tests/​unit/​install/​test_pipeline_entry.py Tests preview behavior and option forwarding.
tests/​unit/​install/​test_commit_gate.py Tests pre-commit checks and MCP policy handling.
tests/​unit/​deps/​test_lockfile_write_authority.py Tests staged writes, commit decisions and restoration.
tests/​unit/​deps/​test_egress_route.py Tests outbound routing decisions.
tests/​unit/​core/​test_remediation.py Tests remediation message composition.
tests/​unit/​core/​test_apm_home_resolution.py Tests scope paths and APM home resolution.
tests/​quality/​test_taxonomy_baseline.json Removes the runner's taxonomy allowance.
tests/​quality/​test_ci_topology.py Guards scheduled owner-shard enforcement.
tests/​quality/​promise-catalog.json Registers four owner promises.
tests/​quality/​assertion_quality_baseline.json Removes the runner's assertion allowance.
tests/​mutation/​baseline.json Records schema-2 floors and survivor decisions.
scripts/​run_mutation_pilot.py Adds per-owner execution and baseline enforcement.
pyproject.toml Expands mutation sources and repairs test selections.
docs/​src/​content/​docs/​contributing/​development-guide.md Documents mutation execution and survivor review.
CHANGELOG.md Notes expanded nightly mutation testing.
.github/​workflows/​mutation-pilot.yml Runs independent owner shards with negative controls.

Review effort: Balanced

Comment thread scripts/run_mutation_pilot.py Resolved
Comment thread scripts/run_mutation_pilot.py Resolved
Comment thread scripts/run_mutation_pilot.py Resolved
…4121)

The mutation pilot becomes per-owner mutation testing:
- tests/mutation/baseline.json (schema 2) records each owner's kill-rate
  floor and its survivors. equivalent_survivors carry a reason; only the
  five original pilot owners keep an unexplained legacy allowlist.
- A run fails on an unrecorded survivor, a kill rate below its floor, or an
  incomplete outcome. --owner runs one owner, --list-owners feeds the
  scheduled matrix, and --negative-control proves that losing one killed
  mutant fails the floor. run_owners() is the reusable entry point for
  other fault-injection harnesses (#4514).
- mutation-pilot.yml runs one nightly shard per owner with the negative
  control; tests/quality/test_ci_topology.py pins that topology.

Wave A adds eight owners from the 0.37 owner moves, each with a unit seam
that kills its mutants: policy-outcome-routing, executable-trust-context,
install-entry-routing, install-commit-order, lockfile-write-authority,
apm-home-resolution, egress-route-policy and remediation-advice. Every
survivor is killed or recorded as equivalent with its reason.

The nightly pilot had failed since a test consolidation removed
test_link_resolver_phase3.py and moved the policy serializer tests; the
seams now point at the surviving modules and a unit test fails when a seam
file is missing.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…nt lockfile key test (#4121)

AQ004: the new owner seams replaced symbols of modules they import.
Collaborators are now replaced at their own module, the owners' own
chains run for real, and import-time or warn-once state comes from a
fresh module import. The staged-key test no longer takes a relpath
across Windows drives.

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

mutmut's stats pass resolves its source paths through os.getcwd, so a
faked getcwd failed every owner shard. A fresh import captures the real
starting directory; the removed-directory run sets it on its own copy.

Co-authored-by: Copilot App <[email protected]>
…eport the negative control (#4121)

Review follow-ups on the runner:
- --update-baseline keeps recorded equivalent reasons for legacy owners
  and allowlists only the remaining survivors.
- run_owners refuses an owner missing from OWNERS: mutmut reads its
  sources and tests from [tool.mutmut], which lists only registered owners.
- A failed negative control is written to the report and makes its
  status a regression.

Co-authored-by: Copilot App <[email protected]>
…ersection of both shrinks

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

The train rebase dropped this module's promise_exempt_modules entry,
so tm006 flagged it as a new module without pytest.mark.promise. It now
declares P-LAW-transaction.failed_command_preserves_state, the promise
its replay disposition row already names.

Co-authored-by: Copilot App <[email protected]>
#4001 passes the fetch result's explicit flag to logger.policy_resolved.
Assert it for both explicit and discovered sources.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit d5cc457 into main Nov 22, 2026
49 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-4121-owner-mutation branch November 22, 2026 09:00
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