Repository navigation
feat: environment cluster behind one main host - #1
andrebrait wants to merge 389 commits into
Conversation
Review round 1: SimplificationScope:
Not checked: full render bodies of |
Review round 1: AdversarialScope:
Mutations: 10 run, 9 caught; the decode guard (finding 2) survived. Not checked: client-runtime registry races; web and mobile UI behaviour; whether T3 Connect sets X-Forwarded-For (affects which sessions count as loopback); a live SSH run of the authorized_keys write path; hostnames with shell metacharacters reaching a user |
Review round 1: Code reviewScope:
Not checked: web and mobile UI code paths in depth; i18n; docs. |
|
Review round 1 closed. It reviewed head 9e9dc7a, and the fixes landed at d28a998. The stop rule does not hold yet. This round found correctness and security defects (one High, five Medium), and the fixes change production logic. Round 2 is therefore due: the code-review pass only, scoped to |
Three-server run (head d28a998)Server A is the main host on 127.0.0.1:13901. Members B (:13902) and C (:13903) joined over HTTPS with A real agent on B (
The first Automated coverage of the same route already exists in |
Review round 2: code review (
|
| # | Finding | Severity | Verdict |
|---|---|---|---|
| 1 | ClusterProxy.test.ts:312: the anonymous-descriptor 502 is said to race with the control link coming up |
important | Rejected. serveMain never calls cluster.start, so no link runs in that test and the member stays offline. The assertion is deterministic. |
| 2 | ClusterService.ts: a failed re-add tells the member to leave but keeps the main host's old row, whose token the new join had already revoked |
important | Fixed in f0d106b. The undo now also drops the stored row, its secret and its old ssh key. The removal test failed first (member count stayed 1). |
| 3 | ClusterService.ts: startup repair in start could run after the HTTP server starts serving |
important | Rejected. start runs inside layerMakeRoutes, which HttpRouter.serve builds before it listens. The repair is awaited, and only the link supervision is forked. |
| 4 | ClusterProxy.ts: the descriptor gate also answers 502 for https members until their link is up |
nit | Rejected. After a restart the 502 lasts only until the link reconnects, and the client retries. A gate that depends on the transport is extra code with no safety gain. |
| 5 | ClusterService.ts: a lost join answer leaves no token to undo with, so the comment overclaims |
pre_existing | Comment narrowed. This is the known gap from round 1. Recovery: re-add the member, or run t3 cluster leave on it. |
| 6 | ClusterProxy.ts: each anonymous descriptor request opens a settings subscription |
nit | Rejected. That cost is negligible next to the upstream HTTP hop the same request makes, and the stream keeps the 403 for a disabled cluster. |
| 7 | ClusterProxy.ts: the status can lag a dropped tunnel, so "never starts ssh" overclaims |
nit | Comment softened ("cannot keep starting ssh"). |
Checks: typecheck, lint, format and knip pass. The cluster tests pass (52). check:changed shows only the same 5 environment-only failures as round 1.
Round 2 closed at f0d106b. It found one correctness defect (pingdotgg#2), and the fix changes production logic, so the stop rule does not hold: a code-review-only round 3 (the last allowed) is due on d28a998abc..f0d106b115.
Review round 3: code review (
|
| # | Finding | Severity | Verdict |
|---|---|---|---|
| 1 | The stored row was looked up after the id-mismatch check and role.current, so a failure in either one, which comes after the member already rotated its token, still left the dead row |
important | Fixed in 4f96020. The lookup now runs right after the join answer. No new test: making role.current fail, or making a member answer under two ids, would need a fake built only for this. The change only moves the lookup earlier. |
| 2 | Dropping the row on a failed re-add loses a custom label | nit | Rejected. The row's token is dead and the member has left, so a row kept only for its label is the inconsistent state this fix removes. A re-add needs a new invite anyway, and --label sets the label again. |
| 3 | The old target's key was revoked even when deleting the row failed | nit | Fixed. The revoke runs only after the row is gone, so a row that survives keeps a working key for t3 cluster remove. |
| 4 | The branch that revokes the old ssh target's key on a failed move is untested | nit | Fixed. The ssh member test now covers a failed move from me@box9 to me@box3: both keys are revoked and no member remains. Removing that revoke makes the test fail (checked). |
| 5 | Effect.suspend(() => reload) is redundant |
nit | Fixed. reload is defined above dropRow. |
| 6 | A lost join answer on a re-add leaves the stored row with a dead token | pre_existing | Rejected for this PR. This is the known gap from rounds 1 and 2. Recovery is the same: re-add, or run t3 cluster leave on the member. |
Checks: typecheck, lint, format and knip pass. The cluster tests pass (52). check:changed shows only the same 5 environment-only failures as before.
Round 3 closed at 4f96020. This is the last round the policy allows (3 of 3), so no further review round runs on this PR.
198747f to
0461ec8
Compare
Review round 2 (full): adversarialScope:
Not checked: a full two-server WebSocket RPC run of #1 (proven at the service layer and by the permission map); |
Review round 2 (full): code reviewScope:
Not checked: the web |
Review round 2 (full): simplificationScope:
Not checked: Round 2 head: |
96ec52e to
5387173
Compare
Review round 3 (light): code reviewScope:
Not checked: whether Round 3 head: |
Review round 4 (light): code reviewScope:
Not checked: the rest of the branch beyond this range. Round 4 head: |
Review round 5 (light): code reviewScope:
Not checked: the follow-up commits' new features (per-cluster balancing in 64ab0af, clone path in adbd3db) beyond the fixes listed here; no device or browser run. Round 5 head: |
…tgg#24888) Co-authored-by: Julius Marminge <julius0216@outlook.com>
…s current (pingdotgg#36868) Co-authored-by: Julius Marminge <julius0216@outlook.com>
…checkout (pingdotgg#37191) Co-authored-by: Julius Marminge <julius0216@outlook.com>
… errors (pingdotgg#40042) Co-authored-by: Julius Marminge <julius0216@outlook.com>
…ingdotgg#39994) Co-authored-by: Julius Marminge <julius0216@outlook.com>
…nvironment inputs (pingdotgg#39992)
…Button, and ControlPill (pingdotgg#40002)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
pingdotgg#40133) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…h the agent (pingdotgg#40777) Co-authored-by: Julius Marminge <julius0216@outlook.com>
…0816) Co-authored-by: Julius Marminge <julius0216@outlook.com>
…ingdotgg#29438) Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>
…usage frames (pingdotgg#40804) Co-authored-by: lvning.liu <lvning.liu@weimob.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
…pingdotgg#40830) Co-authored-by: lvning.liu <lvning.liu@weimob.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
…ad of stepping through stale states (pingdotgg#27401) Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>
pingdotgg#40841) Co-authored-by: Julius Marminge <julius0216@outlook.com>
pingdotgg#27391) Co-authored-by: Enmani <43571965+Enmani@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
…on (pingdotgg#21667) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
…gg#40874) Co-authored-by: Abhiram-745 <237478249+Abhiram-745@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
…nder its full name (pingdotgg#40877) Co-authored-by: Abhiram-745 <237478249+Abhiram-745@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
…l finds no match (pingdotgg#40886) Co-authored-by: Julius Marminge <julius0216@outlook.com>
Co-authored-by: Abhiram-745 <237478249+Abhiram-745@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
…pers Adds the cluster contracts (membership, join codes, host requests, the cluster connection target), the cluster.* RPCs and their permission scopes, ServerConfig.homeDirectory, and the client load-balancing settings. packages/ssh and packages/shared gain what the main host needs to add a member over SSH.
A main host accepts members by join code over HTTPS or by SSH, proxies /cluster/<memberId>/ to them, and routes agents' cross-environment calls through itself. Members accept only their main host and local apps. The Cluster migration, CLI (t3 cluster join/add/remove/leave), TLS pinning and the Cluster lab setting come with it.
… and cloning Members appear in the connection catalog behind their main host. New threads can balance across a cluster's machines or across all machines, weighted per client, and a thread can start on a machine that lacks the project by cloning it to the same path under that machine's home.
…gets Settings -> Environments -> Cluster manages membership. The machine picker offers "<main host> (load balanced)" per cluster, groups machines by cluster, warns and asks when some machines lack the project, and offers Don't ask again per project. Add to another machine keeps the source path.
Mobile manages a cluster, shows members behind their main host, and balances new threads per cluster or across machines with the same weights, warnings and confirmation as web.
…e main host Signed file links load in <img> and native image views, which send no sign-in, so the cluster proxy answered them 401 before reaching the member. The proxy now forwards GET and HEAD under /api/assets/ without a client session, with an empty scope cap; the member checks the link's signature as it does for direct clients, and only while its control link is up.
fadbe4f to
591dfda
Compare
Proposal tracked in Ideas discussion pingdotgg#38571. This draft PR lives on the fork to hold review rounds; it is not aimed at upstream.
Problem
T3 Code can link environments one to one, but there is no way to group several machines behind one main host so that every client that connects to that host reaches all of them, and agents on any machine can reach the others.
What this adds
t3 cluster join|add|remove|leaveon the CLI)./cluster/<memberId>/*, so clients connected only to the main host see every member as an environment, including Settings, threads and the Device panel.<url>#<code>[.<sha256 pin>]; the main host accepts a pin match or a CA-valid chain.authorized_keys, and removes it on Remove.Also changed outside clusters
These reach users who never set up a cluster:
~/git/project) instead of the target's default folder; a project outside the home folder falls back to the default folder. The server config now reports its home directory for this.t3 pair --url <address>puts the address you give in the printed pairing link.Screenshots
Taken from a live three-machine cluster (ai-dev main host, ai-worker-2 and ai-worker-3 members).
Web
Desktop
Mobile (Android)
Verified