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.

Validate all Patrol investigation manifests

rcourtmanb08831958953
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 2dfa39cbcc..e213062d57 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -7457,13 +7457,16 @@ Core uses the same scoped evidence mapping to project generic query/read tools,
the relevant subsystem evidence tool, and only the investigation-owned
capability lookup and typed proposal sink. The type is not model-authored and
cannot add a tool outside the already-projected investigation profile. Unknown
-types keep the full safe investigation profile. Known types intersect their
-evidence ceiling with tools that are actually available after profile
+types keep the full safe investigation profile, but that fallback is not a
+validation bypass: it must still contain real evidence, the capability lookup,
+and the proposal sink before inference. Known types intersect their evidence
+ceiling with tools that are actually available after profile
projection, so a deployment without an agent-routed or native `pulse_read`
adapter still investigates from canonical query and subsystem evidence. At
least one structured evidence tool plus both the capability lookup and proposal
-sink remain mandatory; missing proposal authority or a zero-evidence manifest
-fails before inference. Runtime completion and proposal authority additionally
+sink remain mandatory for both scoped and full-profile paths; missing proposal
+authority or a zero-evidence manifest fails before inference. Runtime
+completion and proposal authority additionally
require at least one of those evidence calls to succeed; attempted calls remain
visible for budget accounting and forensics, but failed or blocked results are
not grounding. This keeps focused Patrol
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 13d5f1af78..c403346faf 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -4159,9 +4159,12 @@ relevant subsystem evidence surface, and the investigation-owned capability
lookup/proposal tools. It is not a client-selectable execution profile, cannot
add authority, and is never inferred from prompt text. Empty or unknown types
retain the full governed investigation profile so an additive resource kind
-cannot silently lose evidence access. Scoped Watch uses the same shared typed
-mapping after exact canonical scope resolution, with detection lifecycle tools
-composed separately from investigation proposal tools.
+cannot silently lose evidence access. That full-profile fallback still fails
+before inference unless it contains at least one evidence tool, the
+side-effect-free capability lookup, and the typed proposal sink; additive type
+compatibility does not bypass the investigation boundary. Scoped Watch uses the
+same shared typed mapping after exact canonical scope resolution, with detection
+lifecycle tools composed separately from investigation proposal tools.
Unified Agent connections now carry agent-authored lifecycle evidence through
the shared host model and `/api/connections` contract. The payload may include
@@ -9516,7 +9519,9 @@ investigation boundary. Investigations carry their finding `resource_type` over
the public Pulse/Enterprise orchestrator dependency contract and use the companion
investigation projection. That projection intersects optional evidence tools
with the runtime-available governed profile, while requiring at least one
-evidence tool plus the capability lookup and typed proposal sink. The bridge's
+evidence tool plus the capability lookup and typed proposal sink. Unknown and
+empty resource types retain the full governed profile but undergo the same
+mandatory-tool validation before inference. The bridge's
`evidence_calls` value remains attempted-call budget accounting; the core chat
runtime separately requires a successful evidence result before it exposes the
proposal sink or accepts a completed investigation. Failed and policy-blocked
diff --git a/internal/ai/chat/service_filter_test.go b/internal/ai/chat/service_filter_test.go
index 75762965ae..685ae894fc 100644
--- a/internal/ai/chat/service_filter_test.go
+++ b/internal/ai/chat/service_filter_test.go
@@ -82,12 +82,14 @@ func TestRestrictInvestigationProviderToolsAllowsUnavailableOptionalDeepRead(t *
func TestRestrictInvestigationProviderToolsRequiresEvidenceAndProposalBoundary(t *testing.T) {
tests := []struct {
- name string
- tools []providers.Tool
- want string
+ name string
+ resourceType string
+ tools []providers.Tool
+ want string
}{
{
- name: "missing proposal sink",
+ name: "known type missing proposal sink",
+ resourceType: "vm",
tools: []providers.Tool{
{Name: agentcapabilities.PulseQueryToolName},
{Name: agentcapabilities.PatrolActionCapabilitiesToolName},
@@ -95,8 +97,55 @@ func TestRestrictInvestigationProviderToolsRequiresEvidenceAndProposalBoundary(t
want: agentcapabilities.PatrolProposeActionToolName,
},
{
- name: "missing evidence",
+ name: "known type missing capability lookup",
+ resourceType: "vm",
tools: []providers.Tool{
+ {Name: agentcapabilities.PulseQueryToolName},
+ {Name: agentcapabilities.PatrolProposeActionToolName},
+ },
+ want: agentcapabilities.PatrolActionCapabilitiesToolName,
+ },
+ {
+ name: "known type missing evidence",
+ resourceType: "vm",
+ tools: []providers.Tool{
+ {Name: agentcapabilities.PatrolActionCapabilitiesToolName},
+ {Name: agentcapabilities.PatrolProposeActionToolName},
+ },
+ want: "no evidence tool",
+ },
+ {
+ name: "unknown type missing proposal sink",
+ resourceType: "future-resource-kind",
+ tools: []providers.Tool{
+ {Name: agentcapabilities.PulseKnowledgeToolName},
+ {Name: agentcapabilities.PatrolActionCapabilitiesToolName},
+ },
+ want: agentcapabilities.PatrolProposeActionToolName,
+ },
+ {
+ name: "empty type missing proposal sink",
+ resourceType: "",
+ tools: []providers.Tool{
+ {Name: agentcapabilities.PulseKnowledgeToolName},
+ {Name: agentcapabilities.PatrolActionCapabilitiesToolName},
+ },
+ want: agentcapabilities.PatrolProposeActionToolName,
+ },
+ {
+ name: "unknown type missing capability lookup",
+ resourceType: "future-resource-kind",
+ tools: []providers.Tool{
+ {Name: agentcapabilities.PulseKnowledgeToolName},
+ {Name: agentcapabilities.PatrolProposeActionToolName},
+ },
+ want: agentcapabilities.PatrolActionCapabilitiesToolName,
+ },
+ {
+ name: "unknown type missing evidence",
+ resourceType: "future-resource-kind",
+ tools: []providers.Tool{
+ {Name: ""},
{Name: agentcapabilities.PatrolActionCapabilitiesToolName},
{Name: agentcapabilities.PatrolProposeActionToolName},
},
@@ -105,7 +154,7 @@ func TestRestrictInvestigationProviderToolsRequiresEvidenceAndProposalBoundary(t
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
- if _, err := restrictInvestigationProviderToolsForResourceType(tc.tools, "vm"); err == nil || !strings.Contains(err.Error(), tc.want) {
+ if _, err := restrictInvestigationProviderToolsForResourceType(tc.tools, tc.resourceType); err == nil || !strings.Contains(err.Error(), tc.want) {
t.Fatalf("error = %v, want %q", err, tc.want)
}
})
diff --git a/internal/ai/chat/service_investigation.go b/internal/ai/chat/service_investigation.go
index 81ce4ec8c9..858dd1eeca 100644
--- a/internal/ai/chat/service_investigation.go
+++ b/internal/ai/chat/service_investigation.go
@@ -254,7 +254,15 @@ func (s *Service) ExecuteInvestigationStream(ctx context.Context, req Investigat
func restrictInvestigationProviderToolsForResourceType(providerTools []providers.Tool, resourceType string) ([]providers.Tool, error) {
scopedNames, ok := agentcapabilities.PatrolInvestigationToolNamesForResourceTypes([]string{resourceType})
if !ok {
- return append([]providers.Tool(nil), providerTools...), nil
+ // Unknown and additive resource kinds retain the full already-governed
+ // profile so they do not silently lose evidence access. They must still
+ // satisfy the same investigation boundary as a typed projection before
+ // inference begins.
+ filtered := append([]providers.Tool(nil), providerTools...)
+ if err := validateInvestigationProviderTools(filtered, resourceType); err != nil {
+ return nil, err
+ }
+ return filtered, nil
}
// The typed map is a least-manifest ceiling, not a claim that every
@@ -272,32 +280,44 @@ func restrictInvestigationProviderToolsForResourceType(providerTools []providers
}
filtered := make([]providers.Tool, 0, len(scoped))
- present := make(map[string]bool, len(scoped))
- evidenceCount := 0
for _, tool := range providerTools {
name := strings.TrimSpace(tool.Name)
if !scoped[name] {
continue
}
filtered = append(filtered, tool)
+ }
+ if err := validateInvestigationProviderTools(filtered, resourceType); err != nil {
+ return nil, err
+ }
+ return filtered, nil
+}
+
+func validateInvestigationProviderTools(providerTools []providers.Tool, resourceType string) error {
+ present := make(map[string]bool, len(providerTools))
+ evidenceCount := 0
+ for _, tool := range providerTools {
+ name := strings.TrimSpace(tool.Name)
+ if name == "" {
+ continue
+ }
present[name] = true
if isInvestigationEvidenceTool(name) {
evidenceCount++
}
}
-
for _, required := range []string{
agentcapabilities.PatrolActionCapabilitiesToolName,
agentcapabilities.PatrolProposeActionToolName,
} {
if !present[required] {
- return nil, fmt.Errorf("failed to project scoped investigation tools: required tool unavailable after profile projection: %s", required)
+ return fmt.Errorf("failed to project investigation tools: required tool unavailable after profile projection: %s", required)
}
}
if evidenceCount == 0 {
- return nil, fmt.Errorf("failed to project scoped investigation tools: no evidence tool is available for resource type %q", strings.TrimSpace(resourceType))
+ return fmt.Errorf("failed to project investigation tools: no evidence tool is available for resource type %q", strings.TrimSpace(resourceType))
}
- return filtered, nil
+ return nil
}
// ListInvestigationTools names the tools an investigation run offers,