From 4f1e92160acbeb35981af0352ca9550999d45983 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 8 Nov 2026 00:38:36 +0100 Subject: [PATCH] Round 1: the pin tests merged (test budget), KVWatch's doc says what folds The review of fe9533c1: a new test function raised a count already over the budget, so two broker-pin tests are one; KVWatch no longer yields every change, and its doc says so (issue 1966). Claude-Session: https://claude.ai/code/session_01NcbgfFfQ4Z9UE5jK32PmE5 --- internal/link/pinned_test.go | 10 +++------- internal/link/watch.go | 7 +++++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/internal/link/pinned_test.go b/internal/link/pinned_test.go index d3dbd6f..19ef8c1 100644 --- a/internal/link/pinned_test.go +++ b/internal/link/pinned_test.go @@ -61,8 +61,8 @@ func server(t *testing.T) (address string, fingerprint string) { return listener.Addr().String(), Fingerprint(der) } -// The right broker is accepted; and a malformed pin is caught before connecting, rather than at the handshake, so a mistyped -// token fails while a person is looking at it (two tests merged). +// The right broker is accepted, a different one refused, and a malformed pin is caught before connecting, rather than at +// the handshake, so a mistyped token fails while a person is looking at it (three tests merged). func TestTheRightBrokerIsAcceptedAndAMalformedPinRefused(t *testing.T) { address, pin := server(t) conn, err := dialPinned(address, pin, 5*time.Second) @@ -76,15 +76,11 @@ func TestTheRightBrokerIsAcceptedAndAMalformedPinRefused(t *testing.T) { t.Errorf("%q was accepted as a fingerprint", bad) } } -} -func TestADifferentBrokerIsRefused(t *testing.T) { // The case the pin exists for: something else answering at that address. Since the host // applies whatever the link delivers, connecting to the wrong mesh is the whole machine. - address, _ := server(t) _, other := server(t) - - _, err := dialPinned(address, other, 5*time.Second) + _, err = dialPinned(address, other, 5*time.Second) if err == nil { t.Fatal("a broker presenting a different certificate was accepted") } diff --git a/internal/link/watch.go b/internal/link/watch.go index 621ef6a..37d8816 100644 --- a/internal/link/watch.go +++ b/internal/link/watch.go @@ -23,8 +23,11 @@ type KVUpdate struct { // KVBus is a link that can watch a bucket's keys: the node agent follows its wants and its compositions with it, and // never polls. type KVBus interface { - // KVWatch yields the keys of the bucket matching the pattern now, a Caught update, then every change, until ctx ends - // or the link does (the channel is then closed). A bucket the node's account may not read is an error. The pattern + // KVWatch yields the keys of the bucket matching the pattern now, a Caught update, then the changes, until ctx ends + // or the link does (the channel is then closed). It never holds the bus client back: while the reader does not take, + // a key's changes fold into its newest (a delete included), so a reader sees each key's latest state, not every + // change, and a key still queued from before Caught is handed before Caught with its newest value; across keys the + // order is the order each key was first queued. A bucket the node's account may not read is an error. The pattern // may be several, separated by spaces (WatchPatterns), watched as one: a node's assignment in either form of its // keys (research 072 row 37). KVWatch(ctx context.Context, bucket, pattern string) (<-chan KVUpdate, error)