Skip to content

feat(guardian): own the Vite dev port — probe, strictPort, truthful banner, origin allowlist#322

Merged
luokerenx4 merged 1 commit into
masterfrom
feat/guardian-ui-port
Jun 11, 2026
Merged

feat(guardian): own the Vite dev port — probe, strictPort, truthful banner, origin allowlist#322
luokerenx4 merged 1 commit into
masterfrom
feat/guardian-ui-port

Conversation

@luokerenx4

Copy link
Copy Markdown
Contributor

Summary

  • Guardian's port authority now covers the Vite dev port: planPorts claims a fourth ui port (default 5173, probe upward), with OPENALICE_UI_PORT env / ports.json "ui" key following the same explicit-config-fails-loud rule as web/mcp/uta.
  • The dev banner prints the resolved UI port instead of a hardcoded "5173 (Vite picks +1 if taken)" guess; Vite binds exactly that port (strictPort) so banner, Vite, and allowlist can never disagree. Standalone pnpm --filter open-alice-ui dev keeps the classic 5173 + auto-increment behavior.
  • buildDefaultOrigins derives the UI origins from the injected port instead of literal 5173 — the PTY WS origin gate now tracks the real frontend location, and a stale 5173 entry no longer whitelists whatever unrelated app happens to sit there.

Test plan

  • npx tsc --noEmit clean (root) and tsc -b clean (ui/)
  • pnpm test passes (113 files / 1825 tests)
  • End-to-end with 5173+5174 deliberately occupied: banner and Vite both land on 5175; WS upgrade probes against the backend: Origin localhost:5175 → 101, stale localhost:5173 → 403, evil.example → 403, same-origin via Vite proxy → 101.

Boundary touch

Touches the workspace WS origin allowlist (src/workspaces/config.ts buildDefaultOrigins). Net effect is a tightening: the allowlist follows the actual Vite port; no new origins are admitted beyond what Guardian itself resolved. The #318 same-origin rule is unaffected.

🤖 Generated with Claude Code

…anner, origin allowlist

Previously the UI port lived outside Guardian's port authority: dev.ts
printed a hardcoded "5173 (Vite picks +1 if taken)" banner before Vite
even spawned, Vite auto-incremented on its own, and the workspace WS
origin allowlist kept trusting literal 5173 — so a drifted Vite port
meant a lying banner plus an allowlist pointing at whatever unrelated
app sat on 5173.

- planPorts claims a fourth `ui` port (default 5173, probe upward; env
  OPENALICE_UI_PORT / ports.json `ui` key follow the same explicit
  fail-loud rule as the backend trio)
- dev.ts banner prints the resolved port; injects OPENALICE_UI_PORT
  into both Vite and Alice
- vite.config.ts binds exactly the injected port (strictPort) under the
  orchestrator; standalone keeps classic 5173 + auto-increment
- buildDefaultOrigins derives UI origins from the injected port instead
  of hardcoded 5173, so the WS origin gate tracks the real frontend

Verified end-to-end with 5173+5174 occupied: banner/Vite agree on 5175;
WS upgrade with Origin 5175 → 101, stale 5173 → 403, foreign origin →
403, same-origin through the Vite proxy → 101.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openalice-demo Ready Ready Preview, Comment Jun 11, 2026 10:11am

Request Review

@luokerenx4 luokerenx4 merged commit 8148c57 into master Jun 11, 2026
5 checks passed
pull Bot pushed a commit to jinzaizhichi/OpenAlice that referenced this pull request Jun 12, 2026
Headless sessions become reopenable + the ~/.openalice data root + sealed
broker credentials + the UTA order lifecycle closes. release.yml tags
v0.42.0-beta.1 + publishes the prerelease on master push.

Highlights:
- Headless runs are now real sessions: all four agent CLIs' session ids are
  captured from headless stdout while running, full output logs persist on
  disk, and a finished run reopens as a normal interactive session
  (resume-by-id). UI: collapsed "headless · N" tier under each workspace +
  output viewer in the Automation panel (TraderAlice#326).
- User data moves to ~/.openalice (OPENALICE_HOME); broker credentials are
  sealed at rest (AES-256-GCM, machine-bound key, migration 0009); desktop
  relocates packaged data on first launch.
- UTA order lifecycle closed: auto-sync poller + fill data + PnL invariant
  (TraderAlice#325); externally-placed orders observed as squashed [observed] commits
  with configurable cadence (TraderAlice#327); Alpaca error bodies surfaced, bybit
  spot+swap order sweep, listing-driven sync perf (TraderAlice#328).
- CLI is the default workspace tool access; trading lands on the CLI surface
  as the alice-uta export family (TraderAlice#319, TraderAlice#320).
- Self-host hardening: configurable ports, MCP loopback bind + lock, Docker
  self-host image, Guardian owns the Vite dev port (TraderAlice#303TraderAlice#308, TraderAlice#322).
- Market data: status-first settings page with coverage map (TraderAlice#323), hub FX
  table, keyless yfinance fallbacks, long-tail fetcher fixes (TraderAlice#310TraderAlice#317).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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