20260906 - Give the fleet one order, the same on every node - #84
Merged
Merged
Conversation
Each node draws its own banner, and the sort put this node first, so an operator got a different row of tabs on every box and a tab moved under the cursor as they clicked through the fleet. Sort on the node_id alone. Everything else available drifts: the friendly name rides in a TXT record that can be a browse interval out of date, so during a rename the nodes genuinely disagree about the value they are sorting on, and an unnamed node sorts ahead of every named one until somebody names it, then jumps. The sequence node_id gives is arbitrary rather than meaningful, and that is the trade. An arbitrary order that never changes can be learned; a meaningful one that differs per node cannot. Which node you are looking at is answered by the active tab. The banner's self-injection, for the seconds before discovery populates, now sorts into place rather than prepending, so that window matches too. Verified on owl-ded9 against owl-debb: banner and Summary cards both read "Rooftop North | ret824685c9" on both nodes, with only the active marker moving. A mixed fleet still disagrees until every node has this. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
Every node draws its own banner, and
peers()sorted withnot is_selffirst, so each node put itself at the head of the row. Node A servedA, B, C; node B servedB, A, C. Users reported the tabs being in a different order depending on which node they happened to be on, and a tab moving under the cursor as they clicked through the fleet.Three smaller sources of drift sat behind it:
BROWSE_RESTART_SECONDS(60s) late, so during a rename the nodes genuinely disagree about the value they are sorting on.""beats any name), then jumped elsewhere the moment somebody named it.discovered_nodes()prepended this node when mDNS had not found it yet, so the seconds after boot used a different order again.The change
Sort on the
node_idalone, via a sharedmdns_peers.sort_key. It is derived from the board serial: unique, fixed for the life of the board, and known to every node the moment it has seen the peer at all.The sequence that produces is arbitrary rather than meaningful, and that is the trade. An arbitrary order that never changes can be learned; a meaningful one that differs per node cannot. Which node you are looking at is answered by the active tab, not by position, so pinning self to the front bought nothing.
discovered_nodes()now sorts its self-injection into place rather than prepending it, so the pre-discovery window matches what every other node is showing.The Summary cards share
discovered_nodes(), so they follow along.Verification
Full suite green (881 passed), ruff clean.
Tests: the old
test_this_node_sorts_first_then_by_nameasserted exactly the behaviour being removed, so it is replaced by three that pin down the new guarantee: order is bynode_idwherever you are standing, a rename does not move a tab (the TXT-lag case), and an unnamed node does not jump to the front.test_this_node_is_not_duplicated_once_discovery_finds_itwas incidentally order-dependent and now compares sets; a new sibling asserts self lands in sorted position rather than first.Live tested on
owl-ded9(ret824685c9) againstowl-debb(ret4c844c20). Before, ded9 servedret824685c9 | Rooftop Northwhile debb served the reverse. After, both the banner and the Summary cards readRooftop North | ret824685c9on both nodes, with only the "this node" marker moving.Worth knowing
order=NTXT record inowl-mdns-identityplus a GUI field, sorting on(order, node_id). It layers on top of this without regressing it.🤖 Generated with Claude Code