Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

Publish Patrol investigation limits live

rcourtmancdc109d408e6
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index a3898c3727..fa4d764fb4 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -5897,6 +5897,15 @@ The open-source/free `PUT /api/ai/patrol/autonomy` adapter may persist
findings-only `monitor` configuration and the governed investigation budget /
timeout clamps, but it must continue to reject `approval`, `assisted`, and
`full` autonomy with the canonical safe-remediation license response.
+Every successful autonomy mutation must publish the persisted investigation
+budget and timeout to the already-wired tenant investigation orchestrator
+before a newly triggered finding can be admitted. Requiring a server restart,
+or leaving the orchestrator on its construction-time defaults while the API
+reports the new values, is a contract violation: it silently turns the
+operator's model-led investigation allowance into a smaller framework-owned
+ceiling. A running investigation snapshots its limits when execution starts,
+so later settings changes affect subsequent runs without racing or rewriting
+an in-flight run.
The same canonical findings store owns dismissal-reason semantics. The three
`dismissed_reason` values must remain behaviorally distinct, not copy-only
variants: `not_an_issue` flips `Suppressed=true`, `expected_behavior`
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 2b363ab023..331f0629ed 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -1995,6 +1995,11 @@ a new API state machine, queue contract, or verification-accounting field.
(`orchestratorChatAdapter`) exposes only
`ExecuteInvestigationStream` (returning the structured investigation
result with its typed proposal errors) and `ListInvestigationTools`.
+ The shared optional `InvestigationExecutionLimitUpdater` contract carries
+ successful Patrol autonomy budget/timeout updates into the live enterprise
+ orchestrator. The API mutation is not complete if persistence and the
+ response advance while the execution boundary remains on stale defaults;
+ newly admitted investigations must snapshot the newly published limits.
The retired command-execution, autonomy, and command-shaped approval
adapters are removed, and the legacy `aiautofix` command-approval
endpoints fail closed with `command_fix_retired`.
diff --git a/internal/ai/patrol_init_additional_test.go b/internal/ai/patrol_init_additional_test.go
index b69141a641..19295bbf3e 100644
--- a/internal/ai/patrol_init_additional_test.go
+++ b/internal/ai/patrol_init_additional_test.go
@@ -8,6 +8,7 @@ import (
"github.com/rcourtman/pulse-go-rewrite/internal/ai/circuit"
"github.com/rcourtman/pulse-go-rewrite/internal/ai/knowledge"
+ "github.com/rcourtman/pulse-go-rewrite/internal/config"
"github.com/rcourtman/pulse-go-rewrite/internal/servicediscovery"
)
@@ -23,7 +24,10 @@ type mockForecastProvider struct{}
func (m mockForecastProvider) FormatKeyForecasts() string { return "forecast" }
-type stubInvestigationOrchestrator struct{}
+type stubInvestigationOrchestrator struct {
+ maxTurns int
+ timeout time.Duration
+}
func (s *stubInvestigationOrchestrator) InvestigateFinding(ctx context.Context, finding *InvestigationFinding, autonomyLevel string) error {
return nil
@@ -45,6 +49,34 @@ func (s *stubInvestigationOrchestrator) ReinvestigateFinding(ctx context.Context
func (s *stubInvestigationOrchestrator) Shutdown(ctx context.Context) error { return nil }
+func (s *stubInvestigationOrchestrator) SetInvestigationExecutionLimits(maxTurns int, timeout time.Duration) {
+ s.maxTurns = maxTurns
+ s.timeout = timeout
+}
+
+func TestApplyPatrolAutonomyConfigPublishesInvestigationExecutionLimits(t *testing.T) {
+ orchestrator := &stubInvestigationOrchestrator{}
+ patrol := &PatrolService{investigationOrchestrator: orchestrator}
+ service := &Service{
+ cfg: config.NewDefaultAIConfig(),
+ patrolService: patrol,
+ }
+ next := config.NewDefaultAIConfig()
+ next.PatrolAutonomyLevel = config.PatrolAutonomyApproval
+ next.PatrolInvestigationBudget = 27
+ next.PatrolInvestigationTimeoutSec = 420
+
+ if err := service.ApplyPatrolAutonomyConfig(next); err != nil {
+ t.Fatalf("ApplyPatrolAutonomyConfig: %v", err)
+ }
+ if orchestrator.maxTurns != 27 {
+ t.Fatalf("investigation max turns = %d, want 27", orchestrator.maxTurns)
+ }
+ if orchestrator.timeout != 7*time.Minute {
+ t.Fatalf("investigation timeout = %s, want 7m", orchestrator.timeout)
+ }
+}
+
func TestPatrolService_SettersAndScopeHints(t *testing.T) {
ps := NewPatrolService(nil, nil)
diff --git a/internal/ai/service.go b/internal/ai/service.go
index 9353b3d774..55395e996d 100644
--- a/internal/ai/service.go
+++ b/internal/ai/service.go
@@ -1062,6 +1062,15 @@ func (s *Service) ApplyPatrolAutonomyConfig(cfg *config.AIConfig) error {
activation := *cfg.PatrolAutopilotActivation
s.cfg.PatrolAutopilotActivation = &activation
}
+ if s.patrolService != nil {
+ orchestrator := s.patrolService.GetInvestigationOrchestrator()
+ if updater, ok := orchestrator.(aicontracts.InvestigationExecutionLimitUpdater); ok {
+ updater.SetInvestigationExecutionLimits(
+ s.cfg.GetPatrolInvestigationBudget(),
+ s.cfg.GetPatrolInvestigationTimeout(),
+ )
+ }
+ }
return nil
}
diff --git a/pkg/aicontracts/interfaces.go b/pkg/aicontracts/interfaces.go
index d0df8543a3..8f6ecc8161 100644
--- a/pkg/aicontracts/interfaces.go
+++ b/pkg/aicontracts/interfaces.go
@@ -26,6 +26,15 @@ type InvestigationOrchestrator interface {
Shutdown(ctx context.Context) error
}
+// InvestigationExecutionLimitUpdater is the optional live-configuration
+// contract implemented by investigation orchestrators whose turn and timeout
+// limits can change without rebuilding the orchestrator. Autonomy settings
+// persistence must publish these limits before a newly triggered
+// investigation is admitted.
+type InvestigationExecutionLimitUpdater interface {
+ SetInvestigationExecutionLimits(maxTurns int, timeout time.Duration)
+}
+
// InvestigationStoreMaintainer is an optional interface for orchestrators that
// expose their investigation store for periodic maintenance.
type InvestigationStoreMaintainer interface {