T1b verb-timeout-serve: a verb served from a bundle waits the timeout its definition names
Tool gains RunWithin and Within; a bundle's tool call waits `within` where the seat verb it serves names a timeout, else CallTimeout. serveSeats takes the bound of a verb's key beside `chunked`. Builds: design 47 H §760, H-A-43 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
@@ -82,7 +82,8 @@ while IFS= read -r line; do
|
||||
case "$line" in
|
||||
*'"method":"initialize"'*) echo started >&2; printf '{"jsonrpc":"2.0","id":%s,"result":{}}\n' "$id" ;;
|
||||
*'"method":"tools/list"'*) printf '{"jsonrpc":"2.0","id":%s,"result":{"tools":[{"name":"t","description":"d"}]}}\n' "$id" ;;
|
||||
*'"method":"tools/call"'*) [ "$MODE" = long ] && printf '%4096s\n' x ;;
|
||||
*'"method":"tools/call"'*) [ "$MODE" = long ] && printf '%4096s\n' x
|
||||
[ "$MODE" = late ] && { sleep 0.3; printf '{"jsonrpc":"2.0","id":%s,"result":{"content":[{"type":"text","text":"{}"}]}}\n' "$id"; } ;;
|
||||
esac
|
||||
done
|
||||
`
|
||||
@@ -150,3 +151,28 @@ func TestAnOverlongLineAndAnUnansweredCallAreSaid(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Design 47 H §760: a verb served from a bundle waits the `timeout` its definition names, not the runner's own bound: a bundle
|
||||
// that answers after CallTimeout is answered through Within and fails through Run.
|
||||
func TestAToolWithinWaitsTheBoundItsVerbNames(t *testing.T) {
|
||||
oldCall := CallTimeout
|
||||
CallTimeout = 100 * time.Millisecond
|
||||
t.Cleanup(func() { CallTimeout = oldCall })
|
||||
dir := t.TempDir()
|
||||
entry := filepath.Join(dir, "bundle")
|
||||
if err := os.WriteFile(entry, []byte(callingBundle), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
l, err := Start("caller", entry, append(os.Environ(), "MODE=late"), &refusingState{}, func(string, ...any) {})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(l.Stop)
|
||||
tool := l.Registrations[0].Tools[0]
|
||||
if _, err := tool.Run("caller-1", nil); err == nil || !strings.Contains(err.Error(), "did not answer") {
|
||||
t.Fatalf("a call that waits the runner's own bound of 100ms: %v, want it unanswered", err)
|
||||
}
|
||||
if got, err := tool.Within(5*time.Second).Run("caller-1", nil); err != nil || string(got) != "{}" {
|
||||
t.Fatalf("a call that waits the verb's 5s: %s, %v, want its answer", got, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user