Merge branch 'main' into the desktop updater, and give way on two numbers

Main landed a realtime push feature while this branch was building the updater,
and the two collided in three places. Every one of them resolves the same way:
main got there first, so this branch moves.

**Two ADRs were both numbered 0012.** Main's is realtime push; this one is now
[ADR 0013](docs/adr/0013-desktop-distribution-and-updates.md). Git did not call
this a conflict — the filenames differ — so it would have merged quietly and left
the directory with two 0012s and every cross-reference ambiguous. Renumbered here
along with the nine places that point at it.

**Two manual-check phases were both numbered 15**, and that one git did catch.
Main's "Changes that arrive without a timer" keeps 15; installing and updating
the desktop client becomes Phase 16, with its checks and every reference to them
renumbered. The file's own rule is that a number is for life, which is exactly
why the one that had not been pushed is the one that gives way.

**The merge rewrote several files with CRLF**, and `.editorconfig` asks for LF on
everything except `*.ps1`. That is not cosmetic here: IDE0055 is an error and
`EnforceCodeStyleInBuild` is on, so it failed the build on three lines of
App.axaml.cs whose only change in this branch was an ADR number in a comment.
Forty-six files normalised back to LF; the release script keeps CRLF, which is
what `.gitattributes` and `.editorconfig` both already say for a PowerShell file.

Nothing else conflicted. The updater does not touch the sync loop or the event
stream, and the one file both sides edited heavily — MainWindowViewModel — merged
without a hunk in common.

Verified after merging: the solution restores locked and builds clean, and 304
shell, 100 layout, 54 session, 28 client-api and 25 contracts tests pass. The
first two counts are higher than before the merge because main's own tests came
with it and pass alongside these.
This commit is contained in:
2026-08-04 17:52:57 +02:00
52 changed files with 6205 additions and 341 deletions
@@ -66,6 +66,11 @@ namespace DodoSSH.Contracts;
// Registered in its own right, not only as a member of the sync DTOs: the client's local
// cache seals this record under the LocalCacheKey and needs its type info directly.
[JsonSerializable(typeof(SyncPlaintextFields))]
// The event socket's only frame type. Registered although nothing else references it: frames are
// written straight onto a WebSocket rather than through a response body, so the resolver never
// infers it from an endpoint's signature the way it does for every DTO above.
[JsonSerializable(typeof(VaultEvent))]
[JsonSerializable(typeof(RelayTicketRequest))]
[JsonSerializable(typeof(RelayTicketResponse))]
[JsonSerializable(typeof(RelaySessionSummary))]
+134
View File
@@ -0,0 +1,134 @@
namespace DodoSSH.Contracts;
/// <summary>
/// The event socket's protocol constants.
/// </summary>
/// <remarks>
/// The version lives in the subprotocol name rather than in the URL, for the reason ADR 0002 gives
/// about the rest of this API: a client and a server that upgrade independently have to agree by
/// negotiating rather than by assuming, and a WebSocket handshake already has a field for exactly
/// that. A server that does not offer <see cref="SubProtocol"/> fails the handshake, which a client
/// can act on — rather than opening a socket that then speaks a dialect it cannot read.
/// </remarks>
public static class VaultEvents
{
/// <summary>The path the event socket is served from.</summary>
public const string Path = "/api/v1/events";
/// <summary>The only subprotocol this version speaks.</summary>
public const string SubProtocol = "dodossh.events.v1";
/// <summary>The <c>/api/v1/meta</c> feature flag advertising that this server pushes at all.</summary>
public const string Feature = "events";
/// <summary>
/// Close code for a socket whose access token has expired.
/// </summary>
/// <remarks>
/// In the 40004999 range, which the WebSocket specification reserves for applications. Its own
/// code because it is the one close a client should answer by reconnecting immediately with a
/// fresh token, rather than by backing off as it would for a server that went away.
/// </remarks>
public const int TokenExpiredCloseCode = 4401;
/// <summary>
/// Close code for a caller already holding as many sockets as it may.
/// </summary>
/// <remarks>
/// Distinguished from <see cref="TokenExpiredCloseCode"/> because the remedy is the opposite:
/// reconnecting at once is what caused it. A client that meets this backs off and keeps polling.
/// </remarks>
public const int TooManyConnectionsCloseCode = 4429;
}
/// <summary>
/// The kinds of event this socket carries.
/// </summary>
/// <remarks>
/// <para>
/// Constants rather than an <c>enum</c>, and that is a compatibility decision rather than a style
/// one. <c>DodoSshJsonContext</c> sets <c>UseStringEnumConverter</c>, which <em>throws</em> on a
/// value it does not know — so a newer server sending a kind an older client has never heard of
/// would not merely add an unreadable frame, it would break that client's socket. A string is
/// ignored instead, which is what makes this list extensible. <see cref="ProblemCodes"/> is the same
/// shape for the same reason.
/// </para>
/// <para>
/// <b>Anything a client cannot parse must be skipped, not treated as an error.</b> That rule is what
/// the shared-session frames of ADR 0012 will rely on when they arrive.
/// </para>
/// </remarks>
public static class VaultEventKinds
{
/// <summary>The server accepted the socket. Always the first frame.</summary>
public const string Hello = "hello";
/// <summary>
/// A vault has changes at or before <see cref="VaultEvent.Sequence"/>.
/// </summary>
/// <remarks>
/// Carries no ciphertext and no item identity — the client's answer is the delta pull it would
/// have run on its timer anyway. See ADR 0012 for why pushing the items themselves is refused.
/// </remarks>
public const string VaultChanged = "vault.changed";
/// <summary>
/// The set of vaults this account can reach is no longer what it was.
/// </summary>
/// <remarks>
/// A vault shared with the caller, or a grant withdrawn. Deliberately says nothing about
/// <em>which</em>: the client re-reads the list, which is the same call it already makes at the
/// start of every synchronisation pass.
/// </remarks>
public const string VaultsChanged = "vaults.changed";
/// <summary>Heartbeat. Whichever side receives one answers <see cref="Pong"/>.</summary>
public const string Ping = "ping";
/// <summary>The answer to a <see cref="Ping"/>.</summary>
public const string Pong = "pong";
}
/// <summary>
/// One frame on the event socket.
/// </summary>
/// <remarks>
/// <para>
/// One flat record for every kind, with the fields a given kind does not use left null, rather than
/// a polymorphic hierarchy. The set is small, the frames are tiny, and <c>System.Text.Json</c>
/// polymorphism would put a second discriminator mechanism next to the <see cref="Kind"/> string
/// that is already the discriminator. Nothing else in <c>DodoSSH.Contracts</c> is polymorphic.
/// </para>
/// <para>
/// <b>Nothing here is secret, by construction.</b> The server cannot read a vault's contents, so a
/// notice cannot describe them; what it does disclose — that a vault changed, and when — is the same
/// metadata ADR 0001 already accepts the server holding.
/// </para>
/// </remarks>
/// <param name="Kind">One of <see cref="VaultEventKinds"/>. An unrecognised kind must be ignored.</param>
/// <param name="VaultId">The vault a <see cref="VaultEventKinds.VaultChanged"/> is about.</param>
/// <param name="Sequence">
/// The change-log position that vault has reached. A hint for logging and for coalescing, not a
/// cursor: cursors are opaque and HMAC-tagged, and this is neither.
/// </param>
/// <param name="ServerTime">
/// The server's clock when the frame was written. The client already measures skew against
/// <c>SyncPullResponse.ServerTime</c>; this lets a socket that is quiet for other reasons keep that
/// measurement current.
/// </param>
/// <param name="HeartbeatSeconds">
/// How often the server will ping, sent with <see cref="VaultEventKinds.Hello"/>. The client uses it
/// to decide when silence means the connection is dead rather than idle.
/// </param>
/// <param name="VaultCount">
/// How many vaults this socket is subscribed to, sent with <see cref="VaultEventKinds.Hello"/>.
/// Diagnostic: a socket subscribed to nothing is a real state — an account with no vaults yet — and
/// is otherwise indistinguishable from one that is quietly broken.
/// </param>
public sealed record VaultEvent(
string Kind,
Guid? VaultId = null,
long? Sequence = null,
DateTimeOffset? ServerTime = null,
int? HeartbeatSeconds = null,
int? VaultCount = null);
+10
View File
@@ -66,6 +66,16 @@ public static class ProblemCodes
/// </remarks>
public const string MalformedRequest = "malformed-request";
/// <summary>
/// This deployment does not push vault changes over a socket.
/// </summary>
/// <remarks>
/// Not a failure to recover from: synchronising on a timer is the supported behaviour and the
/// socket only ever made it early. A client that meets this stops dialling and keeps polling. See
/// ADR 0012.
/// </remarks>
public const string EventsUnavailable = "events-unavailable";
/// <summary>The relay refused the requested target. Never states why, to avoid a probe oracle.</summary>
public const string RelayTargetRejected = "relay-target-rejected";
@@ -2,6 +2,7 @@
const DodoSSH.Contracts.ProblemCodes.AlreadyEnrolled = "already-enrolled" -> string!
const DodoSSH.Contracts.ProblemCodes.ClientTooOld = "client-too-old" -> string!
const DodoSSH.Contracts.ProblemCodes.EnrollmentRequired = "enrollment-required" -> string!
const DodoSSH.Contracts.ProblemCodes.EventsUnavailable = "events-unavailable" -> string!
const DodoSSH.Contracts.ProblemCodes.Forbidden = "forbidden" -> string!
const DodoSSH.Contracts.ProblemCodes.IdempotencyKeyReuse = "idempotency-key-reuse" -> string!
const DodoSSH.Contracts.ProblemCodes.IdentityBindingInvalid = "identity-binding-invalid" -> string!
@@ -22,6 +23,16 @@ const DodoSSH.Contracts.ProblemCodes.TeamNotEmpty = "team-not-empty" -> string!
const DodoSSH.Contracts.ProblemCodes.TeamSlugTaken = "team-slug-taken" -> string!
const DodoSSH.Contracts.ProblemCodes.TypeBaseUri = "https://dodossh.dev/problems/" -> string!
const DodoSSH.Contracts.ProblemCodes.VaultConflict = "vault-conflict" -> string!
const DodoSSH.Contracts.VaultEventKinds.Hello = "hello" -> string!
const DodoSSH.Contracts.VaultEventKinds.Ping = "ping" -> string!
const DodoSSH.Contracts.VaultEventKinds.Pong = "pong" -> string!
const DodoSSH.Contracts.VaultEventKinds.VaultChanged = "vault.changed" -> string!
const DodoSSH.Contracts.VaultEventKinds.VaultsChanged = "vaults.changed" -> string!
const DodoSSH.Contracts.VaultEvents.Feature = "events" -> string!
const DodoSSH.Contracts.VaultEvents.Path = "/api/v1/events" -> string!
const DodoSSH.Contracts.VaultEvents.SubProtocol = "dodossh.events.v1" -> string!
const DodoSSH.Contracts.VaultEvents.TokenExpiredCloseCode = 4401 -> int
const DodoSSH.Contracts.VaultEvents.TooManyConnectionsCloseCode = 4429 -> int
DodoSSH.Contracts.AddTeamMemberRequest
DodoSSH.Contracts.AddTeamMemberRequest.<Clone>$() -> DodoSSH.Contracts.AddTeamMemberRequest!
DodoSSH.Contracts.AddTeamMemberRequest.AddTeamMemberRequest(System.Guid UserId, DodoSSH.Contracts.TeamMemberRole Role, string? Email = null) -> void
@@ -686,6 +697,25 @@ DodoSSH.Contracts.UpdateVaultRequest.Equals(DodoSSH.Contracts.UpdateVaultRequest
DodoSSH.Contracts.UpdateVaultRequest.Name.get -> string!
DodoSSH.Contracts.UpdateVaultRequest.Name.init -> void
DodoSSH.Contracts.UpdateVaultRequest.UpdateVaultRequest(string! Name) -> void
DodoSSH.Contracts.VaultEvent
DodoSSH.Contracts.VaultEvent.<Clone>$() -> DodoSSH.Contracts.VaultEvent!
DodoSSH.Contracts.VaultEvent.Deconstruct(out string! Kind, out System.Guid? VaultId, out long? Sequence, out System.DateTimeOffset? ServerTime, out int? HeartbeatSeconds, out int? VaultCount) -> void
DodoSSH.Contracts.VaultEvent.Equals(DodoSSH.Contracts.VaultEvent? other) -> bool
DodoSSH.Contracts.VaultEvent.HeartbeatSeconds.get -> int?
DodoSSH.Contracts.VaultEvent.HeartbeatSeconds.init -> void
DodoSSH.Contracts.VaultEvent.Kind.get -> string!
DodoSSH.Contracts.VaultEvent.Kind.init -> void
DodoSSH.Contracts.VaultEvent.Sequence.get -> long?
DodoSSH.Contracts.VaultEvent.Sequence.init -> void
DodoSSH.Contracts.VaultEvent.ServerTime.get -> System.DateTimeOffset?
DodoSSH.Contracts.VaultEvent.ServerTime.init -> void
DodoSSH.Contracts.VaultEvent.VaultCount.get -> int?
DodoSSH.Contracts.VaultEvent.VaultCount.init -> void
DodoSSH.Contracts.VaultEvent.VaultEvent(string! Kind, System.Guid? VaultId = null, long? Sequence = null, System.DateTimeOffset? ServerTime = null, int? HeartbeatSeconds = null, int? VaultCount = null) -> void
DodoSSH.Contracts.VaultEvent.VaultId.get -> System.Guid?
DodoSSH.Contracts.VaultEvent.VaultId.init -> void
DodoSSH.Contracts.VaultEventKinds
DodoSSH.Contracts.VaultEvents
DodoSSH.Contracts.VaultGrantsResponse
DodoSSH.Contracts.VaultGrantsResponse.<Clone>$() -> DodoSSH.Contracts.VaultGrantsResponse!
DodoSSH.Contracts.VaultGrantsResponse.Deconstruct(out System.Guid VaultId, out uint KeyGeneration, out bool RekeyRequired, out System.Collections.Generic.IReadOnlyList<DodoSSH.Contracts.VaultGrantSummary!>! Grants) -> void
@@ -877,6 +907,9 @@ override DodoSSH.Contracts.UpdateTeamRequest.ToString() -> string!
override DodoSSH.Contracts.UpdateVaultRequest.Equals(object? obj) -> bool
override DodoSSH.Contracts.UpdateVaultRequest.GetHashCode() -> int
override DodoSSH.Contracts.UpdateVaultRequest.ToString() -> string!
override DodoSSH.Contracts.VaultEvent.Equals(object? obj) -> bool
override DodoSSH.Contracts.VaultEvent.GetHashCode() -> int
override DodoSSH.Contracts.VaultEvent.ToString() -> string!
override DodoSSH.Contracts.VaultGrantsResponse.Equals(object? obj) -> bool
override DodoSSH.Contracts.VaultGrantsResponse.GetHashCode() -> int
override DodoSSH.Contracts.VaultGrantsResponse.ToString() -> string!
@@ -972,6 +1005,8 @@ static DodoSSH.Contracts.UpdateTeamRequest.operator !=(DodoSSH.Contracts.UpdateT
static DodoSSH.Contracts.UpdateTeamRequest.operator ==(DodoSSH.Contracts.UpdateTeamRequest? left, DodoSSH.Contracts.UpdateTeamRequest? right) -> bool
static DodoSSH.Contracts.UpdateVaultRequest.operator !=(DodoSSH.Contracts.UpdateVaultRequest? left, DodoSSH.Contracts.UpdateVaultRequest? right) -> bool
static DodoSSH.Contracts.UpdateVaultRequest.operator ==(DodoSSH.Contracts.UpdateVaultRequest? left, DodoSSH.Contracts.UpdateVaultRequest? right) -> bool
static DodoSSH.Contracts.VaultEvent.operator !=(DodoSSH.Contracts.VaultEvent? left, DodoSSH.Contracts.VaultEvent? right) -> bool
static DodoSSH.Contracts.VaultEvent.operator ==(DodoSSH.Contracts.VaultEvent? left, DodoSSH.Contracts.VaultEvent? right) -> bool
static DodoSSH.Contracts.VaultGrantsResponse.operator !=(DodoSSH.Contracts.VaultGrantsResponse? left, DodoSSH.Contracts.VaultGrantsResponse? right) -> bool
static DodoSSH.Contracts.VaultGrantsResponse.operator ==(DodoSSH.Contracts.VaultGrantsResponse? left, DodoSSH.Contracts.VaultGrantsResponse? right) -> bool
static DodoSSH.Contracts.VaultGrantSummary.operator !=(DodoSSH.Contracts.VaultGrantSummary? left, DodoSSH.Contracts.VaultGrantSummary? right) -> bool