Skip to content

feat: bind every machine link to one identity key - #172

Merged
sanchitrk merged 1 commit into
feat-oauth-clerkfrom
feat/machine-identity-key
Nov 19, 2026
Merged

sanchitrk merged 1 commit into
feat-oauth-clerkfrom
feat/machine-identity-key

Conversation

@sanchitrk

@sanchitrk sanchitrk commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #171.

Why

The relay stores one row per workspace link, keyed by a machine id the machine reports itself. So it can't tell that the links in two workspaces belong to the same machine, and two homes can claim the same id with --machine-id. Multiplayer needs that answer: which workspaces a machine is in, and one machine for an access token to name.

What

  • machine.json gets an identity (an Ed25519 key and its RFC 7638 thumbprint), created inside the existing lock. A home connected before this change gets one on its next locked update.
  • Pairing: the identity key signs { op: "identity.bind", iat, keyId }, naming the new link key. The pairing request carries that JWS as identity.
  • Relay: verifies the binding (it must be fresh and name the request's own key), then stores identity_key_id on the pairing and copies it onto the link at activation. GET /v1/workspaces/:id/machines returns identityKeyId.
  • Per-link keys are unchanged: a leaked link key still exposes one workspace, and each link keeps its own relay.

The relay migration is edited in place because #171 isn't merged and nothing is deployed. A local relay database from #171 needs recreating.

Not covered

An exact copy of a home carries the same identity key, so the two copies prove the same identity. Telling them apart needs a startup claim with a generation number, which is separate work.

Tests

  • Relay E2E (real relay on Docker Postgres, real CLI, a Clerk test user): 8/8 pass. Existing artifacts are unchanged.
  • New identity.json: one home connected to two workspaces shows two different link keys and the same identityKeyId. A binding made for another link key and a malformed binding are both refused with 401, and no pairing row is created.
  • vp check, vp run typecheck and knip pass.

🤖 Generated with Claude Code


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

Each home now holds one Ed25519 identity key in machine.json, created
inside the existing lock (also for homes connected before this change).
At pairing, the identity key signs the new link key's thumbprint; the
relay verifies the binding and stores the identity's thumbprint on the
pairing and then the link. Links that share identityKeyId, in any
workspace, are provably one machine, and the machine list exposes it.

Per-link keys stay as they are: a leaked link key still exposes one
workspace, and each link keeps its own relay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sanchitrk
sanchitrk merged commit bb9d23b into feat-oauth-clerk Nov 19, 2026
@sanchitrk
sanchitrk deleted the feat/machine-identity-key branch November 19, 2026 17:55
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