From 59a73e72c034325333c3ad9b5a13b41b9c43ceff Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 02:30:41 +0100 Subject: [PATCH] seatdef-verb-timeout: a verb's definition names a timeout of whole seconds, 1 to 600, others refused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Builds: design 47 H §760, H-A-43 --- go/seatdef/seatdef.go | 12 ++++++++++++ go/seatdef/seatdef_test.go | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/go/seatdef/seatdef.go b/go/seatdef/seatdef.go index 1a104c9f..63376b86 100644 --- a/go/seatdef/seatdef.go +++ b/go/seatdef/seatdef.go @@ -227,8 +227,17 @@ type Verb struct { // Chunks says the holder's process sends the answer's file in chunks, each acknowledged by the caller, on the // subjects mesh.seat..chunk... and mesh.seat..ack... (design 47 G §681). Chunks bool `json:"chunks,omitempty"` + // Timeout is the most whole seconds, MinTimeout to MaxTimeout, a caller and the serving tool runner wait for the + // verb's answer; nil, the tool runner's own call-timeout (design 47 H §760, H-A-43). + Timeout *int `json:"timeout,omitempty"` } +// The bounds of a verb's Timeout, in whole seconds (design 47 H-A-43). +const ( + MinTimeout = 1 + MaxTimeout = 600 +) + // The streams an accepted kind may ride (design 47 G §415). const ( StreamCheck = "check" @@ -813,6 +822,9 @@ func checkVerbs(vs []Verb, whole bool) Problems { } seen[v.Name] = true ps = append(ps, checkCallers(where+".callers", v.Callers)...) + if v.Timeout != nil && (*v.Timeout < MinTimeout || *v.Timeout > MaxTimeout) { + ps = append(ps, Problem{where + ".timeout", fmt.Sprintf("%d is not whole seconds from %d to %d", *v.Timeout, MinTimeout, MaxTimeout)}) + } if v.Class != "" && !slices.Contains(Classes, v.Class) { ps = append(ps, Problem{where + ".class", fmt.Sprintf("%q is not a class (%s)", v.Class, strings.Join(Classes, ", "))}) } diff --git a/go/seatdef/seatdef_test.go b/go/seatdef/seatdef_test.go index 61890a4e..63190174 100644 --- a/go/seatdef/seatdef_test.go +++ b/go/seatdef/seatdef_test.go @@ -132,6 +132,11 @@ func TestADefinitionIsReadStrictlyNamingWhatIsWrong(t *testing.T) { {"every form among callers", strings.Replace(whole, `"name":"list",`, `"name":"list","callers":["operator","healers","persons","sessions","invokers","seat:mesh-grants","module:mesh-grants","holder:node-backup@same-node"],`, 1), ""}, {"a holder not on the same node", strings.Replace(whole, `"name":"list",`, `"name":"list","callers":["holder:node-backup"],`, 1), "none of operator"}, + {"a verb's timeout of 120 seconds", strings.Replace(whole, `"name":"list",`, `"name":"list","timeout":120,`, 1), ""}, + {"a verb's timeout at either bound", strings.Replace(whole, `"name":"list",`, `"name":"list","timeout":600,`, 1), ""}, + {"a verb's timeout of none", strings.Replace(whole, `"name":"list",`, `"name":"list","timeout":0,`, 1), "verbs[0].timeout: 0 is not whole seconds from 1 to 600"}, + {"a verb's timeout over ten minutes", strings.Replace(whole, `"name":"list",`, `"name":"list","timeout":601,`, 1), "verbs[0].timeout: 601 is not whole seconds from 1 to 600"}, + {"a verb's timeout in fractions", strings.Replace(whole, `"name":"list",`, `"name":"list","timeout":1.5,`, 1), "not a seat definition's JSON"}, {"a class that is none", strings.Replace(whole, `"name":"list",`, `"name":"list","class":"free",`, 1), `verbs[0].class: "free" is not a class (read, act, warrant)`}, {"an accepted kind's callers", strings.Replace(whole, `"events":`, `"accepts":[{"name":"step","body":{},"callers":["seat:mesh-pipeline-runner"]}],"events":`, 1), ""}, {"an event's callers", strings.Replace(whole, `"name":"created"`, `"name":"created","callers":["operator"]`, 1), "only an accepted kind carries callers"},