Skip to content

fix(host): remove the socket directory once it holds no socket - #239

Merged
ThomasK33 merged 15 commits into
mainfrom
fix/227-socket-dir
Nov 2, 2026
Merged

ThomasK33 merged 15 commits into
mainfrom
fix/227-socket-dir

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Why

The operator wants the open issues he filed in coder/agent-tty fixed and landed. #227 reports that a harness with one throwaway Home per run leaves an empty folder under /tmp/agent-tty/ per run (11,005 on one shared host) and a stale Home Registry entry.

What changed

  • removeSocketDirectoryIfEmpty runs rmdir on the Home's socket folder after each socket unlink. It runs in destroy (recordDestroyed), in reconcileSession after a host crash, and in the host's own shutdown. A folder that still holds another session's socket (ENOTEMPTY or EEXIST) or is already gone (ENOENT) stays as it is.
  • listenInSocketDirectory runs mkdir, chmod and listen up to 5 times. It retries when the folder vanished in between, because a teardown in the same Home removed it. libuv reports a bind in a missing folder as EACCES. The host and doctor's socket check both use it, and doctor also removes the folder after its check.

Scope

  • Covers item 1 of destroy leaves an empty socket directory and a stale home registry entry #227. Item 2 is already on main: plain gc deregisters registered Homes whose folder is gone, since feat(home-registry): Home Registry + dashboard Home picker #131. A live check on main showed the stale entry gone after gc and the Home in deregisteredHomes. gc --home and AGENT_TTY_HOME stay scoped to one Home and do not touch the registry, by design.
  • CLI JSON, error codes and exit codes do not change.
  • A host that crashes after its terminal manifest write but before it unlinks its socket still leaves that socket behind, as on main. destroy cleans it up, and changing reconcileSession for terminal manifests is a separate change.

Blast Radius

Session start-up and teardown of every session. The removal never deletes a socket, because rmdir fails on a folder that is not empty. The host's listen retry covers the one new window, where a folder vanishes between mkdir and the bind.

Verification

  • test/integration/socket-directory.test.ts: 8 tests fail on main and pass here. They cover destroy with two sessions in one Home, destroy --force, a host whose program exits, a reconcile after a host crash, doctor with and without a folder that vanishes before its bind, and a folder that a preload removes before the host's chmod or bind (on main, create exits 6).
  • Live A/B on the CLI: main gives destroy: socket dir kept (0 entries) FAIL, this branch gives destroy: socket dir removed PASS. 48 parallel create and destroy pairs in one Home all passed and left no folder.
  • Gates: npm run typecheck, npm run lint and npm run format:check exit 0. vitest run test/unit: 1595 tests pass. vitest run --maxWorkers=1 --retry=2 on test/integration (4 shards, 268 tests) and test/e2e (3 shards, 34 tests) pass. The e2e color-grid screenshot test, a known load flake, needed retry x2. The lifecycle skill's check.sh passes all 52 runs, and coverage.json is synced after the merge of main.

Closes #227


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: xhigh

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

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

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T16:49:59.693677Z e24a85b Manual request
🔒 Security Review ✅ Completed 2026-11-02T16:18:50.372244Z 6acfc10 Manual request

Security findings

Advisory findings (1)

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

Reviewed commit: 98da29e50e

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

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

Reviewed commit: 98da29e50e

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.

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@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: af1b7ec7ea

ℹ️ 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 src/host/lifecycle.ts Resolved
Comment thread src/host/lifecycle.ts Resolved
Comment thread src/host/hostMain.ts Resolved
…t directory

listenInSocketDirectory (lifecycle.ts) now runs the mkdir, chmod and listen retry for the host and for doctor's socket check. doctor's cleanup also removes the Home's socket directory once it is empty.
# Conflicts:
#	.agents/skills/verify-session-lifecycle/coverage.json
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 6acfc10b8f

ℹ️ 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 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 Security Review

Here are some automated security review suggestions for this pull request.

Reviewed commit: 6acfc10b8f

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

Comment thread src/host/lifecycle.ts Resolved
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: e24a85b3cb

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

@ThomasK33
ThomasK33 added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit 58e5a6a Nov 2, 2026
12 checks passed
@ThomasK33
ThomasK33 deleted the fix/227-socket-dir branch November 2, 2026 17:29
@github-actions github-actions Bot mentioned this pull request Nov 2, 2026
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.

destroy leaves an empty socket directory and a stale home registry entry

1 participant