Skip to content

control(fix): Qualify borrowed daemons before attachment - #172

Merged
tony merged 7 commits into
mainfrom
borrowed-control-qualification
Dec 5, 2026
Merged

tony merged 7 commits into
mainfrom
borrowed-control-qualification

Conversation

@tony

@tony tony commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Refs #5. This qualification merged into main. Draft #169 retains a copy along with its pristine tmux 3.3 integration evidence.

What changed, and why

A control client that exits during startup can stop an unpatched borrowed tmux daemon and its sessions. Direct opens, scoped opens and supervised starts now check the daemon before attachment. On pristine tmux 3.3 the caller receives :unsupported_feature with :no_write and can still read the session with Server.run/3. Upstream cleanup fix

Server.capabilities/2 reports the decision. Known upstream releases qualify from tmux 3.7. For an older build, the caller supplies :control_backport_sha256 from a verified backport. The library checks the running daemon executable. The Linux helper pins the socket and verifies its peer before starting the client, including on reconnect. A caller can retry a refused reconnect on the same retired handle.

Checks run

The full suite ran on Linux arm64 with Elixir 1.20.4 and OTP 29.1.2 using mix test --include integration --warnings-as-errors.

tmux build Full suite Borrowed control
Pristine 3.3, 3.3a, 3.4 Passed in 67.29 s, 53.73 s and 62.06 s Refused before attachment. A one-shot read then found the surviving session.
Verified 3.3 backport Passed in 56.16 s Native retirement ran before the connection became ready.
Upstream 3.8 Passed in 47.77 s Native retirement ran before the connection became ready.

A recording client caught the original attempt to attach on pristine 3.3. The corrected branch also passed socket replacement, supervisor restart and caller cancellation. Earlier full runs hit timing failures in startup, waiter and CLI fixtures. The table gives the successful whole-command reruns. The native pre-ready loss cases are skipped on unqualified builds.

The original packed singleton-argv fixture opened borrowed control unconditionally. It failed on pristine 3.3 in 33.18 s after the one-shot split. It now selects the borrowed split from the answering daemon's Server.capabilities/2 report. The one-shot case always verifies caller exit, respawn and what happens when the retained helper path disappears.

Packed examples on 16b1f86 Borrowed split Whole command
Pristine 3.3 Skipped with backport_required Passed in 75.47 s
Verified 3.3 backport Passed with verified_backport Passed in 78.93 s
Upstream 3.8 Passed with upstream_release Passed in 89.86 s

All three ran mix run scripts/check_package.exs --examples. The same command with a wrong digest on the backport failed with digest_mismatch in 46.65 s. All 156 maintainer script tests passed in 69.49 s. ExDoc built with warnings as errors, and the link checker found 0 broken local references across 79 pages.

On fd9b0fd, the native retirement tests also select from the answering daemon's capability report. A client reporting 3.3 against a 3.8 daemon previously skipped all four pre-ready cases. All four now run and pass in 1.77 s. A wrong backport digest fails all four before attachment in 1.54 s. The unconditional refusal test still exercises direct, scoped and supervised starts and checks the surviving session on pristine 3.3.

Full core suite on fd9b0fd Passed Skipped Whole command
Pristine 3.3 442 36 35.24 s
Verified 3.3 backport 453 25 29.27 s
Upstream 3.8, source build 477 1 51.18 s

All three used the CI command with two concurrent cases and seed 624498. The 11 additional skips on pristine 3.3 require qualified borrowed control. A dry run and an unrelated module filter made zero tmux calls.

Tool use

Codex implemented the change, ran the Linux fixtures and checked the resulting process and session state. A separate Codex reviewer checked the exact patch against the tested worktrees and build evidence.

tony added 4 commits December 5, 2026 07:11
why: The socket path can change after a caller identifies its daemon
and before tmux opens its control connection.

what:
- Pin the socket inode before checking the peer PID and start time.
- Pass the pinned path to tmux and disable socket activation on exec.
why: Retiring a control client during startup can stop a borrowed tmux
daemon and its sessions on older builds.

what:
- Check daemon cleanup support before direct, scoped or supervised
  startup. Allow a verified backport digest for older releases.
- Report the observed decision and keep one-shot commands available.
- Keep reconnect refusals retryable on the same retired handle and
  cancel a pending qualification when its last caller leaves.
- Exercise refusal, session survival and native client retirement.
why: Operators need to distinguish the one-shot floor from the build
requirements for a borrowed control connection.

what:
- Describe how to qualify an older daemon from its build record.
- Document refusal, reconnect and the Linux socket identity check.
why: Callers upgrading an older tmux host need the borrowed-control
requirement and the one-shot alternative.

what:
- Link the borrowed-server qualification guide from the fixed notes.
@tony
tony deployed to docs-preview December 5, 2026 13:21 — with GitHub Actions Active
tony added 2 commits December 5, 2026 08:46
why: The packed example opened borrowed control even when the daemon
reported that it required a backport.

what:
- Check the one-shot split, caller exit and respawn on every build.
- Let the daemon's capability report select the borrowed split. Run it
  for a verified backport and fail if the supplied digest is wrong.
- Print the observed tmux version and the reason for running or
  skipping the borrowed split.
why: The fixture runs a split in a separate VM. The two calling sites
need to show which pane result they read after one-shot execution or
scoped control cleanup.

what:
- Return the pane from the shared split callback and match its ID at
  each calling site.
- Lay out the borrowed server descriptor and connection options in the
  embedded Elixir example.
@tony
tony deployed to docs-preview December 5, 2026 15:27 — with GitHub Actions Active
why: The tmux client and daemon can report different versions. Reading
the client version could skip retirement coverage on a qualified daemon.

what:
- Ask a private daemon for its borrowed-control capability before
  selecting the native cases. Keep the refusal test on pristine tmux.
- Check a supplied backport digest on the daemon under test and show
  the qualification decision when a receipt fails.
- Preserve filtered unit runs and report uncertain probe cleanup.
tony added a commit that referenced this pull request Dec 5, 2026
why: The Linux 3.3 retirement check assumes that a borrowed daemon
survives control startup. Pristine tmux 3.3 lacks the required fix.

what:
- Bring in the borrowed-control qualification and test selection from
  #172. Keep one-shot and refusal coverage on pristine tmux 3.3.
- Link the setup instructions to the verified backport guide.
@tony
tony deployed to docs-preview December 5, 2026 16:38 — with GitHub Actions Active
@tony
tony merged commit 4d2fa82 into main Dec 5, 2026
9 checks passed

This branch was successfully deployed

1 active deployment
docs-preview — fd9b0fdc Deployed Dec 5, 2026 by tony via publish (pr-172, pr, false, true, elixir) / publish #361
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