Repository navigation
test: type core verification and semantic contracts - #286
Conversation
|
Warning Rate limit exceeded
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 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (13)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
## 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
`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
`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
`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
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Summary
Anyusage fromtests/unit/coreby promoting core test fixtures, schema payloads, repository fixtures, and Hypothesis model strategies to concrete typed contracts.polylogue, so isolated worktrees remain valid.Problem
tests/unit/corestill had broad dynamic boundaries that obscured the model/schema contracts those tests are supposed to verify.Anywhere the intent was actuallyobjectplus explicit narrowing/casting at the invalid boundary./tmp/polylogue-281.Solution
Anyannotations in 13 core test files with concreteConversation,Message,ConversationRepository,Path, JSON document/value aliases, and targeted callable/projection contracts.objectfor deliberately malformed payloads and narrow at the exact call site where runtime guard behavior is under test.JSONDocument,JSONValue, andjson_documenthelpers.REPO_ROOT.namein 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.pyruff 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.pymypy 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.pypytest -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.pyPATH=/tmp/polylogue-281/.cache/codex-bin:$PATH devtools verify --quickdevtools verify --quickRef #281