seatdef-verb-timeout: a verb's definition names a timeout of whole seconds, 1 to 600, others refused

Builds: design 47 H §760, H-A-43
This commit is contained in:
2026-11-20 02:30:41 +01:00
parent be306f4a04
commit 59a73e72c0
2 changed files with 17 additions and 0 deletions
+12
View File
@@ -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.<seat>.chunk.<verb>.<call>.<n> and mesh.seat.<seat>.ack.<verb>.<call>.<n> (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, ", "))})
}
+5
View File
@@ -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"},