Public Access
Build the three things the phone's + needs, before the + exists
Steps 1 to 3 of docs/adding-hosts-on-the-phone.md: the domain half. Nothing on either head has changed, which is deliberate — the plan orders these first because everything the editors will bind to has to exist and be merge-safe before a screen can offer it. HostGroupSecret gains a parent and four defaults, and the codec gains the version rule it never had. It stamped CurrentSchemaVersion unconditionally, which was harmless with one field and one version and stops being harmless here: upgrading one machine and renaming any group would have made that group uneditable on every machine still on the old build. It now emits the lowest version that loses nothing, so a flat group with no defaults still encodes at version 1, byte for byte, pinned against a literal. Tags become a real item over the reserved slot. Secret, codec, merge, cipher, repository, both registries, the EF entity and a generated AddTagItem migration. TagCipher names AadResourceType.Tag as a constant rather than casting the wire type, because Tag is 5 on the wire and 8 in the crypto enum and 5 there is Credential — a cast would seal every tag under the resource type for a password, encrypt and decrypt perfectly on the machine that wrote it, and only fail when another implementation refused the item, by which time the AAD is frozen into stored ciphertext. HostTag stays reserved and unused: the one thing the join buys over a set on the host is bought instead by merging TagIds per id. HostSecret grows TagIds and Port goes nullable, which is the change with the widest blast radius and the only one that loses an item rather than locking one. A host with no port of its own omits the property, an older build reads int Port as 0, and TryValidate refuses it — unreadable rather than read-only. That cost is confined to hosts which actually inherit, because the version is a maximum over the fields present; the alternative, writing 22 into every host, is the lie inheritance exists to stop telling. One decision the plan did not specify. "Three states where there were two" is four — key, credential, typed password, or the group's answer — and two nullable ids carry three. Naming neither id now means inherit, so AsksForPassword says "a typed password even under a group that lends a key" out loud. Only true is ever written and a decoded false folds back to null, so a host that never touched it encodes as it always did. Nothing already stored changed meaning: no group could lend a binding before this build, so every existing host resolves exactly as it did. HostInheritance is the resolver, and its visited set is load-bearing rather than defensive. Two clients can each re-parent A under B and B under A while offline; the merge sees one item against one item and the server sees ciphertext, so nothing upstream can refuse the pair. With inheritance the chain is walked at connect time, so an unguarded cycle is not an undrawable sidebar — it is a shell that never opens. Stopping at the first repeat degrades it to a group that reads as a root, and clearing the parent is the repair. A tag set turns out to be the one field on a host that can never ask the user anything. TagSet.ToIdMap keys by the value, so no key can hold two values, so the both-sides-moved-differently branch of the keyed merge is unreachable — asserted over the whole eight-row matrix. The conflict loop is kept anyway, because that proof is one edit from ceasing to hold and what it would cause is a discarded tag nothing records. Three guard tests failed by design and were fixed rather than relaxed: the ordered pull filter, the AAD pinning table, and the server's refusal of a plaintext parent — that last one survives with its reason rewritten, because the refusal now means "the parent is not the server's to hold" rather than "there is no such thing as a parent". The prose that said groups are flat is rewritten in all four places it appeared, not deleted. The five view-model sites that read Port directly now go through the resolver, which is a down payment on step 4 rather than the whole of it. HostFields.From still emits the stored port, and that is the one remaining place where an unresolved read would be a wrong wire rather than a wrong label. Verified by the whole suite: 1382 tests over nineteen projects, none failing. Both heads build. Nothing seen on a display, because nothing on a display has changed yet. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -804,6 +804,17 @@ internal sealed partial class VaultViewModel(
|
||||
/// </remarks>
|
||||
private IReadOnlyList<VaultItem<HostGroupSecret>> groupItems = [];
|
||||
|
||||
/// <summary>
|
||||
/// The same groups by id, which is the shape the inheritance walk takes.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Cached beside <see cref="groupItems"/> rather than built per call, because resolving is on the path
|
||||
/// that draws every host row and on the path that opens every shell — and a dictionary rebuilt per host
|
||||
/// would be one allocation per row per redraw.
|
||||
/// </remarks>
|
||||
private IReadOnlyDictionary<Guid, HostGroupSecret> groupsById =
|
||||
new Dictionary<Guid, HostGroupSecret>();
|
||||
|
||||
/// <summary>The groups whose hosts are folded away, by id, with <see cref="Guid.Empty"/> for ungrouped.</summary>
|
||||
private readonly HashSet<Guid> collapsedGroups = [];
|
||||
|
||||
@@ -1813,10 +1824,30 @@ internal sealed partial class VaultViewModel(
|
||||
.ConfigureAwait(true);
|
||||
|
||||
groupItems = [.. listing.Items.OrderBy(group => group.Secret.Label, StringComparer.CurrentCulture)];
|
||||
groupsById = groupItems.ToDictionary(group => group.EntityId, group => group.Secret);
|
||||
|
||||
return listing.Unreadable;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A host with its group chain applied: the port to dial, the user to log in as, and how to
|
||||
/// authenticate.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The one place this view model turns a stored host into a dialled one. A host may leave any of the
|
||||
/// three unset and take its group's, so reading <c>host.Port</c> or <c>host.SshKeyId</c> directly
|
||||
/// answers "what did the user type into this host" and not "what happens when this is connected" — and
|
||||
/// almost everything on screen wants the second question. See <see cref="HostInheritance"/>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Reads <see cref="groupsById"/>, which is refilled by <see cref="ReloadGroupsAsync"/> before the hosts
|
||||
/// are read. That ordering is not incidental: a host resolved against a stale group list would show one
|
||||
/// port and dial another.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
internal ResolvedHost Resolve(HostSecret host) => HostInheritance.Resolve(host, groupsById);
|
||||
|
||||
/// <summary>Refills <see cref="Groups"/>, counting the hosts filed under each.</summary>
|
||||
private void RebuildGroups()
|
||||
{
|
||||
@@ -2177,7 +2208,7 @@ internal sealed partial class VaultViewModel(
|
||||
// Built once rather than searched per pin. A vault with a hundred of each would otherwise be a
|
||||
// hundred scans of the host list on every background sync.
|
||||
var dialled = Hosts
|
||||
.Select(host => Endpoint(host.Host.Hostname, host.Host.Port))
|
||||
.Select(host => Endpoint(host.Host.Hostname, Resolve(host.Host).Port.Value))
|
||||
.ToHashSet(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
// Listed across every readable vault, unlike the trust the SSH handshake consults, which stays in
|
||||
@@ -2521,7 +2552,10 @@ internal sealed partial class VaultViewModel(
|
||||
editingHostVaultId = row.VaultId;
|
||||
EditorLabel = row.Host.Label;
|
||||
EditorHostname = row.Host.Hostname;
|
||||
EditorPort = row.Host.Port;
|
||||
// The resolved port rather than the stored one, so a host that inherits opens showing what it
|
||||
// actually dials rather than an empty box. The editor cannot yet express "leave this to the group",
|
||||
// so saving pins whatever is shown — which is what it did before any of this existed.
|
||||
EditorPort = Resolve(row.Host).Port.Value;
|
||||
EditorUsername = row.Host.Username ?? string.Empty;
|
||||
EditorNotes = row.Host.Notes ?? string.Empty;
|
||||
EditorRelayEnabled = row.Host.RelayEnabled;
|
||||
@@ -3807,7 +3841,11 @@ internal sealed partial class VaultViewModel(
|
||||
}
|
||||
|
||||
var address = row.Host.Hostname;
|
||||
var port = row.Host.Port;
|
||||
|
||||
// The dialled port, because that is what the pin is filed under. A host inheriting 2222 from its
|
||||
// group was pinned at 2222, and forgetting under 22 would leave the pin that caused the mismatch
|
||||
// exactly where it was.
|
||||
var port = Resolve(row.Host).Port.Value;
|
||||
|
||||
await RunAsync(
|
||||
$"Forgetting the pinned host key for {address}…",
|
||||
@@ -4004,7 +4042,7 @@ internal sealed partial class VaultViewModel(
|
||||
|
||||
var request = new SshConnectionRequest(
|
||||
row.Host.Hostname,
|
||||
row.Host.Port,
|
||||
Resolve(row.Host).Port.Value,
|
||||
authentication.Username,
|
||||
authentication.Credential);
|
||||
|
||||
@@ -4170,7 +4208,10 @@ internal sealed partial class VaultViewModel(
|
||||
}
|
||||
|
||||
request = new SshConnectionRequest(
|
||||
host.Hostname, host.Port, authentication.Username, authentication.Credential);
|
||||
host.Hostname,
|
||||
Resolve(host).Port.Value,
|
||||
authentication.Username,
|
||||
authentication.Credential);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user