Skip to content

Add Hypothesis tests for bump_lockfiles path resolution (#93) - #129

Merged
leynos merged 3 commits into
mainfrom
issue-93-hypothesis-bump-lockfiles-paths
Jul 22, 2026
Merged

Add Hypothesis tests for bump_lockfiles path resolution (#93)#129
leynos merged 3 commits into
mainfrom
issue-93-hypothesis-bump-lockfiles-paths

Conversation

@leynos

@leynos leynos commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #93

Property tests covering the four invariants of manifest-path resolution in bump_lockfiles:

  • Path normalisation — arbitrary in-workspace manifest strings (including redundant . segments) always produce a normalised sibling Cargo.lock path inside the workspace.
  • Deduplication — every spelling of the workspace root manifest (Cargo.toml, ./Cargo.toml, repeated) produces exactly one root entry.
  • Ordering invariant — the workspace root Cargo.lock is always the first element, regardless of input order; resolved paths are unique.
  • Rejection invariant — any manifest path escaping the workspace root raises LockfileRegenerationError. The escape test anchors the workspace in a subdirectory and excludes (via assume) the degenerate suffix that would legitimately resolve back inside.

Testing

  • make check-fmt, make lint, make typecheck, and make test (697 passed) all green after rebasing onto current main.

🤖 Generated with Claude Code

Summary by Sourcery

Add property-based tests to verify manifest path resolution behavior in bump_lockfiles, including normalization, deduplication, ordering, and rejection of paths escaping the workspace root.

Tests:

  • Introduce Hypothesis-based property tests ensuring in-workspace manifests resolve to normalized sibling Cargo.lock files with unique paths and correct ordering.
  • Add tests confirming multiple spellings of the workspace root manifest deduplicate to a single root Cargo.lock entry.
  • Add tests asserting that manifest paths attempting to escape the workspace root are rejected with LockfileRegenerationError.

References

@coderabbitai

coderabbitai Bot commented Jun 10, 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: 0c79d618-f2f5-41e4-a752-e8e0adc69f10

📥 Commits

Reviewing files that changed from the base of the PR and between fb13d90 and fa8c1b2.

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

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

  • leynos/cmd-mox (auto-detected)
  • leynos/cuprum (auto-detected)
  • leynos/shared-actions (auto-detected)

Summary

Adds Hypothesis property-based tests for bump_lockfiles manifest-path resolution, addressing #93.

Test coverage

  • Normalises arbitrary in-workspace manifest paths, including redundant . and safe .. segments.
  • Resolves manifests to unique sibling Cargo.lock files while preserving order.
  • Ensures the workspace Cargo.lock is returned first.
  • Deduplicates root manifest spellings such as Cargo.toml and ./Cargo.toml.
  • Rejects paths escaping the workspace root with LockfileRegenerationError.

Formatting, linting, type checking, and the full test suite pass with 697 tests.

Walkthrough

Add Hypothesis property tests for resolve_lockfile_paths, covering sibling lockfile resolution, root-path deduplication, ordering, normalisation, and rejection of manifests that escape the workspace.

Changes

Lockfile path validation

Layer / File(s) Summary
Property-based manifest path checks
tests/unit/test_bump_lockfiles.py
Add generated tests for in-workspace path normalisation, sibling Cargo.lock resolution, root lockfile ordering and deduplication, and rejection of escaping paths with LockfileRegenerationError.

Possibly related PRs

  • leynos/lading#135: Wraps resolve_lockfile_paths behind CargoLockfileRepository, complementing these path-resolution tests.

Suggested labels: Issue

Poem

Paths twist and turn,
Root locks gather at the front,
Duplicates fade out.
.. meets a firm boundary,
Hypothesis guards the route.

🚥 Pre-merge checks | ✅ 20
✅ Passed checks (20 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the PR scope and includes the linked issue reference (#93).
Description check ✅ Passed The description is on topic and describes the property tests added for bump_lockfiles.
Linked Issues check ✅ Passed The changes cover the required Hypothesis tests for normalisation, deduplication, ordering, and workspace escape rejection in #93.
Out of Scope Changes check ✅ Passed Keep the changes within the test coverage scope; no unrelated code changes are indicated.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Testing (Overall) ✅ Passed The Hypothesis tests use real paths and fail on plausible regressions in normalisation, deduplication, ordering, and escape rejection.
User-Facing Documentation ✅ Passed PASS: PR only adds tests; no new user-facing behaviour was introduced, and the users guide already documents lockfile regeneration and its options.
Developer Documentation ✅ Passed PASS: The PR only adds Hypothesis tests; no internal API, architecture, tooling, roadmap, or execplan changes were introduced, so no doc update was required.
Module-Level Documentation ✅ Passed PASS: tests/unit/test_bump_lockfiles.py starts with a module docstring describing its lockfile-regeneration test purpose.
Testing (Unit And Behavioural) ✅ Passed Pass: keep the Hypothesis tests on the public resolver API; cover normalisation, dedupe, ordering, and escape rejection without private seams.
Testing (Property / Proof) ✅ Passed PASS: The PR adds Hypothesis properties for manifest-path normalisation, deduplication, ordering, and escape rejection in test_bump_lockfiles.py.
Testing (Compile-Time / Ui) ✅ Passed PASS: the PR only changes Python property tests; it adds no Rust/TS compile-time path or UI/text snapshot surface, so the trybuild/snapshot rule is not applicable.
Unit Architecture ✅ Passed The patch only adds property tests for a pure resolver and an injected command path; it does not blur query/command boundaries or hide side-effects.
Domain Architecture ✅ Passed Only tests changed, and they exercise the command-layer port/repository API; no domain model now depends on transport or filesystem details.
Observability ✅ Passed Pass this: the patch is test-only, so it adds no production logging, metrics, tracing, or alerts to evaluate.
Security And Privacy ✅ Passed Only unit tests changed; they use synthetic paths and no secrets, credentials, logs, or broadened permissions.
Performance And Resource Use ✅ Passed Only bounded Hypothesis tests were added; no production code changed, and all new generators cap size/examples and use temp dirs.
Concurrency And State ✅ Passed PASS: The PR only adds synchronous property tests around pure path-resolution code; no shared mutable state, async work, locks, or lifetimes were introduced.
Architectural Complexity And Maintainability ✅ Passed PASS: Only tests/unit/test_bump_lockfiles.py changed; the production resolver is unchanged, and the new helpers stay local to the test module.
Rust Compiler Lint Integrity ✅ Passed Only tests/unit/test_bump_lockfiles.py changed; no Rust files, lint suppressions, or clone-heavy ownership changes 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 issue-93-hypothesis-bump-lockfiles-paths

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

@sourcery-ai

sourcery-ai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds Hypothesis-based property tests to validate bump_lockfiles manifest path resolution invariants, including normalization, deduplication, ordering, and rejection of paths escaping the workspace root.

File-Level Changes

Change Details Files
Introduce Hypothesis property-based tests that exercise manifest path resolution invariants in bump_lockfiles.resolve_lockfile_paths.
  • Add Hypothesis and supporting imports (strategies, given, settings, assume, string, tempfile, Path) and remove unused TYPE_CHECKING gate for Path.
  • Define reusable Hypothesis strategies for safe path segments and in-workspace directory lists, plus a helper to render manifest path strings from components.
  • Add a property test ensuring arbitrary in-workspace manifests resolve to sibling Cargo.lock files under the workspace root, with normalized paths, root-first ordering, and uniqueness of resolved lockfile paths.
  • Add a property test that multiple spellings of the workspace root manifest (e.g., Cargo.toml and ./Cargo.toml) deduplicate to a single root Cargo.lock entry.
  • Add a property test that manifests whose paths escape the workspace root (using .. segments) are rejected with LockfileRegenerationError, anchoring the workspace in a subdirectory and using assume to exclude degenerate suffixes.
tests/unit/test_bump_lockfiles.py

Assessment against linked issues

Issue Objective Addressed Explanation
#93 Add Hypothesis property-based tests to verify path normalisation: arbitrary relative manifest strings that resolve inside the workspace always produce a sibling Cargo.lock path.
#93 Add Hypothesis property-based tests to verify deduplication and ordering invariants: any combination of manifest paths that normalise to the workspace root manifest produces exactly one root invocation, and the workspace root Cargo.lock is always the first element returned with unique resolved paths.
#93 Add Hypothesis property-based tests to verify the rejection invariant: any manifest path that escapes the workspace root raises LockfileRegenerationError.

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

@lodyai
lodyai Bot force-pushed the issue-93-hypothesis-bump-lockfiles-paths branch from cdf28ae to 516fa42 Compare July 8, 2026 18:14
codescene-access[bot]

This comment was marked as outdated.

@pandalump
pandalump marked this pull request as ready for review July 8, 2026 20:29
@lodyai
lodyai Bot force-pushed the issue-93-hypothesis-bump-lockfiles-paths branch from 516fa42 to b3a9016 Compare July 8, 2026 20:40
codescene-access[bot]

This comment was marked as outdated.

@leynos

leynos commented Jul 8, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

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

@lodyai
lodyai Bot force-pushed the issue-93-hypothesis-bump-lockfiles-paths branch from b3a9016 to 18ee5ba Compare July 9, 2026 13:07
codescene-access[bot]

This comment was marked as outdated.

@lodyai
lodyai Bot force-pushed the issue-93-hypothesis-bump-lockfiles-paths branch from 18ee5ba to 6e4ad75 Compare July 14, 2026 01:21
codescene-access[bot]

This comment was marked as outdated.

@coderabbitai coderabbitai Bot added the Issue label Jul 14, 2026
coderabbitai[bot]

This comment was marked as resolved.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

@lodyai
lodyai Bot force-pushed the issue-93-hypothesis-bump-lockfiles-paths branch from b241742 to 2dc6390 Compare July 14, 2026 08:49
@pandalump

Copy link
Copy Markdown
Collaborator

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews resumed.

@lodyai
lodyai Bot force-pushed the issue-93-hypothesis-bump-lockfiles-paths branch from 2dc6390 to df8de67 Compare July 14, 2026 18:02
codescene-access[bot]

This comment was marked as outdated.

@leynos

leynos commented Jul 14, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

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

@lodyai
lodyai Bot force-pushed the issue-93-hypothesis-bump-lockfiles-paths branch from df8de67 to 6bf17fc Compare July 15, 2026 09:50
codescene-access[bot]

This comment was marked as outdated.

@leynos

leynos commented Jul 19, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews resumed.

leynos and others added 2 commits July 19, 2026 22:39
The path normalisation, deduplication, and ordering invariants in
bump_lockfiles manifest resolution were exercised only by fixed
parametrised cases.

Add property tests covering the four invariants from issue #93:
arbitrary in-workspace manifest strings (including redundant "."
segments) always produce a normalised sibling Cargo.lock path; every
spelling of the workspace root manifest deduplicates to exactly one
root entry; the workspace root Cargo.lock is always the first element
regardless of input order; and any manifest path escaping the
workspace root raises LockfileRegenerationError. The escape test
anchors the workspace in a subdirectory and excludes the degenerate
suffix that would legitimately resolve back inside.

Closes #93
Respond to reviewer comments on the manifest-path resolution property
tests:

- Add diagnostic messages to every assertion in
  test_inside_manifests_resolve_to_sibling_lockfiles so a Hypothesis
  counter-example names the violated invariant. Convert the bare
  relative_to() containment call into an explicit is_relative_to
  assertion with a message.
- Rename the module-level strategies to UPPER_SNAKE_CASE constants
  (_SEGMENT, _INSIDE_DIR) to match the naming convention for
  module-level values.
- Strengthen the ordering invariant: compare the full resolved tuple
  against an ordered expected tuple built with dict.fromkeys (root
  Cargo.lock first, then per-manifest siblings in execution order,
  duplicates removed) instead of a set comparison, which permitted
  reordered nested lockfiles to pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lodyai
lodyai Bot force-pushed the issue-93-hypothesis-bump-lockfiles-paths branch from 6bf17fc to fb13d90 Compare July 19, 2026 20:40
codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/unit/test_bump_lockfiles.py`:
- Around line 289-295: Extend the _INSIDE_DIR Hypothesis strategy to generate
safe ".." parent-traversal segments alongside _SEGMENT and "." entries, while
keeping generated paths within the workspace after normalization. Preserve the
existing bounds and ensure cases such as crate/../Cargo.toml are exercised
without allowing traversal above the workspace root.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 2019179c-15d3-44a0-978b-3a6e01cbde43

📥 Commits

Reviewing files that changed from the base of the PR and between 2dc6390 and fb13d90.

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

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

  • leynos/cmd-mox (auto-detected)
  • leynos/cuprum (auto-detected)
  • leynos/shared-actions (auto-detected)

Comment thread tests/unit/test_bump_lockfiles.py Outdated
Extend the _INSIDE_DIR Hypothesis strategy so generated in-workspace
manifest paths also include ".." parent-traversal segments alongside
real and "." segments. A composite strategy tracks the running segment
balance and only emits ".." while a prior real segment remains to cancel
it, so paths such as crate/../Cargo.toml are exercised while never
ascending above the workspace root after normalisation. The existing
list bounds (0-4 segments) are preserved, and resolve_lockfile_paths
continues to accept every generated manifest.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

@buzzybee-df12

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

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

@leynos
leynos merged commit ef9c8f7 into main Jul 22, 2026
7 checks passed
@leynos
leynos deleted the issue-93-hypothesis-bump-lockfiles-paths branch July 22, 2026 22:19
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.

Add Hypothesis property-based tests for path normalisation and deduplication in bump_lockfiles

3 participants