From 9c61918ac36f80f5ec694040be10738fdfb59487 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 26 Oct 2026 12:12:53 +0100 Subject: [PATCH] =?UTF-8?q?delivery:=20a=20turn=20never=20holds=20the=20ch?= =?UTF-8?q?eck=20of=20heads=20that=20wait=20in=20it,=20so=20two=20approved?= =?UTF-8?q?=20merges=20in=20one=20turn=20never=20hold=20each=20other's=20c?= =?UTF-8?q?arry=20(ADR=200548=20=C2=A73;=20issue=20568,=20review=20round?= =?UTF-8?q?=201)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go/delivery/gate_test.go | 6 +++--- go/delivery/turns.go | 14 +++++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/go/delivery/gate_test.go b/go/delivery/gate_test.go index 227c81e..71ea691 100644 --- a/go/delivery/gate_test.go +++ b/go/delivery/gate_test.go @@ -202,9 +202,9 @@ func TestGateValuesRoundTrip(t *testing.T) { // 1201/AC4 t.Errorf("the turn lacks %s: %s", field, data) } } - // ADR 0548 §3: a turn holds off every check but the one of a waiting delivery's own heads. - if !TurnHolds(tu, "fedcba987654") || TurnHolds(Turn{Waiting: tu.Waiting[:1]}, tu.Waiting[0].Heads) || !TurnHolds(tu, tu.Waiting[0].Heads) { - t.Error("TurnHolds: a turn holds other heads' checks and never its only delivery's own") + // ADR 0548 §3: a turn holds off every check but those of the heads that wait in it, whoever else waits there. + if !TurnHolds(tu, "fedcba987654") || TurnHolds(tu, tu.Waiting[0].Heads) || TurnHolds(tu, tu.Waiting[1].Heads) || TurnHolds(Turn{}, "fedcba987654") { + t.Error("TurnHolds: a turn holds other heads' checks and never the check of heads waiting in it") } for name, dec := range map[string]func([]byte) error{ "turn": func(b []byte) error { _, err := DecodeTurn(b); return err }, diff --git a/go/delivery/turns.go b/go/delivery/turns.go index b0e86c4..e9f0000 100644 --- a/go/delivery/turns.go +++ b/go/delivery/turns.go @@ -117,15 +117,19 @@ func (t Turn) check() error { return nil } -// TurnHolds says whether a turn holds off the check of the heads: it names a delivery of other heads. The check of a waiting -// delivery's own heads (the carry its merge waits for) is never held by its own turn. +// TurnHolds says whether a turn holds off the check of the heads: it names deliveries, and none of them of these heads. A +// turn never holds the check of heads that wait in it (the carry a waiting merge needs): two approved merges in one turn whose +// trunk moved would otherwise each hold the other's carry, and neither would ever merge (review of ADR 0548's build, round 1). func TurnHolds(t Turn, heads string) bool { + if len(t.Waiting) == 0 { + return false + } for _, w := range t.Waiting { - if w.Heads != heads { - return true + if w.Heads == heads { + return false } } - return false + return true } // EncodeTurn is t as JSON at Version; it refuses a turn with no delivery, a repository that is not lowercase /,