Skip to content

Add isolated headed Chrome browser sessions #18

Closed

Description

@ElbertePlinio

Parent: #17

Goal

Add a first-class browser session that launches real headed Chrome inside a private PickLab Xvfb display and exposes a safe, stable lifecycle contract for visual control and the later DevTools relay.

Shared session contract

Add SessionType = "browser" with ID prefix brow. One browser record owns both legs:

  • desktop: display, PID, width, height, optional VNC metadata
  • browser: browserPid, browserStartTimeTicks, binaryPath, profileMode: "ephemeral", profileDir, cdpPort

Do not persist the DevTools websocket path/GUID or a separate desktop session ID. Existing session status remains lifecycle-only; human control is not stored there.

Session resolution becomes capability-based:

  • desktop tools accept records with a desktop leg, including browser sessions
  • browser relay requires a browser leg
  • Android tools require an Android leg
  • implicit resolution is project-local and succeeds only for exactly one live candidate
  • missing, dead, wrong-capability, and ambiguous selection fail closed

Browser lifecycle

  • Detect supported Chrome/Chromium binaries with actionable errors.
  • Create a private Xvfb and ephemeral profile under the session directory.
  • Launch with argv arrays and shell:false.
  • Use explicit loopback binding, --remote-debugging-port=0, and read <profile>/DevToolsActivePort.
  • Never borrow a personal browser profile.
  • Use cleanEnv:true with a small allowlist: display, isolated HOME/XDG paths, PATH, locale, and required runtime variables.
  • Track process identity using PID plus /proc start ticks.
  • Terminate the whole verified process group, confirm it is dead, then delete the profile.
  • Partial startup failure and stale-session reaping perform the same cleanup.

Security posture

Chrome and CDP still run as the invoking user. This is accepted for v1 only with explicit SECURITY.md documentation: loopback is not isolation from local processes and PickLab is not a hostile-web sandbox. Track uid isolation and --remote-debugging-pipe separately.

Checklist

  • PR 2 — session/process contracts
  • Browser binary detection and package
  • Ephemeral profile confinement
  • Port 0 + DevToolsActivePort discovery
  • Scrubbed launch environment
  • Create/status/destroy/reaper lifecycle
  • Existing session CLI/MCP wiring for type browser
  • Concurrent-session and partial-failure tests
  • SECURITY.md, README, and docs/releases/UNRELEASED.md
  • PR/review

Validation

  • bun run typecheck
  • focused core/browser/CLI/MCP tests
  • bun run test
  • bun run test:coverage
  • bun run build
  • headed Chrome under Xvfb in CI
  • two sessions get distinct displays, ports, and profiles
  • CDP listens only on loopback
  • planted environment secrets are absent from the browser process
  • destroy/reap leaves no process-group members and removes the profile
  • cancellation and every partial-failure point clean up

No feature flag: the new session type is independently releasable and current defaults remain unchanged.

Current status: In progress
Next: land the shared browser/session/process contract PR.

Activity

  1. ElbertePlinio commented on Jul 12, 2026

    @ElbertePlinio
    MemberAuthor

    Implementation started:

    • PR 2: shared browser/session/process contracts
    • Browser lifecycle and CLI/MCP wiring follow on the stabilized contract

    Branch: feat/browser-session-contracts
    Current status: In progress

  2. ElbertePlinio commented on Jul 12, 2026

    @ElbertePlinio
    MemberAuthor

    PR 2 opened: #24

    • Browser session record contract
    • Capability-based resolution
    • Verified process-group teardown
    • Full local validation green
    • Automatic Codex review and CI
    • Browser lifecycle package after contract review

    Current status: In review

  3. ElbertePlinio commented on Jul 12, 2026

    @ElbertePlinio
    MemberAuthor

    PR 2 review status (#24):

    • CI green
    • PID reuse, zombie membership, missing-leader, and zombie-identity findings handled
    • Blocked by a new valid P2 found on the fourth/final Codex round: browser process group must stop before VNC/Xvfb helpers

    Per review policy, no fifth round will run and #24 will not merge. The ordering fix is required in the active browser lifecycle branch before #18 can proceed.

    Current status: Blocked / PR left open

  4. ElbertePlinio commented on Jul 12, 2026

    @ElbertePlinio
    MemberAuthor

    Recovery started:

    • Build a replacement contracts PR from feat(core): add browser session contracts #24 with browser-group-before-VNC/Xvfb ordering and regression coverage
    • Fresh Codex review on the corrected HEAD
    • Rebase the local Chrome lifecycle slice onto the accepted contracts

    #24 remains open and unmerged until the replacement is ready.

    Current status: In progress
    Next: open the replacement contract PR.

  5. ElbertePlinio commented on Jul 12, 2026

    @ElbertePlinio
    MemberAuthor

    Progress update:

    • Replacement contracts PR fix(core): order browser teardown safely #26 merged
    • Browser group stops before VNC/Xvfb
    • PID reuse, group leadership, zombie ownership, and helper failures fail closed
    • Full tests, coverage, build, CI, and Codex review green
    • Isolated Chrome lifecycle PR

    PR #24 was closed as superseded.

    Current status: In progress
    Next: rebase and ship the completed Chrome lifecycle slice.

  6. ElbertePlinio commented on Jul 12, 2026

    @ElbertePlinio
    MemberAuthor

    Chrome lifecycle PR opened: #28

    • Isolated headed Chrome + ephemeral profile
    • Loopback port 0 / DevToolsActivePort
    • Scrubbed environment and stable process supervision
    • CLI/MCP create/status/destroy/all
    • Full tests, coverage, build, and real visual Chrome proof
    • CI and automatic Codex review

    Current status: In review

  7. ElbertePlinio commented on Jul 13, 2026

    @ElbertePlinio
    MemberAuthor

    Current lifecycle HEAD pushed to PR #28: 104db9d.

    Current status: CI queued
    Next: merge only after current-head CI is green.

  8. ElbertePlinio commented on Jul 13, 2026

    @ElbertePlinio
    MemberAuthor

    CI follow-up: PR #28 is now at 02c444b.

    The previous current-head run exposed two deterministic-test issues; both were root-caused, fixed, stress-tested, and independently reviewed. Full local suite is green again: 63 files, 705 passed / 2 skipped.

    Current status: waiting for required CI on 02c444b
    Next: merge only after that run is green.

  9. ElbertePlinio commented on Jul 13, 2026

    @ElbertePlinio
    MemberAuthor

    PR #28 merged at eddf853 after current-head CI passed.

    • Isolated headed Chrome lifecycle
    • Full local and hosted validation
    • Fresh serious local workflow review
    • Real visual/browser lifecycle proof
    • Complete verified teardown and session-directory cleanup
    • Defensive follow-up tracked in Harden pre-identity browser daemon cleanup #29

    Current status: Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions