Skip to content

test: add mutation law frontier suites - #348

Merged
Sinity merged 1 commit into
masterfrom
feature/test/mutation-law-frontiers
Apr 22, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/test/mutation-law-frontiers

Conversation

@Sinity

@Sinity Sinity commented Apr 22, 2026 •

Copy link
Copy Markdown
Owner

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

@coderabbitai

coderabbitai Bot commented Apr 22, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Two 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

Cohort / File(s) Summary
Filter Property Tests
tests/unit/core/test_filters_props.py
Added _conversation_ids() helper and two property-based tests verifying filter subset behavior, count consistency, and semantic equivalence of filter order (commutativity of .provider() and .title() filters).
Provider Detection Tests
tests/unit/sources/test_source_laws.py
Added _minimal_chatgpt_payload() helper and parametrized test verifying that provider detection correctly identifies ChatGPT payloads even when stream names suggest alternative grouping strategies; validates payload order and detection metrics preservation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • The PR addresses objectives from issue #327, which targets mutation-frontier test suites for filter semantics covering provider filtering subset behavior and filter order equivalence laws.

Poem

🐰 Whiskers twitching with test-day cheer,
Filters bounded, provider clear,
Properties checked both far and wide,
No misleading streams can hide! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding mutation law frontier test suites addressing issue #327.
Description check ✅ Passed The description includes all required sections (Summary, Problem, Solution, Verification) with clear, detailed information about the changes and testing performed.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/test/mutation-law-frontiers

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.

@coderabbitai coderabbitai Bot 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between f97a0ab and bad1dc1.

📒 Files selected for processing (2)
  • tests/unit/core/test_filters_props.py
  • tests/unit/sources/test_source_laws.py

Comment on lines +435 to +453
@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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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).

@Sinity
Sinity merged commit bcb5cc3 into master Apr 22, 2026
14 checks passed
@Sinity
Sinity deleted the feature/test/mutation-law-frontiers branch April 22, 2026 05:22
Sinity added a commit that referenced this pull request Apr 22, 2026
## 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`
Sinity added a commit that referenced this pull request Apr 22, 2026
#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
Sinity added a commit that referenced this pull request Apr 22, 2026
#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
Sinity added a commit that referenced this pull request Apr 22, 2026
#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
@Sinity

Sinity commented Apr 28, 2026

Copy link
Copy Markdown
Owner Author

🤖 Post-hoc audit note: this PR received bot review feedback verified against current HEAD as part of #544. 1 finding(s) confirmed still present → tracked in #550.

@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. 🎉

ℹ️ 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 review from Copilot and removed request for Copilot May 1, 2026 00:43
@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:53

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants