Skip to content

Comments

feat: pytest-authoritative collection (closes #98)#99

Merged
NikkeTryHard merged 8 commits intomasterfrom
feat/pytest-authoritative-collection
Feb 11, 2026
Merged

feat: pytest-authoritative collection (closes #98)#99
NikkeTryHard merged 8 commits intomasterfrom
feat/pytest-authoritative-collection

Conversation

@NikkeTryHard
Copy link
Owner

@NikkeTryHard NikkeTryHard commented Feb 11, 2026

Summary

Make pytest's perform_collect() the single source of truth for test discovery, eliminating the 142-module tests.py collection gap.

  • Add CollectedTest IPC wire format and get_collected_tests() Python serializer
  • Zygote sends collected test list back to Supervisor after session effects handshake
  • Supervisor merges pytest's authoritative list with Rust's toxicity/fixture data
  • Add tests.py to is_test_file() for accurate toxicity scanning
  • Falls back to Rust-only discovery if pytest collects nothing

Architecture

Zygote: init_session() → perform_collect() → _ITEMS_MAP populated
Zygote: get_collected_tests() → Vec<CollectedTest> serialized
Zygote: cmd_socket.write_all(framed_collected_tests)   ← NEW
Supervisor: read collected tests from socket             ← NEW
Supervisor: merge with toxicity graph → final RunnableTest list

Testing

  • 948 unit tests pass (4 new: roundtrip, empty, large batch, is_test_name)
  • cargo fmt --check clean
  • cargo clippy -- -D warnings clean
  • E2E with Django test suite requires Docker (not tested in CI)

Closes #98

Summary by CodeRabbit

Release Notes

  • New Features
    • Test discovery now incorporates pytest-collected metadata as the authoritative source for test detection.
    • Added support for tests.py files in test discovery workflows.
    • Enhanced test metadata handling, including marker detection and async test identification.

@NikkeTryHard NikkeTryHard merged commit 705a4f9 into master Feb 11, 2026
1 of 2 checks passed
@github-actions github-actions bot added documentation Improvements or additions to documentation rust python core discovery execution labels Feb 11, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR implements the pytest-authoritative collection workflow by introducing a CollectedTest data structure and IPC communication pathway. The Zygote now fetches test metadata from Python's pytest collection and sends it to the Supervisor, which merges this authoritative list with Rust-discovered toxicity and fixture data to form the final RunnableTest schedule.

Changes

Cohort / File(s) Summary
Protocol Definition
src/core/protocol.rs
Introduces CollectedTest struct with node_id, file_path, markers, and is_async fields; includes wire-format round-trip, empty list, and large batch tests.
Test Discovery Extension
src/discovery/scanner.rs
Extends is_test_file logic to recognize tests.py as a valid test file name; adds unit test validation.
Python Harness API
src/tach_harness.py
Adds get_collected_tests() function that serializes _ITEMS_MAP entries with node_id, file_path, markers, and is_async metadata for export to Rust.
Zygote Integration
src/execution/zygote.rs
Reworks Python initialization to collect pytest-authoritative test metadata via get_collected_tests(); broadcasts collected_tests alongside session_effects over IPC with length-prefix framing; updates return type to tuple of (effects, collected_tests).
Supervisor Merging
src/main.rs
Reads collected_tests from IPC; merges pytest-authoritative tests with Rust-discovered toxicity/fixture data by node_id; creates conservative RunnableTest entries for Python-only tests; logs merged test counts and toxicity determination.
Architecture Plan
docs/plans/2026-02-11-pytest-authoritative-collection.md
Comprehensive design document outlining multi-batch implementation strategy, data structures, IPC wiring, edge-case handling, and integration test scaffolding for pytest-authoritative collection workflow.

Sequence Diagram(s)

sequenceDiagram
    participant Supervisor as Supervisor<br/>(main.rs)
    participant Zygote as Zygote<br/>(zygote.rs)
    participant PythonHarness as Python Harness<br/>(tach_harness.py)
    participant IPC as IPC Channel
    participant ToxGraph as Toxicity Graph<br/>(Rust Scan)

    Supervisor->>Zygote: Spawn + config
    Zygote->>PythonHarness: Load module & init_session(TACH_TARGET_PATH)
    PythonHarness->>PythonHarness: pytest perform_collect()
    PythonHarness->>PythonHarness: Populate _ITEMS_MAP
    activate PythonHarness
    PythonHarness->>PythonHarness: get_collected_tests() → serialize metadata
    deactivate PythonHarness
    Zygote->>IPC: Send session_effects (existing)
    Zygote->>IPC: Send collected_tests vector (new)
    Supervisor->>IPC: Recv session_effects
    Supervisor->>IPC: Recv collected_tests
    Supervisor->>ToxGraph: Lookup toxicity for Python-only tests
    Supervisor->>Supervisor: Merge: collected_tests + Rust RunnableTests by node_id
    Supervisor->>Supervisor: Create RunnableTest for Python-only entries
    Supervisor->>Supervisor: Build final RunnableTest list (Rust+Python merged)
    Supervisor->>Supervisor: Schedule tests (pytest-authoritative source)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • PR #72: Modifies tach_harness.py and scanner.rs in ways that directly intersect with the new get_collected_tests() function and expanded scanner behavior for tests.py file recognition.

Suggested labels

rust, core, discovery, execution, python, tests, documentation

Poem

🐰 The Rust and Python now dance in sync so fine,
Where pytest's discoveries become the authoritative line!
No more tests.py left behind to weep,
The Zygote whispers over IPC, secrets deep!
Merged toxicity graphs and fixtures unite,
Where Supervisor schedules tests, both day and night. 🎯

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/pytest-authoritative-collection

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.

NikkeTryHard added a commit that referenced this pull request Feb 12, 2026
Move 138 zero-failure modules to Cleared (pending tach re-test) and 4
modules with pytest failures to Failures. Remove Blocked section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core discovery documentation Improvements or additions to documentation execution python rust

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: pytest-authoritative collection — feed Zygote collection results back to Supervisor

1 participant