Skip to content

fix(browser): start headed Chrome from nested homes; keep a desktop test out of the real home - #108

Merged
ElbertePlinio merged 3 commits into
mainfrom
fix/17-chrome-tmp-alias
Sep 5, 2026
Merged

ElbertePlinio merged 3 commits into
mainfrom
fix/17-chrome-tmp-alias

Conversation

@ElbertePlinio

@ElbertePlinio ElbertePlinio commented Sep 5, 2026 •

Copy link
Copy Markdown
Member

Refs #17
Refs #89

Why

The #17 acceptance pass on current main (c4b601d) hit two defects that are not visible in CI:

  1. Headed Chrome cannot start from a deeply nested PICKFORGE_HOME. Chrome's process singleton binds a Unix socket at $TMPDIR/com.google.Chrome.*/SingletonSocket; sun_path is 108 bytes, and the session-confined TMPDIR under the session directory pushed the path over it. The first browser session of the pass died with FATAL: Socket path too long and the record went to error (issue17-final/logs/create-browser-1.json). Any home path longer than roughly 60 bytes reproduces it deterministically.
  2. A desktop-linux integration test writes into the developer's real home. records a screenshot artifact in a run called createRun without the test's isolated env, so the default home storage put a desktop-shot run under the real ~/.pickforge/lab/projects/... on every suite run. Fifteen of them appeared in the real home during the pass while a sibling worktree ran the suite.

What

  • Chrome now gets TMPDIR=/tmp/pickforge-browser-<uid>/<sha256(sessionDir)[:16]>, a symlink into the session's own tmp directory, so the socket and every Chrome temp file still live under the session directory and are deleted with it. The alias root must be a real directory owned by the invoking user at mode 0700; an existing alias is refused, not reused; removal unlinks only a symlink that resolves to this session's tmp; destroy and failed-start cleanup remove it with the rest of the runtime.
  • An entry already at the alias path is classified before anything is done: this session's own alias is reused, a dangling symlink (session directory removed without a destroy) is replaced, and a symlink to a live foreign directory or a real directory is refused. Without this, a later session with the same key failed with "already exists"; the full gate run surfaced it as two dangling aliases left by startup.test.ts, whose afterEach now removes its alias.
  • The desktop-linux test passes its isolated env to createRun.
  • SECURITY.md and docs/releases/UNRELEASED.md describe the alias.

Tests

  • New packages/browser/test/chrome-tmp-alias.test.ts: publish, refuse an existing alias, two sessions under one root, no-op removal, refuse a foreign symlink, refuse a real directory, remove an owned alias without touching the session tree.
  • Fake-Chrome session tests assert the alias, its target, and the root's 0700 mode, and that destroy removes it.
  • Real-Chrome integration test starts a session from a nested home, checks TMPDIR in /proc/<pid>/environ, and checks the singleton directory landed inside the session tmp.
  • Canary PICKFORGE_HOME for the desktop-linux suite: a desktop-shot run appears before the change, nothing after.

Gate results and the full acceptance evidence for #17 (real watch, takeover, concurrency, sensitive-evidence, cleanup, recordings, independent vision verdict) are in ~/Projects/Boards/pickforge/0.4-release/issue17-final/REPORT.md. Issue #17 stays open until this PR is merged and its evidence is recorded.

…s start

A headed browser session under a deeply nested PICKFORGE_HOME never started:
Chrome's process singleton binds a Unix socket at
$TMPDIR/com.google.Chrome.*/SingletonSocket, sun_path is 108 bytes, and the
session-confined TMPDIR pushed the path past it. Chrome aborted with
"Socket path too long" during the #17 acceptance pass, and the session
record went to error. The failure is deterministic for any home path longer
than roughly 60 bytes.

Chrome now receives TMPDIR=/tmp/pickforge-browser-<uid>/<sha256(sessionDir)[:16]>,
a symlink into the session's own tmp directory. The socket and every Chrome
temp file still live under the session directory and are removed with it.
The per-uid alias root must be a real directory owned by the invoking user
at mode 0700, an existing alias is refused rather than reused, and removal
unlinks only a symlink that resolves to this session's tmp directory. Destroy
and failed-start cleanup remove the alias with the rest of the runtime.

Tests: alias lifecycle unit tests (create, refuse existing, refuse foreign
symlink or real directory on removal, sibling sessions share one root), the
fake-Chrome session tests assert the alias and its root permissions, and the
real-Chrome integration test starts a session from a nested home and checks
the singleton directory landed inside the session tmp.

Refs #17
Refs #89
…ated home

"records a screenshot artifact in a run" created its run with createRun's
default env, so with the default "home" storage mode every run of the suite
wrote a desktop-shot run into the developer's real ~/.pickforge/lab. The #17
acceptance pass caught fifteen of them appearing in the real home while a
sibling worktree ran the suite. Pass the test's isolated env instead. A
canary PICKFORGE_HOME reproduced the leak before the change and is empty
after it.

Refs #89
…xt start

The alias key is derived from the session directory, so a symlink left in
/tmp/pickforge-browser-<uid>/ after a session directory was removed without
a destroy (a deleted PICKFORGE_HOME, or a test that deliberately keeps a
failed session's runtime for the reaper and then deletes its temp root)
would have made a later session with the same key fail with "already
exists". Now an entry at the alias path is classified first: this session's
own alias is reused, a dangling symlink is replaced (only this uid can create
entries in the 0700 root), and anything else, a symlink to a live foreign
directory or a real directory, is still refused.

The full gate run left two such dangling aliases behind from
startup.test.ts, whose "unconfirmed Xvfb cleanup" case keeps the runtime on
purpose. Its afterEach now removes the alias before the temp root goes.

Refs #17
Refs #89
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