test: wait for eventual state under a loaded race run

The approval request commits before the executor marks the parent
intention blocked, so the commitment test now waits for both instead of
asserting the status immediately. The milestone test's reply wait rises
from 20s to 90s; it returns as soon as the reply lands.
This commit is contained in:
Andy Dixon
2026-10-03 19:48:25 +01:00
parent 682f6c56ec
commit f609fae746
2 changed files with 8 additions and 5 deletions
+5 -2
View File
@@ -47,9 +47,12 @@ func TestCommitmentTurnsActionIntoRequestForApproval(t *testing.T) {
if it.Kind != volition.IntentRequestApproval || !it.RequireApproval { if it.Kind != volition.IntentRequestApproval || !it.RequireApproval {
t.Fatalf("intention should be to request approval: %+v", it) t.Fatalf("intention should be to request approval: %+v", it)
} }
waitFor(t, h, m, 15*time.Second, "an approval request", func() bool { // The approval request commits before the executor marks the intention
// blocked, so wait for both.
waitFor(t, h, m, 60*time.Second, "an approval request and a blocked intention", func() bool {
ap, _ := h.Deps.Capabilities.Approvals(ctx, m.ID, "pending", 10) ap, _ := h.Deps.Capabilities.Approvals(ctx, m.ID, "pending", 10)
return len(ap) == 1 cur, _ := h.Deps.Volition.GetIntention(ctx, nil, m.ID, it.ID)
return len(ap) == 1 && cur.Status == volition.IntentionBlocked
}) })
if host.count() != 0 { if host.count() != 0 {
t.Fatal("restart ran without approval") t.Fatal("restart ran without approval")
+3 -3
View File
@@ -173,7 +173,7 @@ func TestFirstMilestone(t *testing.T) {
Reply *conversation.Message `json:"reply"` Reply *conversation.Message `json:"reply"`
Note string `json:"note"` Note string `json:"note"`
} }
if code := h.do("POST", "/api/v1/minds/m1/ask", map[string]any{"text": "atlas has a failing disk.", "wait_seconds": 20}, &ask); code != 200 || ask.Reply == nil { if code := h.do("POST", "/api/v1/minds/m1/ask", map[string]any{"text": "atlas has a failing disk.", "wait_seconds": 90}, &ask); code != 200 || ask.Reply == nil {
t.Fatalf("ask 1: %d %+v", code, ask) t.Fatalf("ask 1: %d %+v", code, ask)
} }
if !strings.Contains(ask.Reply.Content, "Noted") || ask.Reply.LLMCallID.IsZero() || ask.Reply.EventID.IsZero() { if !strings.Contains(ask.Reply.Content, "Noted") || ask.Reply.LLMCallID.IsZero() || ask.Reply.EventID.IsZero() {
@@ -184,7 +184,7 @@ func TestFirstMilestone(t *testing.T) {
if intent.Kind != "acknowledge" || len(intent.Beliefs) != 1 { if intent.Kind != "acknowledge" || len(intent.Beliefs) != 1 {
t.Fatalf("intent 1 wrong: %+v", intent) t.Fatalf("intent 1 wrong: %+v", intent)
} }
if code := h.do("POST", "/api/v1/minds/m1/ask", map[string]any{"text": "What do you believe about atlas?", "wait_seconds": 20}, &ask); code != 200 || ask.Reply == nil { if code := h.do("POST", "/api/v1/minds/m1/ask", map[string]any{"text": "What do you believe about atlas?", "wait_seconds": 90}, &ask); code != 200 || ask.Reply == nil {
t.Fatalf("ask 2: %d %+v", code, ask) t.Fatalf("ask 2: %d %+v", code, ask)
} }
json.Unmarshal(ask.Reply.Intent, &intent) //nolint:errcheck json.Unmarshal(ask.Reply.Intent, &intent) //nolint:errcheck
@@ -274,7 +274,7 @@ func TestFirstMilestone(t *testing.T) {
t.Fatalf("state not continued after restart: before %d/%d after %d/%d", cycleBefore, len(ws.State.WorkingMemory), ws2.State.Cycle, len(ws2.State.WorkingMemory)) t.Fatalf("state not continued after restart: before %d/%d after %d/%d", cycleBefore, len(ws.State.WorkingMemory), ws2.State.Cycle, len(ws2.State.WorkingMemory))
} }
// 14. Continue the same mind: it still holds the belief and answers. // 14. Continue the same mind: it still holds the belief and answers.
if code := h2.do("POST", "/api/v1/minds/m1/ask", map[string]any{"text": "What do you believe about atlas?", "wait_seconds": 20}, &ask); code != 200 || ask.Reply == nil { if code := h2.do("POST", "/api/v1/minds/m1/ask", map[string]any{"text": "What do you believe about atlas?", "wait_seconds": 90}, &ask); code != 200 || ask.Reply == nil {
t.Fatalf("ask after restart: %d %+v", code, ask) t.Fatalf("ask after restart: %d %+v", code, ask)
} }
json.Unmarshal(ask.Reply.Intent, &intent) //nolint:errcheck json.Unmarshal(ask.Reply.Intent, &intent) //nolint:errcheck