Skip to content

feat: broker macOS Claude through the Aqua session - #99

Merged
BytePioneer-AI merged 1 commit into
mainfrom
feat/macos-aqua-harness-broker
Sep 1, 2026
Merged

BytePioneer-AI merged 1 commit into
mainfrom
feat/macos-aqua-harness-broker

Conversation

@mouzhi

@mouzhi mouzhi commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Managed macOS SSH Hosts run in a detached Background audit session, while native Claude Code login and Keychain access belong to the logged-in Aqua session. Launching Claude directly from the remote Host therefore makes a valid native login appear expired.

This change adds a current-user Aqua Harness broker and routes Claude Code through it only for managed macOS remote Hosts.

Design

  • installs ai.bytepioneer.codexhost.native-harness-broker in the current non-root gui/<uid> Aqua domain;
  • runs the packaged Host Runtime with the caller's explicit npm Node path, so npm packages do not assume a bundled Node runtime;
  • exposes an owner-only Unix socket and owner-only descriptor with a fresh generation and 256-bit capability;
  • rejects symlinks, foreign ownership, unsafe file modes, stale endpoints, replayed/out-of-sequence frames, oversized frames, and overfull request queues;
  • strips remote per-session environment data and persists only the reviewed proxy allowlist, never Claude/OAuth/Keychain values;
  • keeps native Claude session identity, model, thinking, permission mode, and writer ownership across bounded authentication recovery;
  • retires and awaits old output forwarders before reopen so stale output cannot be relabeled as the replacement generation;
  • reserves known and delayed native writers before awaiting native open, closing cross-cwd and concurrent-open races;
  • adds codexhost broker install|status|stop|uninstall and composes broker lifecycle with macOS remote install|status|uninstall;
  • keeps remote status machine-readable JSON on stdout and sends broker status diagnostics to stderr.

The Background Host never unlocks Keychain, asks for a password, copies Claude credentials, changes ~/.claude, or proxies Claude through OpenCodex.

Validation

  • npm run check
    • formatting, lint, boundary checks, and typecheck passed;
    • TypeScript: 174 files passed, 1 skipped; 1507 tests passed, 16 skipped;
    • Clippy with -D warnings passed;
    • full Rust workspace tests passed.
  • Focused broker/release tests include:
    • stale output after reopen;
    • same native session across different cwd values;
    • pre-await known-native open reservation;
    • delayed create identity and bootstrap-turn reservation;
    • packed-frame queue overflow;
    • descriptor/socket mode and replacement checks;
    • macOS LaunchAgent directory/plist hardening;
    • npm wrapper lifecycle and JSON stdout compatibility.
  • Live macOS arm64 candidate 0.4.0-main.38dbcbb.1:
    • LaunchAgent, descriptor, plist, and socket ownership/modes verified;
    • broker ran in Aqua ASID 100015 while the managed SSH Host ran in Background ASID 305362;
    • exactly one managed remote Host chain survived the reconnect and an 8-second stability window;
    • Host-level codexhost/harness/inspect returned 5 native Claude models and 5 native permission modes;
    • an ephemeral Host-routed Claude thread completed with exact reply HOST_BROKER_OK;
    • no Keychain prompt or Claude configuration change was used.

Rollback

The candidate is versioned independently. broker uninstall removes the LaunchAgent, and the prior 0.4.0 candidate plus pre-switch remote shim/manifest backup remain available for a controlled rollback.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@mouzhi

mouzhi commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

CI note after three Windows reruns at the unchanged head 38dbcbb:

  • Linux ARM64, Ubuntu, and macOS are green.
  • The new broker and npm-wrapper tests passed on every Windows attempt.
  • Attempt 1 failed in the unchanged Shim test replacement_does_not_signal_a_reused_owner_process_id after a transient Access is denied while reading a rapidly reused PID.
  • Attempt 2 passed Rust and failed three unchanged Host tests on unrelated 2 s / 5 s timeouts.
  • Attempt 3 passed all 1,507 TypeScript tests, then failed two different unchanged Shim lifecycle tests on the same transient Windows PID executable-read error.

The four production/test files involved in the Shim failures have no diff from origin/main. Locally, the first failing Shim test passed 10/10 runs, and the three timed-out Host tests passed 5/5 combined runs. This is a pre-existing Windows process-identity / runner-load flake, not an Aqua broker regression.

I am intentionally not mixing an unrelated lifecycle-test repair into this PR. The safe follow-up is a separate bounded Windows fix that retries only transient ERROR_ACCESS_DENIED identity reads, requires a complete PID + start-time + executable match, and never signals or takes over when identity remains unprovable.

Managed SSH Hosts run in a background audit session that cannot use the interactive user's native Claude login. Install an owner-only LaunchAgent broker in the current Aqua session and route managed macOS Claude adapters through its authenticated Unix socket, with bounded lifecycle recovery and writer leases.
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.

2 participants