Skip to content

test(sel): stabilize cross-process lock tests - #6855

Merged
NicholasRBowers merged 1 commit into
mainfrom
fix/sel-nonblocking-test-flake
Aug 29, 2026
Merged

test(sel): stabilize cross-process lock tests#6855
NicholasRBowers merged 1 commit into
mainfrom
fix/sel-nonblocking-test-flake

Conversation

@bolichen97

Copy link
Copy Markdown
Collaborator

Problem / Motivation

Two cross-process SEL tests were nondeterministic on Windows:

  • The nonblocking event-loop test asserted that the entire critical-log path completed in under 50 ms. A correct implementation made exactly one nonblocking lock attempt, yet shared-runner scheduling and file I/O produced 188 ms in CI and up to 470 ms locally.
  • The sidecar symlink security test assumed every Windows runner could create symlinks, although that capability depends on privilege/developer-mode policy.

Why it matters

These tests can reject unrelated PRs even when production lock behavior is correct. Raising the timeout or rerunning the shard would preserve the false signal. The tests should directly prove the lock contract and explicitly model platform capability.

What changed

  • Keep a real competing lock holder.
  • Record calls to try_acquire_lock and require exactly one exclusive, nonblocking attempt.
  • Replace blocking acquire_lock and file_lock primitives with fail-fast sentinels for this path.
  • Remove the wall-clock assertion because scheduler and surrounding I/O latency are not the behavior under test.
  • Apply the repository's existing requires_symlinks capability marker to the symlink-specific security case. Capable CI still runs it; incapable hosts skip explicitly.

Production SEL code is unchanged.

Tests

  • Targeted nonblocking test: serial and 2-worker xdist passed.
  • Real contention stress: 500/500 passed.
  • TestCrossProcessSafety: 17 passed, 1 capability skip.
  • Full test/test_sel.py: 231 passed, 26 capability skips.
  • Mutation checks:
    • routing through a blocking acquire makes the test fail immediately;
    • making two nonblocking attempts fails with polled 2 times.
  • Independent final targeted run: 1 passed, 1 capability skip.
  • isort, Flake8, Black gate, subprocess-encoding, brand, and diff checks passed.

No retry, rerun, sleep, timeout increase, threshold relaxation, or warning filter is used.

Manual verification

N/A — the test now proves calls to the actual lock primitives under real contention; mutation checks prove the assertions reject both blocking and polling implementations.

Screenshots / video

Why no screenshot: This changes only backend tests and has no rendered UI effect.

Merge order

Merge #6849 first. It fixes the separate Windows text-mode legacy lock-key flake in the same SEL test area. This PR is test-only and should then merge before replaying the much larger conflicting #4997.

Assert loop-side lock behavior from primitive calls instead of wall time,
so a loaded runner cannot fail a correct single-shot attempt. Fail
immediately if the event-loop path reaches a blocking primitive.

Use the existing symlink capability probe for the symlink-specific guard
so unprivileged Windows hosts skip while capable runners retain coverage.
@bolichen97
bolichen97 requested a review from a team as a code owner August 29, 2026 21:49
@bolichen97
bolichen97 requested a review from dwu96 August 29, 2026 21:49
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Aug 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of b0cb80dc030d66604cd42710889c029526557f1c — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Replaces a flaky wall-clock proxy with structural assertions on the actual lock contract — exactly the shape-not-duration fix the repo's own testing conventions mandate.

The sleep gap left by dropping the timing bound is already covered by the adjacent source-level test_on_loop_acquire_helper_never_sleeps, the fail-fast sentinels on both blocking primitives close the "blocked instead of refused" hole the old timer only approximated, and the symlink skip reuses the existing requires_symlinks capability marker rather than inventing a new one. Test-only, production untouched, mutation-verified.

[DESIGN-REVIEWED] b0cb80d

@github-actions

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed b0cb80dc030d66604cd42710889c029526557f1c — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] b0cb80d

Verdict parsed from the review's SHA-scoped output markers for commit b0cb80dc030d66604cd42710889c029526557f1c.

False positive or not applicable? A repository writer can comment:
/ai-review override fable b0cb80dc030d66604cd42710889c029526557f1c: <one-sentence reason>

@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of b0cb80dc030d66604cd42710889c029526557f1c and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] b0cb80d

False positive or not applicable? A repository writer can comment:
/ai-review override gpt b0cb80dc030d66604cd42710889c029526557f1c: <one-sentence reason>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Aug 29, 2026
@NicholasRBowers
NicholasRBowers enabled auto-merge (squash) August 29, 2026 22:24

@NicholasRBowers NicholasRBowers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tier 1 auto-approve: test (1 file). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: test-files-only change to test/test_sel.py replacing wall-clock timing assertions with structural lock-primitive assertions and gating a symlink test behind requires_symlinks.

@NicholasRBowers
NicholasRBowers merged commit c510b4a into main Aug 29, 2026
67 checks passed
@NicholasRBowers
NicholasRBowers deleted the fix/sel-nonblocking-test-flake branch August 29, 2026 22:24
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants