Skip to content

fix(session): preserve unresponsive session sockets - #28

Merged
serabi merged 3 commits into
mainfrom
fix/preserve-unresponsive-sessions
Nov 7, 2026
Merged

serabi merged 3 commits into
mainfrom
fix/preserve-unresponsive-sessions

Conversation

@edequalsawesome

@edequalsawesome edequalsawesome commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Why

Keep a live session when its daemon is slow or sends an incompatible reply. A failed probe must not remove a socket that may still lead to running work.

What's Included

  • After the retry budget, return ambiguous probe errors without removing the socket or creating another daemon.
  • Keep recovery for missing sessions and refused stale sockets.
  • Add test/reconnect.py to check healthy attach, paused and incompatible daemons, stale socket recovery, and fixture cleanup.
  • Set a 24×80 PTY in the reconnect fixture so it starts with a usable terminal size.
  • Clarify the README fork note: refused sockets can recover; timeouts and incompatible replies preserve the socket. Stacked on feat: add existing-only session attach #22.

UI / UX

Not applicable. This changes backend session recovery.

Notes

Models: Codex

Merge risk: medium. This changes which failed probes allow session recovery. Recovery: revert for future attempts; a revert cannot restore work ended by an earlier recovery attempt.

Current-head check: git diff --check passes. Changes since 6c6ab41, including inherited changes, are documentation only; runtime and test source are unchanged. At 6c6ab41, macOS Zig 0.16 formatting, unit tests, build, 3 reattach cases, and 5 reconnect checks passed with clean fixture teardown. These are prior-head results. The test/reconnect.py review thread remains open for Sarah; the fork-fit review did not find a demonstrated blocker. Native app presentation and VoiceOver are not covered by the backend regression.

Keep awesomux-pin-ffa16fa and awesomux-pin-cc24771; awesoMux refs still use those old revisions. Merge with a merge commit and keep the branch.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

fix(session): preserve unresponsive session sockets

Summary

  • Updated ensureSession probe handling so a session socket is recreated only when the probe fails with error.ConnectionRefused.
  • Other probe failures—such as timeouts or incompatible replies—are returned to the caller. The existing socket is preserved and the attach/run operation fails instead of replacing a live session.
  • Documented the behavior: ordinary attach creates missing sessions and recovers refused sockets; ambiguous failures preserve the socket because an unresponsive daemon may still own a running shell.
  • Added test/reconnect.py, an end-to-end regression test covering healthy attach, timeout preservation, resumed attach, incompatible-backend preservation, and refused stale-socket recovery.

Security impact

  • The fix is fail-closed for ambiguous probe failures, preventing destructive replacement of a socket that may still refer to live work.
  • Only a positively refused connection is treated as stale/recoverable. A listening but incompatible backend is preserved.

Performance impact

  • No meaningful production hot-path cost. The production change is a one-line guard.
  • Avoids unnecessary daemon/child recreation when probe results are inconclusive. The new test harness is test-only overhead.

Code quality

  • The production change is minimal and DRY: one condition prevents non-refused errors from reaching the existing recreation path.
  • test/reconnect.py is large and contains platform-specific process-birth detection plus custom PTY/socket orchestration. It is purposeful regression coverage, but if similar helpers already exist, extracting shared test utilities would reduce duplication.

Testing

  • Run python3 test/reconnect.py /path/to/zmx for the isolated reconnect regression.

@kody-ai

This comment has been minimized.

@kody-ai

This comment has been minimized.

@github-actions github-actions Bot added the size:XS 0-9 effective changed lines. label Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

External contributor checklist

Thanks for contributing. A maintainer will handle the trusted checks and final merge.

  • A maintainer has reviewed the change.
  • The PR description follows the template.
  • Visible changes include screenshots or a clear not-applicable explanation.
  • A maintainer confirmed no untrusted fork code was run with repository secrets.

Comment thread test/reconnect.py Resolved
@serabi
serabi force-pushed the fix/preserve-unresponsive-sessions branch from 6c6ab41 to 3f06807 Compare November 7, 2026 05:15
@kody-ai

kody-ai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

Access your configuration settings here.

​

@github-actions github-actions Bot added size:S 10-29 effective changed lines. and removed size:XS 0-9 effective changed lines. labels Nov 7, 2026
@serabi
serabi changed the base branch from feat/attach-existing to main November 7, 2026 05:22
@serabi
serabi merged commit b42130e into main Nov 7, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 effective changed lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants