Design 47 H2's corrections: ledger forms, ask once, the event hub by key, the away answers (issue 1984) #215

Merged
mesh-tools merged 16 commits from feat/47-H2-corrections into main 2026-11-25 20:11:45 +00:00
2 changed files with 15 additions and 2 deletions
Showing only changes of commit fd01ec91a2 - Show all commits
+5 -2
View File
@@ -67,10 +67,13 @@ func (c *Conn) CallKeptOn(node, key string, body any) (json.RawMessage, error) {
}
// KeptAsk is what a caller names of its kept call (design 47 H2 §775): the ask's id, which the call carries in the
// header stdio.AskHeader for the holder to take it once by (H-A-351), and the caller's bound (zero is busretry.Bound).
// header stdio.AskHeader for the holder to take it once by (H-A-351), the caller's bound (zero is busretry.Bound), and its
// hook (nil gives none): told when the call has waited busretry.WaitSaid and once at its answer, as busretry.Kept's is
// (design 47 H2 H-A-708 (4), H-A-731).
type KeptAsk struct {
ID string
Bound time.Duration
Hook func(busretry.Waited)
}
// CallKeptAsk is CallKept carrying ask's id and stopping at ask's bound: past it the error is a *busretry.Unanswered
@@ -110,7 +113,7 @@ func (c *Conn) callKeptAskOn(ask KeptAsk, node, key string, body any, open *busr
// keptOf is the paced form's naming of a call on key: its seat and verb, or its module and tool.
func keptOf(key string, ask KeptAsk, open *busretry.Open) busretry.Kept {
k := busretry.Kept{Ask: ask.ID, Bound: ask.Bound, Open: open}
k := busretry.Kept{Ask: ask.ID, Bound: ask.Bound, Open: open, Hook: ask.Hook}
if a, err := calladdress.Parse(key); err == nil {
k.Seat, k.Verb = a.Seat, a.Verb
if a.Seat == "" {
+10
View File
@@ -227,6 +227,16 @@ func TestACallIsAskedAgainOnlyWhenItReachedNoOne(t *testing.T) {
t.Errorf("%v answered %s", row.err, body)
}
}
// Design 47 H2 H-A-731: the hook a caller gives on its KeptAsk reaches the kept-call form, and a caller giving none gives none.
var hooked []busretry.Waited
k := keptOf("seat:mesh-catalog.revision", KeptAsk{ID: "ask-3", Hook: func(w busretry.Waited) { hooked = append(hooked, w) }}, nil)
if k.Hook == nil || k.Seat != "mesh-catalog" || k.Verb != "revision" || k.Ask != "ask-3" {
t.Fatalf("keptOf gave %+v", k)
}
k.Hook(busretry.Waited{Seat: k.Seat, Verb: k.Verb, Ask: k.Ask, Answered: true})
if len(hooked) != 1 || !hooked[0].Answered || keptOf("seat:mesh-catalog.revision", KeptAsk{}, nil).Hook != nil {
t.Errorf("the hook on KeptAsk: told %+v", hooked)
}
// Design 47 H2 §775, H-A-405: a kept chunked call (CallChunksKept, CallFileKept) asks its verb through the kept-call
// form, carries its one ask id on every chunk's acknowledgement, and past its bound ends with the kept call's words.
send := buscalls.SeatChunks{Seat: "node-build-go", Verb: "output", Call: "c1"}