Feature: presigned team invites (one-click join) #126

Closed
jhgaylor wants to merge 6 commits from lex00/presigned-invites into main
Owner

Brought over from https://github.com/lex00/illogical/pull/1 by @lex00 (branch integration, commits unchanged).


Adds presigned team invites to illogical control. An owner makes a link, the invitee presses Join once, and they're in, with no approval step afterwards. Control still can't add anyone by itself.

How it works

  • When the link is made, the owner's device signs an invite: team, role, expiry, and a one-time Ed25519 public key. The private half lives only in the link's #fragment and never reaches control.
  • The invitee's device writes the next roster version (v: 2): the previous members plus themselves, the invite marked spent, and the one-time key's signature over exactly that member and version.
  • Roster::follows accepts that from a non-owner. Control, daemons and browsers all run the same check, and control can't move the proof to an account of its own.
  • Links work once, last 24 hours, and never grant owner. "Ask me first" keeps the old request-then-approve link, and owner invites always use it.
  • Older daemons refuse v2 rosters. So daemons now report features=presigned-invites, and control only makes a presigned link when every daemon checking the team (its own machines, plus ones a session was shared with) has reported it. Otherwise the owner gets an Ask-me-first link and a note naming the machines to update.

Changes

  • crates/e2e/src/team.rs: Invite, Spent, Redeem, v2 bodies, the redeem rule, unit tests
  • web/src/e2e/team.ts: the same rule in TypeScript; e2e-interop checks Rust and TS agree
  • crates/control: presigned_invites and daemon_watches tables, a daemons.features column, /api/presigned/..., the version gate, a push to owners after someone joins
  • crates/daemon/src/control.rs: reports features on team calls
  • web/src/control.ts, web/src/ui/control.tsx: link creation with fallback, one-click join prompt
  • docs/teams.md, docs/control-e2e.md

Tests

  • cargo fmt --check, clippy -D warnings, workspace unit tests, just e2e-interop, just control-smoke
  • Playwright (Chrome): teams, control, passkey, fleet-control, team-swarm, team-answers
  • The new e2e case: someone who already owns a team joins a second one in one click; the team box takes the new roster; the link fails the second time; an older-style team machine forces an Ask-me-first link until it leaves
  • Two unrelated tests flaked once and passed on rerun: attention::failures_and_long_builds_say_what_happened and team-answers' service-worker test

Not done

  • Not run in Safari or WebKit
  • Daemons check expiry against the roster's at, which the invitee writes. Control enforces expiry with its own clock, but a daemon can't independently.

🤖 Generated with Claude Code

Brought over from https://github.com/lex00/illogical/pull/1 by @lex00 (branch `integration`, commits unchanged). --- Adds presigned team invites to illogical control. An owner makes a link, the invitee presses Join once, and they're in, with no approval step afterwards. Control still can't add anyone by itself. ## How it works - When the link is made, the owner's device signs an invite: team, role, expiry, and a one-time Ed25519 public key. The private half lives only in the link's `#fragment` and never reaches control. - The invitee's device writes the next roster version (`v: 2`): the previous members plus themselves, the invite marked spent, and the one-time key's signature over exactly that member and version. - `Roster::follows` accepts that from a non-owner. Control, daemons and browsers all run the same check, and control can't move the proof to an account of its own. - Links work once, last 24 hours, and never grant owner. "Ask me first" keeps the old request-then-approve link, and owner invites always use it. - Older daemons refuse v2 rosters. So daemons now report `features=presigned-invites`, and control only makes a presigned link when every daemon checking the team (its own machines, plus ones a session was shared with) has reported it. Otherwise the owner gets an Ask-me-first link and a note naming the machines to update. ## Changes - `crates/e2e/src/team.rs`: `Invite`, `Spent`, `Redeem`, v2 bodies, the redeem rule, unit tests - `web/src/e2e/team.ts`: the same rule in TypeScript; `e2e-interop` checks Rust and TS agree - `crates/control`: `presigned_invites` and `daemon_watches` tables, a `daemons.features` column, `/api/presigned/...`, the version gate, a push to owners after someone joins - `crates/daemon/src/control.rs`: reports features on team calls - `web/src/control.ts`, `web/src/ui/control.tsx`: link creation with fallback, one-click join prompt - `docs/teams.md`, `docs/control-e2e.md` ## Tests - `cargo fmt --check`, `clippy -D warnings`, workspace unit tests, `just e2e-interop`, `just control-smoke` - Playwright (Chrome): `teams`, `control`, `passkey`, `fleet-control`, `team-swarm`, `team-answers` - The new e2e case: someone who already owns a team joins a second one in one click; the team box takes the new roster; the link fails the second time; an older-style team machine forces an Ask-me-first link until it leaves - Two unrelated tests flaked once and passed on rerun: `attention::failures_and_long_builds_say_what_happened` and team-answers' service-worker test ## Not done - Not run in Safari or WebKit - Daemons check expiry against the roster's `at`, which the invitee writes. Control enforces expiry with its own clock, but a daemon can't independently. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
An owner's device signs an invite (team, role, expiry, a one-time Ed25519
key) when it makes the link; the key's private half lives only in the
link's fragment. The invitee's device writes the next roster version
(v2): the previous members plus themselves, the invite marked spent, the
one-time key's signature over exactly that member and version. Roster
follows() accepts that from a non-owner; control, daemons and browsers
all check it, and control can't move the proof to an account of its own.

- crates/e2e: Invite, Spent, Redeem; v2 bodies; the redeem rule + tests
- web/src/e2e/team.ts: the same rule, one-time keys, redeemInvite;
  e2e-interop checks Rust and TS agree on redeemed and tampered rosters
- control: presigned_invites table; invite stores a signed invite;
  /api/presigned/{team}/{key} (+ /preview); set_roster takes a redeem
  once, not after a lock, for the signed-in account, and pushes owners
- web UI: presigned by default, "Ask me first" keeps the old flow (and
  owner invites); PresignedPrompt joins in one click; owner edits carry
  spent invites forward until they expire
- e2e: someone already in a team joins a second one in one click, the
  team box takes the new roster, and the link works once
- docs: teams.md, control-e2e.md

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A daemon from before presigned invites refuses a v2 roster, and then
every later version of that team's: members would stop changing there,
removals too. Daemons now tell control what they understand on each team
call (features=presigned-invites); control records it, and which daemons
check a team because a session was shared with it (daemon_watches, a
week). A presigned invite is made only when every such daemon understands
it; otherwise 409 names the machines, and the Teams panel makes an
"Ask me first" link instead and says which to update.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Merge presigned-invites into integration: the older-daemon gate
All checks were successful
check / linux (push) Successful in 5m5s
check / macos (push) Successful in 5m7s
1b68122526
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Review fixes on top of lex00's presigned invites:

- The one-time key's seed no longer reaches control. Signing in with
  GitHub from an invite link put the whole fragment in `?next=`; the seed
  now waits in the tab's sessionStorage and comes back after sign-in.
  Presigned links are `#pinvite=` so pages from before them never send
  the seed as an ask-first code. The e2e signs Dave in from the link and
  checks no request carries the seed.
- A redeemed version is signed by the one-time key, not the invitee's
  device. Devices are judged as of now, so an invitee revoking that device
  later stopped every later version checking on daemons that check from
  the start (shared teams, new team machines): removals included.
- A redeem's `at` can't be before the version it follows (no backdating
  past expiry once owners drop the spent entry).
- The browser checks well-formedness as Rust does (types, words), so
  both take the same rosters; e2e-interop covers the new cases.
- Control checks the older-daemon gate again at redeem, caps presigned
  invites at a day, refuses joining or moving an older daemon into a team
  whose history has a presigned version, and gives an older daemon that
  was shared a session nothing for such a team rather than a stale roster.
  Daemons report features on joins and trust refreshes; ILLOGICAL_FEATURES
  plays an older one in tests.
- Only a duplicate version or invite key is a 409; other database errors
  are 500s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#126: a redeem adds the account with its own root; TS words measured in bytes as in Rust
All checks were successful
check / macos (push) Successful in 4m46s
check / linux (push) Successful in 5m7s
3410a6a1f9
Control checks the new member's root is the signed-in account's first
device (the invitee's device signature used to imply it), so owners see a
real fingerprint. isWord compares UTF-8 length, as Rust's word() does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Review fixes pushed on top of lex00's commits (11b396d, 3410a6a):

  • Seed leak: signing in with GitHub from an invite link sent the whole #fragment, one-time key included, to control in ?next=. The seed now waits in sessionStorage. Presigned links use #pinvite=, so older cached pages never send the seed as an ask-first code. The e2e signs a signed-out invitee in from the link and checks no request carries the seed.
  • Redeem signer: a redeemed version is signed by the one-time key, not the invitee's device. Devices are judged as of now, so revoking that device later froze every later version (removals included) on daemons that check from the start.
  • Rule: a redeem's at can't be before the previous version's. The browser checks well-formedness as Rust does, and e2e-interop covers the new cases. Control also checks that the new member's root is the account's own.
  • Older daemons: the gate is checked again at redeem. Presigned invites are capped at a day. Joining or moving an older daemon into a team with a v2 roster in its history is refused, and an older daemon shared a session with such a team gets nothing for it. Daemons report features on join and trust refreshes.
  • 409s: only a duplicate version or invite key returns 409.

Verified, merged into current main: just check and 30 Playwright tests (teams, control, passkey, fleet-control, team-swarm, team-answers, fountain). Not done: cancelling a single outstanding link.

Review fixes pushed on top of lex00's commits (11b396d, 3410a6a): - **Seed leak:** signing in with GitHub from an invite link sent the whole `#fragment`, one-time key included, to control in `?next=`. The seed now waits in sessionStorage. Presigned links use `#pinvite=`, so older cached pages never send the seed as an ask-first code. The e2e signs a signed-out invitee in from the link and checks no request carries the seed. - **Redeem signer:** a redeemed version is signed by the one-time key, not the invitee's device. Devices are judged as of now, so revoking that device later froze every later version (removals included) on daemons that check from the start. - **Rule:** a redeem's `at` can't be before the previous version's. The browser checks well-formedness as Rust does, and e2e-interop covers the new cases. Control also checks that the new member's root is the account's own. - **Older daemons:** the gate is checked again at redeem. Presigned invites are capped at a day. Joining or moving an older daemon into a team with a v2 roster in its history is refused, and an older daemon shared a session with such a team gets nothing for it. Daemons report features on join and trust refreshes. - **409s:** only a duplicate version or invite key returns 409. Verified, merged into current main: `just check` and 30 Playwright tests (teams, control, passkey, fleet-control, team-swarm, team-answers, fountain). Not done: cancelling a single outstanding link.
Author
Owner

Also left open, besides cancelling a single link:

  • Downgrades: a machine downgraded to an older illogical after a one-click join still gets the team's v2 rosters and stops at that version. It's rare; control's daemon_team could refuse with an error naming the problem, the way daemon_teams now skips such a team.
  • Safari/WebKit: not run in either, as in the original PR.
  • Flaky test: teams.spec's team-box test failed once in Chrome: it checks the join command's stdout for "Waiting for approval" before that line has been printed. It passed on two reruns, and it doesn't touch these changes.
Also left open, besides cancelling a single link: - **Downgrades:** a machine downgraded to an older illogical after a one-click join still gets the team's v2 rosters and stops at that version. It's rare; control's daemon_team could refuse with an error naming the problem, the way daemon_teams now skips such a team. - **Safari/WebKit:** not run in either, as in the original PR. - **Flaky test:** teams.spec's team-box test failed once in Chrome: it checks the join command's stdout for "Waiting for approval" before that line has been printed. It passed on two reruns, and it doesn't touch these changes.
Author
Owner

illogical has moved to GitHub, with the same numbers: this PR continues as https://github.com/arugula-salad/illogical/pull/126 (same branch, lex00/presigned-invites). Closing it here.

illogical has moved to GitHub, with the same numbers: this PR continues as https://github.com/arugula-salad/illogical/pull/126 (same branch, `lex00/presigned-invites`). Closing it here.
jhgaylor closed this pull request 2026-10-04 04:34:59 +00:00
Commenting is not possible because the repository is archived.
No description provided.