mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-11-30 01:32:00 +01:00
Patrol investigations inferred their outcome from prose markers, so a bold or bulleted RESOLVED line became the terminal needs_attention and the finding was never investigated again. Timeouts clustered on subscription agents. Patrol's 60s stream idle timeout bounds a whole buffered CLI turn there, three investigations queued on one serial CLI slot, and the final summary call was capped at 20s. - Add patrol_conclude_investigation, an investigation-only, side-effect-free capture of resolved, cannot_fix or needs_attention. It is carried on InvestigationRunResult and OrchestratorInvestigationResult. - After a conclusion, the next turn is the summary. The final turn offers only the tools that end a run. A deadline reserve makes the current turn final before the run times out, and the summary call may use the time left. - Give investigation turns on subscription agents a 4-minute turn budget, a 25-minute default timeout and one investigation at a time. These limits are republished on config reload without holding the service lock across the Patrol lock. - Derive Patrol's outer deadline from the effective timeout. Sessions now carry their own deadline, and the stuck-run sweep measures a live run against it, so neither a lowered timeout nor the previous run's time resets a running investigation. - Record a run orphaned by a restart as interrupted, not timed out. A first investigation cut short that way used to stay running for good, which also blocked a manual re-run. Recovery applies only while the finding still shows that run, takes a result the run's session already recorded, and keeps an action outcome such as fix_queued. - Add unclassified and interrupted outcomes, with lifecycle, telemetry bucket, digest and record handling.
84 lines
3.7 KiB
Go
84 lines
3.7 KiB
Go
package agentcapabilities
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
)
|
|
|
|
func TestPatrolScopedToolProjectionUsesTypedLeastManifest(t *testing.T) {
|
|
dockerEvidence, ok := PatrolEvidenceToolNamesForResourceTypes([]string{"app-container"})
|
|
if !ok {
|
|
t.Fatal("app-container scope was not recognized")
|
|
}
|
|
if !slices.Equal(dockerEvidence, []string{PulseQueryToolName, PulseReadToolName, PulseDockerToolName}) {
|
|
t.Fatalf("Docker evidence tools = %v", dockerEvidence)
|
|
}
|
|
for _, forbidden := range []string{PulseStorageToolName, PulseKubernetesToolName, PulsePMGToolName, PulseAlertsToolName, PulseKnowledgeToolName, PulseSummarizeToolName} {
|
|
if slices.Contains(dockerEvidence, forbidden) {
|
|
t.Fatalf("Docker evidence surface included unrelated tool %q: %v", forbidden, dockerEvidence)
|
|
}
|
|
}
|
|
|
|
storageInvestigation, ok := PatrolInvestigationToolNamesForResourceTypes([]string{"physical-disk"})
|
|
if !ok {
|
|
t.Fatal("physical-disk scope was not recognized")
|
|
}
|
|
for _, required := range []string{PulseQueryToolName, PulseReadToolName, PulseMetricsToolName, PulseStorageToolName, PatrolActionCapabilitiesToolName, PatrolProposeActionToolName, PatrolConcludeInvestigationToolName} {
|
|
if !slices.Contains(storageInvestigation, required) {
|
|
t.Fatalf("storage investigation tools missing %q: %v", required, storageInvestigation)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestPatrolScopedToolProjectionFailsOpenToGovernedProfileForUnknownType(t *testing.T) {
|
|
if names, ok := PatrolEvidenceToolNamesForResourceTypes(nil); ok || names != nil {
|
|
t.Fatalf("empty scope = (%v, %v), want no projection", names, ok)
|
|
}
|
|
if names, ok := PatrolEvidenceToolNamesForResourceTypes([]string{"future-resource-kind"}); ok || names != nil {
|
|
t.Fatalf("unknown scope = (%v, %v), want no projection", names, ok)
|
|
}
|
|
if names, ok := PatrolEvidenceToolNamesForResourceTypes([]string{"app-container", "future-resource-kind"}); ok || names != nil {
|
|
t.Fatalf("mixed unknown scope = (%v, %v), want no partial projection", names, ok)
|
|
}
|
|
}
|
|
|
|
func TestPatrolScopedToolProjectionComposesProfileOwnedTools(t *testing.T) {
|
|
detection, ok := PatrolDetectionToolNamesForResourceTypes([]string{"network-endpoint"})
|
|
if !ok {
|
|
t.Fatal("network-endpoint scope was not recognized")
|
|
}
|
|
for _, required := range []string{PulseQueryToolName, PatrolGetFindingsToolName, PatrolReportFindingToolName, PatrolAssessFindingToolName} {
|
|
if !slices.Contains(detection, required) {
|
|
t.Fatalf("detection surface missing %q: %v", required, detection)
|
|
}
|
|
}
|
|
if slices.Contains(detection, PatrolResolveFindingToolName) {
|
|
t.Fatalf("detection surface exposed the legacy direct resolver: %v", detection)
|
|
}
|
|
if slices.Contains(detection, PulseReadToolName) {
|
|
t.Fatalf("detection surface included optional deep-read authority: %v", detection)
|
|
}
|
|
if slices.Contains(detection, PatrolProposeActionToolName) {
|
|
t.Fatalf("detection surface gained investigation proposal authority: %v", detection)
|
|
}
|
|
if slices.Contains(detection, PatrolConcludeInvestigationToolName) {
|
|
t.Fatalf("detection surface gained the investigation conclusion capture: %v", detection)
|
|
}
|
|
}
|
|
|
|
func TestGuestInvestigationsCanReadCollectedBackupEvidence(t *testing.T) {
|
|
for _, kind := range []string{"vm", "system-container"} {
|
|
t.Run(kind, func(t *testing.T) {
|
|
names, ok := PatrolInvestigationToolNamesForResourceTypes([]string{kind})
|
|
if !ok || !slices.Contains(names, PulseStorageToolName) {
|
|
t.Fatalf("guest investigation lacks backup evidence: %v", names)
|
|
}
|
|
for _, name := range names {
|
|
if !IsPatrolInfrastructureEvidenceToolName(name) && name != PatrolActionCapabilitiesToolName && name != PatrolProposeActionToolName && name != PatrolConcludeInvestigationToolName {
|
|
t.Fatalf("read projection gained action authority: %s", name)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|