Skip to content

Fix the staged-enrollment suite: ps state flags broke the stopped-child probe - #831

Open
Aurora Capital (auroracapital) wants to merge 1 commit into
mainfrom
fix-ps-state-flags
Open

Fix the staged-enrollment suite: ps state flags broke the stopped-child probe#831
Aurora Capital (auroracapital) wants to merge 1 commit into
mainfrom
fix-ps-state-flags

Conversation

@auroracapital

@auroracapital Aurora Capital (auroracapital) commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

test-staged-enrollment.sh has been red on main, failing with
timed out waiting for replacement-lock fault stop. The fault injection it
tests was working fine. The probe watching for it was wrong.

Cause

childProcessState compared the entire ps -o state= field to 'T':

const childProcessState = (child) =>
  spawnSync('ps', ['-o', 'state=', '-p', String(child.pid)], {encoding: 'utf8'}).stdout.trim();
const waitForStoppedChild = (child, label) => waitFor(() => childProcessState(child) === 'T', label);

BSD ps appends flag characters to the state field: + foreground process
group, s session leader, N reduced priority, < raised priority. A stopped
child on macOS reads TN or T+, never a bare T, so the equality could never
hold and every waitForStoppedChild call burned its full 5s timeout before
asserting.

Linux ps reports a bare T. That is why CI stayed green while local runs
failed, and why the bug survived.

Measured, not assumed

Spawning a child and stopping it on this machine:

running state : "SN"
stopped state : "TN"
strict === 'T' : false
startsWith('T'): true

Fix

Take the leading state letter and drop the flags. One helper, so all four
waitForStoppedChild call sites are covered — line 608 was simply the first to
run, which is why only it appeared in the failure output.

Verification

test-staged-enrollment.sh exits 0 on this branch off main, and also on the
CRS-removal branch (#830). That takes the repo from 27/28 suites to 28/28.

Worth noting why this matters beyond one suite: a suite that fails permanently
teaches everyone to skim past failures, which is how the rm -rf guard defect
in #826 sat unnoticed inside the other red suite.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved detection of stopped child processes across macOS and Linux.
    • Process-state handling now ignores additional platform-specific status flags.

…Linux

test-staged-enrollment.sh has been failing on main with "timed out waiting for
replacement-lock fault stop". The fault injection was fine; the probe that
watches for it was wrong.

childProcessState compared the whole `ps -o state=` field to 'T'. BSD ps appends
flag characters to that field: `+` foreground process group, `s` session leader,
`N` reduced priority, `<` raised priority. A stopped child on macOS reads `TN`
or `T+`, so the equality could never hold and every waitForStoppedChild call
burned its full 5s timeout before asserting. Linux ps reports a bare `T`, which
is why CI stayed green and only local runs failed.

Measured on this machine rather than inferred: a spawned child reports "SN"
while running and "TN" after SIGSTOP, so `=== 'T'` is false and `charAt(0)` is
'T'. The fix takes the leading state letter and drops the flags.

One helper, so all four waitForStoppedChild call sites are covered. Line 608 was
simply the first to run, which is why only it appeared in the failure output.

Verified: test-staged-enrollment.sh now exits 0 both on this branch off main and
on the CRS-removal branch, taking the repo from 27/28 suites to 28/28.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@cursor

cursor Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6b195e66-b571-46de-9bce-b2f72d9d6d14

📥 Commits

Reviewing files that changed from the base of the PR and between cea6de6 and 09d3e04.

📒 Files selected for processing (1)
  • claude-ops/scripts/account-rotation/__tests__/staged-enrollment.test.mjs

Included review availability: Your plan includes up to 2 reviews per rolling hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The childProcessState helper now normalizes trimmed ps output to its leading process-state character. This removes BSD state suffixes while preserving bare-state behavior.

Changes

Process-state detection

Layer / File(s) Summary
Normalize ps state output
claude-ops/scripts/account-rotation/__tests__/staged-enrollment.test.mjs
childProcessState trims ps output and returns the first character. Documentation describes BSD state suffixes.
Estimated code review effort: 1 (Trivial) ~5 minutes

Merge Risk: ⚪ Minimal · up to 09d3e

This localized test fix corrects stopped-child detection for platform-specific process-state flags; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ 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 describes the macOS-specific staged-enrollment failure and the fix for process-state flags.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-ps-state-flags

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.

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