Skip to content

refactor: promote schema relation and core test contracts - #285

Merged
Sinity merged 4 commits into
masterfrom
feature/refactor/source-test-contract-cleanup
Apr 21, 2026
Merged

Sinity merged 4 commits into
masterfrom
feature/refactor/source-test-contract-cleanup

Conversation

@Sinity

@Sinity Sinity commented Apr 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Promote schema relation targets from a dynamic _ref_target attribute into the typed FieldStats.ref_target contract.
  • Replace several source-side type: ignore suppressions with explicit protocols, casts, or version-gated imports.
  • Remove explicit Any from core config, privacy, schema validation, field stats, JSON, annotation, and version test files.

Problem

The previous mypy cleanup removed the broad exclusion list and explicit first-party Any from source modules, but a few source suppressions still represented real internal concepts rather than unavoidable dynamic boundaries. Core tests also still had substantial fixture/callback Any usage, making the test suite less useful as documentation of the typed contracts it exercises.

Ref #281

Solution

  • Added FieldStats.ref_target and updated relation detection, annotation generation, and relation tests to use the typed field directly.
  • Replaced source suppressions around Rich progress, structlog stderr proxying, Pydantic schema handler access, and TOML loading with explicit typed boundaries.
  • Retained only the source suppressions that still reflect valid external/dynamic constraints: untyped dateparser and dataclass replace over the fluent query-plan builder.
  • Typed core test fixtures and helpers with Path, pytest.MonkeyPatch, protocols, callable aliases, JSONDocument, and Hypothesis DataObject.

Verification

  • pytest -q tests/unit/core/test_schema_relational_inference.py tests/unit/core/test_schema_annotation_contracts.py tests/unit/core/test_schema_generation.py tests/unit/core/test_schema_validation.py
  • pytest -q tests/unit/core/test_privacy_config.py tests/unit/core/test_config.py tests/unit/core/test_schema_validation.py
  • pytest -q tests/unit/core/test_json.py tests/unit/core/test_field_stats.py tests/unit/core/test_schema_annotation_contracts.py
  • pytest -q tests/unit/core/test_version.py
  • PATH=/tmp/polylogue-281/.cache/codex-bin:$PATH devtools verify --quick
  • PATH=/tmp/polylogue-281/.cache/codex-bin:$PATH git push -u origin feature/refactor/source-test-contract-cleanup

@coderabbitai

coderabbitai Bot commented Apr 21, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 37 minutes and 25 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 37 minutes and 25 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 83f49a31-2ad3-4e51-95ca-fe973f299e8f

📥 Commits

Reviewing files that changed from the base of the PR and between dd31b9d and 4503902.

📒 Files selected for processing (16)
  • polylogue/cli/run_observers.py
  • polylogue/lib/messages.py
  • polylogue/logging.py
  • polylogue/schemas/field_stats_collection.py
  • polylogue/schemas/field_stats_models.py
  • polylogue/schemas/generation_field_annotations.py
  • polylogue/schemas/privacy_config.py
  • polylogue/schemas/relational_inference_foreign_keys.py
  • tests/unit/core/test_config.py
  • tests/unit/core/test_field_stats.py
  • tests/unit/core/test_json.py
  • tests/unit/core/test_privacy_config.py
  • tests/unit/core/test_schema_annotation_contracts.py
  • tests/unit/core/test_schema_relational_inference.py
  • tests/unit/core/test_schema_validation.py
  • tests/unit/core/test_version.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/source-test-contract-cleanup

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.

@Sinity
Sinity merged commit 38e8371 into master Apr 21, 2026
12 checks passed
@Sinity
Sinity deleted the feature/refactor/source-test-contract-cleanup branch April 21, 2026 07:49
Sinity added a commit that referenced this pull request Apr 22, 2026
## Summary
- Promote schema relation targets from a dynamic `_ref_target` attribute into the typed `FieldStats.ref_target` contract.
- Replace several source-side `type: ignore` suppressions with explicit protocols, casts, or version-gated imports.
- Remove explicit `Any` from core config, privacy, schema validation, field stats, JSON, annotation, and version test files.

## Problem
The previous mypy cleanup removed the broad exclusion list and explicit first-party `Any` from source modules, but a few source suppressions still represented real internal concepts rather than unavoidable dynamic boundaries. Core tests also still had substantial fixture/callback `Any` usage, making the test suite less useful as documentation of the typed contracts it exercises.

Ref #281

## Solution
- Added `FieldStats.ref_target` and updated relation detection, annotation generation, and relation tests to use the typed field directly.
- Replaced source suppressions around Rich progress, structlog stderr proxying, Pydantic schema handler access, and TOML loading with explicit typed boundaries.
- Retained only the source suppressions that still reflect valid external/dynamic constraints: untyped `dateparser` and dataclass `replace` over the fluent query-plan builder.
- Typed core test fixtures and helpers with `Path`, `pytest.MonkeyPatch`, protocols, callable aliases, `JSONDocument`, and Hypothesis `DataObject`.

## Verification
- `pytest -q tests/unit/core/test_schema_relational_inference.py tests/unit/core/test_schema_annotation_contracts.py tests/unit/core/test_schema_generation.py tests/unit/core/test_schema_validation.py`
- `pytest -q tests/unit/core/test_privacy_config.py tests/unit/core/test_config.py tests/unit/core/test_schema_validation.py`
- `pytest -q tests/unit/core/test_json.py tests/unit/core/test_field_stats.py tests/unit/core/test_schema_annotation_contracts.py`
- `pytest -q tests/unit/core/test_version.py`
- `PATH=/tmp/polylogue-281/.cache/codex-bin:$PATH devtools verify --quick`
- `PATH=/tmp/polylogue-281/.cache/codex-bin:$PATH git push -u origin feature/refactor/source-test-contract-cleanup`
@Sinity Sinity added area:qa QA area:schema Schema tool:claude Claude type:refactor Code restructuring labels Apr 22, 2026
Sinity added a commit that referenced this pull request Apr 22, 2026
Previous mypy cleanup removed the broad exclusion list and explicit
first-party `Any` from source modules, but a few source suppressions
still represented real internal concepts rather than unavoidable
dynamic boundaries. Core tests also still had substantial fixture/
callback `Any` usage, making the suite less useful as documentation
of the typed contracts it exercises.

Promotes `FieldStats.ref_target` from a dynamic `_ref_target`
attribute into a typed field; relation detection, annotation
generation, and relation tests use it directly. Replaces source
suppressions around Rich progress, structlog stderr proxying,
Pydantic schema handler access, and TOML loading with explicit
typed boundaries. Retains only the source suppressions that still
reflect valid external/dynamic constraints (untyped `dateparser`,
dataclass `replace` over the fluent query-plan builder). Types core
test fixtures and helpers with `Path`, `pytest.MonkeyPatch`,
protocols, callable aliases, `JSONDocument`, and Hypothesis
`DataObject`.

Verification: pytest + mypy over schema relation/annotation/
generation/validation, privacy/config, json/field-stats, and
version suites; devtools verify --quick green.

Ref #281
Sinity added a commit that referenced this pull request Apr 22, 2026
Previous mypy cleanup removed the broad exclusion list and explicit
first-party `Any` from source modules, but a few source suppressions
still represented real internal concepts rather than unavoidable
dynamic boundaries. Core tests also still had substantial fixture/
callback `Any` usage, making the suite less useful as documentation
of the typed contracts it exercises.

Promotes `FieldStats.ref_target` from a dynamic `_ref_target`
attribute into a typed field; relation detection, annotation
generation, and relation tests use it directly. Replaces source
suppressions around Rich progress, structlog stderr proxying,
Pydantic schema handler access, and TOML loading with explicit
typed boundaries. Retains only the source suppressions that still
reflect valid external/dynamic constraints (untyped `dateparser`,
dataclass `replace` over the fluent query-plan builder). Types core
test fixtures and helpers with `Path`, `pytest.MonkeyPatch`,
protocols, callable aliases, `JSONDocument`, and Hypothesis
`DataObject`.

Verification: pytest + mypy over schema relation/annotation/
generation/validation, privacy/config, json/field-stats, and
version suites; devtools verify --quick green.

Ref #281
Sinity added a commit that referenced this pull request Apr 22, 2026
Previous mypy cleanup removed the broad exclusion list and explicit
first-party `Any` from source modules, but a few source suppressions
still represented real internal concepts rather than unavoidable
dynamic boundaries. Core tests also still had substantial fixture/
callback `Any` usage, making the suite less useful as documentation
of the typed contracts it exercises.

Promotes `FieldStats.ref_target` from a dynamic `_ref_target`
attribute into a typed field; relation detection, annotation
generation, and relation tests use it directly. Replaces source
suppressions around Rich progress, structlog stderr proxying,
Pydantic schema handler access, and TOML loading with explicit
typed boundaries. Retains only the source suppressions that still
reflect valid external/dynamic constraints (untyped `dateparser`,
dataclass `replace` over the fluent query-plan builder). Types core
test fixtures and helpers with `Path`, `pytest.MonkeyPatch`,
protocols, callable aliases, `JSONDocument`, and Hypothesis
`DataObject`.

Verification: pytest + mypy over schema relation/annotation/
generation/validation, privacy/config, json/field-stats, and
version suites; devtools verify --quick green.

Ref #281
@Sinity

Sinity commented May 1, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ 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".

@Sinity
Sinity requested a review from Copilot May 1, 2026 01:52

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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