Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Refresh Assistant handoff finding context
rcourtman50fee63c9ecb
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex c68935bd27..e84b104417 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -360,13 +360,17 @@ profile and assignment columns, but embedded table framing must route throughcontext for a Patrol finding, including same-session metadata retained forfollow-up turns and any resolved-resource scope hydrated from that finding,is also not agent lifecycle state and must not be used as enrollment- evidence, command-websocket identity, or installer authority. Structured- Assistant handoff action references from the same Patrol finding remain- AI/runtime review metadata only; lifecycle code must not treat approval IDs,- fix IDs, risk, or target-resource labels from that handoff as agent command- grants, enrollment proof, or auto-approval policy. Any approval status- snapshot refreshed for Assistant review remains read-only AI/runtime context- and must not become command-websocket authority or lifecycle execution state.+ evidence, command-websocket identity, or installer authority. If Assistant+ stores the originating finding ID to refresh the current unified finding and+ investigation record on follow-up turns, that stored reference remains an+ AI/runtime context selector and still cannot become agent enrollment,+ lifecycle, or command-websocket authority. Structured Assistant handoff action+ references from the same Patrol finding remain AI/runtime review metadata+ only; lifecycle code must not treat approval IDs, fix IDs, risk, or+ target-resource labels from that handoff as agent command grants, enrollment+ proof, or auto-approval policy. Any approval status snapshot refreshed for+ Assistant review remains read-only AI/runtime context and must not become+ command-websocket authority or lifecycle execution state.The same isolation rule applies to CSRF token-store behavior in`internal/api/csrf_store.go`: lifecycle-adjacent browser flows may rely onthe shared API/security layer to keep parallel replacement-token retriesdiff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex b4646a44db..2be3095bd5 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -185,11 +185,16 @@ runtime cost control, and shared AI transport surfaces.references may persist as session model-context metadata for follow-up turns,but they remain references only; each turn must rehydrate them from thecurrent canonical unified-resource model before action validation can use- them. Assistant runtime may also hydrate canonical resource-policy context- for those handoff resources, using the same unified-resource resolution and- policy presentation helpers that govern mention prefetch and provider-bound- redaction; that context remains model-only handling guidance, not saved user- text or disclosure authority. Assistant runtime may also hydrate canonical+ them. Structured finding references from Patrol/Assistant handoffs may also+ persist as session model-context metadata so follow-up turns can refresh the+ current unified finding and investigation record before model execution;+ those references remain model-only context selectors, not saved user text or+ lifecycle authority. Assistant runtime may also hydrate canonical+ resource-policy context for those handoff resources, using the same+ unified-resource resolution and policy presentation helpers that govern+ mention prefetch and provider-bound redaction; that context remains+ model-only handling guidance, not saved user text or disclosure authority.+ Assistant runtime may also hydrate canonicalrelationship context for those handoff resources through`FormatResourceRelationshipContext(...)` and canonical parent-edge synthesis,but those topology facts remain read-only explanation context and do notdiff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 9bd9cb424e..e8fa9ac143 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -756,7 +756,11 @@ the canonical monitored-system blocked payload.affect session-scoped action validation. If stored for follow-up turns, theyremain model-context references rather than saved user text or actionauthority, and the runtime must re-resolve them against current canonical- resources before use. Chat execution may also hydrate canonical+ resources before use. The API/chat boundary may also store the originating+ finding ID as model-context metadata so later turns in the same Assistant+ session can refresh the current unified finding and investigation record+ before model execution; that reference is not lifecycle authority and must not+ be persisted as user text. Chat execution may also hydrate canonicalresource-policy context for those resources through unified-resourceresolution and shared policy presentation helpers, but the resulting handlingguidance is read-only, model-only context and must not become saved user text,diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.mdindex 8681bc7389..8a24ade4a1 100644--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md@@ -109,13 +109,13 @@ Patrol-specific presentation helpers.approval's current status for review, but Patrol presentation must still keepcommand payloads inside governed approval/remediation context rather thanrendering them as handoff copy. Assistant may also enrich that same handoff- with canonical resource-policy guidance, canonical resource-relationship- context, and recent canonical resource-timeline changes for explanation;- Assistant resolves those timeline lookups through the current canonical- unified-resource model before falling back to handoff IDs. Patrol must keep- the visible finding and drawer briefing tied to the shared investigation- payload rather than forking a Patrol-local policy, topology, or timeline- summary.+ with refreshed unified finding and investigation-record state, canonical+ resource-policy guidance, canonical resource-relationship context, and recent+ canonical resource-timeline changes for explanation; Assistant resolves those+ timeline lookups through the current canonical unified-resource model before+ falling back to handoff IDs. Patrol must keep the visible finding and drawer+ briefing tied to the shared investigation payload rather than forking a+ Patrol-local lifecycle, policy, topology, or timeline summary.## Current Statediff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 634b682d50..15bb2cc4ab 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -416,14 +416,18 @@ bypass the API fail-closed execution gate.unchanged. If the same handoff seeds Assistant resolved-resource scope, thatscope remains AI/runtime action-validation context only and still cannotbecome backup freshness, restore eligibility, or storage-local recovery- authority. Structured action or approval references carried by that handoff- are also adjacent AI/runtime review metadata only; storage and recovery- surfaces must not reinterpret approval IDs, fix IDs, risk, or target labels- as restore support, backup freshness, recovery execution authority, or a- storage-local approval bypass. Any refreshed approval status snapshot in- Assistant handoff context is still read-only AI/runtime context and must not- become recovery freshness, restore eligibility, or storage-local execution- state.+ authority. If Assistant stores the originating finding ID to refresh current+ unified finding and investigation-record context on follow-up turns, that+ stored reference is still an adjacent AI/runtime context selector and must+ not become backup freshness, restore support, recovery execution authority,+ or storage-local lifecycle state. Structured action or approval references+ carried by that handoff are also adjacent AI/runtime review metadata only;+ storage and recovery surfaces must not reinterpret approval IDs, fix IDs,+ risk, or target labels as restore support, backup freshness, recovery+ execution authority, or a storage-local approval bypass. Any refreshed+ approval status snapshot in Assistant handoff context is still read-only+ AI/runtime context and must not become recovery freshness, restore+ eligibility, or storage-local execution state.That same adjacent `internal/api/` boundary still carries Patrol-runexecution identity. Storage and recovery may observe shared Patroltransport through `internal/api/chat_service_adapter.go`, but they must notdiff --git a/internal/ai/chat/service.go b/internal/ai/chat/service.goindex 05cc66d95d..06f9338626 100644--- a/internal/ai/chat/service.go+++ b/internal/ai/chat/service.go@@ -452,6 +452,12 @@ func (s *Service) ExecuteStream(ctx context.Context, req ExecuteRequest, callbachandoffContext := strings.TrimSpace(req.HandoffContext)handoffResources := normalizeHandoffResources(req.HandoffResources)handoffActions := normalizeHandoffActions(req.HandoffActions)+ handoffFindingID := strings.TrimSpace(req.FindingID)+ if handoffFindingID != "" {+ if err := sessions.SetModelHandoffFindingID(session.ID, handoffFindingID); err != nil {+ log.Warn().Err(err).Str("session_id", session.ID).Msg("[ChatService] Failed to persist model handoff finding reference")+ }+ }if handoffContext != "" {if err := sessions.SetModelHandoffContext(session.ID, handoffContext); err != nil {log.Warn().Err(err).Str("session_id", session.ID).Msg("[ChatService] Failed to persist model handoff context")@@ -1590,6 +1596,20 @@ func (s *Service) GetMessages(ctx context.Context, sessionID string) ([]Message,return sessions.GetMessages(sessionID)}+// GetModelHandoffFindingID returns the session-scoped finding reference used to+// refresh model-only Patrol context on follow-up turns.+func (s *Service) GetModelHandoffFindingID(ctx context.Context, sessionID string) (string, error) {+ s.mu.RLock()+ sessions := s.sessions+ s.mu.RUnlock()++ if sessions == nil {+ return "", fmt.Errorf("service not started")+ }++ return sessions.GetModelHandoffFindingID(sessionID)+}+// AbortSession aborts an ongoing sessionfunc (s *Service) AbortSession(ctx context.Context, sessionID string) error {s.mu.RLock()diff --git a/internal/ai/chat/service_execute_additional_test.go b/internal/ai/chat/service_execute_additional_test.goindex ac01d7dc55..6cda82d89c 100644--- a/internal/ai/chat/service_execute_additional_test.go+++ b/internal/ai/chat/service_execute_additional_test.go@@ -189,6 +189,7 @@ func TestService_ExecuteStream_HandoffContextIsModelOnly(t *testing.T) {req := ExecuteRequest{SessionID: "sess-handoff",Prompt: "What happened?",+ FindingID: "finding-123",HandoffContext: "[Finding Context]\nID: finding-123\nConclusion: CPU saturated after backup.",HandoffResources: []HandoffResource{{ID: "vm-100",@@ -233,6 +234,13 @@ func TestService_ExecuteStream_HandoffContextIsModelOnly(t *testing.T) {if strings.Contains(stored[0].Content, "Recent Changes Across Infrastructure") {t.Fatalf("stored user message should not include timeline context: %q", stored[0].Content)}+ storedFindingID, err := store.GetModelHandoffFindingID("sess-handoff")+ if err != nil {+ t.Fatalf("GetModelHandoffFindingID failed: %v", err)+ }+ if storedFindingID != "finding-123" {+ t.Fatalf("stored handoff finding ID = %q, want finding-123", storedFindingID)+ }if len(capturedMessages) == 0 {t.Fatal("expected provider messages")diff --git a/internal/ai/chat/session.go b/internal/ai/chat/session.goindex 2a74f377c5..136db877ce 100644--- a/internal/ai/chat/session.go+++ b/internal/ai/chat/session.go@@ -51,6 +51,7 @@ type sessionData struct {}type sessionModelContext struct {+ HandoffFindingID string `json:"handoff_finding_id,omitempty"`HandoffContext string `json:"handoff_context,omitempty"`HandoffResources []HandoffResource `json:"handoff_resources,omitempty"`HandoffActions []HandoffAction `json:"handoff_actions,omitempty"`@@ -128,7 +129,8 @@ func modelContextEmpty(modelContext *sessionModelContext) bool {if modelContext == nil {return true}- return strings.TrimSpace(modelContext.HandoffContext) == "" &&+ return strings.TrimSpace(modelContext.HandoffFindingID) == "" &&+ strings.TrimSpace(modelContext.HandoffContext) == "" &&len(normalizeHandoffResources(modelContext.HandoffResources)) == 0 &&len(normalizeHandoffActions(modelContext.HandoffActions)) == 0}@@ -381,6 +383,34 @@ func (s *SessionStore) AddMessage(id string, msg Message) error {return s.writeSession(*data)}+// SetModelHandoffFindingID stores the product-originated finding reference for+// follow-up turns. The reference lets API handlers refresh the current Patrol+// context without treating the finding as user-authored chat text.+func (s *SessionStore) SetModelHandoffFindingID(id, findingID string) error {+ findingID = strings.TrimSpace(findingID)+ if findingID == "" {+ return nil+ }++ s.mu.Lock()+ defer s.mu.Unlock()++ data, err := s.readSession(id)+ if err != nil {+ return err+ }++ now := time.Now()+ if data.ModelContext == nil {+ data.ModelContext = &sessionModelContext{}+ }+ data.ModelContext.HandoffFindingID = findingID+ data.ModelContext.UpdatedAt = now+ data.UpdatedAt = now++ return s.writeSession(*data)+}+// SetModelHandoffContext stores model-only handoff context for future turns.// It is intentionally session metadata, not a user-authored chat message.func (s *SessionStore) SetModelHandoffContext(id, handoffContext string) error {@@ -464,6 +494,22 @@ func (s *SessionStore) SetModelHandoffActions(id string, handoffActions []Handofreturn s.writeSession(*data)}+// GetModelHandoffFindingID returns the stored product-originated finding+// reference for a session.+func (s *SessionStore) GetModelHandoffFindingID(id string) (string, error) {+ s.mu.RLock()+ defer s.mu.RUnlock()++ data, err := s.readSession(id)+ if err != nil {+ return "", err+ }+ if data.ModelContext == nil {+ return "", nil+ }+ return strings.TrimSpace(data.ModelContext.HandoffFindingID), nil+}+// GetModelHandoffContext returns model-only handoff context for a session.func (s *SessionStore) GetModelHandoffContext(id string) (string, error) {s.mu.RLock()diff --git a/internal/ai/chat/session_additional_test.go b/internal/ai/chat/session_additional_test.goindex 52a2c87ef8..d70313d42b 100644--- a/internal/ai/chat/session_additional_test.go+++ b/internal/ai/chat/session_additional_test.go@@ -59,6 +59,24 @@ func TestSessionStore_ModelHandoffContextLifecycle(t *testing.T) {if initial != "" {t.Fatalf("initial handoff context = %q, want empty", initial)}+ initialFindingID, err := store.GetModelHandoffFindingID(session.ID)+ if err != nil {+ t.Fatalf("GetModelHandoffFindingID failed: %v", err)+ }+ if initialFindingID != "" {+ t.Fatalf("initial handoff finding ID = %q, want empty", initialFindingID)+ }++ if err := store.SetModelHandoffFindingID(session.ID, " finding-123 "); err != nil {+ t.Fatalf("SetModelHandoffFindingID failed: %v", err)+ }+ gotFindingID, err := store.GetModelHandoffFindingID(session.ID)+ if err != nil {+ t.Fatalf("GetModelHandoffFindingID failed: %v", err)+ }+ if gotFindingID != "finding-123" {+ t.Fatalf("handoff finding ID = %q, want finding-123", gotFindingID)+ }handoffContext := " [Finding Context]\nID: finding-123\nConclusion: CPU saturated after backup. "if err := store.SetModelHandoffContext(session.ID, handoffContext); err != nil {@@ -158,6 +176,13 @@ func TestSessionStore_ModelHandoffContextLifecycle(t *testing.T) {if len(reloadedResources) != 1 || reloadedResources[0].ID != "vm-100" {t.Fatalf("reloaded handoff resources = %#v, want persisted VM reference", reloadedResources)}+ reloadedFindingID, err := reloadedStore.GetModelHandoffFindingID(session.ID)+ if err != nil {+ t.Fatalf("GetModelHandoffFindingID after reload failed: %v", err)+ }+ if reloadedFindingID != "finding-123" {+ t.Fatalf("reloaded handoff finding ID = %q, want finding-123", reloadedFindingID)+ }reloadedActions, err := reloadedStore.GetModelHandoffActions(session.ID)if err != nil {t.Fatalf("GetModelHandoffActions after reload failed: %v", err)@@ -183,6 +208,13 @@ func TestSessionStore_ModelHandoffContextLifecycle(t *testing.T) {if got != strings.TrimSpace(handoffContext) {t.Fatalf("handoff context after resource clear = %q, want retained context", got)}+ gotFindingID, err = store.GetModelHandoffFindingID(session.ID)+ if err != nil {+ t.Fatalf("GetModelHandoffFindingID after resource clear failed: %v", err)+ }+ if gotFindingID != "finding-123" {+ t.Fatalf("handoff finding ID after resource clear = %q, want retained finding reference", gotFindingID)+ }gotActions, err = store.GetModelHandoffActions(session.ID)if err != nil {t.Fatalf("GetModelHandoffActions after resource clear failed: %v", err)@@ -247,6 +279,13 @@ func TestSessionStore_ModelHandoffContextLifecycle(t *testing.T) {if len(gotActions) != 1 {t.Fatalf("expected keep-pinned context clear to retain handoff actions, got %#v", gotActions)}+ gotFindingID, err = store.GetModelHandoffFindingID(session.ID)+ if err != nil {+ t.Fatalf("GetModelHandoffFindingID after keep-pinned clear failed: %v", err)+ }+ if gotFindingID != "finding-123" {+ t.Fatalf("expected keep-pinned context clear to retain finding reference, got %q", gotFindingID)+ }store.ClearSessionState(session.ID, false)got, err = store.GetModelHandoffContext(session.ID)@@ -270,6 +309,13 @@ func TestSessionStore_ModelHandoffContextLifecycle(t *testing.T) {if len(gotActions) != 0 {t.Fatalf("handoff actions after full clear = %#v, want empty", gotActions)}+ gotFindingID, err = store.GetModelHandoffFindingID(session.ID)+ if err != nil {+ t.Fatalf("GetModelHandoffFindingID after full clear failed: %v", err)+ }+ if gotFindingID != "" {+ t.Fatalf("handoff finding ID after full clear = %q, want empty", gotFindingID)+ }}func TestSessionStore_ResolvedContextLifecycle(t *testing.T) {diff --git a/internal/api/ai_handler.go b/internal/api/ai_handler.goindex 30339a0240..808e345c0a 100644--- a/internal/api/ai_handler.go+++ b/internal/api/ai_handler.go@@ -43,6 +43,7 @@ type AIService interface {CreateSession(ctx context.Context) (*chat.Session, error)DeleteSession(ctx context.Context, sessionID string) errorGetMessages(ctx context.Context, sessionID string) ([]chat.Message, error)+ GetModelHandoffFindingID(ctx context.Context, sessionID string) (string, error)AbortSession(ctx context.Context, sessionID string) errorSummarizeSession(ctx context.Context, sessionID string) (map[string]interface{}, error)GetSessionDiff(ctx context.Context, sessionID string) (map[string]interface{}, error)@@ -1175,10 +1176,18 @@ func (h *AIHandler) HandleChat(w http.ResponseWriter, r *http.Request) {handoffContext := ""var handoffResources []chat.HandoffResourcevar handoffActions []chat.HandoffAction- if req.FindingID != "" {+ findingID := strings.TrimSpace(req.FindingID)+ if findingID == "" && strings.TrimSpace(req.SessionID) != "" {+ if storedFindingID, err := svc.GetModelHandoffFindingID(ctx, req.SessionID); err != nil {+ log.Debug().Err(err).Str("session_id", req.SessionID).Msg("Unable to load stored Assistant finding handoff reference")+ } else {+ findingID = strings.TrimSpace(storedFindingID)+ }+ }+ if findingID != "" {store := h.GetUnifiedStoreForOrg(GetOrgID(ctx))if store != nil {- if f := store.Get(req.FindingID); f != nil {+ if f := store.Get(findingID); f != nil {handoffContext = buildUnifiedFindingChatContext(f)handoffResources = buildUnifiedFindingHandoffResources(f)handoffActions = buildUnifiedFindingHandoffActions(f)@@ -1193,7 +1202,7 @@ func (h *AIHandler) HandleChat(w http.ResponseWriter, r *http.Request) {SessionID: req.SessionID,Model: req.Model,Mentions: chatMentions,- FindingID: req.FindingID,+ FindingID: findingID,HandoffContext: handoffContext,HandoffResources: handoffResources,HandoffActions: handoffActions,diff --git a/internal/api/ai_handler_recovery_wiring_test.go b/internal/api/ai_handler_recovery_wiring_test.goindex a555c4ab15..a04c0e8bb2 100644--- a/internal/api/ai_handler_recovery_wiring_test.go+++ b/internal/api/ai_handler_recovery_wiring_test.go@@ -43,6 +43,9 @@ func (s *capturingAIService) DeleteSession(ctx context.Context, sessionID stringfunc (s *capturingAIService) GetMessages(ctx context.Context, sessionID string) ([]chat.Message, error) {return nil, nil}+func (s *capturingAIService) GetModelHandoffFindingID(ctx context.Context, sessionID string) (string, error) {+ return "", nil+}func (s *capturingAIService) AbortSession(ctx context.Context, sessionID string) error { return nil }func (s *capturingAIService) SummarizeSession(ctx context.Context, sessionID string) (map[string]interface{}, error) {return nil, nildiff --git a/internal/api/ai_handler_test.go b/internal/api/ai_handler_test.goindex 3e92a59385..22215120db 100644--- a/internal/api/ai_handler_test.go+++ b/internal/api/ai_handler_test.go@@ -83,6 +83,16 @@ func (m *MockAIService) GetMessages(ctx context.Context, sessionID string) ([]chreturn args.Get(0).([]chat.Message), args.Error(1)}+func (m *MockAIService) GetModelHandoffFindingID(ctx context.Context, sessionID string) (string, error) {+ for _, call := range m.ExpectedCalls {+ if call.Method == "GetModelHandoffFindingID" {+ args := m.Called(ctx, sessionID)+ return args.String(0), args.Error(1)+ }+ }+ return "", nil+}+func (m *MockAIService) AbortSession(ctx context.Context, sessionID string) error {args := m.Called(ctx, sessionID)return args.Error(0)@@ -670,6 +680,64 @@ func TestHandleChat_IncludesInvestigationRecordContext(t *testing.T) {assert.Equal(t, http.StatusOK, w.Code)}+func TestHandleChat_RefreshesStoredFindingContextForFollowUp(t *testing.T) {+ cfg := &config.Config{}+ h := newTestAIHandler(cfg, nil, nil)+ mockSvc := new(MockAIService)+ h.defaultService = mockSvc++ resolvedAt := time.Date(2026, 5, 6, 13, 0, 0, 0, time.UTC)+ store := unified.NewUnifiedStore(unified.DefaultAlertToFindingConfig())+ store.AddFromAI(&unified.UnifiedFinding{+ ID: "finding-123",+ Source: unified.SourceAIPatrol,+ Severity: unified.SeverityWarning,+ Category: unified.CategoryReliability,+ ResourceID: "vm-100",+ ResourceName: "web-server",+ ResourceType: "vm",+ Node: "pve-1",+ Title: "Backup pressure resolved",+ Description: "CPU pressure returned to baseline.",+ Recommendation: "Keep monitoring the next backup window.",+ InvestigationStatus: "completed",+ InvestigationOutcome: "resolved",+ UserNote: "Operator confirmed the maintenance window completed.",+ ResolvedAt: &resolvedAt,+ DetectedAt: resolvedAt.Add(-30 * time.Minute),+ LastSeenAt: resolvedAt,+ })+ h.SetUnifiedStore(store)++ mockSvc.On("IsRunning").Return(true)+ mockSvc.+ On("GetModelHandoffFindingID", mock.Anything, "session-123").+ Return("finding-123", nil)+ mockSvc.+ On("ExecuteStream", mock.Anything, mock.Anything, mock.Anything).+ Return(nil).+ Run(func(args mock.Arguments) {+ reqArg := args.Get(1).(chat.ExecuteRequest)+ assert.Equal(t, "session-123", reqArg.SessionID)+ assert.Equal(t, "finding-123", reqArg.FindingID)+ assert.Equal(t, "What changed?", reqArg.Prompt)+ assert.Contains(t, reqArg.HandoffContext, "[Finding Context]")+ assert.Contains(t, reqArg.HandoffContext, "Title: Backup pressure resolved")+ assert.Contains(t, reqArg.HandoffContext, "Investigation Outcome: resolved")+ assert.Contains(t, reqArg.HandoffContext, "User Note: Operator confirmed the maintenance window completed.")+ assert.NotContains(t, reqArg.HandoffContext, "User message: What changed?")+ })++ body := `{"prompt":"What changed?","session_id":"session-123"}`+ req := httptest.NewRequest("POST", "/api/ai/chat", strings.NewReader(body))+ w := httptest.NewRecorder()++ h.HandleChat(w, req)++ assert.Equal(t, http.StatusOK, w.Code)+ mockSvc.AssertExpectations(t)+}+func TestHandleChat_DropsLegacyMentionTypes(t *testing.T) {cfg := &config.Config{}h := newTestAIHandler(cfg, nil, nil)diff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex 11a66e0ef2..fcf4d9a252 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -140,6 +140,7 @@ func TestContract_AssistantFindingContextUsesModelOnlyHandoff(t *testing.T) {handlerText := string(handlerSource)for _, required := range []string{+ `svc.GetModelHandoffFindingID(ctx, req.SessionID)`,"handoffContext = buildUnifiedFindingChatContext(f)","handoffResources = buildUnifiedFindingHandoffResources(f)","handoffActions = buildUnifiedFindingHandoffActions(f)",@@ -159,8 +160,11 @@ func TestContract_AssistantFindingContextUsesModelOnlyHandoff(t *testing.T) {chatServiceText := string(chatServiceSource)for _, required := range []string{"handoffContext := strings.TrimSpace(req.HandoffContext)",+ "handoffFindingID := strings.TrimSpace(req.FindingID)",+ "sessions.SetModelHandoffFindingID(session.ID, handoffFindingID)","handoffResources := normalizeHandoffResources(req.HandoffResources)","sessions.SetModelHandoffContext(session.ID, handoffContext)",+ "GetModelHandoffFindingID","sessions.GetModelHandoffContext(session.ID)","sessions.SetModelHandoffResources(session.ID, handoffResources)","sessions.GetModelHandoffResources(session.ID)",@@ -190,6 +194,9 @@ func TestContract_AssistantFindingContextUsesModelOnlyHandoff(t *testing.T) {chatSessionText := string(chatSessionSource)for _, required := range []string{"ModelContext *sessionModelContext",+ "SetModelHandoffFindingID",+ "GetModelHandoffFindingID",+ "HandoffFindingID string","SetModelHandoffContext","GetModelHandoffContext","SetModelHandoffResources",