Skip to content

test: stabilize Darwin cancellation drain assertions - #29477

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/test-audit-darwin-cancellation-clock
Oct 16, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/test-audit-darwin-cancellation-clock

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​54 $\color{#cf222e}{\Huge{\mathbf{−}}}$​18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​36
Prod 0 0 0 0

ELI5

A macOS terminal-name cancellation test failed in CI because real timers no longer provided the observation window it assumed. Control the clock in the two affected cases so a busy runner cannot finish the active read before cancellation is checked.

What Changed

Use scoped fake timers for the candidate-read and directory-scan cancellation tests. Each starts a read, aborts, proves the operation remains pending while that read is active, then drains it and verifies no later reads were admitted. Cleanup drains pending work and restores real timers even after a failed assertion. Production behavior is unchanged.

Why

The failed run 38856466593 expected an operation to remain pending after a real 2 ms delay followed by a zero-delay timer, while the simulated read lasted 10 ms. Scheduler delays can invalidate that window. The adjacent scan test had the same assumption. Controlling time preserves both distinct cancellation contracts without increasing sleeps or removing the failing assertion.

Linked Issue

Internal test audit; observed failure in #29471.

Visual Proof

N/A — test-only change with no application UI or interaction change.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

All 42 owner cases pass in 12 alternating original/candidate runs across Bun 1.4.3 and Node 24.21, and shuffled runs on both runtimes. All 54 owner/sibling cases pass. Node typecheck, changed-code-quality checks, normal/anti-slop lint, formatting and whitespace checks pass. All 31 declarations remain; only these two bodies and the timer import change.

Four deliberate owner regressions fail at their intended guards: admitting later candidate reads, admitting later scan reads, rejecting before a candidate read drains, and rejecting before a scan read drains. Production source restored byte-for-byte. The fake filesystem exercises the Darwin contract on Linux; no macOS device or desktop run claimed.

Three alternating pairs per runtime, original first; single worker, official module reporter:

Runtime Original module median Candidate module median Original process wall median Candidate process wall median
Bun 1.4.3 238 ms 226 ms 1,794 ms 1,759 ms
Node 24.21 264 ms 240 ms 907 ms 881 ms

These small timing differences establish no overall speed improvement. Hosted run 38858886806 attempt 2 passed the full PR aggregate and all five unit shards with all 42 cases passing. Official module duration was 228 → 207 ms; ordinary execution was 176 ms and is a separate measure. Baseline and candidate used Node 24.19/Bun 1.4.3, four workers/five shards and Blacksmith Ubuntu 24.04 X64 runners. The actual candidate test and unchanged production owner were source-verified. Broader source/dependency changes, HOME setup, workload (12,205 → 12,230 files), runner instance and scheduling differ, so this unpaired result establishes no causal or whole-workflow speedup. Attempt 1 lacked timing artifacts and is excluded.

Review

Independent diagnosis, pre-review and final preservation review approved the scoped-clock repair, both distinct cancellation contracts, cleanup and all four mutation controls.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

No production, wire, SSH, folder workspace, Windows or Linux behavior changes.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 092e78c9-d9e9-483b-80eb-36f93cbcd3bf
📥 Commits

Reviewing files that changed from the base of the PR and between a8e3734 and e84df63.

📒 Files selected for processing: 1
  • src/shared/darwin-terminal-names.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

📝 Walkthrough

Two cancellation tests replace real-time waits with fake-timer advancement. They track or handle expected rejections and add finally cleanup to abort operations, drain timers, await rejection, and restore real timers. The test file also imports Vitest’s vi utility for timer control.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to e84df

No actionable issue is established in these test changes. The PR is mergeable after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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.
Title check Passed The title clearly identifies the test-only change: stabilizing Darwin cancellation drain assertions.
Description check Passed The description is detailed and covers the change, motivation, testing, scope, compatibility considerations, and checklist. It identifies the observed failure in issue #29471, explains why visual proo…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@OrcaWin
OrcaWin merged commit 2a3eaab into main Oct 16, 2026
51 of 53 checks passed
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.

1 participant