Skip to content

fix(test): isolate daemon session routes from the default tmux server - #844

Merged
roodboi merged 2 commits into
nextfrom
fix/daemon-session-test-isolation
Nov 14, 2026
Merged

roodboi merged 2 commits into
nextfrom
fix/daemon-session-test-isolation

Conversation

@roodboi

@roodboi roodboi commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

The daemon session route tests created myproject123, my-project and my_project on the developer's default tmux server and never stopped them. The first name matches the orphan reported after a parallel test batch.

Run these route tests against a fresh private socket instead. A fixture PATH shim invokes the real tmux executable with that socket and an empty config, clears inherited TMUX, and starts a fixed sleeping command so no user shell startup files run. Each case stops only its private server, verifies it is absent, and restores PATH even when the case fails. Final cleanup removes the owned fixture. Successful name validation now requires an actual 201 response; the alphanumeric case verifies its session exists on the private socket.

Validation: 39 tests across daemon-sessions, session-list-stop-tmux, shell-timeout and tmux-backend pass locally with real tmux. Typecheck, check/privacy and changed-file lint pass. The same persistent independent Opus reviewer is clean after two rounds, including all three session-presence assertions and guarded PATH restoration. No macOS result is claimed yet; no extra macOS CI dispatch was requested.

This fixes a confirmed test leak found during HACK-2219 investigation. It does not establish that the leak causes the post-parallel authored-start failures. The diagnostic #813 head remains separate and stable for the requested five-round Mac reproduction. Existing sessions on the default server are untouched.


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

@vercel

vercel Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hack-docs Ready Ready Preview Nov 14, 2026 11:57am UTC

Request Review

@roodboi

roodboi commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T11:59:54.802841Z 6eda997 Manual request
🔒 Security Review ✅ Completed 2026-11-14T12:02:00.808191Z 6eda997 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 6eda997f92

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 6eda997f92

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@roodboi

roodboi commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Ready for lead: #844 at 6eda997f92096bd55356334f50bcc83646e13b87 (confirmed test leak found during HACK-2219).

tests/daemon-sessions.test.ts was creating myproject123, my-project and my_project on the default tmux server without cleanup. It now runs real tmux through a private-socket shim, clears inherited TMUX, reads no user config, uses a finite sleeping pane, verifies each created session on that socket, and stops/verifies only its owned server after every case. PATH is restored even when a case fails. The old default-server sessions are not cleanup targets.

Both required checks and all five planned Linux shards passed in CI run 43592448391. Local verification with real tmux: 39 passed / 0 failed, across the session route, CLI private-socket, shell timeout and tmux backend tests; typecheck, check/privacy and changed-file lint pass. The same persistent Opus reviewer cleared the final source tree 04ad8458 after two rounds. Current-head Codex found no issues; there are zero unresolved review threads.

No extra macOS shard dispatch was requested. Hosted macOS evidence is deferred; please run bun --no-env-file test tests/daemon-sessions.test.ts on the Mac before merge. No VM scenario is needed for this test-only change. No causal link between this confirmed leak and the authored-start failures is claimed.

#813 remains unchanged at 15344d2cf211b90e436189917a4b063cf13f54a6 for the five-round Mac diagnostic run. No merge performed here.

@roodboi
roodboi merged commit ecb667f into next Nov 14, 2026
22 of 34 checks passed
@roodboi
roodboi deleted the fix/daemon-session-test-isolation branch November 14, 2026 14:34
roodboi added a commit that referenced this pull request Nov 15, 2026
Tests can invoke tmux directly or through helper children and inherit
the user's default server. Test startup now owns a private socket root,
removes inherited `TMUX`, and stops its server after teardown, including
assertion failures. The E2E runner also owns a private server scope
closed in `finally`.

Bun's spawn APIs and Node's child-process APIs receive an explicit
environment with a registered private `TMUX_TMPDIR`. This covers scripts
and helper children with omitted or minimal environments. Direct tmux
commands additionally validate socket arguments and directory
ownership/mode. Cleanup runs after the checkout guard's Git children;
the global-state guard retains its fixed read-only native-environment
probe.

The daemon-session fixture merged in #844 keeps its stricter explicit
socket, empty config, finite pane lifetime, per-case cleanup and real
session-presence assertions. This PR adds only four socket-registration
lines to that file. Other real-tmux fixtures register their roots, and
project-view unit tests inject session data.

Seven compiler environment-contract checks use an async-local scope for
their owned, pure compiler fixture only. Those fixtures keep the
original explicit compiler environment and unchanged PATH-only
assertions. Sibling commands and commands outside the scope remain
isolated; these pure fixtures never invoke tmux.

Regressions cover indirect real tmux calls reaching the owned server
PID, Bun/Node API forms, null/undefined argv preserving options,
fixture-only environment scopes, unsafe-socket refusals using a harmless
stand-in, and cleanup after a deliberately failing child test.

Validation after a normal merge of frozen `next` at `8e7242db94`:
- Linux, Bun 1.4.4, real tmux, synthetic inherited tmux selection: 760
passed, 1 skipped, 0 failed across 36 suites (4,617 assertions),
including all compiler transport suites and the incoming Rust
test-runner tests. The existing compiled re-exec case skips without its
compiled artifact.
- Default `tmux list-sessions -F '#{session_id}:#{session_name}'`, with
`TMUX` and `TMUX_TMPDIR` unset: byte-identical stdout and stderr
before/after; 3 sessions before and after. No user session names are
included here.
- Root typecheck/check/privacy and docs checks passed. The other 21
owned files are unchanged from reviewed head `1a09a7037`; the
contributor guide retains all incoming guidance.

Scripts that deliberately erase their environment or name an explicit
socket must maintain isolation themselves; explicit `Bun.$.env(...)` is
unwrapped. SIGKILL skips teardown and may leave a private server/root;
stale-root recovery remains follow-up work. Lead full-suite/Mac
acceptance remains separate from local evidence.

Fixes HACK-2242.

---------

Co-authored-by: Kit <344842+roodboi@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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