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
Bill quickstart by Patrol execution
rcourtman830215e4c3a1
diff --git a/docs/release-control/v6/internal/status.json b/docs/release-control/v6/internal/status.jsonindex bf4d59d922..6084f5899d 100644--- a/docs/release-control/v6/internal/status.json+++ b/docs/release-control/v6/internal/status.json@@ -1871,6 +1871,7 @@"blocking_level": "repo-ready","proof_type": "automated","lane_ids": [+ "L3","L6"],"subsystem_ids": [@@ -1988,6 +1989,7 @@"blocking_level": "repo-ready","proof_type": "automated","lane_ids": [+ "L3","L6"],"subsystem_ids": [@@ -2091,6 +2093,104 @@"kind": "file"}]+ },+ {+ "id": "RA23",+ "summary": "Patrol quickstart credits are billed per higher-level Patrol execution, not per internal provider turn: the runtime must propagate one stable execution ID across retries, agentic turns, and the evaluation pass, and the license server must treat repeated quickstart proxy calls for that execution as one commercial run.",+ "kind": "invariant",+ "blocking_level": "repo-ready",+ "proof_type": "automated",+ "lane_ids": [+ "L3",+ "L6"+ ],+ "subsystem_ids": [+ "ai-runtime",+ "cloud-paid"+ ],+ "release_gate_ids": [],+ "proof_commands": [+ {+ "id": "patrol-quickstart-execution-contract-tests",+ "run": [+ "go",+ "test",+ "./internal/ai/providers",+ "./internal/ai/chat",+ "./internal/ai",+ "-run",+ "Quickstart|ExecutePatrolStream|RunEvaluationPass|RetriesWithProviderDerivedSeedBudget",+ "-count=1"+ ]+ }+ ],+ "evidence": [+ {+ "repo": "pulse",+ "path": "docs/release-control/v6/internal/status.json",+ "kind": "file"+ },+ {+ "repo": "pulse",+ "path": "docs/release-control/v6/internal/subsystems/ai-runtime.md",+ "kind": "file"+ },+ {+ "repo": "pulse",+ "path": "docs/release-control/v6/internal/subsystems/cloud-paid.md",+ "kind": "file"+ },+ {+ "repo": "pulse",+ "path": "internal/ai/chat/service.go",+ "kind": "file"+ },+ {+ "repo": "pulse",+ "path": "internal/ai/chat/service_patrol_additional_test.go",+ "kind": "file"+ },+ {+ "repo": "pulse",+ "path": "internal/ai/patrol_ai.go",+ "kind": "file"+ },+ {+ "repo": "pulse",+ "path": "internal/ai/patrol_ai_more_test.go",+ "kind": "file"+ },+ {+ "repo": "pulse",+ "path": "internal/ai/providers/quickstart.go",+ "kind": "file"+ },+ {+ "repo": "pulse",+ "path": "internal/ai/providers/quickstart_test.go",+ "kind": "file"+ },+ {+ "repo": "pulse-pro",+ "path": "license-server/quickstart_proxy.go",+ "kind": "file"+ },+ {+ "repo": "pulse-pro",+ "path": "license-server/quickstart_proxy_test.go",+ "kind": "file"+ },+ {+ "repo": "pulse-pro",+ "path": "license-server/quickstart_store.go",+ "kind": "file"+ },+ {+ "repo": "pulse-pro",+ "path": "license-server/v6_schema.go",+ "kind": "file"+ }+ ]}],"evidence_reference_policy": {diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex fd407fe654..2b7244dd82 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -141,7 +141,12 @@ management, and fleet control surfaces.The shared installation-scoped `activation.enc` path is that authority:tenant-local lifecycle routes may reuse it, but they must not fork per-orgactivation caches, alternate installation-token stores, or competing- quickstart-owner identity.+ quickstart-owner identity. That same shared AI/runtime boundary now also+ owns Patrol quickstart execution identity: lifecycle-adjacent flows may+ trigger or observe Patrol runs through `internal/api/chat_service_adapter.go`,+ but they must preserve the stable execution identifier that lets the hosted+ quickstart contract bill once per higher-level Patrol run rather than once+ per internal provider turn.2. Add or change update continuity and persisted-version handoff through `internal/agentupdate/`.3. Add or change runtime-side Unified Agent startup, first-report assembly, and enroll/runtime continuity through `internal/hostagent/`.Proxmox host-agent setup must treat local `proxmox-registered` markers as a cache, not authority: before skipping token setup or node repair, `internal/hostagent/proxmox_setup.go` must revalidate the current type and candidate hosts against Pulse through the canonical auto-register contract.diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 53fb74f3ae..685a438ba0 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -146,6 +146,12 @@ response, accept both `quickstart_token_expires_at` and the older`token_expires_at` response field while mixed quickstart deployments exist,and invalidate the cached token on auth rejection. Explicit BYOK providercredentials still outrank Patrol quickstart whenever both are present.+That same Patrol quickstart contract is execution-scoped rather than+provider-turn-scoped: the runtime must stamp one stable execution identifier+per higher-level Patrol run and propagate it through every hosted quickstart+provider call, including retries and the evaluation pass, so one Patrol run+consumes at most one quickstart credit even when the underlying agentic loop+makes multiple model turns.Public-facing copy that reflects those runtime fields must therefore speak inPatrol quickstart runs on activated or trial-backed installs and Patrol-onlyno-key activation, not in generic AI credits, anonymous Community bootstrap,diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 3c8d5bb1af..89dc08cb19 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -251,6 +251,11 @@ Own canonical runtime payload shapes between backend and frontend.quickstart inventory and active runtime source on activated or trial-backedinstalls rather than a generic hosted AI quota, anonymous Communityentitlement, or full-chat entitlement+ and the Patrol execution billing rule, so shared runtime bridges such as+ `internal/api/chat_service_adapter.go` must preserve the stable Patrol+ execution identifier that the hosted quickstart contract uses to charge+ once per higher-level Patrol run rather than once per internal provider+ turn7. Keep Patrol summary payload consumers aligned on one assessment hierarchy: transport-driven Patrol summary surfaces may show supporting counts and outcomes, but the canonical assessment and verification states must remain singular and not be repeated as a second compact verdict strip8. Keep Patrol verification and activity facts unified on one transport-backed secondary status area: when frontend consumers combine Patrol status payloads (`runtime_state`, `last_patrol_at`, `last_activity_at`, `trigger_status`) with run-history transport, the latest run result, activity mix, scoped-trigger state, and circuit-breaker context must read as one supporting explanation beneath the primary assessment instead of being re-expanded into a separate full-width status strip plus duplicate summary layersand the main Patrol page composition boundary, so once that governeddiff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.mdindex 63543dd351..153921fda4 100644--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md@@ -256,6 +256,11 @@ mixed-version compatible while quickstart rolls out: Pulse may send optionalbinding metadata such as `instance_name` and `use_case=patrol`, and the servermust not reject that additive metadata or rely on one expiry field spellingonly when returning the quickstart token snapshot.+`POST /v1/quickstart/patrol` also owns the Patrol-run billing boundary: the+runtime may send an execution identifier for one higher-level Patrol run, and+the license server must treat repeated proxy calls that share that execution+identifier as one commercial quickstart run rather than charging once per+agentic provider turn.That quickstart allowance is therefore activation support, not the maincommercial pitch: self-hosted pricing and docs may promise Patrol-onlyquickstart runs with no API key for activated or trial-backed installs, butdiff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex ae0e0d3d6c..50a56d044f 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -117,6 +117,12 @@ querying, and the operator-facing storage health presentation layer.`quickstart:pulse-hosted` alias, but they must not treat vendor model IDsor quickstart upstream-model defaults as part of storage/recovery transportownership or route behavior.+ That same adjacent `internal/api/` boundary also now carries Patrol-run+ execution identity for hosted quickstart billing. Storage and recovery may+ observe shared Patrol transport through `internal/api/chat_service_adapter.go`,+ but they must not drop, rewrite, or reinterpret the execution identifier+ that lets the server-authoritative quickstart ledger charge once per Patrol+ run instead of once per agentic provider turn.Activation-required quickstart block reasons exposed on that same sharedAI settings surface are likewise not storage/recovery onboarding truth;adjacent pages may react to the message, but they must not reinterpret itdiff --git a/internal/ai/chat/agentic.go b/internal/ai/chat/agentic.goindex 0f22516bfc..7d42e76b45 100644--- a/internal/ai/chat/agentic.go+++ b/internal/ai/chat/agentic.go@@ -116,6 +116,7 @@ type AgenticLoop struct {baseSystemPrompt string // Base prompt without mode contextmaxTurns intorgID string+ executionID string// Provider info for telemetry (e.g., "anthropic", "claude-3-sonnet")providerName string@@ -283,9 +284,10 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, me// Build the request with dynamic system prompt (includes current mode)systemPrompt := a.getSystemPrompt()req := providers.ChatRequest{- Messages: providerMessages,- System: systemPrompt,- Tools: tools,+ Messages: providerMessages,+ System: systemPrompt,+ Tools: tools,+ ExecutionID: a.executionID,}// Determine tool_choice based on turn, intent, and explicit tool requests.diff --git a/internal/ai/chat/agentic_control.go b/internal/ai/chat/agentic_control.goindex a04681c92d..ace3e513ad 100644--- a/internal/ai/chat/agentic_control.go+++ b/internal/ai/chat/agentic_control.go@@ -46,6 +46,15 @@ func (a *AgenticLoop) SetProviderInfo(provider, model string) {a.mu.Unlock()}+// SetExecutionID binds a stable higher-level execution identifier to all+// provider calls made by this loop. Patrol quickstart billing uses this to+// charge once per Patrol run instead of once per provider turn.+func (a *AgenticLoop) SetExecutionID(executionID string) {+ a.mu.Lock()+ a.executionID = executionID+ a.mu.Unlock()+}+// SetBudgetChecker sets a function called after each agentic turn to enforce// token spending limits. If the checker returns an error, the loop stops.func (a *AgenticLoop) SetBudgetChecker(fn func() error) {diff --git a/internal/ai/chat/agentic_final.go b/internal/ai/chat/agentic_final.goindex 21de45a742..8e3a1b3b41 100644--- a/internal/ai/chat/agentic_final.go+++ b/internal/ai/chat/agentic_final.go@@ -53,9 +53,10 @@ func (a *AgenticLoop) ensureFinalTextResponse(})summaryReq := providers.ChatRequest{- Messages: cleanMessages,- System: a.getSystemPrompt(),- ToolChoice: &providers.ToolChoice{Type: providers.ToolChoiceNone},+ Messages: cleanMessages,+ System: a.getSystemPrompt(),+ ExecutionID: a.executionID,+ ToolChoice: &providers.ToolChoice{Type: providers.ToolChoiceNone},// No Tools field — completely omit tools to prevent hallucinated function calls}diff --git a/internal/ai/chat/service.go b/internal/ai/chat/service.goindex 0f722f5519..3c65fe6289 100644--- a/internal/ai/chat/service.go+++ b/internal/ai/chat/service.go@@ -732,6 +732,7 @@ type PatrolRequest struct {Prompt string `json:"prompt"`SystemPrompt string `json:"system_prompt"`SessionID string `json:"session_id,omitempty"`+ ExecutionID string `json:"execution_id,omitempty"`UseCase string `json:"use_case"`MaxTurns int `json:"max_turns,omitempty"`}@@ -788,6 +789,7 @@ func (s *Service) ExecutePatrolStream(ctx context.Context, req PatrolRequest, catempLoop := NewAgenticLoop(provider, executor, systemPrompt)tempLoop.SetOrgID(s.orgID)tempLoop.SetAutonomousMode(true) // Patrol runs without approval prompts+ tempLoop.SetExecutionID(req.ExecutionID)if req.MaxTurns > 0 {tempLoop.SetMaxTurns(req.MaxTurns)}diff --git a/internal/ai/chat/service_patrol_additional_test.go b/internal/ai/chat/service_patrol_additional_test.goindex d306facc55..949b8db40f 100644--- a/internal/ai/chat/service_patrol_additional_test.go+++ b/internal/ai/chat/service_patrol_additional_test.go@@ -161,9 +161,10 @@ func TestService_ExecutePatrolStream_Success(t *testing.T) {doneCount := 0resp, err := service.ExecutePatrolStream(context.Background(), PatrolRequest{- Prompt: "check status",- MaxTurns: 1,- SessionID: "",+ Prompt: "check status",+ MaxTurns: 1,+ SessionID: "",+ ExecutionID: "patrol-run-123",}, func(event StreamEvent) {if event.Type == "done" {doneCount++@@ -181,6 +182,9 @@ func TestService_ExecutePatrolStream_Success(t *testing.T) {if mockProvider.lastRequest.System == "" {t.Fatalf("expected system prompt to be set")}+ if mockProvider.lastRequest.ExecutionID != "patrol-run-123" {+ t.Fatalf("execution_id=%q want patrol-run-123", mockProvider.lastRequest.ExecutionID)+ }if doneCount != 1 {t.Fatalf("expected done event to be emitted")}diff --git a/internal/ai/patrol_ai.go b/internal/ai/patrol_ai.goindex 10a6c44984..88b7b9a88a 100644--- a/internal/ai/patrol_ai.go+++ b/internal/ai/patrol_ai.go@@ -14,6 +14,7 @@ import ("sync""time"+ "github.com/google/uuid""github.com/rcourtman/pulse-go-rewrite/internal/ai/baseline""github.com/rcourtman/pulse-go-rewrite/internal/ai/chat""github.com/rcourtman/pulse-go-rewrite/internal/ai/correlation"@@ -268,6 +269,7 @@ func (p *PatrolService) runAIAnalysisState(ctx context.Context, snap patrolRuntilog.Debug().Msg("AI Patrol: Starting agentic patrol analysis")maxTurns := computeTriageMaxTurns(len(triageResult.Flags), scope)+ executionID := uuid.NewString()log.Debug().Int("triage_flags", len(triageResult.Flags)).Int("max_turns", maxTurns).@@ -338,6 +340,7 @@ func (p *PatrolService) runAIAnalysisState(ctx context.Context, snap patrolRuntiPrompt: prompt,SystemPrompt: p.getPatrolSystemPromptForTriage(),SessionID: "patrol-main",+ ExecutionID: executionID,UseCase: "patrol",MaxTurns: maxTurns,}, func(event ChatStreamEvent) {@@ -600,7 +603,7 @@ func (p *PatrolService) runAIAnalysisState(ctx context.Context, snap patrolRuntiInt("unmatched_signals", len(unmatchedSignals)).Msg("AI Patrol: Unmatched signals found, running evaluation pass")- evalResp, evalErr := p.runEvaluationPass(ctx, adapter, unmatchedSignals)+ evalResp, evalErr := p.runEvaluationPass(ctx, adapter, unmatchedSignals, executionID)if evalErr != nil {log.Warn().Err(evalErr).Msg("AI Patrol: Evaluation pass failed")} else if evalResp != nil {@@ -802,7 +805,7 @@ func formatToolResult(result tools.CallToolResult) string {// runEvaluationPass runs a focused second LLM call to evaluate unmatched signals// that the main patrol pass detected but did not report as findings.-func (p *PatrolService) runEvaluationPass(ctx context.Context, adapter *patrolFindingCreatorAdapter, unmatchedSignals []DetectedSignal) (*PatrolStreamResponse, error) {+func (p *PatrolService) runEvaluationPass(ctx context.Context, adapter *patrolFindingCreatorAdapter, unmatchedSignals []DetectedSignal, executionID string) (*PatrolStreamResponse, error) {cs := p.aiService.GetChatService()if cs == nil {return nil, fmt.Errorf("chat service not available for evaluation pass")@@ -823,6 +826,7 @@ func (p *PatrolService) runEvaluationPass(ctx context.Context, adapter *patrolFiPrompt: userPrompt,SystemPrompt: systemPrompt,SessionID: "patrol-eval",+ ExecutionID: executionID,UseCase: "patrol",MaxTurns: 5,}, func(event ChatStreamEvent) {diff --git a/internal/ai/patrol_ai_eval_additional_test.go b/internal/ai/patrol_ai_eval_additional_test.goindex 80b7f5fc93..94a00ebbc7 100644--- a/internal/ai/patrol_ai_eval_additional_test.go+++ b/internal/ai/patrol_ai_eval_additional_test.go@@ -124,7 +124,7 @@ func TestSignalHelpersAndFindingsFromSignals(t *testing.T) {func TestRunEvaluationPass(t *testing.T) {ps := NewPatrolService(&Service{}, nil)- _, err := ps.runEvaluationPass(context.Background(), nil, []DetectedSignal{{SignalType: SignalHighCPU}})+ _, err := ps.runEvaluationPass(context.Background(), nil, []DetectedSignal{{SignalType: SignalHighCPU}}, "patrol-run-eval")if err == nil {t.Fatal("expected error when chat service is unavailable")}@@ -139,7 +139,7 @@ func TestRunEvaluationPass(t *testing.T) {svc.SetChatService(mockCS)ps.aiService = svc- resp, err := ps.runEvaluationPass(context.Background(), nil, []DetectedSignal{{SignalType: SignalHighCPU}})+ resp, err := ps.runEvaluationPass(context.Background(), nil, []DetectedSignal{{SignalType: SignalHighCPU}}, "patrol-run-eval")if err != nil {t.Fatalf("expected evaluation pass to succeed, got %v", err)}diff --git a/internal/ai/patrol_ai_more_test.go b/internal/ai/patrol_ai_more_test.goindex 96abb0f8a8..773b20471b 100644--- a/internal/ai/patrol_ai_more_test.go+++ b/internal/ai/patrol_ai_more_test.go@@ -283,10 +283,12 @@ func TestRunAIAnalysis_RetriesWithProviderDerivedSeedBudget(t *testing.T) {executor := tools.NewPulseToolExecutor(tools.ExecutorConfig{})promptTokens := make([]int, 0, 2)+ executionIDs := make([]string, 0, 2)mockCS := &mockChatService{executor: executor,executePatrolStreamFunc: func(ctx context.Context, req PatrolExecuteRequest, callback ChatStreamCallback) (*PatrolStreamResponse, error) {promptTokens = append(promptTokens, chat.EstimateTokens(req.Prompt))+ executionIDs = append(executionIDs, req.ExecutionID)if len(promptTokens) == 1 {return nil, fmt.Errorf("API error (400): {\"error\":{\"message\":\"request exceeds the available context size (4096 tokens)\",\"type\":\"exceed_context_size_error\",\"n_ctx\":4096}}")}@@ -340,6 +342,12 @@ func TestRunAIAnalysis_RetriesWithProviderDerivedSeedBudget(t *testing.T) {if len(promptTokens) != 2 {t.Fatalf("expected 2 patrol attempts, got %d", len(promptTokens))}+ if len(executionIDs) != 2 || executionIDs[0] == "" || executionIDs[1] == "" {+ t.Fatalf("expected execution IDs for each retry attempt, got %#v", executionIDs)+ }+ if executionIDs[0] != executionIDs[1] {+ t.Fatalf("expected retry attempts to share execution ID, got %#v", executionIDs)+ }if promptTokens[1] >= promptTokens[0] {t.Fatalf("expected retry prompt to shrink, got %d then %d tokens", promptTokens[0], promptTokens[1])}@@ -428,7 +436,18 @@ func TestRunEvaluationPass_RecordsCostUsage(t *testing.T) {},costStore: cost.NewStore(cost.DefaultMaxDays),}- svc.SetChatService(&streamChatService{})+ var seenExecutionID string+ svc.SetChatService(&mockChatService{+ executor: tools.NewPulseToolExecutor(tools.ExecutorConfig{}),+ executePatrolStreamFunc: func(ctx context.Context, req PatrolExecuteRequest, callback ChatStreamCallback) (*PatrolStreamResponse, error) {+ seenExecutionID = req.ExecutionID+ return &PatrolStreamResponse{+ Content: "evaluation complete",+ InputTokens: 5,+ OutputTokens: 7,+ }, nil+ },+ })ps := NewPatrolService(svc, nil)signals := []DetectedSignal{@@ -444,13 +463,16 @@ func TestRunEvaluationPass_RecordsCostUsage(t *testing.T) {},}- resp, err := ps.runEvaluationPass(context.Background(), nil, signals)+ resp, err := ps.runEvaluationPass(context.Background(), nil, signals, "patrol-run-eval")if err != nil {t.Fatalf("runEvaluationPass failed: %v", err)}if resp == nil {t.Fatal("expected non-nil response")}+ if seenExecutionID != "patrol-run-eval" {+ t.Fatalf("execution_id=%q want patrol-run-eval", seenExecutionID)+ }summary := svc.costStore.GetSummary(1)if summary.Totals.InputTokens != 5 || summary.Totals.OutputTokens != 7 {diff --git a/internal/ai/providers/provider.go b/internal/ai/providers/provider.goindex ff82e1aa5c..b70e6bcabd 100644--- a/internal/ai/providers/provider.go+++ b/internal/ai/providers/provider.go@@ -99,6 +99,7 @@ type ToolChoice struct {type ChatRequest struct {Messages []Message `json:"messages"`Model string `json:"model"`+ ExecutionID string `json:"execution_id,omitempty"` // Stable higher-level run ID shared across related provider turnsMaxTokens int `json:"max_tokens,omitempty"`Temperature float64 `json:"temperature,omitempty"`System string `json:"system,omitempty"` // System prompt (Anthropic style)diff --git a/internal/ai/providers/quickstart.go b/internal/ai/providers/quickstart.goindex 0362285152..9a1c9dcca9 100644--- a/internal/ai/providers/quickstart.go+++ b/internal/ai/providers/quickstart.go@@ -80,9 +80,10 @@ func NewQuickstartClientWithToken(quickstartToken string, onStateSync func(Quick// quickstartRequest is the payload sent to the hosted proxy.type quickstartRequest struct {- Messages []Message `json:"messages"`- System string `json:"system,omitempty"`- Tools []Tool `json:"tools,omitempty"`+ Messages []Message `json:"messages"`+ System string `json:"system,omitempty"`+ Tools []Tool `json:"tools,omitempty"`+ ExecutionID string `json:"execution_id,omitempty"`// LicenseID is retained only for the legacy caller-chosen identity path.LicenseID string `json:"license_id,omitempty"`}@@ -165,9 +166,10 @@ func IsQuickstartUnavailable(err error) bool {// Chat sends a chat request through the Pulse-hosted quickstart proxy.func (c *QuickstartClient) Chat(ctx context.Context, req ChatRequest) (*ChatResponse, error) {payload := quickstartRequest{- Messages: req.Messages,- System: req.System,- Tools: req.Tools,+ Messages: req.Messages,+ System: req.System,+ Tools: req.Tools,+ ExecutionID: strings.TrimSpace(req.ExecutionID),}if strings.TrimSpace(c.quickstartToken) == "" {payload.LicenseID = c.licenseIDdiff --git a/internal/ai/providers/quickstart_test.go b/internal/ai/providers/quickstart_test.goindex 1b4180274b..d9da6fc701 100644--- a/internal/ai/providers/quickstart_test.go+++ b/internal/ai/providers/quickstart_test.go@@ -55,6 +55,7 @@ func TestQuickstartClientChat_UsesOverrideProxyURL(t *testing.T) {func TestQuickstartClientWithToken_UsesBearerAuthAndSyncsServerState(t *testing.T) {var seenAuthorization stringvar seenLicenseID string+ var seenExecutionID stringvar synced QuickstartServerStatevar syncCalls int@@ -65,6 +66,7 @@ func TestQuickstartClientWithToken_UsesBearerAuthAndSyncsServerState(t *testing.}seenAuthorization = r.Header.Get("Authorization")seenLicenseID = req.LicenseID+ seenExecutionID = req.ExecutionIDw.Header().Set("Content-Type", "application/json")if err := json.NewEncoder(w).Encode(quickstartResponse{Content: "hello",@@ -86,7 +88,8 @@ func TestQuickstartClientWithToken_UsesBearerAuthAndSyncsServerState(t *testing.syncCalls++}, nil)resp, err := client.Chat(context.Background(), ChatRequest{- Messages: []Message{{Role: "user", Content: "Hi"}},+ Messages: []Message{{Role: "user", Content: "Hi"}},+ ExecutionID: "patrol-run-123",})if err != nil {t.Fatalf("Chat(): %v", err)@@ -97,6 +100,9 @@ func TestQuickstartClientWithToken_UsesBearerAuthAndSyncsServerState(t *testing.if seenLicenseID != "" {t.Fatalf("license_id=%q want empty for bearer-token quickstart", seenLicenseID)}+ if seenExecutionID != "patrol-run-123" {+ t.Fatalf("execution_id=%q want patrol-run-123", seenExecutionID)+ }if resp.Content != "hello" {t.Fatalf("content=%q want hello", resp.Content)}diff --git a/internal/ai/service.go b/internal/ai/service.goindex aa1cbea8cd..05307694fa 100644--- a/internal/ai/service.go+++ b/internal/ai/service.go@@ -156,6 +156,7 @@ type PatrolExecuteRequest struct {Prompt string `json:"prompt"`SystemPrompt string `json:"system_prompt"`SessionID string `json:"session_id,omitempty"`+ ExecutionID string `json:"execution_id,omitempty"`UseCase string `json:"use_case"` // "patrol" — for model selectionMaxTurns int `json:"max_turns,omitempty"`}diff --git a/internal/api/chat_service_adapter.go b/internal/api/chat_service_adapter.goindex d927928011..d432767f44 100644--- a/internal/api/chat_service_adapter.go+++ b/internal/api/chat_service_adapter.go@@ -38,6 +38,7 @@ func (a *chatServiceAdapter) ExecutePatrolStream(ctx context.Context, req ai.PatPrompt: req.Prompt,SystemPrompt: req.SystemPrompt,SessionID: req.SessionID,+ ExecutionID: req.ExecutionID,UseCase: req.UseCase,MaxTurns: req.MaxTurns,}, adaptCallback(callback))diff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex e05d39f0ca..62aa6bf62d 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -22,6 +22,7 @@ import ("github.com/rcourtman/pulse-go-rewrite/internal/ai/chat""github.com/rcourtman/pulse-go-rewrite/internal/ai/correlation""github.com/rcourtman/pulse-go-rewrite/internal/ai/memory"+ "github.com/rcourtman/pulse-go-rewrite/internal/ai/providers""github.com/rcourtman/pulse-go-rewrite/internal/alerts""github.com/rcourtman/pulse-go-rewrite/internal/config""github.com/rcourtman/pulse-go-rewrite/internal/license/entitlements"@@ -41,6 +42,29 @@ import ("github.com/rcourtman/pulse-go-rewrite/pkg/reporting")+type contractCapturingStreamingProvider struct {+ lastRequest providers.ChatRequest+}++func (p *contractCapturingStreamingProvider) Chat(ctx context.Context, req providers.ChatRequest) (*providers.ChatResponse, error) {+ p.lastRequest = req+ return &providers.ChatResponse{Content: "ok", Model: req.Model}, nil+}++func (p *contractCapturingStreamingProvider) ChatStream(ctx context.Context, req providers.ChatRequest, callback providers.StreamCallback) error {+ p.lastRequest = req+ callback(providers.StreamEvent{Type: "content", Data: providers.ContentEvent{Text: "hello"}})+ callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{StopReason: "end_turn"}})+ return nil+}++func (p *contractCapturingStreamingProvider) TestConnection(ctx context.Context) error { return nil }+func (p *contractCapturingStreamingProvider) Name() string { return "contract-capture" }+func (p *contractCapturingStreamingProvider) ListModels(ctx context.Context) ([]providers.ModelInfo, error) {+ return nil, nil+}+func (p *contractCapturingStreamingProvider) SupportsThinking(model string) bool { return false }+func TestContract_WebSocketTrustedProxyHostedOrigin(t *testing.T) {t.Setenv("PULSE_TRUSTED_PROXY_CIDRS", "127.0.0.1/32")resetTrustedProxyCIDRsForTests()@@ -88,6 +112,41 @@ func TestContract_WireAIChatDependencies_WiresTrueNASAppActionProvider(t *testin}}+func TestContract_ChatServiceAdapterPatrolForwardsExecutionID(t *testing.T) {+ cfg := chat.Config{+ DataDir: t.TempDir(),+ AIConfig: &config.AIConfig{+ Enabled: true,+ ChatModel: "stub:model",+ PatrolModel: "stub:model",+ },+ }+ service := chat.NewService(cfg)+ provider := &contractCapturingStreamingProvider{}+ setUnexportedField(t, service, "providerFactory", func(string) (providers.StreamingProvider, error) {+ return provider, nil+ })+ if err := service.Start(context.Background()); err != nil {+ t.Fatalf("Start: %v", err)+ }+ t.Cleanup(func() { _ = service.Stop(context.Background()) })++ adapter := &chatServiceAdapter{svc: service}+ resp, err := adapter.ExecutePatrolStream(context.Background(), ai.PatrolExecuteRequest{+ Prompt: "patrol",+ ExecutionID: "patrol-run-contract",+ }, func(ai.ChatStreamEvent) {})+ if err != nil {+ t.Fatalf("ExecutePatrolStream: %v", err)+ }+ if resp == nil || resp.Content == "" {+ t.Fatalf("expected patrol response content, got %#v", resp)+ }+ if provider.lastRequest.ExecutionID != "patrol-run-contract" {+ t.Fatalf("execution_id=%q want patrol-run-contract", provider.lastRequest.ExecutionID)+ }+}+func TestContract_AIQuickstartPayloadFieldsRemainCanonical(t *testing.T) {settingsBody, err := json.Marshal(AISettingsResponse{QuickstartCreditsRemaining: 7,