Skip to content

[CTX-1187] fix(winjob): harden gone-process resume assertion with bounded drain - #2051

Merged
Xuepoo merged 1 commit into
mainfrom
carryctx/ctx-1187
Oct 14, 2026
Merged

Xuepoo merged 1 commit into
mainfrom
carryctx/ctx-1187

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Resumes of a terminated suspended child can spuriously succeed when the Windows thread snapshot still lists the dead pid just after reap, flaking resuming_a_gone_process_fails (3x tracked).

Change: replace the single resume assert with a bounded drain loop (200 x 10ms via saturating math, about 2s ceiling). Only ErrorKind NotFound counts as gone; Ok or any other error retries until the ceiling, then fails closed with pid, attempts, ok polls, and last error kind. The Child handle stays alive across probes so the pid cannot be recycled (generation fencing). Reap now expects success instead of ignoring the result. No production change; assertion is tightened, never weakened to always-pass.

Evidence (Linux host, Windows-only test compiles to empty surface):

  • cargo fmt --all -- --check: pass
  • cargo clippy --workspace --all-targets --locked -- -D warnings: pass
  • cargo clippy -p bitty-winjob --target x86_64-pc-windows-gnu --all-targets --locked -- -D warnings: pass
  • cargo check -p bitty-winjob --target x86_64-pc-windows-gnu --all-targets --locked: pass
  • cargo check --workspace --target x86_64-pc-windows-gnu --all-targets --locked: pass
  • cargo test -p bitty-winjob --locked: 0 tests (expected on Linux; crate is Windows-only)
  • No TODO/FIXME, English-only, no hardcoded paths.

Windows re-verification still needed: this host cannot execute the winjob suite; remote Windows CI on this PR is the real proof.

Priority: P2 | Area: stability | Labels: fix,P2,area:stability | Milestone: v0.1.0 | Task: CTX-1187

Related #2030

Summary by CodeRabbit

  • Tests
    • Windows process-termination checks now retry up to 200 times while confirming that a terminated process is no longer running. If the expected result is not observed within that limit, the test reports diagnostic details. This makes the test outcome more informative when checking how the system handles attempts to resume a terminated process.

@Xuepoo Xuepoo added this to the v0.1.0 milestone Oct 13, 2026
@Xuepoo Xuepoo added fix Bug fix P2 Priority: medium area:stability Stability hardening labels Oct 13, 2026
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 29 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 11112fa2-a01b-4f90-8cca-0a900cb0b2d4
📥 Commits

Reviewing files that changed from the base of the PR and between 5b68f38 and 917e97e.

📒 Files selected for processing: 1
  • crates/bitty-winjob/src/job.rs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: be374748-3e90-4773-a334-b8be80c91600
📥 Commits

Reviewing files that changed from the base of the PR and between 542c113 and 5b68f38.

📒 Files selected for processing: 1
  • crates/bitty-winjob/src/job.rs

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

📝 Walkthrough

The Windows job-object test now polls when resuming a terminated process. It expects NotFound within 200 attempts and reports diagnostic details if the check reaches its limit.

Changes: Terminated process check

Layer / File(s) Summary
Poll for terminated-process result
crates/bitty-winjob/src/job.rs
The test retries resume_suspended_process up to 200 times, with POLL spacing. It accepts NotFound as the expected result and reports attempt details if the limit is reached.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 5b68f

This change only hardens a flaky Windows test and does not alter production behavior. Windows CI should confirm it, but no merge-blocking risk is evident.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: hardening the Windows job test for resuming a terminated process with a bounded drain.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • 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.

@Xuepoo Xuepoo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Independent review verdict — PR #2051 ([CTX-1187] fix(winjob): harden gone-process resume assertion with bounded drain).

Reviewer: independent agent (guard-dispatched, separate session). Reviewed head: 5b68f3887c7dc1cda4030f49c9b4e49e5602250b (task CTX-1187, issue #2030).

VERDICT: LGTM

Checks run (read-only, 3 tool calls):

  1. git show 5b68f388 --stat → 1 file, crates/bitty-winjob/src/job.rs (+42 / −2).
  2. git show 5b68f388 -- crates/bitty-winjob/src/job.rs → bounded drain loop.
  3. PR review-thread query → zero prior review comments.

Findings: none blocking. The bounded drain loop is sound — only io::ErrorKind::NotFound counts as gone, any other error or spurious Ok retries, POLL = 10ms between probes (no busy-wait), fail-closed with a rich diagnostic at the ceiling GONE_RESUME_ATTEMPTS = 200 (≈2s, far below the 20s WAIT_BOUND). Arithmetic is panic-free (saturating_add / Duration::saturating_mul). The durable assertion is preserved (resume settles to NotFound + trailing !process_is_running(pid)); the open child handle fences the pid against recycling. Non-blocking notes: a spurious Ok now retries rather than failing directly (intended tradeoff), and ok_polls is diagnostic-only.

Limitation: the test is Windows-only (#[cfg(test)] + std::os::windows), so no execution evidence exists on this Linux host — CI green (Windows check and test passed on run 38483875624) is the execution gate.

All required checks green at head 5b68f388: Quality gates (1)(2), MSRV 1.85, Linux X11 (xvfb), Linux Wayland, macOS ARM64, Windows check and test, Supply chain, Analyze (actions/rust), CodeQL, M1 matrix (Tier 1 aggregate), Compat release matrix (Tier 1 aggregate), VM tier (PR).

@Xuepoo
Xuepoo force-pushed the carryctx/ctx-1187 branch from 5b68f38 to 917e97e Compare October 13, 2026 23:53
@Xuepoo

Xuepoo commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Rebase note (guard): branch rebased onto origin/main (542c113) because branch protection requires an up-to-date head; no conflicts, and crates/bitty-winjob is untouched by the intervening commits. Content unchanged; new head 917e97ea. The independent review verdict above (LGTM) was read on the pre-rebase commit 5b68f388 — the diff is byte-identical apart from the base.

@Xuepoo
Xuepoo merged commit 0d78686 into main Oct 14, 2026
17 checks passed
@Xuepoo
Xuepoo deleted the carryctx/ctx-1187 branch October 14, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:stability Stability hardening fix Bug fix P2 Priority: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant