Skip to content

fix(test): isolate tmux servers and guard default sockets - #845

Merged
roodboi merged 7 commits into
nextfrom
codex/hack-2242-private-test-tmux
Nov 15, 2026
Merged

roodboi merged 7 commits into
nextfrom
codex/hack-2242-private-test-tmux

Conversation

@roodboi

@roodboi roodboi commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

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.

@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 5:11pm UTC

Request Review

@linear-code

linear-code Bot commented Nov 14, 2026

Copy link
Copy Markdown

HACK-2242

@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: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-14T17:11:25.167008Z
We couldn’t complete this review. Comment @codex review to try again.
4d00738 Manual request
🔒 Security Review ✅ Completed 2026-11-14T14:47:27.387355Z 05e9461 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. Can't wait for the next one!

Reviewed commit: ee1b830e1f

ℹ️ 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: ee1b830e1f

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

@codex review

@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: 88ebc8b50e

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 88ebc8b50e

ℹ️ 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".

Comment thread tests/helpers/tmux-socket-guard.ts Resolved
@roodboi

roodboi commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: da2f935803

ℹ️ 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: da2f935803

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

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 2cfc8de13c

ℹ️ 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: 2cfc8de13c

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

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 1a09a70372

ℹ️ 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: 1a09a70372

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

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 05e9461080

ℹ️ 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: 05e9461080

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.

The guard admits `-L name` and `-S <root>/x.sock`, but cleanup only
killed the root's default server, so a named or explicit-socket server
could outlive its removed root. Close now stops each socket found under
the owned root (symlinks not followed) and keeps the root if any stop
fails. Regression starts both forms and checks their servers stop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@roodboi

roodboi commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@roodboi

roodboi commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Ready for lead: 4d00738

Took over HACK-2242 from the previous owner (account out of capacity).

  • Merge check: after the merge of frozen next (8e7242d), tests/daemon-sessions.test.ts differs from next by 4 added lines only (import, root registration, unregister). fix(test): isolate daemon session routes from the default tmux server #844's explicit socket, empty config, finite pane lifetime, per-case cleanup and session assertions are intact.
  • New commit 4d00738 (reviewer finding): the guard allows -L name and -S <root>/x.sock, but privateTmux().close() only stopped the root's default server, so a named or explicit-socket server could outlive its deleted root. Close now stops every Unix socket under the owned root (symlinks not followed) and keeps the root when a stop fails. New regression starts both forms and checks both server PIDs stop and the root is gone; it fails against the old close (I reproduced two orphaned fixture servers, then stopped them).
  • Not changed: an explicit Bun.$.env({...}) still bypasses isolation (already listed as a limit). A probe under the same preloads, with an inherited TMUX, showed plain Bun.$ gets the private TMUX_TMPDIR and no TMUX; no test runs tmux through Bun.$. The reviewer withdrew it as a blocker.

Ran on Linux, Bun 1.4.4, real tmux, temp HOME, HACK_DAEMON_AUTOSTART_DISABLE=1, fake inherited TMUX:

  • All 13 test files this PR changes: 373 pass, 0 fail.
  • Default socket (tmux list-sessions -F '#{session_id}:#{session_name}', TMUX/TMUX_TMPDIR unset): stdout and stderr byte-identical before and after, 3 sessions both times. No leftover /tmp/hack-test-mux-* roots or fixture servers after the run.
  • Biome on changed files; root tsc reports no errors in the changed files.

Review: persistent Codex reviewer (gpt-6.1-sol, codex-dio) CLEAN at 4d00738 after one fix round. @codex review was requested at this head, but the bot replied that its review usage limit was reached, so there is no bot review of 4d00738 (it was clean at 05e9461). No unresolved bot threads.

Exact-head hosted CI at 4d00738: all 29 active checks passed (8 test shards, 4 Docker e2e shards and fan-ins, linux-process-lifetime, Candidate core and Config compiler on every host). Optional Proof skipped. GitHub reports mergeable. computer pr review-status: CLEAR at 4d00738: no unresolved bot threads, bot change requests, or overlapping base changes. Review summaries and conversation comments above still need reading.

No further pushes planned after this note.

Not verified: macOS (the guard and cleanup run on Darwin paths in the lead's Mac suite), e2e harness changes under Docker, SIGKILL leftovers (follow-up, as before).

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits. You can see your limits in the Codex usage dashboard.

@roodboi
roodboi merged commit 5079213 into next Nov 15, 2026
30 checks passed
@roodboi
roodboi deleted the codex/hack-2242-private-test-tmux branch November 15, 2026 02:15
roodboi added a commit that referenced this pull request Nov 15, 2026
… guard

next's tmux socket guard (#845) admits only registered private socket
roots. lifecycle-session-recovery points TMUX_TMPDIR at its own fixture
root, so its first tmux call was refused, and its cleanup then threw
before restoring TMUX_TMPDIR, which broke later scenarios in the shard
with ENOENT on the deleted root. Register the fixture root (mkdtemp, 0700)
for the scenario and always restore and unregister in an inner finally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
roodboi added a commit that referenced this pull request Nov 15, 2026
After merging next, tests/sync-spawn-bound.test.ts failed on two files
that landed after this branch's base: tmux-socket-guard.test.ts (12) and
nss-read-safety.test.ts (1). Bun.spawnSync sites use spawnSyncBounded; it
still calls Bun.spawnSync, so the tmux socket guard under test still
applies. The Node execFileSync/spawnSync/execSync calls, and the
Bun.spawnSync call that must throw from the guard, keep their API and get
an explicit timeout.

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