From 00e84bb977f9052f669aadd304e74f8983ccceb7 Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 10 Nov 2026 04:20:04 +0100 Subject: [PATCH] =?UTF-8?q?D10:=20the=20assigner=20calls=20the=20operator-?= =?UTF-8?q?channel=20seat's=20asks=20with=20its=20declared=20input=20and?= =?UTF-8?q?=20reads=20its=20declared=20answer=20(issue=201966,=20ADR=20066?= =?UTF-8?q?8=20=C2=A74;=20review=20round=201,=20finding=205)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ --- .../internal/assign/asks_test.go | 2 +- .../internal/assign/ended.go | 18 ++++-------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/modules/mesh-delivery-assigner/internal/assign/asks_test.go b/modules/mesh-delivery-assigner/internal/assign/asks_test.go index d550f1fa..5264609f 100644 --- a/modules/mesh-delivery-assigner/internal/assign/asks_test.go +++ b/modules/mesh-delivery-assigner/internal/assign/asks_test.go @@ -147,7 +147,7 @@ func anAskEndedAtTheChannelIsReadAtBind(t *testing.T) { t.Error("with no ask held the channel is asked") } q, ok := ChannelAsksQuery(held) - if since, _ := q["since"].(string); !ok || q["state"] != "ended" || since != asked.Add(-time.Hour-time.Minute).Format(time.RFC3339) { + if !ok || q.State != "ended" || q.Bound != ChannelAsksBound || q.Since != asked.Add(-time.Hour-time.Minute).Format(time.RFC3339) { t.Errorf("the query is %v, want the ended asks since %s", q, asked.Add(-time.Hour-time.Minute).Format(time.RFC3339)) } at := func(key string, a asks.Ask, state string) string { diff --git a/modules/mesh-delivery-assigner/internal/assign/ended.go b/modules/mesh-delivery-assigner/internal/assign/ended.go index 8b5e4e7f..a59e1bbf 100644 --- a/modules/mesh-delivery-assigner/internal/assign/ended.go +++ b/modules/mesh-delivery-assigner/internal/assign/ended.go @@ -84,7 +84,7 @@ const ChannelAsksBound = 1 << 20 // every asking of its held asks (key to value, as the asks state holds them) that ended at the channel: the ended asks // opened since the earliest of them could have been opened, less a minute (issue 1966 note 155, ADR 0668 §4). ok is false // when no held ask reads, and then nothing is asked. -func ChannelAsksQuery(held map[string][]byte) (query map[string]any, ok bool) { +func ChannelAsksQuery(held map[string][]byte) (query oc.AsksInput, ok bool) { var since time.Time for key, value := range held { a, ask, err := DecodeAsk(key, value) @@ -102,19 +102,9 @@ func ChannelAsksQuery(held map[string][]byte) (query map[string]any, ok bool) { } } if !ok { - return nil, false + return oc.AsksInput{}, false } - return map[string]any{"state": "ended", "since": since.Add(-time.Minute).UTC().Format(time.RFC3339), "bound": ChannelAsksBound}, true -} - -// channelAsks is what the assigner reads of the verb asks' answer: each ask's key (".", the seat's state asks) -// and the state it ended with. -type channelAsks struct { - Asks []struct { - Key string `json:"key"` - State string `json:"state"` - } `json:"asks"` - Cut string `json:"cut"` + return oc.AsksInput{State: "ended", Since: since.Add(-time.Minute).UTC().Format(time.RFC3339), Bound: ChannelAsksBound}, true } // EndedAtChannel is, of the operator-channel seat's answer of its verb asks, each held ask whose asking ended there @@ -123,7 +113,7 @@ type channelAsks struct { // to it (issue 1966 note 155, ADR 0668 §4). cut is the answer's own cut, said by the caller; an answer that does not read // is the error. func EndedAtChannel(held map[string][]byte, answer []byte) (ended []tellerevents.Ended, cut string, err error) { - var got channelAsks + var got oc.AsksAnswer // the seat's declared answer: each ask's key and its state, and the cut if err := json.Unmarshal(answer, &got); err != nil { return nil, "", fmt.Errorf("assign: the operator channel's asks do not read: %w", err) }