Skip to content

test: bind fixture unix sockets under a path the platform can hold - #132965

Merged
steipete merged 1 commit into
mainfrom
steipete/desktop-observe-socket-path
Aug 30, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/desktop-observe-socket-path

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

scripts/lib/vitest-process.mts:22 creates an oc-vt-XXXXXX namespace below the
ambient temporary directory and assigns it to TMPDIR/TMP/TEMP. Any fixture
that then builds a Unix socket path from os.tmpdir() inherits that extra depth,
and on macOS the result can exceed the 104-byte sockaddr_un.sun_path limit.
listen fails with EINVAL.

Three fixtures were affected, with very different symptoms:

  • src/gateway/desktop/observe-bridge.test.ts produced a 105-byte path and
    never observed the server's error event. The bind failure was therefore
    completely invisible: the harness's peerConnected promise stayed pending and
    seven tests waited out their full 120-second timeout — roughly 14 minutes of
    dead wall-clock per run — reporting "Test timed out" instead of the real cause.
    This is the repo's worst bug class: an action that ends in no visible outcome and
    no recorded reason.
  • extensions/cua-computer/src/mcp-driver-client.test.ts produced a 110-byte
    path and fails 3/3 on current main. It does await its bind with an error
    handler, so it fails loudly rather than hanging.
  • extensions/openshell/src/backend.e2e.test.ts produces a 116-byte mirror
    socket path (.../mirror/host.sock). Opt-in Docker E2E, so it is not part of a
    normal run.

Why This Change Was Made

src/infra/jsonl-socket.test.ts:16 already carries the exact comment "macOS
sockaddr_un cannot hold the test runner's nested temporary path" and binds under an
explicit short root. That constraint was solved locally once and never applied to
the sibling fixtures. This change applies it consistently.

There is no universal Unix-socket fixture helper to reuse here, and adopting one
would be wrong: withTestDir and createSuiteTempRootTracker both default to
os.tmpdir() (src/test-helpers/temp-dir.ts:46, :154) and so do not fix the
budget without an explicit short parentDir. withTestDir's callback scope would
additionally tear down the observe harness's live server, socket, and WebSocket,
which tests use until afterEach. The canonical constraint is an explicitly short
parent plus resource-owned cleanup, which is what each fixture now does.

Two lifecycle defects were repaired alongside the paths, because a bind that can
now fail loudly must not leak: every resource's cleanup is registered before the
operation that can fail. Previously observe-bridge registered its temp-root
removal and httpServer close only after a successful Unix bind, and
cua-computer registered its directory cleanup only after a successful listen.
observe-bridge's HTTP startup is now error-observing too.

User Impact

None at runtime. Production LOC is unchanged (+0/-0); all three files are tests.
Maintainers get a red extensions lane back to green, ~14 minutes of wall-clock back
per full run, and a bind failure that names itself instead of masquerading as a
timeout.

Evidence

Root cause, measured on this host (69-byte runner namespace) with a live Node
v26.5.0 / libuv 1.52.1 probe using real mkdtemp and net.Server.listen:

Path Bytes Bind result
Original observe fixture 105 EINVAL, syscall listen
Revised observe fixture 51 Success
Boundary control 104 Success
Boundary control 105 EINVAL

Observed failure before the change, reproduced directly:

listen EINVAL: invalid argument
  /private/var/folders/.../T/oc-vt-LzgRGk/openclaw-cua-mcp-test-OcGDa3/daemon.sock

Results:

node scripts/run-vitest.mjs src/gateway/desktop/observe-bridge.test.ts
  before: 7 failed (120s timeouts each) — after: 8 passed, 156ms
node scripts/run-vitest.mjs extensions/cua-computer
  before: 3 failed (EINVAL), exit 1 — after: 12 files, 98 passed, exit 0
node scripts/run-vitest.mjs extensions/openshell
  7 files, 180 passed, exit 0
node scripts/check-changed.mjs -- <all three files>   exit 0
git diff --check                                       exit 0

Lifecycle repairs were proven with real faults, not mocked bind results: an
occupied socket pathname (EADDRINUSE) left the short root present before the fix
and absent after it; an occupied TCP port exercised the HTTP path the same way.

Sibling inventory. Every other real Unix-bind fixture was measured; all fit, and
those already using an explicit short root are listed for contrast:
src/infra/jsonl-socket.test.ts, src/infra/exec-host.socket.test.ts,
src/node-host/invoke-system-run.socket.test.ts and
extensions/codex/src/app-server/transport-websocket.test.ts already choose /tmp;
src/worker/worker.runtime.test.ts (95), extensions/openshell/src/mirror.test.ts
(100), and src/gateway/server.plugin-node-capability-auth.test.ts (94) fit under
the current one-level namespace. src/secrets/egress-proxy/proxy-server.test.ts,
src/proxy-capture/proxy-server.test.ts and the Mattermost monitor bind TCP, not
Unix sockets.

Limitation: extensions/openshell/src/backend.e2e.test.ts requires Docker and a
registered local gateway and was not executed here. Its change is a strictly
shortening root swap (116 → 47 bytes) with no assertion on the path prefix, covered
by typecheck, lint and format.

Named follow-up (not in this PR)

src/gateway/worker-environments/desktop-tunnel.ts:138 derives desktop.sock from
a root created under unrestricted os.tmpdir() in
src/gateway/worker-environments/ssh.ts:153, so the -L forward argument can
exceed the same budget — 113 bytes under this namespace, and real
ssh -G -F none -L <path>:127.0.0.1:5900 exits 255 with "Bad local forwarding
specification". It is deliberately excluded here: it is production, it fails loudly
rather than silently (ExitOnForwardFailure=yes, with rejection and captured
diagnostics in tunnel-ssh-runner.ts:77), and git log --follow places its
introducing commit outside every available stable tag, so it is a current-main
analogue rather than a shipped regression. The fix belongs with the desktop-tunnel
lifecycle owner, as a short private socket directory independent of the credential
temporary directory.

The vitest runner nests TMPDIR under an oc-vt-* namespace, so socket paths
built from os.tmpdir() can exceed macOS's 104-byte sockaddr_un.sun_path.
observe-bridge listened without observing the server's error event, so the
EINVAL was invisible and seven tests waited out their full 120s timeout;
cua-computer already reported it and fails 3/3 on main; the OpenShell E2E
mirror socket is 116 bytes.

Bind under the short canonical root the other socket suites use, await each
listen so bind failures surface, and register every resource's cleanup before
the operation that can fail.
@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 30, 2026 01:07
@steipete steipete self-assigned this Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 9:15 PM ET / August 30, 2026, 01:15 UTC.

ClawSweeper review

What this changes

The PR moves three Unix-socket test fixtures to a short /tmp parent and registers cleanup and bind-error handling before local socket or HTTP servers start.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. This maintainer-authored, maintainer-labeled PR repairs current-main test-fixture failures; the per-fixture short-path and pre-bind cleanup changes match existing repository patterns, with no blocking defect found.

Priority: P3
Reviewed head: c87853b7e595f97e9410054f2b1fdca2fb3998f8

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused test-only repair with source-confirmed lifecycle handling and credible direct runtime evidence, with one opt-in E2E path left unexecuted.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable: this is a maintainer-authored test-only PR, so the external-contributor proof gate does not apply; the supplied body nevertheless includes direct real Node/Vitest before-and-after evidence for the exercised fixtures.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable: this is a maintainer-authored test-only PR, so the external-contributor proof gate does not apply; the supplied body nevertheless includes direct real Node/Vitest before-and-after evidence for the exercised fixtures.
Evidence reviewed 6 items Current main still has the failing setup: The current-main version creates the observe fixture under the runner-provided temporary directory and starts its Unix server without awaiting or observing bind errors; the PR has not been superseded.
Changed lifecycle owner: The PR creates the short root, registers Unix-server cleanup before binding, awaits the bind with an error listener, and does the same for the HTTP listener; the test harness continues to exercise the real observer-upgrade entrypoint.
Existing sibling pattern: The JSONL Unix-socket fixture already uses an explicit /tmp parent and awaits a bind error before running its transport assertions, supporting a per-fixture repair rather than changing the global test-runner temporary directory.
Findings None None.
Security None None.

How this fits together

Gateway and plugin tests start local Unix/TCP endpoints, then connect clients through them. The Vitest runner nests its temporary namespace, so fixtures that derive Unix socket paths from it can exceed macOS path limits before the tested transport behavior runs.

flowchart LR
  Runner[Vitest temporary namespace] --> Fixture[Local socket fixture]
  Fixture --> SocketPath[Unix socket path]
  SocketPath --> Bind[Local server bind]
  Bind --> TestFlow[Gateway and plugin test flow]
  Bind --> Cleanup[Fixture cleanup]
Loading

Before merge

  • Resolve merge risk (P1) - The opt-in OpenShell Docker E2E path was not rerun in the supplied evidence; its change is limited to the same short-root substitution used by the exercised sibling fixtures.
  • Complete next step (P2) - No repair job is needed: no actionable review finding was found, and the remaining action is normal exact-head CI and maintainer merge handling.
Agent review details

Security

None.

PR surface

Tests +8. Total +8 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 3 33 25 +8
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 33 25 +8

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests +33/-25 All changed lines are test fixtures, so the repair has no runtime or upgrade-surface delta.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the per-fixture short canonical path and pre-bind resource cleanup, then merge after exact-head checks complete; do not alter the global Vitest temporary-directory policy.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the per-fixture short canonical path and pre-bind resource cleanup, then merge after exact-head checks complete; do not alter the global Vitest temporary-directory policy.

Do we have a high-confidence way to reproduce the issue?

Yes: current-main source constructs Unix socket paths beneath the Vitest-controlled nested temporary root, and the PR body supplies direct pre-fix EINVAL and timeout results from real Node/Vitest runs.

Is this the best way to solve the issue?

Yes: fixture-local short roots preserve the runner's isolation behavior while matching the existing Unix-socket fixture pattern; a global temporary-directory change would broaden the repair unnecessarily.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c72ce0b549bd.

Labels

Label changes:

  • add P3: This is bounded test-fixture reliability maintenance with no production behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Label justifications:

  • P3: This is bounded test-fixture reliability maintenance with no production behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

  • Current main still has the failing setup: The current-main version creates the observe fixture under the runner-provided temporary directory and starts its Unix server without awaiting or observing bind errors; the PR has not been superseded. (src/gateway/desktop/observe-bridge.test.ts:43, c72ce0b549bd)
  • Changed lifecycle owner: The PR creates the short root, registers Unix-server cleanup before binding, awaits the bind with an error listener, and does the same for the HTTP listener; the test harness continues to exercise the real observer-upgrade entrypoint. (src/gateway/desktop/observe-bridge.test.ts:42, c87853b7e595)
  • Existing sibling pattern: The JSONL Unix-socket fixture already uses an explicit /tmp parent and awaits a bind error before running its transport assertions, supporting a per-fixture repair rather than changing the global test-runner temporary directory. (src/infra/jsonl-socket.test.ts:16, c87853b7e595)
  • Node server cleanup contract: The directly inspected Node built-in net source shows Server.close emits the close path even when no handle exists and supplies ERR_SERVER_NOT_RUNNING to its callback; the new cleanup callbacks resolve in either case, so a failed bind does not strand the short root.
  • History and routing: The pre-existing affected fixture lines are attributed by blame to the recent merged commit 009cd5b; its raw commit identifies Peter Steinberger as author. The blame boundary marker prevents treating this as introduction proof, so this is routing evidence only. (src/gateway/desktop/observe-bridge.test.ts:43, 009cd5b800a1)
  • Submitted real-run evidence: The PR body records real Node/Vitest before-and-after results for the observe and CUA fixtures, plus fault-injection cleanup checks; it also candidly states that the opt-in OpenShell Docker E2E was not run. (c87853b7e595)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit fb570d4 into main Aug 30, 2026
181 checks passed
@steipete
steipete deleted the steipete/desktop-observe-socket-path branch August 30, 2026 01:18
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 30, 2026
…penclaw#132965)

The vitest runner nests TMPDIR under an oc-vt-* namespace, so socket paths
built from os.tmpdir() can exceed macOS's 104-byte sockaddr_un.sun_path.
observe-bridge listened without observing the server's error event, so the
EINVAL was invisible and seven tests waited out their full 120s timeout;
cua-computer already reported it and fails 3/3 on main; the OpenShell E2E
mirror socket is 116 bytes.

Bind under the short canonical root the other socket suites use, await each
listen so bind failures surface, and register every resource's cleanup before
the operation that can fail.
amittell added a commit to amittell/openclaw that referenced this pull request Sep 21, 2026
mantis-telegram-failure binds its ingress socket at
os.tmpdir()/oc-vt-XXXXXX/tg-diagnostic-ingress-XXXXXX/api.sock. On macOS that
path is 107 bytes under vitest, past the 104-byte sockaddr_un.sun_path, so
listen() fails with EINVAL. Root the socket dir under realpath("/tmp") on POSIX,
the openclaw#132965 idiom, and keep os.tmpdir() on win32 where the socket is a named
pipe. mantis-telegram-proof gets the same change: its path is 8 bytes under the
limit today.

Rebased onto main 5733bb1. The other half of the original change, spawning
python3 instead of bare python, landed on main in e572c0c (openclaw#146807), so the
conflict resolution takes main's line and this commit is the socket fix only.

Measured on an M4 (macOS, os.tmpdir() under /var/folders), node
scripts/run-vitest.mjs run on both files:

  main 5733bb1          5 failed, 22 passed. All five are
                            mantis-telegram-failure's ingress cases, each
                            "listen EINVAL" on a 107-byte socket path
  main + this commit        27 passed

oxfmt --check and oxlint on both files: clean.

Claude assisted with the rebase and the measurements. The submitter owns the conclusions and final review.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant