Skip to content

Kill metrics-counter and install_patch gate mutation survivors (#27, #28) - #33

Open
leynos wants to merge 2 commits into
kill-mutation-survivorsfrom
kill-mutation-survivor-metrics-gates
Open

Kill metrics-counter and install_patch gate mutation survivors (#27, #28)#33
leynos wants to merge 2 commits into
kill-mutation-survivorsfrom
kill-mutation-survivor-metrics-gates

Conversation

@leynos

@leynos leynos commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Closes #27, #28.

Summary

Second of two survivor-triage PRs following the 2026-07-10 mutmut 3.6.0
run on main @ 03b8ed1. Stacked on #32 (branch
kill-mutation-survivors); it kills the 61 survivors that PR
explicitly deferred:

Tests only; no production code changes.

Before/after survivor counts

State Mutants Killed Outstanding (survived + no tests)
main @ 03b8ed1 (baseline) 621 381 240
Base PR (kill-mutation-survivors) 407 346 61
This PR (full mutmut run) 407 407 0

Two mutants the triage worklist had recorded as equivalent (the "0"
version-default strings in install_patch) are killed here instead of
annotated: asserting the exact skip-warning message
(pylint 0, astroid 0) distinguishes them.

Review walkthrough

Red-green evidence

_patch module (hand-applied metric mutant,
_record_metric("dispatch.routine")_record_metric(None)):

=== RED: apply _patch.x__dispatch_member_to_child metric mutant ===
FAILED tests/test_patch_helpers.py::test_dispatch_member_to_child_routes_routines
1 failed in 0.49s
=== GREEN: revert ===
1 passed in 0.13s

Validation

  • ruff format --check, ruff check, ty check pkg tests tools, and
    pytest -n auto (91 passed, 1 skipped) all pass on this branch.
  • Full uv run mutmut run at this branch's tree: 407 generated,
    407 killed, 0 survived, 0 timeouts, 0 suspicious.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 835c2370-a52b-466a-91c0-e8d16d91c629

📥 Commits

Reviewing files that changed from the base of the PR and between 845a5b2 and 6b94e98.

📒 Files selected for processing (1)
  • tests/test_patch_helpers.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • leynos/shared-actions (auto-detected)

Summary

  • Added comprehensive tests for get_metrics() counters across dispatch, caching, resolution, descriptors, routines, module-like members, and dummy fallbacks, addressing #27.
  • Expanded coverage for install_patch version gates, strict-mode logging, AST-shape validation, logger routing, exact errors, missing attributes, and tolerant signatures, addressing #28.
  • Mutation testing kills all 407 generated mutants, with no survivors or timeouts.
  • Formatting, linting, type checks, and tests pass: 91 passed and 1 skipped.

Walkthrough

The test suite now verifies patch-helper metric counters, cached versus rebuilt children, dummy fallbacks, version-gate messages, strict errors, logger propagation, AST-shape validation, and acceptance of extra trailing parameters.

Changes

Patch helper coverage

Layer / File(s) Summary
Resolution and dispatch metric assertions
tests/test_patch_helpers.py
Assert counters for bound-method unwrapping, successful and failed resolution, descriptor and routine dispatch, module-like dispatch, and non-string directory entries.
Child-build and fallback metrics
tests/test_patch_helpers.py
Distinguish cached and rebuilt class children, special and normal constant dispatch, and dummy getattr-failure recording.
Installation gates and shape validation
tests/test_patch_helpers.py
Verify exact version-related warnings and errors, caller logger usage, builder validation failures, signature reporting, and extra trailing parameters.

Possibly related issues

  • Issue 28 — The tests cover its version-gate, logging, strict-mode, missing-version, and extra-parameter objectives.

Suggested labels: Issue

Poem

Count every route and name every gate,
Let logs speak clearly and errors translate.
Cache what is cached, build what is new,
Validate shapes as signatures pass through.
Tests march brightly, metric bells ring.

🚥 Pre-merge checks | ✅ 19 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR also adds install_patch and AST-shape tests tied to #28, which are outside the only linked issue #27. Split the #28 test coverage into a separate PR, or add #28 to the linked issues if it is intended to be in scope.
✅ Passed checks (19 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the survivor-triage test work and includes the linked issue references.
Description check ✅ Passed The description is directly about the same test-only survivor-triage changes and their issue references.
Linked Issues check ✅ Passed The PR covers the metrics-counter survivors required by #27, including exact keys and increments for the listed paths.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Testing (Overall) ✅ Passed Approve: the new tests hit real routing, public metric counters, version-gate messages, and logger routing; they fail on plausible regressions.
User-Facing Documentation ✅ Passed PASS: Only tests changed; no user-facing functionality or behaviour was added, so docs/users-guide.md needed no update.
Developer Documentation ✅ Passed Only test comments changed; no internal API, architecture, tooling, or build requirements changed, and the developers' guide already covers _patch.py, install_patch, get_metrics, and build steps.
Module-Level Documentation ✅ Passed PASS: the only changed module, tests/test_patch_helpers.py, has a clear top-level docstring, and the repo-wide scan found docstrings on all Python modules.
Testing (Unit And Behavioural) ✅ Passed Accept it: the PR adds boundary tests for install_patch/object_build and unit tests for metrics, edge cases, and error paths; no E2E gap appears.
Testing (Property / Proof) ✅ Passed The PR only adds concrete regression tests for finite branches; no new broad invariant or proof obligation calls for extra property/proof tooling.
Testing (Compile-Time / Ui) ✅ Passed No Rust/TypeScript compile-time surface exists here; the PR only adds focused Python assertions, so trybuild or snapshots are not required.
Unit Architecture ✅ Passed PASS: Side effects and fallibility stay explicit at the command/validation boundary; the branch adds tests and no-op logging/typing refactors, not hidden state or conflated responsibilities.
Domain Architecture ✅ Passed PASS: the branch changes only tests, and they probe patch-helper boundary behaviour without altering domain code or leaking new infrastructure concerns.
Observability ✅ Passed PASS: this PR is test-only plus no-op pragma/comment changes; it does not alter production observability, and existing logs/counters were already in place.
Security And Privacy ✅ Passed Tests only; they add no secrets, auth gaps, injection sinks, or broadened permissions, and the logged/versioned values are fake or dependency metadata.
Performance And Resource Use ✅ Passed Approve it: only tests changed, and the added loops, Hypothesis cases, and thread pools are small, bounded, and CI-only.
Concurrency And State ✅ Passed Only test comments changed; no shared mutable state, locking, async, or ordering semantics were altered.
Architectural Complexity And Maintainability ✅ Passed Approve it: the PR stays in one test file and adds only local test fixtures; the NamedTuple/helper cut argument noise instead of adding a new layer.
Rust Compiler Lint Integrity ✅ Passed Only tests/test_patch_helpers.py changed; no Rust sources, lint suppressions, or clone-related edits were introduced.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch kill-mutation-survivor-metrics-gates

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds precise metrics Counter assertions and new coverage around _patch dispatch/resolve flows plus detailed install_patch version-gate and astroid shape validation behavior, all in tests only.

File-Level Changes

Change Details Files
Assert exact metrics Counter contents for resolve/dispatch paths and add focused metrics tests to pin every _record_metric counter key/increment behavior.
  • Augment existing resolve-member tests with full Counter equality checks covering bound-method unwraps, successful resolves, getattr failures, and non-string dir-entry handling.
  • Extend dispatch-member tests to assert per-path metric increments for method descriptors, data descriptors, routines, module-like members, imported members, and builder object_build calls.
  • Add new tests for _build_class_child to distinguish cached vs built members via separate class dispatch counters.
  • Add new tests for _build_const_child to distinguish special attributes from ordinary const builds via separate const dispatch counters.
  • Add an object-build test that drives a getattr failure path and asserts the dummy getattr-failure dispatch metric is incremented.
tests/test_patch_helpers.py
Expand install_patch and astroid shape-validation tests to lock down exact messages, logger routing, and version/signature handling semantics.
  • Add helper to simulate PyPy environment with specific/missing pylint and astroid version values, used across new version-gate tests.
  • Parametrize install_patch version-gate tests over unsupported and missing-version combinations, asserting exact warning messages including the reported versions and that the patch is not installed.
  • Add strict-mode test asserting PatchError is raised with the exact skip message and that the same message is logged at ERROR level.
  • Add install_patch test verifying shape-validation errors are logged through a caller-supplied logger and that object_build is left untouched when validation fails.
  • Add _validate_astroid_shape tests for missing InspectBuilder, non-callable object_build, completely missing object_build, unsupported signatures (including logged signature detail), and accepted signatures with extra trailing parameters.
tests/test_patch_helpers.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

codescene-access[bot]

This comment was marked as outdated.

@leynos

leynos commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

Review finding actioned (branch rebased onto the updated #32):

  • CodeScene — Excess Number of Function Arguments (test_install_patch_version_gate_reports_exact_versions): the parametrized version scenarios are now expressed as a _VersionGateCase named tuple, reducing the test to (monkeypatch, caplog, case).

A full mutmut run at the new tip still reports 407 generated / 407 killed / 0 survived.

@leynos
leynos force-pushed the kill-mutation-survivor-metrics-gates branch from 4013d9e to ccafc4d Compare July 13, 2026 19:33
codescene-access[bot]

This comment was marked as outdated.

@leynos

leynos commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

Heads-up: #34 replaced ci.yml's bespoke cs-coverage upload step (which CodeScene rejects on pull-request branches) with the shared generate-coverage action, and the CS_ACCESS_TOKEN secret is now set repo-wide. This branch's head still carries the old ci.yml, so its next CI run would execute the old upload step and fail. Please rebase onto (or merge) main before pushing further changes.

@leynos leynos changed the title Kill metrics-counter and install_patch gate mutation survivors Kill metrics-counter and install_patch gate mutation survivors (#27, #28) Jul 17, 2026
@leynos
leynos force-pushed the kill-mutation-survivor-metrics-gates branch from ccafc4d to 8ab93ef Compare July 17, 2026 16:51
codescene-access[bot]

This comment was marked as outdated.

@leynos
leynos force-pushed the kill-mutation-survivors branch from d9724d5 to 845a5b2 Compare July 18, 2026 18:48
leynos added 2 commits July 18, 2026 20:49
Kill the remaining `get_metrics()` counter survivors (#27) and the
`install_patch` version-gate and `_validate_astroid_shape` survivors
(#28) deferred from the base PR.
Add one-line comments naming the mutation-survivor issue each new
metrics-counter test (#27) and install_patch/shape-validation test
(#28) kills, so the kill sites are traceable back to the triage
issues without relying solely on the PR body.
@leynos
leynos force-pushed the kill-mutation-survivor-metrics-gates branch from 8ab93ef to 6b94e98 Compare July 18, 2026 18:49
codescene-access[bot]

This comment was marked as outdated.

@codescene-access codescene-access Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No quality gates enabled for this code.

@leynos
leynos marked this pull request as ready for review July 25, 2026 14:52

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @leynos, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@buzzybee-df12

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 29, 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.

@coderabbitai coderabbitai Bot added the Issue label Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants