Skip to content

fix(session): keep process snapshots monotonic - #42

Merged
guicybercode merged 4 commits into
mainfrom
codex/macos-session-lifecycle-stability
Sep 6, 2026
Merged

fix(session): keep process snapshots monotonic#42
guicybercode merged 4 commits into
mainfrom
codex/macos-session-lifecycle-stability

Conversation

@guicybercode

@guicybercode guicybercode commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Context

The post-merge macOS quality job for #40 failed twice in PTY lifecycle cleanup, but in different tests. Local exact repetitions stayed green while parallel suite repetition reproduced StopTimedOut in three cleanup tests.

Root cause

Process snapshots are scanned outside the global cache lock. An older scan could finish after a newer root-proving scan and overwrite the cache. A Session ProcessTree could then consume that older snapshot, permanently prune its root identity, skip SIGKILL delivery, and time out.

Changes

  • assign every process scan a strictly monotonic AtomicU64 sequence
  • publish a cache entry only when its sequence is newer
  • reject cached snapshots older than the scan that proved a ProcessTree root
  • add deterministic unit coverage for out-of-order publication and pre-root cache rejection
  • use the production-like reap deadline in the force-kill timing test while preserving the assertion that kill completes before the supervisor interval

Validation

  • cargo test -p cli-master-session: 85/85
  • cargo clippy -p cli-master-session --all-targets -- -D warnings: pass
  • cargo fmt --all --check: pass
  • git diff --check: pass
  • full PTY suite stress: 20 sequential runs, 620/620 tests
  • concurrent PTY suite stress: two parallel loops of 10 runs, 620/620 tests

Follow-up to #40.

Keep the assertion tied to the two-second supervisor interval while using the production-like one-second reap deadline from the shared test configuration. This avoids treating a loaded macOS runner's inability to reap within 50 ms as a runtime failure.
@guicybercode
guicybercode marked this pull request as ready for review September 6, 2026 02:24
Copilot AI lite review requested due to automatic review settings September 6, 2026 02:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@guicybercode
guicybercode merged commit 9884861 into main Sep 6, 2026
4 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.

2 participants