Repository navigation
Conversation
|
✅ Deterministic PR hygiene checks passed. |
⏳ DRAFT
What to do
Review readiness checklist
0/4 boxes ticked. This PR stays in draft until every box above is ticked. Hygiene✅ Deterministic PR hygiene checks passed. |
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
A connected client stores only a per-client data key. Its listener answered 404 for every `/api/*` path, so the machine's own tools could not read accounts at all: `ocx account list`, the AImorph panel and the usage reporter all died on `not_found`, and the panel's add/reauth never worked. The relay already existed for the dashboard. This points it at the CLI too: a hub client now relays any `/api/*` path it does not own to the hub and answers with the hub's own handler. `/api/machine/*` stays local. Nothing reaches the wire credential-free. `ocx connect` already obtained a management credential to issue the client key — a gui-session from the pairing exchange, or the admin token — and threw it away. That credential is now kept at `hub-management-session.json` (0600) and stamped on relayed requests. A browser bringing its own session or admin token keeps it. `ocx connect rotate` refreshes it, `ocx disconnect` removes it, and `ocx connect status` reports its state without the value. A pairing grant is single-use, so an expired session is not re-exchanged automatically: management reads 401 until the next `ocx connect rotate`, while inference keeps working. `ocx status` says so. Tests cover the store, the stamp (including EUID-free CLI callers and a browser that must keep its own credential), and the listener relaying a bare management path while machine routes stay local. Two existing assertions that expected a client-local 404 now expect the relay.
The first cut of this kept any caller credential already present. A CLI on a connected machine attaches the LOCAL config home's admin token, which the hub does not know, so every account read still 401'd while the e2e run showed the wrong token leaving the machine. Only a hub-issued session is valid at the hub, so the stored credential now replaces anything that is not one. The origin gate takes the stamped session's browser origin rather than the caller's own port, which also fixes a CLI whose listener port differs from the port the session was minted for. Also documents that the hub must allow the client's origin in `corsAllowOrigins` (the same entry `ocx hub invite` already demands) and that changing the client port invalidates the session's origin. Verified end to end against a stub hub: `ocx account list`, a raw `/api/codex-auth/accounts` GET, and an `ocx account use` PUT all reach the hub with the stored session and return 200.
/api/stop is a management path, so the loopback call is relayed to the hub now. The fixture has no hub behind it, which is 502; the attested preflight the test exists for still runs first and still passes.
4eef774 to
873b0a7
Compare
is the config home of my local end-to-end run, not repo content.
The stamp comment still said a caller's credential is kept, written before the fix that replaced a CLI's own admin token.
|
Maintainer review (contributor-backlog lane), head Please fix this first, whatever happens to the feature. The head commit tracks a top-level
On the feature. The bug is real: a connected client's loopback listener 404s on |
|
Merge-manager review (owner accepted this feature in the 2026-11-14/15 backlog review, subject to the security review MAINTAINERS.md requires). The security review found blockers, so this needs changes before it can merge:
The branch is also 463 commits behind |
|
Carried in #8925 with a Co-authored-by trailer for your work, built from current dev without the committed undefined/ directory and with the 2026-11-15 security review items addressed (local auth on every relayed call, relay denylist, ocx stop kept off the hub, Host/Origin checks, no hub admin token at rest, denied-path tests). Nothing further is needed from you here; if any file in that directory came from a real home rather than a test fixture, please rotate that admin token. Thank you for the feature. |
Problem
A connected client stores only a per-client data key. Its listener answered
404for every/api/*path, so the machine's own tools could not read accounts at all:ocx account listprintedError: not_foundocx_accounts()returnedNoneon every runInference was unaffected, which is why this stayed invisible: only the account surfaces broke.
The relay for exactly this existed already, but only the dashboard used it.
Change
A hub client relays any
/api/*path it does not own to the hub and answers with the hub's own handler./api/machine/*stays local; the data plane is untouched. This is independent ofmanagementTransport—directis how a browser reaches the hub, but a CLI has no route to it at all.Nothing reaches the wire credential-free.
ocx connectalready obtained a management credential in order to issue the client key — a gui-session from the pairing exchange, or the admin token — and then threw it away. It is now kept at~/.opencodex/hub-management-session.json(mode0600) and stamped on the relayed request.Only a hub-issued session is stamped over. A CLI attaches the local config home's admin token, which the hub does not know; the first cut of this kept it and every read still 401'd until the e2e run showed the wrong token leaving the machine.
ocx connect rotaterefreshes the stored value,ocx disconnectremoves itocx connect status/ocx statusreport its state without the valueA pairing grant is single-use, so an expired session is not silently re-exchanged: management reads answer
401until the nextocx connect rotate, and status says so. Inference keeps working.Verification
End to end against a stub hub and a real connected client runtime,
ocx account list, a rawGET /api/codex-auth/accounts,/api/provider-quotas, and anocx account usePUT all reached the hub with the stored session and returned200:bun run test --changed=dev: 10167 pass, 4 fail. Two were real and are fixed and re-run green:/api/stoprelays now, soconnected-stop-capability-authand two other assertions finally expect the relay. Two timeouts came from a live client I had left running and pass without it. One failure,catalog-omit-disabled-native, is amodels_cache.jsonENOENT that reproduces identically on a cleanorigin/devworktree.bun run typecheckclean. Tests cover the store, the stamp (CLI caller, local admin token replacement, browser keeps its own), and the listener relaying a bare management path while machine routes stay local.Limits
corsAllowOrigins— the same entryocx hub invitedemands. Changing the client's listener port after connecting invalidates it until the next rotate. Documented inguides/remote-hub.md.ocx connect rotateneeds a fresh code from the hub.Closes nothing; no issue filed yet.
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
Required local validation passed; commands, results, and any full-suite exception are documented.
I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.