D10: the assigner calls the operator-channel seat's asks with its declared input and reads its declared answer (issue 1966, ADR 0668 §4; review round 1, finding 5)

Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
2026-11-10 04:20:04 +01:00
parent 23ddaa8bed
commit 00e84bb977
2 changed files with 5 additions and 15 deletions
@@ -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 {
@@ -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 ("<asker>.<id>", 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)
}