Skip to content

fix: Keep session sockets where each platform keeps a user's - #41

Open
cdamus wants to merge 2 commits into
eclipse-enclave:mainfrom
cdamus:issues/36-e2e-short-root
Open

cdamus wants to merge 2 commits into
eclipse-enclave:mainfrom
cdamus:issues/36-e2e-short-root

Conversation

@cdamus

@cdamus cdamus commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #36

What and why

make test-e2e failed on macOS with the default TMPDIR. The e2e helpers counted the bytes of a bridge socket path against the sun_path limit and refused any isolated home too deep for it, and every home under the macOS temp directory is. That budget was the helpers' own rule. The daemon binds and dials a socket at a path of any length (proto.Listen, proto.DialContext), and with the check switched off the suite passed under the long temp directory.

So this PR removes the budget instead of working around it, and fixes what made the paths long and odd in the first place: where the daemon puts its session bridge sockets. Without XDG_RUNTIME_DIR it used ~/.local/state on every system, macOS included, and it named each socket after its target, which is 44 bytes for a Local System session.

Daemon

  • On macOS without XDG_RUNTIME_DIR, sockets now go to run/ in the provider's state directory, so under ~/Library by default (hostbridge runDirFor). Nothing else moves:

    Condition Run directory
    XDG_RUNTIME_DIR is set, on any system $XDG_RUNTIME_DIR/homeshell-<hash>/, as before
    unset, on macOS run/ in the state directory
    unset, elsewhere ~/.local/state/homeshell-<hash>/, as before
  • A socket file is named by a 12-hex digest of its target, with the exit record beside it. A default macOS install then dials its sockets directly for a user name of up to 25 bytes. Longer paths still work through the existing long-path handling.

  • Sessions that an earlier version started keep working across the upgrade. Their bridges stay at <target>.sock in the directory that version used, and the runtime uses that socket while a bridge listens on it. Start refuses a target such a bridge still serves, and clears the socket file of one that died. legacyRunDir is unchanged.

  • A data directory on a filesystem without unix sockets (exFAT, for one) cannot hold run/. A start that fails on the bind now says to set XDG_RUNTIME_DIR, unless XDG_RUNTIME_DIR is already set and chose the directory the bind failed in.

e2e helpers

  • checkSocketBudget, worstSocketPath, and the 4-char prefix limit of isolatedHome are gone. The e2e root stays $TMPDIR/hs-e2e-<hash> on every platform.
  • bridgeSockets finds sockets in every layout the daemon uses, so the teardown still stops each bridge.
  • The fake bridge of the Go tests (sbridgetest) binds a long path through a short symlink, the way a client dials one, and takes a connection that sends nothing, as the real bridge does.

How I checked the upgrade path

Besides the unit tests, I started a session with a daemon built without this change, stopped that daemon, and started this branch's daemon on the same data directory, once with XDG_RUNTIME_DIR and once without. In both cases the session stayed running, took a prompt, and could be deleted, and a new session got a digest-named socket. With the lookup disabled the same session never became running.

On macOS with the default TMPDIR, the test failures left are the ones #37, #38, #30, and #32 fix, and an occasional EOF when an Enclave session is stopped, which is #40.

Changelog

- On macOS, HomeShell now keeps the sockets of its running sessions in its data directory
  (`~/Library/Application Support/homeshell` by default) instead of `~/.local/state`. Sessions
  that were running before the update keep working.

Checklist

  • Tests added: unit and e2e, or a regression test for a bug fix (see AGENTS.md)
  • Docs updated per the trigger table in AGENTS.md

make test-e2e failed on macOS with the default TMPDIR. The e2e helpers
budgeted the bytes of a bridge socket path against the sun_path limit
and refused any home too deep for it, which every home under the macOS
temp dir is. The budget was the helpers' own rule: the daemon binds and
dials a socket at a path of any length.

The daemon's choice of socket directory fed the problem. Without
XDG_RUNTIME_DIR it used ~/.local/state on every system, macOS included,
and it named each socket after its target, 44 bytes for a Local System
session.

- On macOS without XDG_RUNTIME_DIR, keep sockets in run/ in the
  provider's state directory, so under ~/Library by default (hostbridge
  runDirFor). Linux and XDG_RUNTIME_DIR keep the directories they had.
- Name a socket by a 12-hex digest of its target, with the exit record
  beside it. A default macOS install then dials its sockets directly
  for a user name of up to 25 bytes.
- Keep serving sessions that an earlier version started. Their bridges
  stay at <target>.sock in the directory that version used, and the
  runtime uses that socket while a bridge listens on it. Start refuses
  a target such a bridge still serves and clears a dead one's socket.
- When a start fails because the run directory cannot hold a socket,
  the error says to set XDG_RUNTIME_DIR.
- Drop the socket budget and the 4-char prefix limit from the e2e
  helpers. Teardown finds bridge sockets in every layout.
- The fake bridge of the Go tests binds a long path through a short
  symlink, as a client dials one, and takes a connection that sends
  nothing, as the real bridge does.

Fixes eclipse-enclave#36

Signed-off-by: Christian W. Damus <cdamus@eclipsesource.com>

@EclipseSourceAI EclipseSourceAI 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.

Note

Autonomous AI review. May contain mistakes.

Useful comment? React 👍. Disagree? React 👎 to reject it for follow-up reviews. A reply explaining why helps too.

Agent approval means no blocking issues found. Unrelated and Follow-up comments are non-blocking. A maintainer must still sign off.

Only a maintainer can re-request a review from this agent.

Powered by Eclipse Enclave via review-guard-mcp

Fixes #36. The e2e helpers no longer enforce their own sun_path budget, and the daemon changes where it keeps session bridge sockets: on macOS without XDG_RUNTIME_DIR they now go in run/ inside the provider's state dir, and every socket is named by a 12-hex digest of its target instead of <target>.sock. Bridges an earlier version started keep working, because Runtime.sock dials the old <target>.sock first and uses it while something answers there.

What maintainers should look at:

  • Runtime.sock now does I/O. Each operation for a target that still has an old socket file costs an extra connect (listening). Uncertain dial errors count as "alive", so Start refuses rather than risk a duplicate agent. That fits the existing LocateElsewhere guard, but the not-serving classification is now written out in a second place (inline comment).
  • Sockets in the data dir on macOS. The removed comment said a networked home can't hold a unix socket. The PR answers that with a bind-failure hint, and that hint also appears when XDG_RUNTIME_DIR is already set, where it gives the wrong advice (inline comment).
  • The new API e2e spec pins the digest file name, which is a daemon internal (inline nit).

Docs (ARCHITECTURE, CONFIGURATION, DEV) and the changelog block are updated and match the code. There's no UI change, so I didn't test anything visually. This environment has no Go toolchain and no installed node_modules, so I couldn't run the Go or vitest suites. I reviewed the code by reading it.

Comment thread daemon/internal/hostbridge/sbridge.go Resolved
Comment thread daemon/internal/hostbridge/sbridge.go Resolved
Comment thread daemon/internal/hostbridge/sbridge.go Resolved
A bridge that cannot bind its socket made Start advise setting
XDG_RUNTIME_DIR, also when XDG_RUNTIME_DIR had already chosen the
directory the bind failed in.

- The runtime remembers whether XDG_RUNTIME_DIR chose its run
  directory, and bindAdvice says nothing then.
- sbridge.Listening takes over the bare connection check from
  hostbridge and shares its notion of "not serving" with
  ErrNotServing, so the two cannot drift apart.
- shortHash and socketName share one digest helper.
- The API e2e spec for socket placement no longer pins the shape of
  the socket's file name, which is the daemon's own business.

Signed-off-by: Christian W. Damus <cdamus@eclipsesource.com>

@EclipseSourceAI EclipseSourceAI 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.

Note

Autonomous AI review. May contain mistakes.

Useful comment? React 👍. Disagree? React 👎 to reject it for follow-up reviews. A reply explaining why helps too.

Agent approval means no blocking issues found. Unrelated and Follow-up comments are non-blocking. A maintainer must still sign off.

Only a maintainer can re-request a review from this agent.

Powered by Eclipse Enclave via review-guard-mcp

Follow-up review. The single commit pushed since my last pass (ec795ce) addresses all four threads I opened, and I checked each claim against the code rather than taking the reply at face value:

  • sbridge.Listening is now exported next to ErrNotServing, both backed by the same notServing helper, and hostbridge.listening is gone. Confirmed no leftover references.
  • bindAdvice now checks a new Runtime.inRuntimeDir field, which is set from env.xdgRuntimeDir != "" in newRuntime. That's exactly the condition under which runDirFor picks XDG_RUNTIME_DIR as the run dir (namespacedRunDir), so the hint is correctly suppressed only when it would be useless. TestStartSaysHowToMoveSocketsWhenTheBindFails now covers that case.
  • shortHash and socketName both go through a shared digest12, no more duplicated hashing logic.
  • The e2e spec now matches [^/]+\.sock instead of pinning the digest file name, keeping the directory (user-visible) checked without depending on the daemon-internal digest format.

No new issues in the diff since my last review; it's a tight, well-tested fix-up. No UI change, so no Playwright pass needed.

Suggested squash commit message:

fix: Keep session sockets where each platform keeps a user's

Fixes #36

`make test-e2e` failed on macOS with the default `TMPDIR`. The e2e helpers
counted the bytes of a bridge socket path against the `sun_path` limit and
refused any isolated home too deep for it, and every home under the macOS
temp directory is. That budget was the helpers' own rule, so this removes
it and fixes what made the paths long and odd: where the daemon puts its
session bridge sockets.

- On macOS without XDG_RUNTIME_DIR, sockets now go in `run/` inside the
  provider's state directory instead of `~/.local/state`.
- A socket is named by a 12-hex digest of its target instead of
  `<target>.sock`, keeping every path well inside sun_path even for a
  deep -home-dir.
- Sessions an earlier version started keep working across the upgrade:
  Start looks for that version's `<target>.sock` before picking a new one.
- A bind failure on a filesystem without unix sockets now says to set
  XDG_RUNTIME_DIR, unless XDG_RUNTIME_DIR already chose the directory the
  bind failed in.
- sbridge.Listening is now the one place that tells whether a bridge still
  serves a socket; ErrNotServing and Listening agree on every case by
  construction.

Signed-off-by: Christian W. Damus <cdamus@eclipsesource.com>

These previous comments can be resolved as they are now handled:

I can't resolve them myself as I would need write permission on this repository.

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.

The e2e suite fails on macOS unless TMPDIR is short

2 participants