Repository navigation
test: add mutation law frontier suites - #348
Conversation
📝 WalkthroughWalkthroughTwo test files are enhanced with property-based tests: one adds helper function and tests for filter semantics (subset behavior, count operations, filter order commutativity), and another introduces tests for provider detection that override misleading stream-based fallbacks. Total of 76 lines added across tests. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/unit/core/test_filters_props.py`:
- Around line 435-453: The test
test_equivalent_filter_order_list_count_and_first_law currently only exercises
commutativity on a single matching conversation, so it can miss bugs that affect
ordering or multi-match behavior; update the test fixture (filter_repo or the
underlying seed used by filter_db) to add at least one more Conversation record
that satisfies both ConversationFilter(filter_repo).provider("claude-ai") and
.title("Python") (e.g., another claude-ai conversation with "Python" in its
title) so the assertions using .list(), .count(), and .first() actually validate
behavior over multiple matches and ordering; ensure the new seed is referenced
by the same fixtures used by this test so no test signature changes (symbols:
test_equivalent_filter_order_list_count_and_first_law, filter_repo,
ConversationFilter, provider, title, list, count, first).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: c16f6716-c39f-4b41-83d9-da88849621d3
📒 Files selected for processing (2)
tests/unit/core/test_filters_props.pytests/unit/sources/test_source_laws.py
| @pytest.mark.asyncio | ||
| async def test_equivalent_filter_order_list_count_and_first_law(filter_repo: ConversationRepository) -> None: | ||
| """Commutative filter constraints must agree across all terminal methods.""" | ||
| provider_then_title = await ConversationFilter(filter_repo).provider("claude-ai").title("Python").list() | ||
| title_then_provider = await ConversationFilter(filter_repo).title("Python").provider("claude-ai").list() | ||
|
|
||
| assert _conversation_ids(provider_then_title) == _conversation_ids(title_then_provider) | ||
| assert await ConversationFilter(filter_repo).provider("claude-ai").title("Python").count() == len( | ||
| provider_then_title | ||
| ) | ||
| assert await ConversationFilter(filter_repo).title("Python").provider("claude-ai").count() == len( | ||
| title_then_provider | ||
| ) | ||
|
|
||
| first_provider_then_title = await ConversationFilter(filter_repo).provider("claude-ai").title("Python").first() | ||
| first_title_then_provider = await ConversationFilter(filter_repo).title("Python").provider("claude-ai").first() | ||
| assert first_provider_then_title is not None | ||
| assert first_title_then_provider is not None | ||
| assert first_provider_then_title.id == first_title_then_provider.id |
There was a problem hiding this comment.
Commutativity law is weakly exercised — only one fixture conversation matches both filters.
With filter_db, only claude-1 ("Python Error Handling", claude-ai) matches both .provider("claude-ai") and .title("Python"), so every assertion here is comparing single-element (or single-ID) results. The list-equality, count-equality, and first()-equality checks therefore can't distinguish mutations that, e.g., drop/swap providers or titles but still leave a one-element result, or that permute multi-element ordering. Consider seeding at least one more conversation that satisfies both constraints (e.g., another claude-ai with "Python" in the title) so the list/first ordering assertions actually exercise commutativity over >1 match. Given .provider() extends the tuple and .title() replaces, each filter is applied once per chain here, which is the intended scope.
🔧 Proposed fixture extension
(
ConversationBuilder(db_path, "claude-2")
.provider("claude-ai")
.title("Database Design")
.add_message("m5", role="user", text="How to design a database schema?")
.add_message("m6", role="assistant", text="Start with identifying entities.")
.metadata({"tags": ["database", "design"]})
.save()
)
+
+ (
+ ConversationBuilder(db_path, "claude-3")
+ .provider("claude-ai")
+ .title("Python Data Classes")
+ .add_message("m7", role="user", text="How do dataclasses work?")
+ .add_message("m8", role="assistant", text="They reduce boilerplate.")
+ .metadata({"tags": ["python"]})
+ .save()
+ )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tests/unit/core/test_filters_props.py` around lines 435 - 453, The test
test_equivalent_filter_order_list_count_and_first_law currently only exercises
commutativity on a single matching conversation, so it can miss bugs that affect
ordering or multi-match behavior; update the test fixture (filter_repo or the
underlying seed used by filter_db) to add at least one more Conversation record
that satisfies both ConversationFilter(filter_repo).provider("claude-ai") and
.title("Python") (e.g., another claude-ai conversation with "Python" in its
title) so the assertions using .list(), .count(), and .first() actually validate
behavior over multiple matches and ordering; ensure the new seed is referenced
by the same fixtures used by this test so no test signature changes (symbols:
test_equivalent_filter_order_list_count_and_first_law, filter_repo,
ConversationFilter, provider, title, list, count, first).
## Summary Adds two focused law-style mutation frontier suites for `#327`: - filter semantic oracles covering provider/title composition across `list`, `count`, and `first` - source-detection adversary coverage where grouped-provider hints wrap ChatGPT-shaped JSONL payloads and payload shape must win Ref #327 ## Problem Issue #327 asks for mutation-guided law densification, not broad test-count growth. The current suite already has general filter and source laws, but it was missing small executable oracles for mutation classes such as count/list divergence, order-sensitive filter composition, and fallback/path-hint precedence over payload detection. ## Solution - Added filter frontier laws in `tests/unit/core/test_filters_props.py`: - provider filtering must agree with the base result order - filtered `count()` must match filtered `list()` length - equivalent provider/title filter order must agree across `list`, `count`, and `first` - Added source-detection frontier coverage in `tests/unit/sources/test_source_laws.py`: - `claude-code` and `codex` fallback hints cannot override ChatGPT-shaped JSONL entry payloads - emitted payloads remain preserved while provider attribution follows payload shape ## Verification - `pytest tests/unit/core/test_filters_props.py -q -k "provider_filter_list_count_subset_and_order_law or equivalent_filter_order_list_count_and_first_law"` — 2 passed - `pytest tests/unit/sources/test_source_laws.py -q -k "entry_payload_detection_overrides_misleading_grouped_fallback_law"` — 2 passed - `pytest tests/unit/core/test_filters_props.py -q` — 92 passed - `pytest tests/unit/sources/test_source_laws.py -q` — 110 passed - `ruff format tests/unit/core/test_filters_props.py tests/unit/sources/test_source_laws.py` - `ruff check tests/unit/core/test_filters_props.py tests/unit/sources/test_source_laws.py` - `devtools verify` — all checks passed - pre-push `devtools verify --quick` — all checks passed Relevant mutation campaign commands for this slice, not run locally here: - `devtools mutmut-campaign run filters` - `devtools mutmut-campaign run source-detection`
#327 asks for mutation-guided law densification, not broad test-count growth. The suite had general filter and source laws but was missing small executable oracles for mutation classes such as count/list divergence, order-sensitive filter composition, and fallback/path-hint precedence over payload detection. Adds filter frontier laws in `test_filters_props.py`: provider filtering must agree with the base result order; filtered `count()` must match filtered `list()` length; equivalent provider/title filter order must agree across `list`, `count`, and `first`. Adds source-detection frontier coverage in `test_source_laws.py`: `claude-code` and `codex` fallback hints cannot override ChatGPT-shaped JSONL entry payloads; emitted payloads remain preserved while provider attribution follows payload shape. Verification: ruff + pytest over focused filter/source-law suites (92 + 110 pass); devtools verify and --quick green. Ref #327
#327 asks for mutation-guided law densification, not broad test-count growth. The suite had general filter and source laws but was missing small executable oracles for mutation classes such as count/list divergence, order-sensitive filter composition, and fallback/path-hint precedence over payload detection. Adds filter frontier laws in `test_filters_props.py`: provider filtering must agree with the base result order; filtered `count()` must match filtered `list()` length; equivalent provider/title filter order must agree across `list`, `count`, and `first`. Adds source-detection frontier coverage in `test_source_laws.py`: `claude-code` and `codex` fallback hints cannot override ChatGPT-shaped JSONL entry payloads; emitted payloads remain preserved while provider attribution follows payload shape. Verification: ruff + pytest over focused filter/source-law suites (92 + 110 pass); devtools verify and --quick green. Ref #327
#327 asks for mutation-guided law densification, not broad test-count growth. The suite had general filter and source laws but was missing small executable oracles for mutation classes such as count/list divergence, order-sensitive filter composition, and fallback/path-hint precedence over payload detection. Adds filter frontier laws in `test_filters_props.py`: provider filtering must agree with the base result order; filtered `count()` must match filtered `list()` length; equivalent provider/title filter order must agree across `list`, `count`, and `first`. Adds source-detection frontier coverage in `test_source_laws.py`: `claude-code` and `codex` fallback hints cannot override ChatGPT-shaped JSONL entry payloads; emitted payloads remain preserved while provider attribution follows payload shape. Verification: ruff + pytest over focused filter/source-law suites (92 + 110 pass); devtools verify and --quick green. Ref #327
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 ℹ️ 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". |
|
@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
Adds two focused law-style mutation frontier suites for
#327:list,count, andfirstRef #327
Problem
Issue #327 asks for mutation-guided law densification, not broad test-count growth. The current suite already has general filter and source laws, but it was missing small executable oracles for mutation classes such as count/list divergence, order-sensitive filter composition, and fallback/path-hint precedence over payload detection.
Solution
tests/unit/core/test_filters_props.py:count()must match filteredlist()lengthlist,count, andfirsttests/unit/sources/test_source_laws.py:claude-codeandcodexfallback hints cannot override ChatGPT-shaped JSONL entry payloadsVerification
pytest tests/unit/core/test_filters_props.py -q -k "provider_filter_list_count_subset_and_order_law or equivalent_filter_order_list_count_and_first_law"— 2 passedpytest tests/unit/sources/test_source_laws.py -q -k "entry_payload_detection_overrides_misleading_grouped_fallback_law"— 2 passedpytest tests/unit/core/test_filters_props.py -q— 92 passedpytest tests/unit/sources/test_source_laws.py -q— 110 passedruff format tests/unit/core/test_filters_props.py tests/unit/sources/test_source_laws.pyruff check tests/unit/core/test_filters_props.py tests/unit/sources/test_source_laws.pydevtools verify— all checks passeddevtools verify --quick— all checks passedRelevant mutation campaign commands for this slice, not run locally here:
devtools mutmut-campaign run filtersdevtools mutmut-campaign run source-detection