Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
docs: relay host proof-of-possession closes the join-code takeover (R44)
review027d6e4c807c
diff --git a/CLAUDE.md b/CLAUDE.mdindex a81a8d718..2c8683b4b 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -7270,8 +7270,9 @@ does not survive a real canvas. `canvas/camera-moving.test.ts` pins the absence.**removed**. The toggle (`settings.phoneAccessEnabled`, Settings → Phone + quick-pair popover)shows for everyone; the standing host reconciles on `enabled && relayAllowed()` alone, with noquota metering at `onPeerReady`. **Entitlement passthrough remains**: a stored Pro entitlement is- sent on mints, else the `{deviceId,…}` body (host-token `{deviceId, hostPublicKeyB64}`, device- mint `{deviceId, hostDeviceId, hostPublicKeyB64, label}`). **The backend is the real gate now**:+ sent on mints, else the `{deviceId,…}` body (host-token `{deviceId, hostPublicKeyB64}`, plus+ `popChallenge`/`popProof` when the backend supports it; device mint `{deviceId, hostDeviceId,+ hostPublicKeyB64, label}`). **The backend is the real gate now**:`POST /v1/relay/host-token` / `/v1/relay/device` must admit deviceId (no-entitlement) mints, andthe relay server may rate-limit free hosts independently — a client-side gate must NOT bereintroduced to work around a backend refusal (fix the backend policy instead).@@ -7410,13 +7411,39 @@ The invariants, each with its reason:the API up and the relay down every mint succeeds and every socket dies, and a reset-on-mintre-minted at round-trip speed (relay log, 2026-09-27). Successful mints are also capped at 200per rolling hour, whatever asks for them (the backend's free limit is 240).-- **A join code is enough to take hosting offline (R44), and only the backend can close that.**- `POST /v1/relay/host-token` takes the code's `hostDeviceId` + `hostPublicKeyB64` with no proof of- the host's secret key, and the backend damps host tokens and device mints per that device id. So a- code holder, a removed teammate included, can spend the host's hourly mints, the team's daily- device mints and the 16 pending slots. `team rotate-key` alone does not help (it keeps the device- id); recovery is a fresh `<dataDir>/device-id` + `team rotate-key` + fresh codes (the doc's- troubleshooting list). Proof-of-possession on that endpoint is a `nodeterm-server` follow-up.+- **Every request that trusts a relay host key proves the caller holds its secret half (R44).** A+ join code carries the host's device id and public key, which used to be all a host-token mint+ asked for, so a code holder could spend the host's hourly mints. Now the host-token mint (desktop+ phone relay and Server Edition hosted mint) and the desktop's host-mode push first take a+ challenge from `/v1/relay/challenge` and send a proof. Rules a refactor must not undo:+ - **`src/core/relay/relay-pop.ts` is the ONLY proof computation**, and it refuses an all-zero+ shared secret (a low-order server key gives every caller the same secret). Its bytes are pinned+ by `relay-pop-vector.json`, mirrored byte for byte in nodeterm-server: a protocol change changes+ both.+ - **A request goes out unproven ONLY when the challenge answered 404/405** (a backend that+ predates the proof). Never after a transient failure (5xx, 429, network, an unusable challenge):+ the backend LATCHES a host at its first valid proof and refuses an unproven request from it+ (`403 pop_required`; every host after `POP_REQUIRED_AFTER`, default 2027-01-01), so an+ unproven mint there would stop hosting. Conversely, a `pop_required` answer to a mint sent+ unproven after a 404/405 is TRANSIENT: a reverse proxy answers 404 while the backend redeploys.+ - **A key-proof refusal stops hosting only on the SECOND in a row**, with a fresh challenge in+ between, on both editions: a `POP_SECRET` rotation or an instance mismatch inside one+ challenge-then-mint pair refuses an honest host once. A transient failure between the two does+ not reset the count; only a successful mint or a restart does. The Server Edition says+ `POP_REFUSED_MESSAGE` (it names `team rotate-key`); the desktop shows ONE dialog with+ `POP_REFUSED_MESSAGE_DESKTOP`, which must never name `team rotate-key` (Server Edition only).+ - **Push uses a 15-minute `hostAuth` session from `/v1/push/host-auth`**, re-proven after 10+ minutes on the client's clock, one per stream (`core/push-notify.ts` `createHostAuthCache`). An+ old-backend verdict is cached 10 minutes; failed proofs back off 0/5/15/60 s (a hold further out+ than 60 s is a backward clock step and is ignored); overlapping flushes share one proof; a proof+ that throws is a failure, never a rejection. A batch that cannot be proven is DROPPED, never sent+ unproven. An unproven post refused 403 under a verdict cached from an EARLIER batch means the+ host latched elsewhere: that batch re-proves and re-posts once.+ - **Still open**: the team's 10 daily device mints and the 16 pending join slots (those routes+ take no proof), and, before a host's first proof, a code holder's legacy listeners evicting its+ idle one through the relay's 8-per-host cap. Recovery is a fresh `<dataDir>/device-id` ++ `team rotate-key` + fresh codes. Full write-up and the rollout (backend first; `POP_SECRET` set,+ boot log without `DISABLED`): `docs/hosted-team-relay.md` § Host key proof of possession.- **The joiner never mints a device token it cannot keep.** Device mints are damped per HOST deviceid, so one team shares 10 a day. It probes the bookmarks file before minting and sends a PER-TEAMdevice id (`<machine id>:<hostId>`), because the backend will not re-register one id for a seconddiff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex aab67070c..bbcdfc73e 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -501,6 +501,11 @@ anything else. Board-level fields survive every transform — `pullLinks` is onewrite is cast (`canvas/stored-publish.ts`); a new store writer of that kind must use `ownWrite`too. Deep version: CLAUDE.md § Hosted team relay.+- **A request that trusts a relay host key (host-token mint, host-mode push) proves possession+ through `src/core/relay/relay-pop.ts`, and falls back to an unproven request ONLY on a 404/405+ challenge.** Change the protocol and `relay-pop-vector.json` must change in both repos. Deep+ version: CLAUDE.md § Hosted team relay.+- **Normalize BOTH sides of a path comparison, through one function.** A marker normalized whereit is built and matched raw where it is used is a no-op on the machine you wrote it on and asilent defect on Windows. That is issue #558: the managed-hook marker was folded to `/` whilediff --git a/docs/hosted-team-relay.md b/docs/hosted-team-relay.mdindex a7627d5f3..661cdc4df 100644--- a/docs/hosted-team-relay.md+++ b/docs/hosted-team-relay.md@@ -26,6 +26,7 @@ every message**. The desktop's UI only mirrors it.| Hosted service | `src/core/relay/hosted-service.ts` | Composes the host key, team store, scheduler and access policy; holds pending join requests; answers the `relay:hosted:*` verbs. || Standing listener | `hosted-scheduler.ts` + `host-token.ts` | A pure scheduler over injected mint / open / timers. || Host identity | `host-key.ts` | `<dataDir>/relay/host-key.json`, 0600, plaintext secret (headless Linux has no keyring). |+| Host key proof | `relay-pop.ts` + `relay-pop-vector.json` | The only place a proof of the host key is computed. See [Host key proof of possession](#host-key-proof-of-possession). || Membership | `team-store.ts` | `<dataDir>/relay/team.json`, 0600, single writer. || Role policy | `access-policy.ts` | `VIEW`, `COMMENT`, `EDITOR_ONLY`, `VIEW_EVENTS`; the guard test is `access-policy.guard.test.ts`. || Admin channel | `team-admin.ts` (socket) + `src/server/team-cli.ts` (CLI) | `<dataDir>/relay/admin.sock`, 0600 in a 0700 directory. |@@ -461,8 +462,8 @@ it is a new way to use it.|---|---|| `enabled` | A scheduler is running (hosting is on). || `off` | `null` while hosting is on; otherwise `{reason}`: `no-team` (run `team init`), `no-host-key`, `host-key-unreadable` (with `detail`, the loader's sentence), or `stopped`. |-| `scheduler.state` | `running`, `stopped`, or `backend-refused` (a 402/403 from `/v1/relay/host-token`: minting stops until the service restarts; `team init` does not restart it). |-| `scheduler.lastError` | The most recent failure **since the relay leg was last proven to work**, not a current fault: `network`, `network (<status>)`, `rate-limited (429)`, `refused (402)` / `refused (403)`, `bad-response`, `mint failed: …`, `relay closed the idle listener`, `open failed: …`, or `mint budget`. It clears when an idle listener holds its registration to its refresh, or when a peer completes a handshake. |+| `scheduler.state` | `running`, `stopped`, or `backend-refused`: a 402/403 from `/v1/relay/host-token`, or a 403 `pop_required`/`pop_invalid` (the relay refused this host's key proof) on two mints in a row, each with a fresh challenge. Minting stops until the service restarts or `team rotate-key` runs; `team init` does not restart it. |+| `scheduler.lastError` | The most recent failure **since the relay leg was last proven to work**, not a current fault: `network`, `network (<status>)`, `rate-limited (429)`, `refused (402)` / `refused (403)`, `bad-response`, `mint failed: …`, `relay closed the idle listener`, `open failed: …`, `mint budget`, `key proof refused once (<kind>) — retrying with a fresh challenge` (the first key-proof refusal; `<kind>` is `pop_invalid` or `pop_required`), or, with `backend-refused`, "The relay refused this host's key proof — update nodeterm, or run `team rotate-key` if the key was replaced." It clears when an idle listener holds its registration to its refresh, or when a peer completes a handshake. || `scheduler.mintsLastHour` | Host tokens minted in the last (rolling) hour. The scheduler never mints more than **200** in an hour (counted per running service, so a restart starts over); the backend's free limit is 240. || `scheduler.idle` / `scheduler.bridged` | Idle listeners (the target is one) / sessions joined or awaiting approval. || `peers[]` | `{label, role, connected}`. No keys: find them in `team.json`. |@@ -474,6 +475,8 @@ The human `team status` reads `state`, `idle` and `lastError` together:|---|---|| `Hosting: OFF — …` | `off.reason`, spelled out. For `host-key-unreadable` it is the loader's sentence. || `Hosting: STOPPED — the nodeterm API refused to issue relay tokens (…)` | `backend-refused`. Restart the service once the backend side is fixed. |+| `Hosting: STOPPED — the nodeterm API refused to issue relay tokens.`, then the key-proof sentence on a line of its own, then `Hosting stays off until nodeterm is updated or the key is rotated.` | `backend-refused` after two key-proof refusals in a row. See "Hosting refused by the relay's key proof" below. |+| `Last error:` (or the `Earlier failure …` line) reading `key proof refused once (<kind>) — retrying with a fresh challenge` | One key-proof refusal. The next mint asks for a fresh challenge; a second refusal in a row stops hosting. || `Hosting: ON — listening for teammates.` | An idle listener is registered. An "Earlier failure" line under it is history, not a fault. || `Hosting: ON, but not reachable yet — retrying. Last error: …` | No idle listener and a recent failure: minting or the relay is failing, with backoff. || `Hosting: ON — opening a listener.` | Starting up. |@@ -490,6 +493,9 @@ The human `team status` reads `state`, `idle` and `lastError` together:every socket dies, and resetting on the mint re-minted at round-trip speed (relay log,2026-09-27).- A 429 waits at least 60 s (longer if `Retry-After` says so).+- Every mint first asks the backend for a challenge and carries a proof that this process holds the+ host key. A challenge that fails for any reason but 404/405 mints nothing and backs off. See+ [Host key proof of possession](#host-key-proof-of-possession).**Common situations:**@@ -514,9 +520,37 @@ The human `team status` reads `state`, `idle` and `lastError` together:and restarts the service: live tabs drop and reconnect, and pending requests are lost.- **Windows:** the admin channel is a unix socket, so both ends refuse by name. A team cannot becreated on a Windows Server Edition in v1.-- **Hosting knocked offline by a join code** (see [Threat notes](#threat-notes)). `team status`- shows `rate-limited (429)` as the last error, or teammates read "Too many join attempts … today".- Give the host a new device id **and** a new key, then new codes:+- **Hosting refused by the relay's key proof, or knocked offline by a join code** (see+ [Host key proof of possession](#host-key-proof-of-possession) and [Threat notes](#threat-notes)).++ *Refused by the key proof.* `team status` says `Hosting: STOPPED` and prints "The relay refused+ this host's key proof — update nodeterm, or run `team rotate-key` if the key was replaced." on a+ line of its own. The backend refused this host's proof on two mints in a row, each with a fresh+ challenge; a single refusal only retries. The service log names the kind (`pop_invalid` or+ `pop_required`):++ - `pop_invalid`: the backend checked the proof and it failed. A single one can be a `POP_SECRET`+ rotation, or two backend instances with different secrets, landing between a challenge and its+ mint. Two in a row point at the backend (every instance must carry the same `POP_SECRET`) or at+ a nodeterm bug: update nodeterm, and if it persists, run `team rotate-key` and hand out new codes.+ - `pop_required`: the host proved its key once, so the backend latched it, and it is now refused a+ mint that carries no proof. The current nodeterm does not stop on that: it mints without a proof+ only when the challenge route answers 404/405, and reads `pop_required` there as a backend coming+ back mid-redeploy. So a latched host that stops on it runs an **older nodeterm**, which never+ proves; its `team status` shows `refused (403)` instead (a downgrade, or a copy of this data+ directory under an older build). Update nodeterm. `team rotate-key` and new codes also bring it+ back, because a new key is not latched, but only until `POP_REQUIRED_AFTER`.++ `team rotate-key` restarts hosting in place, and so does the service restart that comes with an+ update.++ *Knocked offline by a join code.* With a PoP-enabled backend, a host that has proven its key has+ its host-token budget keyed by that proof, so a code holder cannot spend it. What a code holder+ can still spend is the **16 pending join slots** and the team's **10 daily device mints**:+ teammates read "Too many join attempts for this team today. Try again tomorrow.", or, while 16+ requests are waiting, "An owner declined the request." A host that has never proven (an older nodeterm, or a backend with+ `POP_SECRET` unset) is exposed to all of R44, and `team status` may show `rate-limited (429)`.+ Either way, give the host a new device id **and** a new key, then new codes:```bashsystemctl --user stop nodeterm-server # `systemctl stop …` for a root install@@ -565,24 +599,40 @@ The human `team status` reads `state`, `idle` and `lastError` together:written) are held (at most 256), then served through the same checks.- **A leaked join code cannot let anyone in**: every device still needs an owner's approval. At most16 requests wait at once, one per device key, each for 10 minutes; the 17th is refused.-- **A join code is enough to take hosting offline** (ruling R44). The code carries the host's device- id and public key (`hosted-service.ts` `info()`), and those are exactly what the backend's- `POST /v1/relay/host-token` takes: `{deviceId, hostPublicKeyB64}` (`host-token.ts`), with no proof- that the caller holds the host's secret key. Its free-tier limit (240 host tokens an hour, a fixed- window) is keyed by the `deviceId` sent, and the team's device mints (`POST /v1/relay/device`, 10 a- day) by the host device id. So anyone holding a code, a teammate you removed included, can:- - spend the host's hourly host-token budget, so the host's own mints are refused with 429 and- hosting stays down until the window resets;- - register listeners under the team's address. A joiner paired with one of them fails its- handshake (only the real host has the secret key), so nothing is exposed, but that join fails;- - open join requests with throwaway device keys until the 16 pending slots are full;- - spend the team's 10 daily device mints, so a new teammate reads "Too many join attempts … today".-- `team remove` does not stop this, and neither does `team rotate-key` on its own: it changes the- address, not the device id the budgets are keyed by. Recovery: "Hosting knocked offline by a join- code" under [Status and troubleshooting](#status-and-troubleshooting). The real fix is on the- backend (proof that the caller holds the host key before `/v1/relay/host-token` mints), a- follow-up in `nodeterm-server`.+- **A join code no longer takes hosting offline, once the host has proven its key** (ruling R44).+ The code carries the host's device id and public key (`hosted-service.ts` `info()`), and those+ were all `POST /v1/relay/host-token` asked for. A backend with `POP_SECRET` set now asks for a+ proof that the caller holds the host's secret key: a challenge from `POST /v1/relay/challenge`,+ answered with an HMAC keyed by an X25519 shared secret (`relay-pop.ts`). The first valid proof+ **latches** the host, and from then on a mint without one is refused `403 pop_required`; after+ `POP_REQUIRED_AFTER` (default `2027-01-01T00:00:00Z`) every host must prove, latched or not. The+ full mechanism is under [Host key proof of possession](#host-key-proof-of-possession). For a+ latched host, it closes two of the four things a code holder, a teammate you removed included,+ could do:+ - **Spend the host's hourly host-token budget.** Closed: a proven mint is charged to the proven+ host in a budget window of its own, and an unproven mint for a latched host is refused before+ it reaches that budget.+ - **Register decoy listeners under the team's address.** Closed: a code holder can no longer mint+ a host token for a latched host. The relay broker also admits only pairing tokens+ (`typ: 'pair'`), closes a listener no peer has joined at its token's `exp + 30 s`, and keeps at+ most 8 pending listeners per host, evicting the oldest, so a decoy minted before the latch is+ gone within 150 s of its mint, and a stale set of them can never keep the host's fresh listener+ out.++ Two stay open, because the routes behind them take no proof:+ - **Open join requests with throwaway device keys** until the 16 pending slots are full.+ - **Spend the team's 10 daily device mints** (`POST /v1/relay/device`, keyed by the host device+ id), so a new teammate reads "Too many join attempts … today".++ And one gap before the latch: until a host has proven once, and before the cutoff, a code holder+ can still mint legacy host tokens for it and register up to 8 listeners under its address,+ evicting the host's own idle listener through the cap. A current nodeterm proves on its first mint+ against a PoP-enabled backend, so the gap closes the first time the host mints after the backend+ enables PoP; it stays open for a host running an older nodeterm, and for every host while+ `POP_SECRET` is unset. `team remove` does not stop the open items, and `team rotate-key` alone+ does not either: the device mints are keyed by the device id, not the address. Recovery is+ "Hosting refused by the relay's key proof, or knocked offline by a join code" under+ [Status and troubleshooting](#status-and-troubleshooting).- **A pinned device key is a long-lived credential**, like an SSH key: a stolen laptop gets inuntil `team remove`. A removed key's live sessions are cut and told `removed`, and until the killlands a session with no team entry is served nothing.@@ -592,6 +642,150 @@ The human `team status` reads `state`, `idle` and `lastError` together:decrypt a recorded session. This predates the hosted relay.- **The host key is never silently regenerated.** Only `team rotate-key` replaces it.+## Host key proof of possession++The fix for R44 (see [Threat notes](#threat-notes)). It covers every request that trusts a relay+host key: the Server Edition's hosted mint, the desktop phone relay's mint, and the desktop's+host-mode push. It is enforced by nodeterm-server; this repository holds the client half.++**The exchange.**++1. `POST /v1/relay/challenge {hostPublicKeyB64, purpose}`, where `purpose` is `host-token` or+ `push`. The backend answers `{challenge, serverPublicKeyB64, exp}`: a challenge sealed with its+ `POP_SECRET` (host id, purpose, a random nonce, a 60 s expiry) and a one-off X25519 public key+ derived from that nonce. Nothing is stored per challenge.+2. The client computes the X25519 shared secret of the host's secret key and that one-off key, and+ sends `popChallenge` and `popProof`: an HMAC-SHA256, keyed by that shared secret, over the+ challenge, the purpose, a subject and the host public key. The subject is the mint's `deviceId`+ (`''` when the desktop mints with a Pro entitlement), or the host device id for push.+3. The backend recomputes it. It refuses a challenge more than 5 s past its expiry, a nonce it has+ already accepted, and an all-zero shared secret, and answers any proof that does not verify with+ `403 {"error":"pop_invalid"}`.++`src/core/relay/relay-pop.ts` is the only place the client computes a proof, and it also refuses an+all-zero shared secret (a low-order server key gives every caller the same secret). The bytes are+pinned by `src/core/relay/relay-pop-vector.json`, which nodeterm-server carries byte for byte as+`test/fixtures/relay-pop-vector.json`. A protocol change changes both.++**The latch and the cutoff.** The first valid proof for a host **latches** it (the backend records+its host id). From then on, a request for that host without a proof is refused+`403 {"error":"pop_required"}`. A host that has never proven stays on the legacy path until+`POP_REQUIRED_AFTER` (default `2027-01-01T00:00:00Z`); after that, every host must prove. With+`POP_SECRET` unset or shorter than 32 characters, the backend logs `[api] POP_SECRET unset or+shorter than 32 characters — relay proof-of-possession is DISABLED` at boot, registers neither+`/v1/relay/challenge` nor `/v1/push/host-auth`, and serves every host the legacy way, latched or+not. It never fails to boot over it.++**What a proof buys.**++- `POST /v1/relay/host-token`: a proven mint is charged to the proven host id, in an hourly window+ of its own (240 an hour, the same size as the legacy window, which stays keyed by the `deviceId`+ sent). A caller who knows only the device id, or the host id printed in every join code, cannot+ spend it.+- `POST /v1/push/host-auth {hostDeviceId, hostPublicKeyB64, popChallenge, popProof}` (purpose+ `push`, subject the host device id): once the backend has checked that the host has a live+ pairing (else `403 forbidden`), a valid proof latches the host too and earns a `hostAuth` session+ good for 15 minutes. Host-mode `POST /v1/push/notify` and `/v1/push/live-update` carry it. A+ latched host's post without one is refused `pop_required`, and one with an expired or foreign+ session `pop_invalid`. Both checks run after the pairing check and before the send budget, so a+ refused post spends nothing.+- Each route has its own per-IP limit: `/v1/relay/challenge` 120 a minute (so the challenge a+ proven mint needs never spends the 30-a-minute bucket `/v1/relay/host-token` uses),+ `/v1/push/host-auth` 30 a minute.++**The relay broker.** nodeterm-server's relay broker admits only pairing tokens (`typ: 'pair'`),+closes a host listener no peer has joined at its token's `exp + 30 s`, keeps at most 8 pending+listeners per host (a new one evicts the oldest), and never expires or evicts a bridged socket. A+real host keeps one idle listener and replaces it 30 s before its token expires, so it meets+neither limit.++**What the clients do.** One rule runs through all three: only a challenge answered **404 or 405**+means "this backend predates the proof", and only then does a request go out unproven. Any other+challenge failure is transient: the request is not sent, and the caller backs off. An unproven+request from a latched host is refused, and for a mint that refusal would stop hosting.++- **Server Edition hosted mint** (`host-token.ts`, `hosted-scheduler.ts`). The challenge, the mint+ and the mint's body read share one 8 s timer. A challenge answered 429 waits at least 60 s+ (`rate-limited (429)`); a 2xx that is not a usable challenge, or a server key the proof cannot+ use, is `bad-response`; anything else is `network` or `network (<status>)`. A `pop_required`+ answer to the one unproven mint (after a 404/405 challenge) is read as `network (403)`, not as a+ refusal: a reverse proxy answers 404 while the backend redeploys, and the mint that follows can+ land on the fresh backend. A **key-proof refusal** (`pop_invalid`, or `pop_required` on a proven+ mint) stops hosting only when it is the **second in a row**, each with a fresh challenge. The+ first only backs off and retries, because a `POP_SECRET` rotation, or two backend instances with+ different secrets, inside one challenge-then-mint pair can refuse an honest host once. A transient failure+ between the two does not reset the count; only a successful mint or a restart does. After the+ first, `team status` shows `key proof refused once (<kind>) — retrying with a fresh challenge`;+ after the second, hosting is `backend-refused` and `team status` prints "The relay refused this+ host's key proof — update nodeterm, or run `team rotate-key` if the key was replaced." on a line+ of its own. Both are logged with their kind (a warning, then an error).+- **Desktop phone relay** (`src/main/remote/standing-host.ts`). The same challenge, proof and+ 404/405 rule, and the same "second refusal in a row" rule. The first refusal is logged and phone+ access retries with its reconnect backoff. The second stops phone access and shows one dialog,+ titled "Remote access stopped", that reads "The relay refused this computer's key proof — update+ nodeterm; if it persists after updating, contact support." followed by "Phone access is off. Turn+ it back on in Settings → Phone after updating." The desktop's text never mentions+ `team rotate-key`, which exists only in the Server Edition.+- **Desktop host-mode push** (`src/core/push-notify.ts`). Push stops nothing: a batch that cannot+ be proven is dropped, like a network error, and the phone still has the agent-status mirror.+ - The `hostAuth` session is good for 15 minutes on the server, and the client proves again after+ 10 minutes on its own clock. notify and live-update each hold their own.+ - A backend without the proof (challenge 404/405, or no host-auth route) is remembered for 10+ minutes, so it costs one challenge per 10 minutes rather than one per batch.+ - Failed proofs back off 0, 5, 15, then 60 s between attempts, since every attempt spends the+ per-IP challenge budget the mint needs too. A hold further out than 60 s can only be a clock+ that stepped back, and is ignored.+ - Overlapping flushes share one proof in flight. The challenge and the host-auth post share one+ 8 s timer. A proof that throws is dropped and backed off like any other failure.+ - A proven post answered `403 pop_invalid`/`pop_required` forgets the session, and the next batch+ proves again. An unproven post answered 403 forgets the "old backend" verdict. When that verdict+ was already on file from an earlier batch, the likely cause is that the host latched since+ (through the phone relay's mint, or the other push stream): the batch proves at once and, if that+ yields a session, is re-posted **once** with it; otherwise it is dropped. A verdict fetched in the+ same batch is not fetched again, so an old backend that refuses this host costs the same two+ requests per batch it always did.+ - The Server Edition pushes only in granted mode (per-grant bearer tokens, no host identity), so+ there is nothing to prove there.++**Rollout.** Clients and backend may ship in either order: a client that finds no challenge route+mints and pushes as before, and a backend with the proof on serves a host that has never proven the+legacy way until the cutoff. The backend goes first anyway, because the proof protects nothing+until it is on:++1. Deploy nodeterm-server.+2. The operator (@eneskirca) sets `POP_SECRET` in Dokploy: at least 32 characters, the same on+ every backend instance. `POP_REQUIRED_AFTER` is optional (an ISO date; one that does not parse is+ logged and the default is used).+3. Check that the boot log does **not** say `relay proof-of-possession is DISABLED`.+4. Ship the clients. A host latches the first time it mints (or pushes) with a current nodeterm.++Rotating `POP_SECRET` voids every challenge and `hostAuth` session in flight: a mint in that window+is refused once and retried, and push proves again on its next batch.++**Residuals.**++- Before a host has proven once, and before the cutoff, a code holder can still mint legacy host+ tokens for it and evict its idle listener through the cap (see [Threat notes](#threat-notes)).+- The team's 10 daily device mints and the 16 pending join slots are still open to a code holder.+- The backend remembers accepted nonces per process, so with several backend instances, or across+ a restart, one proof could be accepted once per process inside its challenge's 65 s. Replaying it+ still takes the proof itself, which only the TLS endpoint sees.+- A NUL character in `hostDeviceId` is now refused with a 400 on the push routes. Other request+ fields that reach a database query may still answer 500 for one; a sweep of the rest of the+ backend is a nodeterm-server follow-up.+- A desktop whose timers run more than about 60 s late (sleep, App Nap) has its idle listener+ expired by the relay: the refresh runs 30 s before the token expires and the relay closes an idle+ listener 30 s after. It recovers through the reconnect backoff. A Server Edition in the same+ state logs `relay closed the idle listener` and backs off the same way.+- After the desktop stops on a key-proof refusal, the Settings switch still reads on, so turning+ phone access back on means switching it off and on, or restarting the app (an update restarts+ it). The stop also ends any phone session in progress.++**Surfaces.** Desktop: the phone relay mint and host-mode push prove. Server Edition: the hosted+mint proves; its push is granted mode and has nothing to prove. Mobile: not applicable. The phone+is never a relay host, mints no host tokens and sends no host-mode push; its device and join tokens+are unchanged.+## Limitations (v1)- **Presence and context metadata cross projects.** Non-editors receive `presence:sync` /@@ -683,9 +877,9 @@ on a Mac and a second desktop as a teammate. Record `team status --json` at eachOFF — the host key could not be read", `team status` says why, `team init` refuses, and the keyfile is left as it was.8. **Long session.** A teammate stays connected for over an hour without the tab greying. The host- never refreshes a bridged session, and the relay broker's source checks a token only when a- socket joins, but whether production ends a bridged socket at its token's lifetime is unverified- (the comments in `hosted-scheduler.ts` and `standing-host.ts` say so). This item settles it.+ never refreshes a bridged session, and nodeterm-server's relay broker never expires or evicts a+ bridged socket (it closes only a listener no peer has joined, at its token's `exp + 30 s`). This+ item confirms that against the deployed relay.9. **Viewer size.** A Viewer with a small window does not shrink the Editor's terminal.10. **Two owners.** With two owners connected, one approves a request; the other owner's dialogcloses with "Another owner answered this request."@@ -706,3 +900,17 @@ on a Mac and a second desktop as a teammate. Record `team status --json` at eachmoment. Both moves stay, on both screens and after a service restart.15. **A Windows joiner.** A teammate on a Windows desktop joins, moves a card and adds a column; bothare still there after a service restart.+16. **Key proof against production.** With nodeterm-server deployed and `POP_SECRET` set (its boot+ log does not say `relay proof-of-possession is DISABLED`):+ 1. The hosted core's first mint carries `popChallenge`/`popProof`, and `team status` stays+ running (`Hosting: ON — listening for teammates.`, no key-proof line).+ 2. A second machine joins with the code.+ 3. A host-token request without a proof for that host now answers `403 pop_required`. Take the+ join code's `hostDeviceId` and `hostPublicKeyB64` from `node $APP team info --json`, then:++ ```bash+ curl -sS -w ' %{http_code}\n' -X POST https://api.nodeterm.dev/v1/relay/host-token \+ -H 'content-type: application/json' \+ -d '{"deviceId":"<hostDeviceId>","hostPublicKeyB64":"<hostPublicKeyB64>"}'+ # {"error":"pop_required"} 403+ ```