Skip to content

test(backend): reuse workflow selector discovery#9731

Merged
kodjima33 merged 1 commit into
BasedHardware:mainfrom
tianmind-studio:codex/windows-workflow-contract-fixture
Jul 17, 2026
Merged

test(backend): reuse workflow selector discovery#9731
kodjima33 merged 1 commit into
BasedHardware:mainfrom
tianmind-studio:codex/windows-workflow-contract-fixture

Conversation

@tianmind-studio

@tianmind-studio tianmind-studio commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

What changed and why

Reuse one module-scoped workflow-selector discovery across the contract tests instead of reloading the selector and rescanning every backend unit test in each test. This keeps the Windows fast-unit lane below its per-file timing budget without changing the contract assertions. Closes #9729.

Product invariants affected

none

How it was verified

  • Reproduced the baseline twice on Windows: all 19 tests passed, but the fast-unit duration guard rejected the file at about 0.14s and 0.12s against the 0.12s budget.
  • Repeated the strict backend/test.sh run five times after the change. All 19 tests passed each time, with total runs of 0.57s, 0.47s, 0.54s, 0.52s, and 0.60s and no duration warning.
  • black --check --line-length 120 --skip-string-normalization backend/tests/unit/test_workflow_contracts.py
  • Passed lifecycle-header, version-filename, import-purity, module-isolation, workflow-contract, diff-hygiene, release-policy, and deployment-concurrency checks.
  • The repository-wide Firestore query ratchet still fails on Windows with 40 unregistered and 3 unsupported fingerprints. The same command reports the identical fingerprints from an unchanged detached origin/main worktree, so that baseline is unrelated to this test-only diff.

Tests

The changed file is the regression coverage. Its existing 19 contract tests still exercise the same assertion set, now under the same strict fast-unit timing guard that exposed the Windows failure.

Root cause and durable guard (bug fixes)

Each of seven tests independently imported select_backend_unit_tests.py and walked the complete unit-test tree. Windows filesystem startup variance pushed that repeated discovery over the fast-unit per-file budget even though every assertion passed. A module-scoped fixture performs the immutable discovery once, and the existing duration guard continues to enforce the budget.

Review in cubic

@Git-on-my-level

Copy link
Copy Markdown
Collaborator

Thanks for this refactor, @tianmind-studio — clean approach.

What I checked

  • The module-scoped selector_and_all_tests fixture correctly replaces per-test _load_script("select_backend_unit_tests") + discover_all_tests() across all seven tests, performing the immutable filesystem discovery once instead of seven times.
  • No assertion logic changed — the fixture returns (selector, all_tests) and each test unpacks it exactly as before.
  • The @pytest.fixture(scope="module") scope is the right choice: discovery is deterministic and side-effect-free within a module run, so caching it is safe.

Checks
All check-runs on this head are green (Formatting, Hygiene, Detect Changes, Backend unit suite, Hermetic Backend E2E, etc.). The cancelled runs in the CI timeline are superseded re-runs, not failures.

Verdict
Good test-infrastructure improvement that directly addresses #9729. The Windows timing root cause (repeated discovery) is well explained in the PR body, and the fix is idiomatic pytest. Leaving this for a maintainer to merge.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added backend Backend Task (python) refactor labels Jul 14, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed — looks good; not auto-merging (over scope/size or non-bug area), landing left to maintainer.

@Git-on-my-level Git-on-my-level added the candidate-clean-pr Small, safe, well-scoped, well-tested contribution; model clean PR label Jul 15, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

test(backend): reuse workflow selector discovery; CI green

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

test(backend): reuse workflow selector discovery; CI green

@kodjima33
kodjima33 merged commit f5bc796 into BasedHardware:main Jul 17, 2026
28 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend Task (python) candidate-clean-pr Small, safe, well-scoped, well-tested contribution; model clean PR refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workflow contract selector test exceeds Windows fast-unit budget

3 participants