diff --git a/docs/architecture.md b/docs/architecture.md index 08a2609..1eb06a9 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -419,33 +419,93 @@ A row whose binding columns cannot be read is listed and read as unbound, with a warning, instead of failing the list; so no damaged row, the account record's included, keeps a sign-out from finishing, and `Forget` still deletes the key it names. -Signing out of an account is the trait's `sign_out`, run on this table: it -removes the account record and the synced copies, unbinds the identities only -this device holds, keeps the device key (unbound, byte for byte) when the -record says it predates the account, and deletes it when it does not or when -the caller asks to forget it. The engine and the UI do not use the key store -yet; accounts, sign-in and the integrations page are later steps. +Signing out of an account is the trait's `sign_out`, run on this table, and it +keeps every key (Phase 2 task 34 of the protocol repository, open question 10 +of its accounts design, answered by the owner on 2026-10-24). The device key +stays, unbound and byte for byte, whether it was in use before the account +existed or the client made it for the account: at every host without accounts +that the user reached with it, it is the user's identity, and deleting it would +lose their servers, roles and memberships there. `AccountRecord.bound_existing_key` +stays in the record for the client's wording, and no rule reads it. The +sign-out unbinds the identities only this device holds and deletes what is not +a key of the device: the account record, and the synced copies of integration +secrets, which the account service holds. It does not release the device key at +the service. The engine and the UI do not use the key store yet; accounts, +sign-in and the integrations page are later steps. -The device key is never a synced copy. The trait's `sign_out` deletes every -identity bound with `synced = true` in its first step, before it reads the -record, so a device key stored that way would be deleted even where the record -says to keep it. `SqliteKeyStore` therefore refuses, with an error that names -the key and the record, a `put` of a `voelin` blob with `synced = true` while an -account record names its uid as the device key, or while an account record -cannot be read (it may name the key); and a `put` of an account record whose -device key is stored as a synced copy. A key bound with `synced = false` is -accepted: a sign-out unbinds it and then follows the record. The check is made -under the store's lock; it is defence in depth against the code that signs in, -which does not exist yet. +The three parts of open question 10, and what each asks of the store and of the +client: + +1. **A sign-out keeps every device key.** The only deletion of a key of the + device is "Forget this device's identity", the user's explicit choice, after + an offer to export the key. Signed in, it is a sign-out with + `DeviceKeyChoice::Forget(uid)` (the key goes before the record is read, so an + unreadable record does not keep it); signed out, it is `KeyStore::remove` of + the key, and for a TeamSpeak identity `Store::delete_identity`. The store has + no export call: the UI reads the bytes first, a Voelin key with + `KeyStore::voelin_key` and `IdentityKey::to_pkcs8`, a TeamSpeak identity with + `Store::identity` and `ts::identity::export`. +2. **A device key can be released from its account**, so that it can serve + another account. Releasing is the account service's operation + (`AccountClient::release`: `POST /v1/devices//release`, after a password + check) followed by the same local sign-out with `Auto`, which keeps the key, + unbound. The store has nothing to add and the client remembers nothing of the + release: the service holds the registration of the key, and a sign-in or a + sign-up refused with `CONFLICT`, field `device`, is how the client learns that + the key is still registered with an account it signed out of. +3. **The deletion of an account releases every device key of it.** The service + writes a DEVICE and a RELEASED entry for each key, the hosts that adopted a + key end their record of it at their next poll, and the account's users on + them stay the deleted account's, out of reach for good: nobody inherits them, + neither a key nor another account. The local half is + `AccountClient::delete_account(choice)`, the same sign-out: this device's key + is kept with `Auto`. + +What the screens owe, as duties of the GPUI client (they do not exist yet; the +acceptance of the task in the protocol repository names the fixtures): + +- The sign-out dialog says what is kept: "This device's identity stays on this + device. Servers that do not use accounts still know you by it. Choose 'Forget + this device's identity' to delete it (you can export it first)." Forgetting is + a separate, explicit choice there, with the export offered before it. +- Settings → Account offers "Release this device's identity from the account", + apart from signing out: the password first (`AccountClient::reauth`), then + `release`, then the text of protocol section 13.6 (the key can sign in to, or + up for, another account; a host that adopted it and knows the kind RELEASED + accepts it after its next poll, within five minutes). After a release the + client closes its own account sessions and shows no prompt to sign in again + when a host closes one with code 11; a release whose answer was lost + (`SignedOut`) is finished with a sign-out with `Auto`; a `CONFLICT`, field + `device`, at sign-in or sign-up is explained. +- **The delete-account dialog warns that the servers of the account become + unreachable** (its users on the hosts that adopted its keys stay the deleted + account's, and nobody inherits them) **and offers an export of the device keys + first**, before the deletion is sent: `KeyStore::list` names the `voelin` + rows, and each is read and exported as above. + +The device key is never a synced copy. The trait's `sign_out` keeps the device +key, but its first step deletes every identity bound with `synced = true`, +before it reads the record, so a device key stored that way would be deleted +all the same, whichever way the record says it came. `SqliteKeyStore` therefore +refuses, with an error that names the key and the record, a `put` of a `voelin` +blob with `synced = true` while an account record names its uid as the device +key, or while an account record cannot be read (it may name the key); and a +`put` of an account record whose device key is stored as a synced copy. A key +bound with `synced = false` is accepted: a sign-out unbinds it and keeps it. The +check is made under the store's lock; it is defence in depth against the code +that signs in, which does not exist yet. The rows are private keys, so a deleted key must not stay in the file. Every connection to the database sets `secure_delete`, which makes SQLite overwrite what it deletes, and deleting a key (`Store::delete_identity`, and the -`KeyStore::remove` a sign-out deletes with) is followed by a -`PRAGMA wal_checkpoint(TRUNCATE)`, so that the frame of the write-ahead log that -held the key's page goes too: neither `client.db` nor `client.db-wal` has the -key's text afterwards. A sign-out runs the checkpoint once, after its last step, -not after each row it removes. The checkpoint waits for another connection for +`KeyStore::remove` that forgetting a Voelin key and a sign-out delete with) is +followed by a `PRAGMA wal_checkpoint(TRUNCATE)`, so that the frame of the +write-ahead log that held the key's page goes too: neither `client.db` nor +`client.db-wal` has the key's text afterwards. A sign-out deletes the synced +copies (private keys of TeamSpeak identities), the account record and, when the +user chose to forget it, the device key; it runs the checkpoint once, after its +last step, not after each row it removes, and not at all when it deleted +nothing. The checkpoint waits for another connection for 150 ms at most (the connection's own busy timeout is restored after it), because while it waits for a reader it holds the writer lock of the log and every other writer waits with it. If another connection blocks it (one that keeps reading an diff --git a/docs/session-seam.md b/docs/session-seam.md index 26c7ee0..d681fa4 100644 --- a/docs/session-seam.md +++ b/docs/session-seam.md @@ -1733,6 +1733,26 @@ were fresh compose projects (`down -v`, `up -d`) for each smoke run. `Command::ObserveGateway` link `ts::identity::to_blob`, `VoiceOptions::client_version` links `ts::versions::resolve`. +- **The key store follows task 34 (`phase4/keystore-task34`).** Open question 10 + of the accounts design (answered by the owner on 2026-10-24) made + `KeyStore::sign_out` keep every device key, and VoelinProtocol `main` + (`c5bb6b9`) has it. `SqliteKeyStore` runs that trait method, so the follow-up + that Phase 2 task 34 leaves to this repository ("Note for VoelinClient") is + the pin of the three protocol crates, the tests that asserted the deletion + of a key made for the account (now kept, unbound, byte for byte; only + `DeviceKeyChoice::Forget` deletes a key of the device), and the documents: + `keystore.rs` and `docs/architecture.md`, "Identities", which has the three + parts of the question and the duties of the GPUI client (the sign-out + dialog's wording with "Forget this device's identity" and an export first, + the release in Settings → Account, and the delete-account dialog, which + warns that the account's servers become unreachable and offers an export of + the device keys first). A sign-out still deletes the synced copies and the + account record, so `SignOutPass` stays for their one checkpoint, and the + refusal of a device key stored as a synced copy stays, with its reason + reworded: the sign-out keeps the key but deletes every synced copy before it + reads the record. The store gained no release call and no "released" record: + `AccountClient::release` ends in `sign_out` with `Auto`, and the design asks + the client to remember nothing of a release. - **The same leak in `voelin-store`, not closed.** `Store::identity` and `Store::identities` read the stored JSON of a TeamSpeak identity with `?`, so an `Error::Json` whose text is the `serde_json` message, which quotes a key