approval: the gate reads no held-back ask (the operator channel offers every ask)

Builds: design 47 H §764 (The operator channel's limit), H-A-57
This commit is contained in:
2026-11-20 02:31:54 +01:00
parent 59a73e72c0
commit bd2db73c3b
4 changed files with 16 additions and 5 deletions
+2 -2
View File
@@ -217,7 +217,7 @@ func (g *Gate) openAsk(module, id string) (bool, time.Time, error) {
return err == nil && k != nil && k.Ended == "", time.Time{}, nil // raised and not yet taken by the router
}
switch rec.State {
case "open", "held-back":
case "open":
return true, time.Time{}, nil
case "chosen":
if w := rec.Warrant; w != nil && w.Option == OptionDecline {
@@ -335,7 +335,7 @@ func (g *Gate) Decided(id string) {
g.d.Logf("[approval] the router's record of ask %s cannot be read (%v): read again at the next start", id, err)
return
}
if rec == nil || rec.State == "open" || rec.State == "held-back" {
if rec == nil || rec.State == "open" {
return
}
calls, err := g.waiting(func(w WaitingCall) bool { return w.Ask == id })
+11
View File
@@ -352,6 +352,17 @@ func TestAHolderHoldsAMarkedCall(t *testing.T) {
t.Fatalf("again: %+v, %v", answer, err)
}
})
t.Run("an ask in the old state held-back is no open ask: the call asks again (ADR 0682 section 14)", func(t *testing.T) {
w := setup()
_, h, _ := hold(t, w, call("n1.a", `{}`), true)
w.router.mu.Lock()
w.router.records[h.Asked] = &Record{State: "held-back"}
w.router.mu.Unlock()
_, h2, err := hold(t, w, call("n1.a", `{}`), false)
if err == nil || h2 != nil || strings.Contains(err.Error(), "still waiting") || len(w.router.asks) != 2 {
t.Errorf("the call: %v, %d asks, want it asked again", err, len(w.router.asks))
}
})
t.Run("a restart between the ask and the Approve runs the waiting call once", func(t *testing.T) {
w := setup()
_, h, _ := hold(t, w, call("n1.a", `{}`), true)
+1 -1
View File
@@ -190,7 +190,7 @@ func (g *Gate) judge(c Call, act operatorask.Act, digest, id, since string, run
return nil, fmt.Errorf("The ask %s %s; asked again. %w", id, why, err)
}
switch rec.State {
case "open", "held-back":
case "open":
return nil, fmt.Errorf("Not run: still waiting for the operator's answer to ask %s (fingerprint %s); it expires at %s",
id, Fingerprint(digest), rec.Expires)
case "refused":
+2 -2
View File
@@ -96,7 +96,7 @@ func (g *Gate) Waited(ctx context.Context, c Call, w Wait, hear func(within time
switch {
case err != nil:
return nil, g.holdRefused(ctx, deadline, g.refused(c, digest, "the router's record of its ask "+id+" cannot be read: "+err.Error()).Error())
case rec == nil, rec.State == "open", rec.State == "held-back":
case rec == nil, rec.State == "open":
return nil, g.holdAsk(ctx, deadline, c.Module, id, digest, false)
case rec.State == "refused":
return nil, g.holdRefused(ctx, deadline, g.refused(c, digest, "the router refused its ask "+id+": "+orNone(rec.Answer)).Error())
@@ -251,7 +251,7 @@ func (g *Gate) waitWords(rec *Record, id, digest string, first bool) error {
return fmt.Errorf("Not run: this wait needs the operator's approval. Asked on %s at %s (ask %s, fingerprint %s); make this wait "+
"again within 30 minutes of the approval; the ask expires at %s", orNone(strings.Join(rec.OfferedOn, ", ")), rec.Opened,
id, Fingerprint(digest), rec.Expires)
case rec.State == "open", rec.State == "held-back":
case rec.State == "open":
return fmt.Errorf("Not run: still waiting for the operator's answer to ask %s (fingerprint %s); it expires at %s",
id, Fingerprint(digest), rec.Expires)
}