Sign the completion and the probe with the same token (V-673)
llm.Client carries a bearer credential and sets it on the completion, and Pair signs the /health probe with it too. An unsigned probe would answer 401, Pair would read that as a card that is busy, and every workstation turn would fall back to the resident model with nothing naming why. The token comes from workstation.token, expanded from MAVEN_GPU_TOKEN like every other secret in that file. Missing, and voicewire says so at startup: the fallback is silent by design and this failure would otherwise be invisible. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESv8hqNPseYt1CnotZpqDz
This commit is contained in:
@@ -250,3 +250,35 @@ func TestNoFloorIsAnError(t *testing.T) {
|
||||
t.Fatalf("err = %v, want ErrNoFloor", err)
|
||||
}
|
||||
}
|
||||
|
||||
// The workstation is behind mavgpud, which requires a bearer token on the
|
||||
// completion and on /health alike. A probe that did not carry it would answer
|
||||
// 401, Pair would read that as a card that is busy, and every turn would fall
|
||||
// back to the resident model with nothing in the log naming why.
|
||||
func TestPairSignsTheProbeAndTheCompletion(t *testing.T) {
|
||||
seen := make(chan string, 2)
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
seen <- r.Header.Get("Authorization")
|
||||
if r.URL.Path == "/health" {
|
||||
return
|
||||
}
|
||||
_, _ = w.Write([]byte(`{"choices":[{"message":{"content":"ok"}}]}`))
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
remote := New(srv.URL, time.Second)
|
||||
remote.SetToken("s3cret")
|
||||
p := NewPair(remote, New(srv.URL, time.Second), srv.URL+"/health", time.Hour)
|
||||
p.probe(context.Background())
|
||||
if !p.Available() {
|
||||
t.Fatal("the probe did not admit an answering workstation")
|
||||
}
|
||||
if _, err := p.Complete(context.Background(), Req{User: "привет"}); err != nil {
|
||||
t.Fatalf("complete: %v", err)
|
||||
}
|
||||
for i := 0; i < 2; i++ {
|
||||
if got := <-seen; got != "Bearer s3cret" {
|
||||
t.Errorf("request %d carried %q, want the bearer token", i, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user