Skip to content

test: guard package version fallback#7

Open
Boulea7 wants to merge 2 commits into
mainfrom
codex/version-fallback-drift-test
Open

test: guard package version fallback#7
Boulea7 wants to merge 2 commits into
mainfrom
codex/version-fallback-drift-test

Conversation

@Boulea7
Copy link
Copy Markdown
Owner

@Boulea7 Boulea7 commented May 27, 2026

Summary

  • add a version metadata regression test that compares the source-checkout fallback in src/agy_mcp/init.py against pyproject.toml
  • protect editable/source installs and generated skill bridge fallbacks from release-version drift

Test plan

  • UV_CACHE_DIR=/private/tmp/agy-mcp-uv-cache uv --no-config run --index-url https://pypi.org/simple pytest tests/test_version.py tests/test_skill_bridge_forwarders.py -q
  • UV_CACHE_DIR=/private/tmp/agy-mcp-uv-cache uv --no-config run --index-url https://pypi.org/simple ruff check tests/test_version.py
  • git diff --check

Reference: packaging/release comparison against gemini-plugin-cc and codex-plugin-cc highlighted release-drift checks as a small useful hardening item.

Summary by Sourcery

Tests:

  • Add a version metadata consistency test that compares the fallback version in src/agy_mcp/init.py against the version in pyproject.toml to guard against release drift.

Summary by cubic

Add a precise regression test to ensure the version fallback in src/agy_mcp/__init__.py exactly matches the pyproject.toml version. The test parses the file’s AST and asserts a single fallback literal, preventing release-version drift for editable/source installs.

Written for commit e297728. Summary will update on new commits. Review in cubic

Change-Id: I5dea4df3b40e1d18c286f8bc4c098e14989a0c08
Copilot AI review requested due to automatic review settings May 27, 2026 08:05
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 27, 2026

Reviewer's Guide

Adds a regression test ensuring the fallback version string embedded in src/agy_mcp/init.py stays in sync with the canonical project version in pyproject.toml, guarding against release-version drift in editable/source installs and skill bridge fallbacks.

File-Level Changes

Change Details Files
Add a regression test that asserts the source-checkout fallback version in the package init stays consistent with the project version defined in pyproject.toml.
  • Introduce tests/test_version.py to validate version metadata consistency using the repo root as a base.
  • Parse pyproject.toml via tomllib to extract the authoritative project.version value.
  • Parse src/agy_mcp/init.py with ast and collect string constants that look like semantic version strings (three numeric components separated by dots).
  • Assert that the pyproject version appears among the discovered fallback version strings to catch divergence during releases.
tests/test_version.py

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

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The AST walk currently treats any string constant with exactly two dots as a candidate version, which is brittle; consider narrowing this to version-like constants in a specific assignment (e.g., the fallback version variable or __version__) to avoid false positives as the module grows.
  • You may want to assert that the parsed pyproject.toml actually has the expected project and version keys and raise a clear failure message if not, so missing or reorganized metadata produces an explicit, actionable test failure rather than a generic KeyError.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The AST walk currently treats any string constant with exactly two dots as a candidate version, which is brittle; consider narrowing this to version-like constants in a specific assignment (e.g., the fallback version variable or `__version__`) to avoid false positives as the module grows.
- You may want to assert that the parsed `pyproject.toml` actually has the expected `project` and `version` keys and raise a clear failure message if not, so missing or reorganized metadata produces an explicit, actionable test failure rather than a generic KeyError.

## Individual Comments

### Comment 1
<location path="tests/test_version.py" line_range="31" />
<code_context>
+        and node.value.count(".") == 2
+    ]
+
+    assert expected in fallback_versions
</code_context>
<issue_to_address>
**suggestion (testing):** Strengthen the assertion by checking for a single, exact fallback version instead of membership in a list.

`expected in fallback_versions` will still pass if extra version-like literals are present. To make this a stricter regression guard, assert that there is exactly one fallback version and that it equals `expected`, e.g. `assert fallback_versions == [expected]` or `assert len(fallback_versions) == 1 and fallback_versions[0] == expected`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread tests/test_version.py Outdated
and node.value.count(".") == 2
]

assert expected in fallback_versions
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (testing): Strengthen the assertion by checking for a single, exact fallback version instead of membership in a list.

expected in fallback_versions will still pass if extra version-like literals are present. To make this a stricter regression guard, assert that there is exactly one fallback version and that it equals expected, e.g. assert fallback_versions == [expected] or assert len(fallback_versions) == 1 and fallback_versions[0] == expected.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

Warning

Review limit reached

@Boulea7, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 41 minutes and 3 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e4cbf496-887e-4819-83da-978df451b676

📥 Commits

Reviewing files that changed from the base of the PR and between 6d619b0 and e297728.

📒 Files selected for processing (1)
  • tests/test_version.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/version-fallback-drift-test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 527d824728

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/test_version.py Outdated
Comment on lines +28 to +31
and node.value.count(".") == 2
]

assert expected in fallback_versions
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Assert the fallback assignment, not any dotted string

If src/agy_mcp/__init__.py later contains any other string constant matching the package version, this test will still pass even when the actual __version__ fallback has drifted, because it accepts every string with exactly two dots rather than the value assigned in the PackageNotFoundError handler. That leaves the release-drift regression this test is meant to catch unguarded in that scenario; parse the __version__ assignment in the fallback block instead of scanning all constants.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a regression test to ensure the hard-coded __version__ fallback used for editable/source checkouts stays in sync with pyproject.toml, preventing release-version drift.

Changes:

  • Introduce tests/test_version.py to compare pyproject.toml’s project.version with the fallback version embedded in src/agy_mcp/__init__.py.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_version.py Outdated
Comment on lines +23 to +31
fallback_versions = [
node.value
for node in ast.walk(tree)
if isinstance(node, ast.Constant)
and isinstance(node.value, str)
and node.value.count(".") == 2
]

assert expected in fallback_versions
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Re-trigger cubic

Change-Id: I09b3766819ba598859329728a25742400bff18bb
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