Skip to content

perf(tests): the invariant tests share one parse of the source tree #1749

Closed

Description

@dan-petty

Split from #1725 (CI time budget), so that this row is one issue delivered by one pull request.

Friction

The architectural and invariant tests each parse the whole source tree again, and several take over 5 seconds, against #1725's limit.

Evidence

The --durations=30 run at release/v0.2.38 49c0c61 on 2026-10-20, on a quiet host:

Test Time
test_architectural_invariants.py::test_no_non_submodule_imports_from_ai_and_github_facades 9.35s
test_the_source_tree_keeps_its_structural_invariants 6.92s
test_public_export_surface.py::test_no_phantom_exports 5.89s
test_no_duplicate_exports 4.79s
test_swallowed_failures_ratchet.py::test_swallowed_failures_stay_under_or_equal_to_ceiling 5.46s
test_test_module_independence.py::test_no_test_module_finds_a_path_from_its_own_file_or_imports_a_test_module 5.07s
test_no_test_certifies_a_failure_without_checking_it 4.91s
test_output.py::test_rich_imports_confined_to_output_submodule 4.48s
test_no_direct_data_dir_path_construction_in_src 4.35s
test_only_bootstrap_imports_the_support_package_itself 4.04s

Remedy

Parse each source and test file once per test process, with a session-scoped fixture in tests/support/ that holds the parsed trees, and have the invariant tests read from it. Every assertion stays.

Acceptance criteria

  • No invariant test takes over 5s on a quiet host, measured before and after.
  • Each file under src/ and tests/ is parsed at most once per test process.
  • uv run devops ci passes.

Activity

  1. added this to the v0.2.38 milestone on Oct 20, 2026
  2. added
    type/test
    priority/p0-critical
    scope/ci
    source/agent
    on Oct 20, 2026
  3. dan-petty commented on Oct 20, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1757, merged into release/v0.2.38 as 79eaacb.

    Resolves #1749

    9 file(s) changed.

    How it was verified

    Check runs at 45874d1:

    • Prune PR DevContainer Images: pass
    • Audit Defect PR Hardening: skipping
    • zizmor: pass
    • devops-cli: pass
    • bandit: pass
    • CodeQL: pass
    • Rule Pack Tests: pass
    • Changed-Test Independence: pass
    • Tests & Coverage: pass
    • Fail-to-Pass Check: pass
    • Fail-to-Pass Self-Check: pass
    • Analyze (python): pass
    • Analyze (actions): pass
    • Static Analysis: pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-1749-invariant-tests-share-parse.md:

    No Acceptance Criteria section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p0-criticalscope/cisource/agenttype/test

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions