Skip to content

feat(relay): register machines by UUID, move workspace links to Relay, and add access checks - #195

Open
sanchitrk wants to merge 1 commit into
canaryfrom
feat/iroh-p2p-slice-1
Open

sanchitrk wants to merge 1 commit into
canaryfrom
feat/iroh-p2p-slice-1

Conversation

@sanchitrk

@sanchitrk sanchitrk commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Moves workspace links out of machines into Relay and establishes the Relay authorization and endpoint-binding layer for Iroh P2P transport. A machine now registers once under its UUID with its Ed25519 identity key (which is also its Iroh endpoint id), stores no workspace state, and asks Relay whether an incoming desktop actor may view it.

packages/schema

  • Added EndpointId, seedOf, irohEndpointId, and publicOfEndpoint helpers in packages/schema/src/jws.ts.
  • Enforced UUID-only MachineId and reshaped Relay records and endpoints in packages/schema/src/records.ts and packages/schema/src/relay.ts with single-word path segments (/v1/machines, /v1/machines/poll, /v1/machines/approve, /v1/machines/:machineId, /v1/machines/heartbeat, /v1/machines/revoke, /v1/machines/check, /v1/workspaces/:workspaceId/machines, /v1/workspaces/:workspaceId/machines/:machineId, /v1/endpoints, /v1/endpoints/:endpointId, /v1/iroh/auth).
  • Dropped workspaces from Machine.Status and Host.Api's machine.connect / machine.disconnect in favor of relay: { url, leaving?: boolean } | null.

infra/relay

  • Reshaped the init migration (machine keyed by id uuid PRIMARY KEY with unique key_id and endpoint_id, shared-only link, device_key, vouch, and identity-signed pairing).
  • Implemented machine registration under UUID with owner-only approval for rebuilt --machine-id key swaps (preserving workspace links and revoking the old key) and refusal of known keys under a different machine id.
  • Added GET /v1/machines for personal local inventory, DELETE /v1/machines/:machineId, single-request POST /v1/machines/heartbeat, transactional POST /v1/machines/revoke (setting revoked_at and deleting link rows), shared-only GET/POST/DELETE /v1/workspaces/:workspaceId/machines (refusing personal local workspaces), POST /v1/endpoints (verifying JWS freshness and sub === caller.accountId, plus bounded per-account vouch), DELETE /v1/endpoints/:endpointId, POST /v1/machines/check (enforcing workspace membership, shared-only scope, link, and device_key binding, and returning MachineRevoked when revoked or replaced), and POST /v1/iroh/auth (bearer-gated admission callout for iroh-relay).

packages/codework

  • Replaced workspaces in machine.json and machine.info with relay: { url, leaving?: true }.
  • Enforced UUID-only --machine-id <uuid> and updated codework connect, codework disconnect, single-request heartbeats, and machine.connect / machine.disconnect RPCs, including offline leaving: true disconnect retry.

apps/contract, apps/server, apps/web

  • Aligned the app contract, app server status/handlers, and desktop Machines/Setup views with the updated Machine.Status and Relay.Api contracts so all workspaces compile and stay green ahead of the Iroh transport and member-sync slices.

Testing

  • cd infra/relay && vp test: 11/11 passed (authz.test.ts, connect.test.ts, me.test.ts), covering Ed25519/endpoint helpers, valid member checks, unbound/cross-account/vouched keys, sub !== caller.accountId replay, stale iat, personal local link/scope refusal, root claim refusal, non-member, unlinked machine, member removal, key unbind, unlink, MachineRevoked on revoke and key replacement, rebuilt machine owner vs non-owner approval, known key under different id refusal, deregister deleting links, offline leaving disconnect, and /v1/iroh/auth.
  • cd packages/codework && vp test test/door.test.ts: 1/1 passed.
  • cd apps/server && vp test test/link.test.ts test/paired.test.ts test/door.test.ts test/schema.test.ts: 8/8 passed.
  • vp run verify: passed (builds, vp check, package typechecks, knip:check).
  • vp check apps/contract apps/server apps/web and app typechecks: passed with 0 errors.
  • Reset local Relay Postgres volume and verified fresh migration, dev Relay (127.0.0.1:8787), and dev RPC server (machine.json) end-to-end.

Built with Gemini in Antigravity.


Proof this PR
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

This branch has not been deployed

No deployments
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