Skip to content

chore(codeql): break static model import cycles#21

Merged
saagpatel merged 1 commit into
mainfrom
codex/fix-cyclic-imports
May 18, 2026
Merged

chore(codeql): break static model import cycles#21
saagpatel merged 1 commit into
mainfrom
codex/fix-cyclic-imports

Conversation

@saagpatel
Copy link
Copy Markdown
Owner

What

  • Breaks the static CodeQL cyclic-import chain rooted in src.models.
  • Keeps AuditReport.from_audits as the public factory API while deferring report assembly dependencies dynamically.

Why

  • The remaining open CodeQL family on main is py/cyclic-import.
  • The model layer was importing scorer/report modules that import the model layer back, creating broad static cycles across analyzers, scorer, and reporting helpers.

How

  • Converts the report-only imports in AuditReport.from_audits to call-time dynamic imports through importlib.import_module.
  • Leaves the dataclasses and output shape unchanged.

Testing

  • python3 -m pytest -q -p no:cacheprovider -> 2085 passed, 2 skipped, 1 warning.
  • ruff check src/ tests/ -> All checks passed.

Performance Impact

  • None expected for normal operation; the same modules are loaded when report assembly runs.

Risk / Notes

  • Low behavior risk, but CodeQL needs to confirm this resolves the static cycle family on the public branch.

- Keep AuditReport assembly imports deferred and dynamic
- Preserve the existing AuditReport.from_audits API while keeping models import-light

Tests: python3 -m pytest -q -p no:cacheprovider; ruff check src/ tests/
@saagpatel saagpatel merged commit d58f4bd into main May 18, 2026
3 checks passed
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.

1 participant