From 393fb4d70fc6bf88debc4ca13d644ea7de9602f5 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 17 Nov 2026 16:32:23 +0000 Subject: dashboard: the federation, in a swarm holding a store MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In a swarm holding a store, the snapshot names the node's party, and the document box shows what counts as the node reads it, read every 5 s: the current version, the parties with their keys and nodes, the rules, the values at places as a tree with who writes there, the proposals on the version with where each stands, who voted what and what its version changes, and what the node refused. `document` beside `remake…` shows the document underneath. Where the node votes for its party by itself, a proposal that can still pass has a vote of each kind, cast through the node on a second click. The page writes no values: a party signs its writes with its key. --- src/api/dashboard/check.js | 52 +++++- src/api/dashboard/dashboard.html | 383 ++++++++++++++++++++++++++++++++++++++- src/api/dashboard/mod.rs | 10 +- 3 files changed, 436 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/api/dashboard/check.js b/src/api/dashboard/check.js index 95f805a..4292e7d 100644 --- a/src/api/dashboard/check.js +++ b/src/api/dashboard/check.js @@ -2,8 +2,9 @@ // dashboard_in_a_browser -- --ignored`, which serves this the page as the node does): the // page loads without errors; the peers table has a row per peer, and an update changes // cells without making the rows anew (`morphChildren`); the map draws a node per member; -// and with 300 members, laid out by round trip, the first drawing doesn't hold the page up -// for long (`LAYOUT_FOR_MS`). +// with 300 members, laid out by round trip, the first drawing doesn't hold the page up +// for long (`LAYOUT_FOR_MS`); and in a swarm holding a store, the document box shows the +// federation: who writes at a place, what a proposal changes, and the votes. // // Needs Node.js, Playwright's library (`playwright-core`) and its Chromium; `check.nix` // gives all three from nixpkgs. @@ -77,6 +78,53 @@ const check = (ok, what) => { check(map.ms < budget, `${n} members drawn in ${map.ms.toFixed(0)} ms (under ${budget})`); } + // The federation, as the node would answer (`GET /events`, `/events/counts`, …). + const federated = await tab.evaluate(() => { + const rules = [{ path: "home/{party}/**", writer: "{party}" }, + { path: "names/*", writer: "tv" }, { path: "names/**", writer: false }]; + const writers = ["home/tv/motd", "home/tv", "home/makefu/motd", "names/r", "names/r/s"] + .map(path => writerAt(rules, ["tv", "lass"], path)); + const version = { federation: 1, number: 0, changes: null, + keys: { tv: { since: 0, keys: ["ssh-ed25519 AAAA1"] }, + lass: { since: 0, keys: ["ssh-ed25519 AAAA2"] } }, + nodes: { tv: { since: 0, nodes: ["continuum:a"] }, lass: { since: 0, nodes: [] } }, + rules }; + const next = { ...version, number: 1, changes: "11", + keys: { ...version.keys, lass: { since: 1, keys: ["ssh-ed25519 AAAA3"] } } }; + state = { node: { id: "continuum:a", alias: "a", party: "tv" }, stats: {}, + peers: { localReaches: [], peers: {} }, graph: { members: {}, intended: {}, measured: {} } }; + federationTimer = 1; + federation.summary = { store: "aa", checkpoint: "aa", heads: ["bb"], taken: 3, + party: "tv", votesByItself: true }; + federation.heads = "bb"; + federation.counts = { version: { number: 0, hash: "11", version }, + parties: { tv: { keys: ["ssh-ed25519 AAAA1"], nodes: ["continuum:a"] }, + lass: { keys: ["ssh-ed25519 AAAA2"], nodes: [] } }, + values: { "home/tv/motd": "hello", "home/tv/hosts/laptop": { ip6: "42::1" } }, + members: [["continuum:a", "tv"]], + proposals: { "22": { proposals: ["cc"], votes: ["dd"], yes: ["tv"], no: [], + passed: false, dead: false } } }; + federation.refused = { own: [], dropped: [], refused: [] }; + federation.versions.set("22", next); + showFederation(); + renderFederation(true); + const tree = document.getElementById("federation"); + return { writers, title: document.getElementById("document-title").textContent, + shown: !document.getElementById("federation-scroll").hidden + && document.getElementById("document-scroll").hidden, + text: tree.textContent, votes: tree.querySelectorAll(".votes button").length }; + }); + check(JSON.stringify(federated.writers) === JSON.stringify(["tv", null, null, "tv", null]), + "who writes at a place is the first rule matching it: " + JSON.stringify(federated.writers)); + check(federated.title === "Federation" && federated.shown, + "in a swarm holding a store, the document box shows the federation"); + check(federated.text.includes("motd: \"hello\" by tv"), "a value, with who writes there"); + check(federated.text.includes("can still pass") && federated.text.includes("number: 0 -> 1") + && federated.text.includes('keys.lass: {"keys":["ssh-ed25519 AAAA2"],"since":0} -> ' + + '{"keys":["ssh-ed25519 AAAA3"],"since":1}'), + "a proposal: where it stands, and what its version changes, party by party"); + check(federated.votes === 2, "a proposal that can still pass has a vote of each kind"); + await tab.waitForTimeout(500); check(errors.length === 0, "no errors on the page" + (errors.length ? ": " + errors : "")); await browser.close(); diff --git a/src/api/dashboard/dashboard.html b/src/api/dashboard/dashboard.html index a20e64c..a918532 100644 --- a/src/api/dashboard/dashboard.html +++ b/src/api/dashboard/dashboard.html @@ -328,6 +328,15 @@ .tree details[open] > summary::before { content: "▾"; } .tree details > .note { padding-left: 1.1em; } .key { color: var(--muted); } + /* The federation (`#federation`): where a proposal stands, its votes, the filter. */ + #federation .standing { font-weight: 600; } + #federation .standing.passed { color: var(--ok); } + #federation .standing.dead { color: var(--bad); } + #federation .leaf { overflow-wrap: anywhere; } + #federation input.filter { width: 100%; box-sizing: border-box; font: inherit; + color: var(--fg); background: var(--bg); border: 1px solid var(--line); + border-radius: 4px; padding: 2px 4px; margin: 2px 0 4px; } + #federation .votes button.toggle { float: none; margin: 2px 6px 2px 0; } /* What a value or key means, after it (`gloss`): an alias, a time, a size. */ .gloss { color: var(--muted); } @@ -387,8 +396,9 @@
-

Document

+

Document