Skip to content

test: type core verification and semantic contracts - #286

Merged
Sinity merged 4 commits into
masterfrom
feature/refactor/core-verification-test-contracts
Apr 21, 2026
Merged

Sinity merged 4 commits into
masterfrom
feature/refactor/core-verification-test-contracts

Conversation

@Sinity

@Sinity Sinity commented Apr 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Remove explicit Any usage from tests/unit/core by promoting core test fixtures, schema payloads, repository fixtures, and Hypothesis model strategies to concrete typed contracts.
  • Tighten schema generation/verification tests, conversation semantic tests, timestamp/privacy/filter law tests, and semantic-facts tests without changing production behavior.
  • Make semantic-facts repo-name expectations derive from the test checkout root instead of hard-coding polylogue, so isolated worktrees remain valid.

Problem

  • The mypy cleanup campaign had already tightened production and devtools seams, but tests/unit/core still had broad dynamic boundaries that obscured the model/schema contracts those tests are supposed to verify.
  • Several malformed-input tests used Any where the intent was actually object plus explicit narrowing/casting at the invalid boundary.
  • Some semantic-facts tests assumed a fixed checkout directory name, which fails in isolated worktrees like /tmp/polylogue-281.

Solution

  • Replace Any annotations in 13 core test files with concrete Conversation, Message, ConversationRepository, Path, JSON document/value aliases, and targeted callable/projection contracts.
  • Use object for deliberately malformed payloads and narrow at the exact call site where runtime guard behavior is under test.
  • Keep dynamic schema traversal local and typed through JSONDocument, JSONValue, and json_document helpers.
  • Derive expected repo names from REPO_ROOT.name in semantic-facts coverage.

Verification

  • ruff format tests/unit/core/test_message_laws.py tests/unit/core/test_filter_composition_laws.py tests/unit/core/test_privacy_guards.py tests/unit/core/test_timestamp_guards.py tests/unit/core/test_conversation_semantics.py tests/unit/core/test_query_retrieval_candidates.py tests/unit/core/test_semantic_facts.py tests/unit/core/test_synthetic_semantic_wiring.py tests/unit/core/test_schema_corpus_alignment.py tests/unit/core/test_filters_schemas.py
  • ruff check tests/unit/core/test_message_laws.py tests/unit/core/test_filter_composition_laws.py tests/unit/core/test_privacy_guards.py tests/unit/core/test_timestamp_guards.py tests/unit/core/test_conversation_semantics.py tests/unit/core/test_query_retrieval_candidates.py tests/unit/core/test_semantic_facts.py tests/unit/core/test_synthetic_semantic_wiring.py tests/unit/core/test_schema_corpus_alignment.py tests/unit/core/test_filters_schemas.py
  • mypy tests/unit/core/test_message_laws.py tests/unit/core/test_filter_composition_laws.py tests/unit/core/test_privacy_guards.py tests/unit/core/test_timestamp_guards.py tests/unit/core/test_conversation_semantics.py tests/unit/core/test_query_retrieval_candidates.py tests/unit/core/test_semantic_facts.py tests/unit/core/test_synthetic_semantic_wiring.py tests/unit/core/test_schema_corpus_alignment.py tests/unit/core/test_filters_schemas.py
  • pytest -q tests/unit/core/test_message_laws.py tests/unit/core/test_filter_composition_laws.py tests/unit/core/test_privacy_guards.py tests/unit/core/test_timestamp_guards.py tests/unit/core/test_conversation_semantics.py tests/unit/core/test_query_retrieval_candidates.py tests/unit/core/test_semantic_facts.py tests/unit/core/test_synthetic_semantic_wiring.py tests/unit/core/test_schema_corpus_alignment.py tests/unit/core/test_filters_schemas.py
  • PATH=/tmp/polylogue-281/.cache/codex-bin:$PATH devtools verify --quick
  • pre-push devtools verify --quick

Ref #281

@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 15 minutes and 4 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 15 minutes and 4 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: 7335ec7a-6b5c-4590-b8ee-572f71fe3755

📥 Commits

Reviewing files that changed from the base of the PR and between 38e8371 and 5066359.

📒 Files selected for processing (13)
  • tests/unit/core/test_conversation_semantics.py
  • tests/unit/core/test_filter_composition_laws.py
  • tests/unit/core/test_filters_schemas.py
  • tests/unit/core/test_message_laws.py
  • tests/unit/core/test_models.py
  • tests/unit/core/test_privacy_guards.py
  • tests/unit/core/test_query_retrieval_candidates.py
  • tests/unit/core/test_schema_corpus_alignment.py
  • tests/unit/core/test_schema_generation.py
  • tests/unit/core/test_semantic_facts.py
  • tests/unit/core/test_synthetic_semantic_wiring.py
  • tests/unit/core/test_timestamp_guards.py
  • tests/unit/core/test_verification.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/core-verification-test-contracts

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 879c3af into master Apr 21, 2026
13 of 14 checks passed
@Sinity
Sinity deleted the feature/refactor/core-verification-test-contracts branch April 21, 2026 08:21
Sinity added a commit that referenced this pull request Apr 22, 2026
## Summary
- Remove explicit `Any` usage from `tests/unit/core` by promoting core test fixtures, schema payloads, repository fixtures, and Hypothesis model strategies to concrete typed contracts.
- Tighten schema generation/verification tests, conversation semantic tests, timestamp/privacy/filter law tests, and semantic-facts tests without changing production behavior.
- Make semantic-facts repo-name expectations derive from the test checkout root instead of hard-coding `polylogue`, so isolated worktrees remain valid.

## Problem
- The mypy cleanup campaign had already tightened production and devtools seams, but `tests/unit/core` still had broad dynamic boundaries that obscured the model/schema contracts those tests are supposed to verify.
- Several malformed-input tests used `Any` where the intent was actually `object` plus explicit narrowing/casting at the invalid boundary.
- Some semantic-facts tests assumed a fixed checkout directory name, which fails in isolated worktrees like `/tmp/polylogue-281`.

## Solution
- Replace `Any` annotations in 13 core test files with concrete `Conversation`, `Message`, `ConversationRepository`, `Path`, JSON document/value aliases, and targeted callable/projection contracts.
- Use `object` for deliberately malformed payloads and narrow at the exact call site where runtime guard behavior is under test.
- Keep dynamic schema traversal local and typed through `JSONDocument`, `JSONValue`, and `json_document` helpers.
- Derive expected repo names from `REPO_ROOT.name` in semantic-facts coverage.

## Verification
- `ruff format tests/unit/core/test_message_laws.py tests/unit/core/test_filter_composition_laws.py tests/unit/core/test_privacy_guards.py tests/unit/core/test_timestamp_guards.py tests/unit/core/test_conversation_semantics.py tests/unit/core/test_query_retrieval_candidates.py tests/unit/core/test_semantic_facts.py tests/unit/core/test_synthetic_semantic_wiring.py tests/unit/core/test_schema_corpus_alignment.py tests/unit/core/test_filters_schemas.py`
- `ruff check tests/unit/core/test_message_laws.py tests/unit/core/test_filter_composition_laws.py tests/unit/core/test_privacy_guards.py tests/unit/core/test_timestamp_guards.py tests/unit/core/test_conversation_semantics.py tests/unit/core/test_query_retrieval_candidates.py tests/unit/core/test_semantic_facts.py tests/unit/core/test_synthetic_semantic_wiring.py tests/unit/core/test_schema_corpus_alignment.py tests/unit/core/test_filters_schemas.py`
- `mypy tests/unit/core/test_message_laws.py tests/unit/core/test_filter_composition_laws.py tests/unit/core/test_privacy_guards.py tests/unit/core/test_timestamp_guards.py tests/unit/core/test_conversation_semantics.py tests/unit/core/test_query_retrieval_candidates.py tests/unit/core/test_semantic_facts.py tests/unit/core/test_synthetic_semantic_wiring.py tests/unit/core/test_schema_corpus_alignment.py tests/unit/core/test_filters_schemas.py`
- `pytest -q tests/unit/core/test_message_laws.py tests/unit/core/test_filter_composition_laws.py tests/unit/core/test_privacy_guards.py tests/unit/core/test_timestamp_guards.py tests/unit/core/test_conversation_semantics.py tests/unit/core/test_query_retrieval_candidates.py tests/unit/core/test_semantic_facts.py tests/unit/core/test_synthetic_semantic_wiring.py tests/unit/core/test_schema_corpus_alignment.py tests/unit/core/test_filters_schemas.py`
- `PATH=/tmp/polylogue-281/.cache/codex-bin:$PATH devtools verify --quick`
- pre-push `devtools verify --quick`

Ref #281
Sinity added a commit that referenced this pull request Apr 22, 2026
`tests/unit/core` still had broad dynamic boundaries that obscured
the model/schema contracts those tests are supposed to verify.
Several malformed-input tests used `Any` where the intent was
actually `object` plus explicit narrowing/casting at the invalid
boundary. Some semantic-facts tests assumed a fixed checkout
directory name, which fails in isolated worktrees like
`/tmp/polylogue-281`.

Replaces `Any` annotations in 13 core test files with concrete
`Conversation`, `Message`, `ConversationRepository`, `Path`, JSON
document/value aliases, and targeted callable/projection contracts.
Uses `object` for deliberately malformed payloads and narrows at
the exact call site where runtime guard behavior is under test.
Keeps dynamic schema traversal local and typed through
`JSONDocument`, `JSONValue`, and `json_document` helpers. Derives
expected repo names from `REPO_ROOT.name` in semantic-facts
coverage so isolated worktrees remain valid.

No production behavior change.

Verification: ruff + mypy + pytest over the touched core test
files; devtools verify --quick green.

Ref #281
Sinity added a commit that referenced this pull request Apr 22, 2026
`tests/unit/core` still had broad dynamic boundaries that obscured
the model/schema contracts those tests are supposed to verify.
Several malformed-input tests used `Any` where the intent was
actually `object` plus explicit narrowing/casting at the invalid
boundary. Some semantic-facts tests assumed a fixed checkout
directory name, which fails in isolated worktrees like
`/tmp/polylogue-281`.

Replaces `Any` annotations in 13 core test files with concrete
`Conversation`, `Message`, `ConversationRepository`, `Path`, JSON
document/value aliases, and targeted callable/projection contracts.
Uses `object` for deliberately malformed payloads and narrows at
the exact call site where runtime guard behavior is under test.
Keeps dynamic schema traversal local and typed through
`JSONDocument`, `JSONValue`, and `json_document` helpers. Derives
expected repo names from `REPO_ROOT.name` in semantic-facts
coverage so isolated worktrees remain valid.

No production behavior change.

Verification: ruff + mypy + pytest over the touched core test
files; devtools verify --quick green.

Ref #281
Sinity added a commit that referenced this pull request Apr 22, 2026
`tests/unit/core` still had broad dynamic boundaries that obscured
the model/schema contracts those tests are supposed to verify.
Several malformed-input tests used `Any` where the intent was
actually `object` plus explicit narrowing/casting at the invalid
boundary. Some semantic-facts tests assumed a fixed checkout
directory name, which fails in isolated worktrees like
`/tmp/polylogue-281`.

Replaces `Any` annotations in 13 core test files with concrete
`Conversation`, `Message`, `ConversationRepository`, `Path`, JSON
document/value aliases, and targeted callable/projection contracts.
Uses `object` for deliberately malformed payloads and narrows at
the exact call site where runtime guard behavior is under test.
Keeps dynamic schema traversal local and typed through
`JSONDocument`, `JSONValue`, and `json_document` helpers. Derives
expected repo names from `REPO_ROOT.name` in semantic-facts
coverage so isolated worktrees remain valid.

No production behavior change.

Verification: ruff + mypy + pytest over the touched core test
files; 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. Keep them coming!

ℹ️ 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
@Sinity
Sinity removed the request for review from Copilot May 1, 2026 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant