Skip to content

fix: address gaps#19

Merged
olivermeyer merged 3 commits into
mainfrom
fix/address-gaps
Mar 30, 2026
Merged

fix: address gaps#19
olivermeyer merged 3 commits into
mainfrom
fix/address-gaps

Conversation

@olivermeyer
Copy link
Copy Markdown
Collaborator

@olivermeyer olivermeyer commented Mar 30, 2026

This PR addresses a few gaps identified while trying to replace the corresponding components in Bridge:

  • Add FoundryContext.python_version to replace platform.python_version() calls throughout the code
  • Add version parameters to init_api() so callers don't need to do get_versioned_api_instances themselves
  • Use FoundryContext.env_prefix in Sentry, log and auth settings

olivermeyer and others added 3 commits March 30, 2026 17:13
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Files with missing lines Coverage Δ
src/aignostics_foundry_core/api/auth.py 100.00% <100.00%> (ø)
src/aignostics_foundry_core/api/core.py 98.01% <100.00%> (+0.12%) ⬆️
src/aignostics_foundry_core/foundry.py 96.55% <100.00%> (+0.06%) ⬆️
src/aignostics_foundry_core/log.py 93.18% <100.00%> (+0.15%) ⬆️
src/aignostics_foundry_core/sentry.py 95.18% <100.00%> (+0.11%) ⬆️

@olivermeyer olivermeyer added the claude Trigger Claude Code automation label Mar 30, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Mar 30, 2026

@olivermeyer olivermeyer marked this pull request as ready for review March 30, 2026 17:08
@olivermeyer olivermeyer requested a review from a team as a code owner March 30, 2026 17:08
@claude
Copy link
Copy Markdown

claude Bot commented Mar 30, 2026

Claude encountered an error —— View job


Code Review Complete ✅

Summary

This PR successfully addresses three gaps identified during Bridge component replacement:

  1. ✅ Adds FoundryContext.python_version field
  2. ✅ Adds versions parameter to init_api() for simplified API setup
  3. ✅ Consolidates environment prefix usage via FoundryContext.env_prefix

Verdict: Approve with minor suggestions - All changes are well-implemented, fully tested (100% coverage), and backwards compatible. Quality Gate passed. Two minor suggestions below for consideration.


Detailed Review

Strengths

  1. Excellent Test Coverage

    • 100% coverage on all modified lines (Codecov report)
    • All new functionality has comprehensive unit tests
    • Tests properly use @pytest.mark.unit markers
  2. Backwards Compatibility

    • All changes are additive and non-breaking
    • python_version defaults to empty string
    • versions parameter in init_api() is optional
    • Existing code continues to work without changes
  3. Code Quality

    • Follows Google-style docstrings
    • Proper type hints throughout
    • Consistent with project conventions
    • Conventional commit messages
  4. Design

    • env_prefix consolidation eliminates duplication
    • init_api() simplification reduces boilerplate for callers
    • python_version centralizes runtime metadata

💡 Suggestions (Optional)

1. Documentation Enhancement (Minor)

File: src/aignostics_foundry_core/AGENTS.md:26

The AGENTS.md update mentions init_api() but doesn't explicitly document the new versions parameter functionality. Consider adding:

**api.core** | Versioned API router and FastAPI factory | ... `init_api(root_path, lifespan, exception_handler_registrations, versions=None, version_exception_handler_registrations=None, **fastapi_kwargs)` — creates a `FastAPI` with standard Foundry exception handlers; when *versions* is supplied, automatically calls `get_versioned_api_instances()`, applies optional per-version exception handlers, and mounts each sub-app at `/{version}` on the root app

This makes the new capability more discoverable.

2. SonarQube Issues (Quality Gate Passed, but 2 new issues)

The SonarQube report shows 2 new issues (Quality Gate still passed). These are likely minor code smells. Without access to the detailed SonarQube report, I cannot identify the specific issues, but common S1192 violations in test files include:

  • Repeated string literals in test assertions
  • Duplicated mock patch paths

Recommendation: Review the SonarQube analysis to identify and address these 2 issues before merge.


🔍 Detailed File Review

src/aignostics_foundry_core/foundry.py

  • Change: Added python_version: str = "" field (line 68), populated via platform.python_version() (line 115)
  • Test: test_from_package_python_version_matches_platform() in tests/aignostics_foundry_core/foundry_test.py:50
  • Assessment: Clean implementation, proper default value, fully tested

src/aignostics_foundry_core/api/core.py

  • Change: Added versions and version_exception_handler_registrations parameters to init_api() (lines 397-398, 414-420)
  • Implementation: Lines 442-447 handle versioned app creation and mounting
  • Tests:
    • test_init_api_mounts_versioned_apps() (line 256)
    • test_init_api_applies_version_exception_handlers() (line 282)
    • test_init_api_without_versions_unchanged() (line 307)
  • Assessment: Well-implemented convenience feature, maintains backwards compatibility

src/aignostics_foundry_core/api/auth.py

  • Change: AuthSettings.__init__() derives prefix from get_context().env_prefix (line 48)
  • Test: test_auth_settings_uses_context_env_prefix() in tests/aignostics_foundry_core/api/auth_test.py:102
  • Assessment: Proper consolidation, eliminates hardcoded prefix

src/aignostics_foundry_core/sentry.py

  • Change: SentrySettings.__init__() derives prefix from get_context().env_prefix (line 133)
  • Tests: Multiple tests verify prefix usage
  • Assessment: Consistent with auth.py changes

src/aignostics_foundry_core/log.py

  • Change: LogSettings.__init__() derives prefix from get_context().env_prefix (line 135)
  • Tests: test_logging_initialize_* tests verify behavior
  • Assessment: Completes the consolidation pattern

🔒 Security Review

✅ No security concerns identified:

  • No new external dependencies
  • No credential handling changes
  • No SQL injection vectors
  • Settings validation remains intact
  • Sentry DSN validation unchanged

Performance Review

✅ No performance concerns:

  • platform.python_version() called once at startup
  • No additional runtime overhead
  • No blocking I/O introduced

📋 Commit Message Review

✅ All commits follow conventional commits:

  • feat(foundry): add python_version to FoundryContext (52a1c27)
  • feat(api): add versions param to init_api() (aa935d9)
  • fix(sentry): derive env_prefix from FoundryContext (954cddc)

Note: The third commit is marked as fix rather than refactor. While it does fix potential inconsistency, refactor might be more accurate since it doesn't fix a bug. Not a blocker, just an observation.


CI/CD Status

  • Codecov: 100% coverage on new code
  • SonarQube: Quality Gate passed (2 new issues - review recommended)
  • Tests: All passing

Recommendation

LGTM with minor follow-ups 🚀

The PR is well-crafted and ready to merge. Consider:

  1. Reviewing the 2 SonarQube issues (likely minor)
  2. Enhancing AGENTS.md documentation for the init_api() changes (optional)

Great work on maintaining the high quality standards of this repository!


@olivermeyer olivermeyer merged commit 4c4b748 into main Mar 30, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude Trigger Claude Code automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant