Skip to content

1.10: device-approved connect, key escrow, roster snapshots, static limits - #2099

Draft
fujibee wants to merge 40 commits into
mainfrom
integration/1.10-cloud
Draft

fujibee wants to merge 40 commits into
mainfrom
integration/1.10-cloud

Conversation

@fujibee

@fujibee fujibee commented Nov 29, 2026

Copy link
Copy Markdown
Owner

Draft: tracks the 1.10 work on integration/1.10-cloud against main.

Opened now so the full test suite runs on the branch tip; pushes to an integration branch skip the bats suite. Not ready to merge: device removal step 2, the client's recovery from a fenced epoch, and the end-to-end test are still to land.

* server: add the accounts profile, capability-URL routing and a features list on health and capabilities

AGMSG_PROFILE=open|accounts (default open). In accounts the data routes exist only under <origin>/t/<secret>/v1/..., where the secret names one live device and one team and is resolved before any /v1 handler runs; a request for another team, a name lookup across teams and a connect for another team answer as an unknown team does. Unknown, malformed, not-yet-activated and revoked secrets answer the same 401. Request logs redact the secret. In the open profile none of the accounts routes exist, pinned by a route-table test. GET /v1/health and GET /v1/capabilities gain a features array (empty in open). Migrations now apply every NNN_*.sql in order.

* server: parse only the team id from route params, keep the origin health probe team-blind in accounts, and keep the secret out of the not-found log

Mounted under /t/:secret the route params also carry the secret, so the strict team-params schema refused the device's own team path; only teamId is parsed now. Origin GET /v1/health in the accounts profile ignores Agmsg-Team-ID so it cannot say which teams exist. A custom not-found handler replaces Fastify's default, which logged the requested URL, secret included.

* server: the own-team history test needs its required after cursor

* server: a refused cross-team request answers with a body that does not name the team asked for

* server: the secret-in-log test checks the whole secret body, not a fragment split on an underscore
…2056)

* wip: device flow

* server: add the device flow, the owner's approval page and GET /v1/devices to the accounts profile

POST /v1/device/code, /token and /activate follow the device-grant contract: strict bodies, flat error names, a provisional secret until the machine confirms it stored its URL. The owner signs in with a secret from configuration (refused when under 128 bits), approves on a script-free page (strict cookie, origin check, per-address limits), and may choose the team when the machine named none. GET /v1/devices lists the caller's team with type and last-fetch fields. Tables accounts, sessions and device_grants are added in migration 003.

* server: refuse a device code request from a client id that is not on the list

* server: number the device-flow migration 006 so the migration order follows merge order

* server: rate limit POST /v1/device/token per source address, and unknown device codes more tightly
…file (#2061)

* server: add the key-escrow seam (none | keyfile) for the accounts profile

AGMSG_ESCROW_BACKEND selects none (default) or keyfile. A keyfile backend
wraps and unwraps a key with AES-256-GCM under a master key read from
AGMSG_ESCROW_KEYFILE. The wrap is bound to the team and the epoch, so a blob
cannot be replayed under another row. The server refuses to start when the
file is missing, unreadable or shorter than 32 bytes.

Migration 005 adds team_key_epochs (one row per team and epoch: wrap kind,
key reference, wrapped key, recipient, key id, public snapshot) and
key_releases (an audit row with no foreign keys). Like the other migrations
it is applied in every profile and stays empty unless escrow is used.

The accounts profile lists key-escrow in capabilities.features only when a
backend is set. The open profile lists nothing new.

No escrow routes yet; those follow once their request and response bodies
are fixed in the shared contract tests.

* server: make the escrow snapshot check reject a missing, null or non-string revision

A CHECK passes when its expression is NULL, and the JSON field accessor gives
NULL for a missing field, a JSON null and a non-object, so such snapshots were
stored. The check now tests the types and coalesces the comparison. The
revision is a decimal string; the test fixture and regressions say so.
The device flow and the escrow seam each added a required Config field and
merged separately, so the integration branch stopped typechecking: each
test's own Config literal was missing the other's fields. Tests now build
their Config with testConfig(), which starts from loadConfig's defaults, so a
field added later is filled in there and a test overrides only what it is
about.
…2058)

## What

`remote.sh connect` and `remote.sh pull` join a machine by device approval when the server says it offers it. The server says so in the `features` array of its unauthenticated `GET /v1/health`. Nothing else decides it: not the host name, not the path, not a setting. A health answer that is not 200, is not JSON, has no `features`, or does not list `device-approval` leaves both commands exactly as they were.

When it is listed, the command asks the server to open an approval (`POST /v1/device/code`), prints one URL and a short code, polls `POST /v1/device/token`, saves the returned data address in a 0600 file, activates it (`POST /v1/device/activate`), and then runs the existing connect or pull against that address. The address is a capability, so it is never printed and never put on a command line: the endpoint validator reads it from stdin, and the engine's `resolve-team`, `pull-bootstrap` and `configure` calls take it from the environment instead of `--endpoint` / `--server`. The client id is `agmsg-cli`, scope `login`. The routes and field names are the protocol's; nothing in the client names a particular host.

## Behaviour

| Situation | Result |
|---|---|
| Server does not list `device-approval` (or health fails, is not JSON, has no `features`) | Manual connect or pull, unchanged. The existing history is still uploaded by connect. |
| Listed, new team | Approve, activate, register the team with its whole roster, start the engine. |
| Approval denied or expired | Nothing changed; the local team keeps working. |
| Failure after approval and before the binding is recorded (server error on `/v1/connect`, or an activation the server could not take) | The local team is untouched. The approval stays in a 0600 file keyed by the approving server and the team (an approval from one server is never offered to another). It holds the address, the start position taken before the first attempt, and whether the address was activated. The same command run again does not ask for approval again, retries the activation first if it had not taken, and reuses the first attempt's start position, so a message written after the failed attempt is still sent. The file is removed once the binding holds the address, or when the server says the address is gone: a 401 or 410 on the activation, or on the registration (`/v1/connect`) of an address that was already activated, drops it (the next run approves again). Any other failure keeps it, because a data host that differs from the approving host may only be unavailable. The same rule holds on `pull`, for both the name lookup and the bootstrap: the engine writes the status code (and only that, never a URL or message text) to a file the caller names (`AGMSG_REMOTE_FAILURE_FILE`) when it fails on a 401 or 410, and the pull reads it. The status is taken from the response itself, so an answer that is not JSON (a gateway page, an empty body) is told apart the same way; the errors that carry it for that purpose use their own field, so retry behaviour is unchanged. The engine's stderr is not redirected, so its progress still streams to the terminal while a long pull runs. |
| Team already connected | Left as it is, and the command says so (a manual end-to-end key is not moved by this). |
| `--e2ee` given | Manual path; the caller chose a manual key. |

## Existing history (a changed default, on the device path only)

Today's manual connect uploads every message the team already holds: the engine's first push offers each local message not yet acknowledged, and `tests/test_remote_sync.bats` ("a legacy-only team pushes its whole history") pins it. That stays as it is.

On the device path the default is now to upload nothing that existed before the command, and to send what is written from then on. `--with-history` uploads the existing history as the manual connect does. The start position is read before the approval is asked for, so a message written while the user is still approving is newer than the command and is sent, once.

This needs two optional storage verbs, added to the driver interface and the Stage-1 reference in this PR: `storage_sync_history_position <team>` (highest local message position, `0` for none) and `storage_sync_start_after <team> <server-instance-id> <remote-team-id> <protocol-version> <position>` (this binding's push begins after the position; idempotent, only moves forward, and the legacy-history rewind in prepare leaves a binding started this way alone). Only the SQLite driver implements them. The default for each path is one value in `remote.sh` (`_REMOTE_HISTORY_DEFAULT_MANUAL`, `_REMOTE_HISTORY_DEFAULT_DEVICE`), so changing a path's default later is that line and nothing else.

## A stop, and how to recover (review-criteria section 10)

On the device path, when the storage driver cannot start from now (it lacks the two verbs, which today means any driver but SQLite), connect stops before anything is asked of the server or sent:

```
agmsg: this storage driver cannot start from now, so this connect would upload the team's existing messages.
agmsg: nothing was sent and nothing was changed. Pass --with-history to upload them, or use the manual connect.
```

Nothing was changed, so recovery is the command it names. The alternative is to upload the history anyway, which would break the default above without saying so. This stop is a maintainer decision. The wording lives in one function (`_remote_history_cannot_start_from_now`).

## Process spawns

Measured by shimming the external commands and counting calls, in an isolated test install.

- The probe added to every connect and pull on the manual path: 11 external processes (4 sed, 2 rm, 2 mktemp, 1 sqlite3, 1 curl, 1 chmod), about 0.08 s including loading the script. No timer, no loop, nothing per message.
- The approval on the device path, with the approval already granted: 47 processes for the whole flow (code, one token poll, activate, and reading the fields), measured at the first head; the saved-approval handling added since (a temp file, a move, a read) was not measured again. The failure file for the engine is made only inside a device pull; the manual path makes none. Each further poll while waiting adds one token request and its helpers; the poll interval is the server's (`interval`, 5 s by default) and the loop ends at the server's `expires_in`.
- `storage_sync_history_position` and `storage_sync_start_after` run once per connect, each one sqlite3 call plus the driver dispatch.

## Tests

- `tests/test_remote_device.bats` (30 tests) against the existing fixture server, extended with `features`, the three device routes, and a few setters: no features, a features list without the feature, manual connect still uploads, the full flow (address recorded, never printed, activated once, client id and scope), history left behind and a message written during the approval sent exactly once (checked on the server by decoding what it holds), `--with-history`, denied approval, failure after approval and the re-run not asking again (and the file mode), the first attempt's position kept across a failed attempt, an approval never offered to a second server, an activation failure keeping the approval and the re-run retrying it, the address absent from every node command line (connect and pull) and a static check that remote.sh passes no endpoint flag, the stop on a driver that cannot start from now, an already connected team, pull with and without the feature.
- Driver contract tests in `tests/test_remote_sync.bats`: position grows, a started binding offers only later messages (with the unstarted control offering everything), idempotent and never moves back, legacy rows are also kept out (red when the rewind guard is removed, checked), non-numeric positions refused.
- Red without the change, each checked by mutating remote.sh: skipping start-after fails the history test; dropping the saved position fails the re-run test; keying the saved approval by team only fails the second-server test; dropping the approval on an activation failure fails the retry test; not dropping on a 401 from the registration fails the revoked-address test; not dropping on a data-side 401 during a pull (bootstrap or name lookup) fails the two pull tests; capturing the engine's stderr until it exits fails the progress-is-live test; reading only the retry status (not the response's) fails the non-JSON refusal test; putting the endpoint back on the `pull-bootstrap` command line fails both argv tests. The device tests signal a process only after its command line is verified to name this test's own install path (engine) or port file (mock), and re-verify before any KILL that follows the TERM wait.
- Run with `AGMSG_HOME` and `AGMSG_INSTALL_HOME` unset: `test_remote_device.bats`, `test_remote_sync.bats`, `test_remote.bats` and the other remote suites. The four `.github/scripts/check-*.sh` pass at their baselines. Real-machine check: none on a live install; the flow ran against the fixture server only.

## Run against the reference server (accounts profile)

Run at head 50458cb (the one later commit changes only how an explicit `--machine-name` is encoded, plus its tests), with the reference server from this branch in the accounts profile (owner secret, public URL on loopback) on a throwaway PostgreSQL 14 cluster on a random loopback port. Docker was not running on the machine, so the database was a local cluster instead of a container; it was stopped and removed afterwards, as were the server process and the three installs. Three fresh installs of this branch ran inside a throwaway sandbox (every path pointed at a throwaway directory); after each step the sandbox reported 0 differences on the real machine. The owner played the approval page by script: sign in with the secret at `/approve/signin`, then `POST /approve/decision` with the code the client printed.

- `GET /v1/health` on the server answers `{"features":["device-approval"], ...}`.
- Machine A: a local team with one message written before connecting, then `remote.sh connect --endpoint <server> demo`. It printed the approval URL and code, the owner approved (HTTP 200), and the command exited 0 with "Connected". Nothing printed contained the owner secret or the address's secret. The server holds the team with one registered member and, after a message was written post-connect and pushed, exactly two stored envelopes: the member join and the post-connect message. The message written before connecting was not uploaded.
- Finding 1, fixed in this PR: the first run was refused with `team_required`. The grant carried no team, the server's approval then needs the owner to choose an existing team, and a first connect has none on the server yet. The client now issues the grant with the team id it already has, which the server accepts without a choice. Covered by a test (`team_id` in the code request equals the local team's id).
- Finding 2, fixed in this PR: a second install on the same host was refused with `machine_exists`, because the machine name defaults to the host name and the server keeps one live device per name per team. The refusal now says what happened and names `--machine-name <name>`, which sets the label and is sent exactly as given (a label the server would refuse stops before it is asked). Covered by four tests.
- Machine B (a fresh install): `remote.sh pull --endpoint <server> --machine-name <name> --team-id <id> demo` pulled the team (2 messages), the history on B excludes A's pre-connect message, B joined as a new member and wrote a message, its push was acknowledged, and A's next sync imported it. The approval it reused had been saved by an earlier attempt of the same command that failed on a `404` (below), which also showed the saved approval surviving a failure the data side did not call invalid.
- Finding 3, not fixed here (server side): `remote.sh pull` without `--team-id` looks the team up by name after the approval, and the accounts profile answers a name lookup under a capability URL with `404` (spec: "a name lookup across teams ... answer as an unknown team does"). So a second machine cannot learn the team id from the server by name; today it has to be given `--team-id`, or the approval response has to carry it. The command says `could not look up 'demo'` and keeps the approval. This needs a decision on the server's side of the protocol.
- Non-SQLite stop: with `AGMSG_STORAGE_DRIVER=jsonl`, `remote.sh connect --endpoint <server> jteam` printed the two-line stop message and exited without a request to the server: the number of rows in `device_grants` was 5 before and 5 after.

Not run: Windows, a server behind TLS, an installed (non-sandbox) machine.

## Not in this PR

Escrow and key upload, where a login and setup client lives, and the server side of any of this. Queued messages while a device waits for approval are never discarded: nothing is sent before the binding exists, and everything written during the wait is sent after it.

## Notes for the release

- remote: connect and pull join by device approval when the server lists `device-approval`. On that path the team's existing messages are not uploaded unless `--with-history` is passed; the manual connect is unchanged.
)

* server: static team and device limits, refused with limit-reached

AGMSG_LIMIT_TEAMS and AGMSG_LIMIT_DEVICES (unset means unlimited). A connect that would pass the team limit answers 403 limit-reached, whose details name the limit and its value as a decimal string; the team count and the insert are serialized under one advisory lock so concurrent connects cannot pass it. GET /v1/capabilities (and the connect snapshot) list the feature and the finite values under limits, and add nothing while none is set. The existing retention maximum is listed as live_messages but keeps evicting the oldest rather than refusing.

* server: state that configured limits apply in every profile

* server: give the test configs of the device flow and the limits suite every field of Config

* server: complete the test configs for escrow, device-flow and limits fields

* server: build the limits suite's Config from the shared test helper
* server: record a device's last fetch on GET /v1/messages, at most once a minute

devices.last_fetch_at is written by one conditional UPDATE when a device fetches messages through its capability URL, and the device list returns it as lastFetchAt. Other routes and refused requests record nothing; a failed write is logged and never fails the fetch.

* server: write last_fetch_at only after a successful fetch, and test a failing write and the refused cases

* server: wait for the last-fetch write with a bounded poll instead of a fixed sleep
Returns the key id of a team's highest stored epoch, or null when the team has
none, reading through the caller's client so it joins the caller's
transaction.
## What

When a sync request is refused, `remote-sync.mjs` printed only `HTTP <status> <code>` and dropped `error.message`. Servers put the full explanation there (the limit, the value, what was not done, the next step), so the operator never saw it. When the answer has a string `error.message`, it now follows the code:

```
HTTP 413 unknown-error The team holds 100 of 100 messages. Nothing was stored. Remove old messages or raise the limit.
```

The message is server text and stays untrusted: ANSI/OSC sequences and control characters are removed, line breaks and whitespace runs become one space, the text is cut at 500 characters, and nothing is added to it (no request URL, nothing from the capability path). No message, or a non-string one, leaves today's line byte for byte.

## The code in the line

The line shows a code of lowercase letters, digits, `-` and `_` (at most 64, starting with a letter) as the server sent it, so both `limit-reached` and `over_capacity` appear. Anything else (uppercase, spaces, control characters, longer) still prints as `unknown-error`; `error.code` keeps the server's value either way. The existing test that pinned snake_case collapsing now pins this charset, with an `over_capacity` case and the out-of-charset cases.

Only the authenticated sync request path is touched. The public pre-connect lookup keeps its line.

## Process spawns

0 new. One pure function over a string, run only when a request is refused.

## Tests

`tests/remote_sync_engine.test.mjs`: message printed after the code; no message / non-string message leaves the line unchanged; ANSI, OSC, control characters and line breaks cleaned; 900 characters cut to 500; a message with nothing printable adds nothing. Red without the change (checked by removing the wiring: 1 failure), 161 pass with it (the charset change is covered by the updated 413 case and the out-of-charset loop). The four `.github/scripts/check-*.sh` pass.
…2055)

* server: accept read state for a member not yet in the roster (open profile)

migration 002 drops the foreign keys from read_frontiers/read_exact to
members, and syncReadState no longer rejects a member_id absent from
members. A late joiner can sync read state before its own roster entry
has propagated; member_id is now opaque read-state identity, the same
as wire_id already is.

Member removal in provision.ts explicitly deletes the member's
read_frontiers/read_exact rows, since that no longer happens via
cascade.

* server: add roster-snapshot (one latest snapshot per team)

POST/GET /v1/roster-snapshot store and return one sealed roster
snapshot per team (migration 003, table roster_snapshots), so a new
machine can bootstrap its cursor from it instead of replaying the
whole message stream. A write older than the stored sequence is
refused (409 roster-snapshot-stale) and leaves the stored row
unchanged; the same sequence resent overwrites in place.

GET /v1/capabilities gains a features array (currently just
roster-snapshot) so a client only ever branches on what the server
lists, never on which server it is talking to.

* server: renumber migrations to 003/004 (fixed merge-order sequence)

002_accounts.sql merges first; this branch's migrations move to
003_open_profile_read_state.sql and 004_roster_snapshot.sql to avoid
a duplicate migration number across in-flight branches.

* server: fix two review findings on #2055

provision.ts: scope the read_frontiers/read_exact cleanup to members
actually being retired (old members minus retained) instead of every
id absent from the manifest -- a late joiner's read state has no
members row by design, so re-provisioning the same roster must not
wipe it.

migrations/004: epoch is BIGINT, not INTEGER -- the wire schema allows
up to 0xffffffff, which overflows a signed 32-bit column. storage.ts
reads it back as a string (node-pg's int8 behavior) and converts.

Added regression tests for both, confirmed red against the prior
code/column.

* server: thread roster-snapshot through the shared features helper

The rebase onto integration/1.10-cloud brought in #2054's featuresFor
mechanism (src/accounts/features.ts), which duplicated this branch's
own capabilities.features addition as a conflicting object key.
roster-snapshot now goes through teamFeatures -- present for every
profile, since it has no profile dependency -- instead of a separate
literal in capabilitySnapshot. Updated the three existing tests that
asserted an exact feature list predating this addition.

* server: update limits.test.ts's teamFeatures expectations for roster-snapshot
* server: enforce the device limit when a device is minted

A grant that would pass AGMSG_LIMIT_DEVICES answers 403 limit-reached (limit and value named) at POST /v1/device/token and is not consumed, so the same machine succeeds on a later poll once a device is removed or the limit raised. Devices that hold a slot are those not revoked and not a provisional one past its deadline; the count and the insert are serialized on one advisory lock.

* server: a name a live device holds still answers machine_exists when the device limit is full

The limit check ran before the duplicate-name insert, so re-logging a machine that already exists on a full server got a retryable 403 instead of the terminal machine_exists. A held name now skips the count and falls through to the insert.

* server: every limited device mint decides under the lock, including one for a name a live device holds

Skipping the lock for a held name let a mint that raced a revoke insert past the limit. The lock is taken first; the held-name and count checks run under it, so only changes that lower the count can happen between the checks and the insert.

* server: build the device limit test config with testConfig
… key epoch (#2064)

* wip removal

* server: let the owner remove a device, revoking it at once and fencing its team's key epoch until rotation

DELETE /v1/devices/:id (owner session and origin only) marks the device revoked, so its secret answers like an unknown one, and records a fence on the team's current key epoch. While fenced, a write sealed under that key id answers 409 epoch-fenced with the team and key id; plaintext and other key ids are unaffected. Rotation lifts the fence in the transaction that publishes the next epoch. The fence table is migration 007.

* server: move the epoch fence into the data plane core so it holds in every profile

team_epoch_fences, the POST /v1/messages check (409 epoch-fenced), fenceEpoch and liftEpochFence now live in src/fence.ts and apply in both profiles; a team with no fence rows behaves as before. Only DELETE /v1/devices/:id stays accounts-only and calls the core fenceEpoch.

* server: check the epoch fence inside the write's transaction under the team lock, and take that lock when fencing

The fence check ran before the write's transaction, so a removal that committed its fence between the check and the store let a write under the old key through. The check now runs after the team row is locked, and removal takes the same lock before recording its fence, so a write is wholly before or wholly after a fence. A test holds an uncommitted fence and shows the waiting write is refused.

* server: build the removal test's Config from the shared helper

* server: read the current epoch key id from the escrow store when removing a device

* server: pin that removing a device fences the highest stored epoch through the real escrow accessor
* server: name the approved team in the device token answer

* server: leave team_name out of the token answer when the team has no row yet

* server: send the token's team pair whole or not at all
)

* test(server): share the accounts HTTP contract across deployments

* test(server): run the contract with finite and unlimited limits

* test(server): use the shared config helper for contract fixtures

* test(server): validate optional team fields in device tokens

* test(server): declare token team expectations in fixtures

* test(server): allow omitted unlimited capability limits
* test(server): define the shared escrow key HTTP contract

* test(server): keep private values out of assertion diagnostics

* test(server): reject secret reflection before response validation
#2083)

* server: register device recipients and hand escrowed team keys to devices

Adds POST /v1/devices (a device registers its public age recipient),
POST <capability>/v1/keys/epochs (register the epoch a device generated, one
winner per epoch, identity wrapped by the escrow backend) and
GET <capability>/v1/keys/bundle (every retained epoch in one age file sealed to
the caller's own recipient, audited in key_releases before it is returned).

Publishing epoch N lifts the write pause a device removal put on epoch N-1, in
the same transaction. Migration 009 adds devices.device_pubkey and makes a key
id unique within a team. Sealing uses age-encryption 0.3.1 (pinned); output was
checked against the age command line in both directions.

* server: run the two device registration cases in the accounts contract

The fixture now registers each claimant's age recipient up front, so the listing
shows it and the registration cases repeat the same key. The two cases that
waited on the key surface now run.

* server: keep key requests from outliving a device removal

Both key routes now take the caller's device row inside their transaction, in the
same order removal does (device, then team), and re-check that the device is
still live there. An epoch registration from a device removed after it was
authenticated is refused and no longer lifts the removal fence. A bundle release
holds the device row for its whole read, unwrap and seal, so a removal waits for
it and the next request is refused. Both interleavings are regression tests.

* server: make the key race tests start from a known point and always release their gate

Each race test now waits for the request to be inside the held backend call
instead of sleeping, and opens its gate in a finally, so a failing assertion no
longer leaves the server call hanging until the suite times out.
…her team

## What

`remote.sh pull` by device approval no longer needs `--team-id` when the server names the team. The server's `/v1/device/token` answer carries `team_id` and `team_name` when the approval is bound to one team (#2069). `pull` uses that id and makes no name lookup, which a capability-scoped server does not answer.

- The pair is used only whole (id and a non-empty name) and only when the id is a UUID. Anything else leaves today's behaviour: the name lookup runs.
- `--team-id` on the command line is still sent in the grant as before; if the approval answers a different team the command stops (below).
- The id is saved with the approval (a fourth line in the 0600 file), so a re-run after a failed attempt does not need the lookup either. An older three-line file reads as no team and falls back to the lookup.
- A server that sends no pair, or the manual path, is unchanged.

## A stop, and how to recover (review-criteria section 10)

When `pull` asked for a team and the server's approval is for a different one, it stops before anything is saved, activated or created locally:

- asked by name (no `--team-id`) and the approval's `team_name` differs: `agmsg: you asked for team 'X', but the approval is for team 'Y' (<id>); nothing was changed.`
- `--team-id` given and it differs from the approval's `team_id`: `agmsg: you asked for team id A, but the approval is for team 'Y' (B); nothing was changed.` A saved approval is checked against `--team-id` the same way.

Both print the exact command that pulls the approved team: `remote.sh pull --endpoint <server> --team-id <id> --machine-name <fresh name> <local name>`. The token step has already created a device under the machine name and a server keeps one live device per name per team, so the same command with the old machine name would be refused as already connected; the printed one carries a fresh `--machine-name` (the machine name plus `-r<random>`). A saved approval that does not match `--team-id` prints the runnable command (no new device is made there, so no new name) and the file to remove to approve again. Every argument is quoted as given: the display text of the server's team name is never put into a command, so Unicode or long names stay valid. Nothing was changed, so recovery is that command. The alternative is to join the other team silently. Decision (2026-11-28): stop with the stated message and the rerun command; joining the other team silently was rejected. The check and its wording live in `_remote_device_team_check`; the command in `_remote_device_rerun_command`. The other team's name is server text, shown as printable characters only (at most 64).

## Run against the reference server (accounts profile)

At this head, server from this branch's base in the accounts profile on a throwaway local PostgreSQL 14 cluster, two fresh installs in the isolated sandbox (0 differences on the real machine after each step). Machine A connected local team `demo` by approval. Machine B then ran `pull --endpoint <server> --machine-name ddvb-m wrongname`, the owner approved team `demo`: B stopped with `you asked for team 'wrongname', but the approval is for team 'demo' (<id>); nothing was changed.` and printed the command with `--machine-name 'ddvb-m-r10864'`. The same pull with the old machine name `ddvb-m` and `--team-id` was refused by the server (`a device named 'ddvb-m' is already connected`), which is the case the fresh name avoids. The printed command, run as printed and approved, pulled `demo` into local team `wrongname` (1 message) and started the engine. Server, database and installs were removed afterwards.

## Process spawns

The token answer is read two more times (id, name) once per approval: each read is one `sqlite3` plus the existing `_remote_json_field` helper's `sed`/`printf` pipeline and the caller's command substitution, so the approval gains a handful of short processes in total. The mismatch stop adds one `tr` and one `cut`, only when it fires. Nothing per poll, nothing on a saved approval, no timer. The whole-flow count was not re-measured at this head.

## Tests

`tests/test_remote_device.bats` (41 tests, 11 new): the pair is used with name lookup broken (proves no lookup); `--team-id` equal to the answer is accepted; asked by name, another team stops with nothing written (no team directory, no saved approval, no activation) and prints the rerun command; `--team-id` that differs stops the same way; the other team's name is printed without control characters; an id without a name and a non-UUID id are not used; the id survives in the saved approval and the re-run needs neither lookup nor a second approval. The mock can model a server that keeps one device per name (`MOCK_DEVICE_UNIQUE_NAMES`): the printed command finishes the pull there, and the old-name command is refused. A saved approval for another team prints a command that finishes the pull. Removing the stop, or the fresh machine name, makes the mismatch tests fail. Red without the change (2 failures when `pull` stops using the id; the two ignore-cases pass either way by design, since falling back is today's behaviour). `docs/remote-setup.md` gets one item. The four `.github/scripts/check-*.sh` pass; `test_remote.bats` passes.
A client picks the cipher a team connects with before /v1/connect, so it has to
learn that keys are escrowed before any team exists. The unauthenticated
/v1/health now lists key-escrow in the accounts profile when an escrow backend is
configured, with the same rule as the team-level list.
* test(server): require the configured origin escrow feature

* test(server): keep the escrow feature assertion in the shared suite
…onnect (#2081)

* sync-cipher: add roster_snapshot as its own canonical projection branch

The blob carries the member list as of one sequence, under one key
epoch -- a pointer for a new machine to bootstrap from, not a mutation
event, so it does not join the roster-mutation union. Fields are
closed like a mutation (no forward-compat passthrough), and members
must be sorted ascending and duplicate-free by member_id since the
server cannot check this itself.

Plaintext teams carry the same projection unsealed, exactly as
messages do today.

* sync-cipher: bind the roster-snapshot blob to its team/epoch/sequence slot

A roster snapshot has no message of its own to carry a wire_id, and every
snapshot for a team shares one stored row, so team_id alone would let a
sealed blob from one (epoch, sequence) slot be replayed into another.
Derive the wire_id deterministically from team_id/epoch/sequence instead,
reusing sealEnvelope/openEnvelope's existing wire_id binding check rather
than adding a second one. The reader recomputes the id from the row it
fetched; a mismatch fails to open with a stated error.

Spec the derivation in server/spec/v1.md next to the route.

* remote: connect writes the first roster snapshot when the server lists it

writeRosterSnapshot (remote-sync.mjs) reads the stored binding's
capabilities.features, skips as a no-op when roster-snapshot is not
listed, and otherwise seals the local roster (member_id/name pairs,
sorted) with sealRosterSnapshot and POSTs it. cmd_connect calls it
through the remote-sync.sh wrapper right after the store migration and
history-start step, before the engine starts, and reports rather than
fails connect if it errors.

_remote_binding_lists_feature reads the team-level features array
already recorded in the connected binding (the connect response
itself), so no extra network round trip is needed to decide whether to
call it.

* remote: a failed roster-snapshot write on connect is stated, not silent

Prints one line naming what failed, that the team is connected, and
the exact command that retries it (remote-sync.sh write-roster-snapshot
--team), rather than claiming a later sync will pick it up -- nothing
does that automatically today.

mock_remote_server.py gains MOCK_TEAM_FEATURES (the connect/capabilities
response's team-level features array) and a minimal POST/GET
/v1/roster-snapshot pair, so this and the write-on-connect path can be
exercised end to end. bats: the feature listed writes a snapshot a GET
confirms, the feature absent leaves today's path unchanged, and a write
failure (mocked 500) is reported rather than dropped while connect
still succeeds — all three mutation-tested (confirmed RED without the
corresponding fix).

* remote: fix 3 review findings on #2081

(1) remote-sync.mjs writeRosterSnapshot: a fresh age-v1 connect has
current_seq '0', but every epoch's effective_from_seq is >= '1', so
looking up the epoch effective AT sequence '0' (currentAgeEpoch's own
target) always found no candidate -- the first E2EE snapshot could
never be written. rosterSnapshotAgeEpoch looks up the epoch effective
for whatever comes NEXT (sequence + 1) instead, which is well-defined
even before any message exists. Regression: a fresh age-v1 team
(current_seq '0', one epoch) now writes a snapshot through to POST.

(2) remote.sh's stated-failure line named a bare 'remote-sync.sh',
which is not on PATH. Prints 'bash "<abs SCRIPT_DIR>/remote-sync.sh"
...' instead. Regression: extracts the printed command from a failed
connect's output and runs it, asserting it does not fail with exit 127
(command not found) -- it still fails on the mocked 500, but for the
server's stated reason, not a shell path error.

(3) writeRosterSnapshot paired a stale, connect-time current_seq (read
from the stored binding) with the CURRENT local roster -- a retry
after a roster change would write a new roster under an old sequence.
Fetches capabilities fresh immediately before reading the roster
instead, keeping the two reads as close together as this client can
get them. Regression: the binding's stored current_seq is set to a
different value than a fresh GET answers; the written sequence must
match the fresh one.

All three mutation-tested (reverted the fix, confirmed RED, restored,
confirmed GREEN).

* remote-sync: fix 2 more review findings on #2081

(1) writeRosterSnapshot silently treated a missing or malformed
current_seq from the fresh capabilities fetch as '0', conflating a
genuinely fresh team with a bad or missing response -- a server (or a
bug) that omitted current_seq entirely would still get a snapshot
written and POSTed under sequence '0', with no indication the value
never validated. Uses sequence(), which throws, instead of the
silent-fallback ternary. Regression: a fresh capabilities response
with current_seq '0' still writes; undefined/null/empty/malformed/
negative values all reject with the sequence() error message (asserted
on the message itself, not just on 'something threw', since the probe
in the test also throws on an unexpected POST either way).

(2) The two new test fixtures (an earlier commit) called
rm(root, {recursive: true}) on a variable path in their cleanup --
left in place now, the scratch directory included. Existing tests in
this file that already did this were not touched; only the two this
PR added.

* test_remote.bats: make the stated-failure assertions bash-3.2-enforceable

The retry-execution block added after them pushed these two
[[ ... ]] checks out of the test body's last-statement position, which
check-enforced-assertions.sh (CI runs bats on macOS's bash 3.2) does
not fail on there -- an assertion that cannot trip errexit, sitting
anywhere but last. grep -qF ... <<<"$output" does fail there.
Checker back at the baseline (605).
Registering epoch N lifted only the fence on epoch N-1's key. It now lifts every
unlifted fence on a key of an earlier epoch, so no fence outlives the epoch that
replaces its key, whatever order removals and registrations ran in. Removal
already reads the current key inside the team lock; a regression holds a removal
there and shows a registration started meanwhile waits behind it and clears the
fence it left.
#2089)

* remote-sync: pull seeds the roster from a snapshot instead of full replay

pullBootstrap, when the server's team snapshot lists roster-snapshot,
reads GET /v1/roster-snapshot before replaying any message. A non-null
sequence seeds the roster driver with the member list as of that
sequence (synthetic member_joined records, deterministic
mutation_ids), then the per-page loop skips any roster mutation at or
before that sequence -- replaying one after the seed could regress
state (an older rename or leave undoing what the snapshot already
reflects), and the driver's own idempotence-by-mutation_id check does
not catch this since these synthetic ids are not the real ones those
messages carry.

No silent fallback: the feature absent, or a sequence of null (an
empty team that has never written one), leaves today's path exactly
as it is. But advertised and the read or the open/verify fails, pull
throws with the exact rerun command rather than falling back to a
plain replay -- after retention has cut the early roster-mutation
history, that fallback would reconstruct the wrong roster with nothing
to say so.

Tests: snapshot + later mutation applied, snapshot + older mutation
skipped, retention having cut the snapshot's own sequence from the
replayable window (the case the feature exists for), both failure
modes stated with the rerun command, feature absent and empty-team
sequence-null both unchanged. The skip-filter and no-fallback fixes
both mutation-tested (reverted, confirmed RED, restored, confirmed
GREEN).

* test_remote.bats: cover pull reading a roster snapshot end to end

mock_remote_server.py's /v1/teams/<id> (the public team snapshot pull
reads) gains the same MOCK_TEAM_FEATURES features array the connect
path already carries, and its existing /v1/roster-snapshot GET/POST
pair gains a fail-next hook so a read failure can be forced without a
dedicated env var.

Two cases: a snapshot covering the first 5 of the mixed fixture's 7
member_joined events seeds those 5, and the pull still applies the
remaining 2 (server_seq 6 and 7, both after the snapshot's own
sequence) plus all 73 ordinary messages, unchanged -- the real client
write path (sealRosterSnapshot) builds the POST body, not a hand-
written fixture shape. A forced read failure fails the pull with the
stated message and rerun command rather than falling back to replay.

check-enforced-assertions.sh back at the baseline (605) after moving
one non-last [[ ]] assertion in the new test to grep -qF.

* remote-sync: fix the printed pull rerun command on #2089

pullRerunCommand used args.endpoint, which cmd_pull never sets --
the endpoint travels as AGMSG_REMOTE_ENDPOINT, never on argv -- so a
failed snapshot read printed 'Rerun: remote.sh pull --endpoint
undefined ...'. Uses serverUrl (the already-resolved value: args.endpoint
?? the env var) instead, and builds the command with an absolute,
shell-quoted path to remote.sh (bash '<abs path>' pull --endpoint
'<url>' --team-id '<id>' '<team>'), the same convention remote.sh's
own printed recovery commands already use -- a bare 'remote.sh' is not
on PATH either.

Regression: the bats failure-path test now extracts the printed
command from a forced-failure pull's output and runs it, asserting it
does not fail with exit 127 (command not found). Mutation-tested
(reverted to the bare/argv-endpoint form, confirmed RED on both the
node and bats regressions, restored, confirmed GREEN).

* remote-sync: narrow the no-silent-fallback rule to when retention has actually cut history

Decision (2026-11-28): when the server lists roster-snapshot and
reading or verifying it fails, (a) if the full roster history is
still on the server (min_available_seq at the start of the pull was
still as low as it can be), warn once on a stated line and fall back
to the ordinary replay below -- it reconstructs the roster correctly
on its own in this case; (b) if retention has already cut that
history, stop before writing anything, with the stated reason and the
exact rerun command -- a replay here could reconstruct the WRONG
roster with nothing to say so. This replaces the previous always-stop
behavior (every GET/verify failure stopped the pull).

Also: a failure WRITING a snapshot this machine already validated
(the local roster driver) is kept distinct from a failure reading or
verifying it -- that is this machine's own storage, not the server's
data, and always stops the same way (b) does, since a local write
failure here means the replay below would likely fail the same way.
Split seedRosterFromSnapshot into openSnapshotForSeed (read + verify,
no write) and applySeededRoster (write only) so the two failure modes
go through separate catch blocks with distinct messages.

Also fixes the printed rerun command: it used args.endpoint, which
the real cmd_pull never sets (the endpoint travels as
AGMSG_REMOTE_ENDPOINT, never on argv), so a failed read printed
'--endpoint undefined'. Uses serverUrl (the already-resolved value)
instead, with an absolute, shell-quoted path to remote.sh -- the same
convention remote.sh's own printed recovery commands already use; a
bare 'remote.sh' is not on PATH either.

mock_remote_server.py gains MOCK_PULL_MIN_AVAILABLE_SEQ so a bats test
can simulate retention having cut the history for case (b).

Tests (node + bats): case (a) warns and succeeds via full replay;
case (b) stops before any write with the stated reason and a rerun
command that actually runs (not exit 127); a local write failure is
distinct from a read/verify failure and always stops. All new/changed
behaviors mutation-tested (reverted, confirmed RED, restored, confirmed
GREEN).

* remote-sync: fix 2 review findings on #2089

(1) historyIntact used BigInt(min_available_seq) <= 1n, but the
server's retention deletes every row with team_seq <= through and
THEN stores min_available_seq = through -- a floor of '1' already
means the row at sequence 1 is gone, not merely that replay starts
there and reaches everything. Only an exact '0' means nothing has
ever been cut. Regression: min_available_seq '1' with a snapshot read
failure now stops (case b), where it previously warned and fell back
to an incomplete replay (case a).

(2) applySeededRoster derived occurred_at from wall-clock time, which
changes on every call. Combined with the deterministic mutation_id, a
retried bootstrap produced the SAME id with DIFFERENT content, and
roster-sync.mjs's own apply() throws 'roster mutation id maps to
different content' the moment anything about an already-journaled
mutation_id differs. Uses a fixed sentinel timestamp instead -- the
seed has no real 'when' to report anyway; it is a reconstruction as
of a sequence, not an event that happened at a moment. Regression:
running the same bootstrap twice now seeds byte-identical records
(asserted with a real delay between the two calls, so the test cannot
pass by two calls landing in the same millisecond by accident).

Both mutation-tested (reverted, confirmed RED, restored, confirmed
GREEN).
….mjs (#2096)

applySeededRoster wrote a literal "member_joined" instead of importing
the one accepted-kinds definition in wire-kinds.mjs, reopening the
very duplication #1284's own regression test exists to catch across
every other call site. Added MEMBER_JOINED_KIND there and use it here.
Confirmed with the existing KIND-S check in test_remote_sync.bats
(revert, RED; restore, GREEN).

Also fixes a umask-dependent flake in the roster-snapshot connect
test: the demo.json fixture it writes relied on the process umask for
its mode, so a group-writable umask (0002, as bats runs under) tripped
loadConfig's own "connected team binding must not be writable by group
or others" check -- the real check is correct and stays as is; the
fixture now sets its mode explicitly, like its sibling config.json
write already does. Confirmed under umask 0002 (revert, RED; restore,
GREEN).
## What

A device-approved `connect` and `pull` use the server's key escrow when the server lists `key-escrow` in the `features` of its unauthenticated `GET /v1/health`. Nothing else decides it.

- **connect.** A team that has no key of its own becomes `age-v1`: the existing generator makes the first epoch, this machine's own device key (an age identity, made once, 0600) is registered with `POST /v1/devices`, and the epoch's key and snapshot go to `POST <address>/v1/keys/epochs`, before the engine starts. One line says the server keeps a wrapped copy of the team key. The team's existing messages are still not sent unless `--with-history` is given. A repeat of the same key is accepted (so the retry command is safe); a different key already held for epoch 1 stops with a stated line, and nothing is overwritten. The manual "back this up by hand" advice is not printed for an escrowed team, because it would be untrue.
- **pull.** A device-approved pull of an `age-v1` team that does not hold the key registers the device key, fetches `GET <address>/v1/keys/bundle` (sealed to that device key), opens it with the real `age` tool, and imports it through the existing handoff import (`unlock --authenticated-bundle-stdin`). The snapshot chain, the identity-to-key links and the rest are checked by that import; the digest is recomputed here from the bundle's last snapshot and the server's `snapshot_sha256` is only compared. Any mismatch is a stated error and nothing is installed; the engine stays halted.
- **Unchanged.** A team that already has a key keeps the manual key (the command says so). `--e2ee` is the manual path even on an escrow server. A pull that is not by device approval never asks the server for a key. A server without `key-escrow` behaves exactly as before.
- **Recovery commands.** `remote.sh escrow-publish <team>` (send the key again and start syncing) and `remote.sh escrow-install <team>` (fetch and install again). Both are safe to repeat.

The address and the keys are never on a command line: requests go through curl with 0600 config and body files, and the key operations stay inside the engine process (`escrow-epoch-body`, `escrow-open-bundle`).

## Stops (review-criteria section 10)

1. The server lists `key-escrow`, the team has no key, and `age` / `age-keygen` is not on `PATH`: connect stops before anything is asked of the server or created here, on fixed-prefix lines: `agmsg: missing: <tools>`, `agmsg: nothing was sent to the server and nothing was created here.`, one `agmsg: install (<OS>): <command>` line each for macOS (`brew install age`), Debian/Ubuntu (`sudo apt install age`), Fedora (`sudo dnf install age`) and Windows (`winget install FiloSottile.age`, or `scoop install age`), and `agmsg: then run again: <the exact command>` with every argument quoted and `--with-history` / `--machine-name` kept as given. The alternative is a silent plain connect on a server whose purpose is an encrypted team. Decision: the stop is the agreed shape for a missing prerequisite an agent can fix by itself (2026-11-28).
2. The server already holds a different key for epoch 1 (a different key id, or the same key id with another public key): connect stops after recording the binding, says so, and starts no engine; recovery is to pull that team instead. Nothing on the server is changed. An answer that is not the expected one (status, epoch or fields missing) is a failure, never a success.
3. A key bundle that fails any check installs nothing and says which check; recovery is `remote.sh escrow-install <team>`.

## One health answer decides

The server's features are read once per origin per run and every question (device approval, key escrow, environment markers) is answered from that one response; a probe that failed stays failed for the run. Two probes could disagree, and a second one failing would have read as "not offered" for an escrow the first one saw, ending in a plain team. A regression makes every health probe after the first fail and checks the team still becomes `age-v1`.

## The device key

The device key is made inside a private directory this call creates and linked into place without replacing anything, so concurrent first calls end with one key on disk and the same public key for all (a regression runs eight at once). Nothing is deleted by a variable path other than that directory.

## Process spawns and time

Counted by shimming the external programs (a launch is an exec of one of them; `$(...)` and subshells are forks of the shell and are not in this number), for one `connect` of a new team on the fixture server, at the first head: 384 launches on the plain device path, 506 with escrow (122 more; one health request fewer at this head). The extra work is the team becoming `age-v1` (key generation, snapshot export, engine configure) plus one device-key registration and one epoch upload (2 curl, 4 node, 3 age-keygen, 1 age). Elapsed, three runs each, wall clock including the script's start: plain 1.39 / 1.45 / 1.51 s, escrow 2.19 / 2.09 / 2.14 s. It runs once per connect, with no timer and nothing per message.

## Run against the reference server (accounts profile, escrow backend on)

Two fresh installs in the isolated sandbox (0 differences on the real machine after each step), a throwaway local PostgreSQL 14 cluster, the reference server of this branch's base with a key file. Machine A connected a new team by approval: it printed the one-line statement, generated the key, registered its device key, uploaded epoch 1 (the first run exposed that the registration needs a `label`, fixed here), and started the engine. Machine A wrote a message. Machine B pulled the team by approval: the key bundle came back, was opened with B's device key and imported through unlock, and B read A's message (history showed `alice -> bob`). Server, database and installs were removed afterwards.

## Not in this PR

The reaction to a push refused with 409 `epoch-fenced` (rotate the key, upload the next epoch, resend queued messages) is a separate change, after the decision on what the server does for an epoch that has no messages yet.

## Tests

`tests/test_remote_escrow.bats` (17 tests, against the fixture server, which seals the bundle with the real age tool and computes digests the way the server does): a new team becomes `age-v1`, the device key is registered once with a label, epoch 1 is sent with the key id and snapshot, no private key and no address in the output; a repeat is accepted; a server without `key-escrow` is unchanged; a team with its own key and `--e2ee` stay manual; a different key held for epoch 1 stops with no engine; the pull installs the key and unlocks; a wrong server digest, a tampered identity and a server with no key install nothing; a pull not by device approval never asks for a key. Red when the digest comparison is removed (1 test), when the pull stops asking for the key (4 tests), when a second health probe is restored (1), and when the recipient is not compared on a repeat (1). Also: without age the stop lines are present, nothing was asked of the server or created, and the printed rerun line works with age present. The device suite (46) and the four `.github/scripts/check-*.sh` pass.
…lable (#2098)

"a fresh age-v1 connect (current_seq 0) still writes a roster
snapshot" seals through the real age binary (sealRosterSnapshot ->
sealEnvelope -> age-v1 -> an actual recipient encryption), unlike the
rest of this file's age-v1 coverage, which only stubs age's --version
probe. On a shard with no age on PATH and no AGMSG_AGE_BIN set, this
failed every run with CipherStateError "age executable \"age\" was
not found on PATH" instead of skipping like the rest of the suite
does for an environment it cannot run in.

Confirmed with a stripped PATH (no age, node still reachable): without
the guard the test throws that exact error (RED); with it, it reports
skipped and the suite exits 0 (GREEN). An unmodified PATH still runs
the real assertion end to end.
Step 2 of removing a device: the server publishes the team's next key epoch and lifts the fence step 1 put on the current one. Step 1 (revoke and fence) is unchanged and is never undone by a failure here.

## How it works
- The state is the fence row: a team needs rotation exactly when its current epoch's key has an unlifted fence. There is no job table, so a restart, a retry or a second server asks the same question and gets the same answer.
- A rotator runs once at server start, after each removal commits, and right after a write the empty-epoch case let through, and again every 30 seconds only while a team is failing or waiting. A failure is logged once per kind (class name only), not every cycle.
- One transaction per team: lock the team, re-check the fence (a client may have published the next epoch first, which leaves nothing to do), generate and wrap the next age identity, store the epoch, lift the fence. The new snapshot extends the previous one (next revision, previous digest, a history entry for the new key). The chain passes the client's own `validateAgeConfiguration` in the test.
- It runs only where keys are escrowed (a backend is configured).

## Epoch with no message since it began
A new epoch must begin after the previous one, so it cannot start until the current epoch holds a message. While it holds none (for example a brand-new team whose first device is removed at once), the fence does not refuse writes. The first write goes out under the current key and the rotator runs right after it commits. Every later write under the old key is refused with the stated `409 epoch-fenced` until the rotation lands.

- Trade-off: the payload of that first batch is sealed under the old key, so any holder of that key, the removed device included, can read it. Later messages are under the new key.
- Why: nothing sealed under that key exists for the removed device to read, so letting the first message through exposes nothing already stored, and refusing it would leave the team with no way to move on until a client acted.
- The rotator logs one stated line (info) while it waits for that first message, and retries every 30 seconds only while waiting or failing.
- No sequence number is reserved: the real sync engine refuses a one-sequence hole in the middle of a stream ("pull page sequence is not contiguous").
- The empty-epoch test compares the epoch's recorded boundary to `current_seq + 1`, so a team whose epoch already holds a message is fenced as before.

The behaviour is documented in `server/spec/v1.md`, which also describes the key epoch routes. The client's recovery for a refused write (publish the next epoch, resend) ships separately.

## Tests
`rotation.integration.test.ts`: owner removal through the route publishes epoch 2 and the client validator accepts the chain, the remaining device opens both identities and the removed one is refused; a second run and a client-first publication do nothing; the empty-epoch case lets the first write through under the old key and rotates right after it, while a write on a non-empty epoch is still refused, and the rotator logs once while waiting; a restart picks up what was pending; a failing backend is retried and reported once; a failure leaves the device revoked and the fence in place. Without the boundary check or the fence lift the matching tests fail. Whole-server `tsc --noEmit` clean, 150 tests pass on PostgreSQL 17.

## Process launches
None. Database work: one query per sweep to find teams that need rotation, and for each such team one transaction of a handful of queries (team lock, epoch list, fence check, server id, insert, fence lift). Nothing runs when no fence is pending.
…e to old-key holders (#2106)

Documentation only. When a device is removed while the team's current epoch holds no message yet, the first batch written after removal goes out under the old key and rotation follows it. The spec described that case but not its cost; it now says plainly that the payload of that first batch can be read by any holder of the old key, the removed device included. Further writes under the old key receive `epoch-fenced` until the rotation lands; the existing lift rule is unchanged.

No code, test or behaviour change. Process launches: none.
…es it (#2109)

The `409 epoch-fenced` message said writes are paused "while the key is rotated after a device was removed". Removal no longer fences or rotates anything, so that wording would mislead anyone reading the code before the opt-in rotation uses the fence. It now reads "writes under this key epoch are paused while the team key is rotated; try again shortly".

Message text only; the error code, details and binding are unchanged. Whole-server `tsc --noEmit` clean, 140 tests pass. Process launches: none.
…nother machine published (#2110)

* remote: send each new key epoch to the server and fetch a newer one another machine published

* tests: run the key-fetch engine tests with the other engine tests

* remote: send every missing key epoch in order, and keep asking for a newer key instead of ending

* remote: show the wait for a newer key in remote status

* tests: connect now reads the server's epochs once before sending

* remote: keep the team's private key out of every command line, and test that epochs are sent in order

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