Repository navigation
fix(herdr): scope idle-shell child check to controlling terminal - #57
Merged
Merged
Conversation
fm_backend_herdr_pane_idle_shell_sample required the candidate shell own exactly zero children. An interactive rc that forks a permanent off-terminal helper makes that unsatisfiable forever: zsh-autosuggestions opens a zpty whose child zsh becomes session leader of a DIFFERENT pty and lives for the shell's lifetime. On such a box the proof could never converge, so fm-herdr-session-cleanup.sh silently preserved every restored projection and stale workspaces accumulated with no way to clear them. Scope the child requirement to the shell's own controlling terminal instead. This loses none of the safety the flat count was providing: any job the pane's shell actually owns - foreground or backgrounded with & - inherits the pane's controlling terminal and still refuses the proof. A child on another terminal, or on none, is not pane work and would survive the shell's death anyway. The "exactly one shell row" requirement is unchanged. Verified on a live box: the zsh-autosuggestions zpty child sits on a different tty than its parent shell (ttys126 vs ttys124), while `sleep 30 &` inherits the shell's own tty. Both shapes are now covered by regression tests.
…backends verification
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughHerdr now scopes idle-shell rejection to child processes sharing the shell’s controlling terminal. Cleanup documentation, verification, fixtures, and tests use the same terminal-aware requirement. ChangesHerdr idle-shell cleanup
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Cleanup
participant Herdr
participant ProcessTable
Cleanup->>Herdr: Check restored shell
Herdr->>ProcessTable: Read PID, PPID, and TTY
ProcessTable-->>Herdr: Return process rows
Herdr-->>Cleanup: Allow or preserve pane
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
trillium
added a commit
that referenced
this pull request
Aug 6, 2026
* herdr: scope the idle-shell child check to the shell's own terminal fm_backend_herdr_pane_idle_shell_sample required the candidate shell own exactly zero children. An interactive rc that forks a permanent off-terminal helper makes that unsatisfiable forever: zsh-autosuggestions opens a zpty whose child zsh becomes session leader of a DIFFERENT pty and lives for the shell's lifetime. On such a box the proof could never converge, so fm-herdr-session-cleanup.sh silently preserved every restored projection and stale workspaces accumulated with no way to clear them. Scope the child requirement to the shell's own controlling terminal instead. This loses none of the safety the flat count was providing: any job the pane's shell actually owns - foreground or backgrounded with & - inherits the pane's controlling terminal and still refuses the proof. A child on another terminal, or on none, is not pane work and would survive the shell's death anyway. The "exactly one shell row" requirement is unchanged. Verified on a live box: the zsh-autosuggestions zpty child sits on a different tty than its parent shell (ttys126 vs ttys124), while `sleep 30 &` inherits the shell's own tty. Both shapes are now covered by regression tests. * no-mistakes(document): update stale "childless" guarantee in runtime-backends verification
trillium
added a commit
that referenced
this pull request
Aug 6, 2026
* herdr: scope the idle-shell child check to the shell's own terminal fm_backend_herdr_pane_idle_shell_sample required the candidate shell own exactly zero children. An interactive rc that forks a permanent off-terminal helper makes that unsatisfiable forever: zsh-autosuggestions opens a zpty whose child zsh becomes session leader of a DIFFERENT pty and lives for the shell's lifetime. On such a box the proof could never converge, so fm-herdr-session-cleanup.sh silently preserved every restored projection and stale workspaces accumulated with no way to clear them. Scope the child requirement to the shell's own controlling terminal instead. This loses none of the safety the flat count was providing: any job the pane's shell actually owns - foreground or backgrounded with & - inherits the pane's controlling terminal and still refuses the proof. A child on another terminal, or on none, is not pane work and would survive the shell's death anyway. The "exactly one shell row" requirement is unchanged. Verified on a live box: the zsh-autosuggestions zpty child sits on a different tty than its parent shell (ttys126 vs ttys124), while `sleep 30 &` inherits the shell's own tty. Both shapes are now covered by regression tests. * no-mistakes(document): update stale "childless" guarantee in runtime-backends verification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Fix fm_backend_herdr_pane_idle_shell_pid so it can converge on a box whose interactive login shell permanently forks an off-terminal helper (zsh-autosuggestions zpty), by scoping the idle-shell child check to the shell's own controlling terminal instead of requiring a flat zero children; stale Herdr projections must become cleanable again while a real pane job still refuses the proof.
What Changed
fm_backend_herdr_pane_idle_shell_samplenow fetchestty=alongsidepid=/ppid=fromps, and the awk check rejects a child only when it shares the shell's own controlling terminal — rather than requiring a flat zero-child count. A permanent rc-forked helper (e.g. the zpty that zsh-autosuggestions opens) sits on a different pty and no longer blocks the proof, so stale Herdr projections on such boxes are cleanable again.&) inherits the pane's controlling terminal and still causes the proof to refuse.psin existing death-lab fixtures is updated to emit the new three-column format.Risk Assessment
✅ Low: The fix is narrowly scoped - it adds one column to the ps invocation and replaces a flat zero-children check with a per-child tty comparison in a single awk block - with correct logic, all three fake-ps test fixtures consistently updated, and two new behavioral tests that drive the real proof function and assert observable output.
Testing
Ran the two newly-added behavioral unit tests exercising the TTY-scoped child check directly via a fake ps table: a child on a different TTY (simulating zsh-autosuggestions zpty) no longer blocks the idle-shell proof, while a child on the same terminal still correctly refuses it. The full fm-backend-herdr.test.sh suite (167 tests) and session-cleanup suite both passed with no regressions.
Evidence: Idle-shell proof test output
ok - herdr idle-shell proof: a permanent rc-forked helper on another terminal still proves the shell idle ok - herdr idle-shell proof: a job on the pane's own terminal, or an ambiguous shell row, still refusesEvidence: Full test run summary
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-backend-herdr.test.sh— 167 tests passed, 0 failed; both new targeted tests (test_idle_shell_proof_converges_past_an_off_terminal_rc_helper,test_idle_shell_proof_refuses_a_background_job_on_the_pane_terminal) passbash tests/fm-herdr-session-cleanup.test.sh— all session cleanup tests passed✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
Summary by CodeRabbit
Bug Fixes
Documentation
Tests