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.

Preserve causal evidence in Patrol conclusions

rcourtman40897a46e69f
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index ab39c323b0..ceb32486e4 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -77,6 +77,17 @@ results before asserting that no peer is implicated. The Docker `services`
operation is explicitly Swarm-only: an empty service list never proves the
absence of ordinary Docker containers or container dependencies, and its tool
result must direct the model to topology or search for that evidence.
+Every accepted investigation proposal carries two separately typed resource
+identities: the action target and the exact canonical causal resource
+established by collected evidence. They may be equal, but a cross-resource
+diagnosis must preserve the peer or dependency as the causal identity and the
+proposal reason must preserve its observed state and causal chain. The
+tool-free completion turn receives that accepted record as an evidence
+checkpoint. Before persistence, core reconciles the Root Cause section against
+the checkpoint and restores the exact causal identity and recorded basis if the
+provider's final prose omits or downgrades them. This reconciliation adds no new
+model claim and grants no action authority; it prevents the narrative from
+contradicting the already accepted, evidence-bound proposal record.
An investigation cannot complete or submit a typed action proposal before the
model has received at least one successful structured result from an advertised
evidence tool. Until then, core withholds proposal authority while leaving
diff --git a/internal/ai/chat/agentic.go b/internal/ai/chat/agentic.go
index 9abddecaca..4c8eef9ebd 100644
--- a/internal/ai/chat/agentic.go
+++ b/internal/ai/chat/agentic.go
@@ -954,6 +954,7 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, me
investigationEvidenceStartRepairAttempted := false
toolBlockedLastTurn := false // When true, request final text after budget/loop block
investigationProposalCompleted := false
+ var acceptedInvestigationProposalBasis *investigationProposalBasis
acceptedFindingReports := 0
// Patrol core normally establishes the exact-scope active-finding snapshot
// before the provider is invoked. Legacy/narrow adapters can still expose a
@@ -1207,7 +1208,7 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, me
case investigationProposalCompleted:
req.Tools = nil
textOnlySafetyBrake = true
- req.System += investigationProposalCompletedSystemPrompt
+ req.System += investigationProposalCompletionSystemPrompt(acceptedInvestigationProposalBasis)
case a.maxEvidenceCalls > 0 && a.totalEvidenceCalls >= a.maxEvidenceCalls:
if a.successfulEvidenceCalls > 0 {
req.Tools = investigationTerminalTools(tools)
@@ -1743,6 +1744,23 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, me
continue
}
+ if isPatrolInvestigationExecution(a.currentExecutionProfile()) && investigationProposalCompleted && acceptedInvestigationProposalBasis != nil {
+ grounded, addition := groundInvestigationConclusionInProposal(assistantMsg.Content, acceptedInvestigationProposalBasis)
+ if grounded != assistantMsg.Content {
+ assistantMsg.Content = grounded
+ resultMessages[len(resultMessages)-1].Content = grounded
+ providerMessages[len(providerMessages)-1].Content = grounded
+ if addition != "" {
+ jsonData, _ := json.Marshal(ContentData{Text: addition})
+ callback(StreamEvent{Type: "content", Data: jsonData})
+ }
+ log.Warn().
+ Str("session_id", sessionID).
+ Str("causal_resource_id", acceptedInvestigationProposalBasis.CausalResourceID).
+ Msg("[AgenticLoop] Restored accepted proposal evidence checkpoint in investigation conclusion")
+ }
+ }
+
// === FSM ENFORCEMENT GATE 2: Check if final answer is allowed ===
a.mu.Lock()
fsm := a.sessionFSM
@@ -2519,6 +2537,7 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, me
}
if isPatrolInvestigationExecution(a.currentExecutionProfile()) && tc.Name == agentcapabilities.PatrolProposeActionToolName {
investigationProposalCompleted = true
+ acceptedInvestigationProposalBasis = investigationProposalBasisFromToolCall(tc)
}
}
diff --git a/internal/ai/chat/agentic_investigation_budget.go b/internal/ai/chat/agentic_investigation_budget.go
index c254fd3c36..f3071e1f3a 100644
--- a/internal/ai/chat/agentic_investigation_budget.go
+++ b/internal/ai/chat/agentic_investigation_budget.go
@@ -14,9 +14,121 @@ func isPatrolInvestigationExecution(profile aitools.ExecutionProfile) bool {
return profile == aitools.ProfilePatrolInvestigation
}
-const investigationProposalCompletedSystemPrompt = `
+type investigationProposalBasis struct {
+ TargetResourceID string
+ CausalResourceID string
+ CapabilityName string
+ Reason string
+}
+
+func investigationProposalBasisFromToolCall(call providers.ToolCall) *investigationProposalBasis {
+ if call.Name != agentcapabilities.PatrolProposeActionToolName {
+ return nil
+ }
+ stringInput := func(key string) string {
+ value, _ := call.Input[key].(string)
+ return strings.TrimSpace(value)
+ }
+ basis := &investigationProposalBasis{
+ TargetResourceID: stringInput("resource_id"),
+ CausalResourceID: stringInput("causal_resource_id"),
+ CapabilityName: stringInput("capability_name"),
+ Reason: stringInput("reason"),
+ }
+ if basis.TargetResourceID == "" || basis.CausalResourceID == "" || basis.CapabilityName == "" || basis.Reason == "" {
+ return nil
+ }
+ return basis
+}
+
+func investigationProposalCompletionSystemPrompt(basis *investigationProposalBasis) string {
+ prompt := `
INVESTIGATION COMPLETION: A typed action proposal has already been accepted for this run. Do not call more tools. Produce the required investigation summary from the evidence already collected and state that the proposal is pending governed policy or operator handling; never claim that it executed.`
+ if basis == nil {
+ return prompt
+ }
+ return prompt + fmt.Sprintf(`
+
+ACCEPTED PROPOSAL EVIDENCE CHECKPOINT: The governed proposal record identifies causal resource %q, action target %q, capability %q, and this exact recorded basis: %q. Preserve the causal resource identity and recorded basis in the Root Cause section, distinguish the action target in Affected Resources, and do not contradict or downgrade facts already used to justify the accepted proposal.`, basis.CausalResourceID, basis.TargetResourceID, basis.CapabilityName, basis.Reason)
+}
+
+// groundInvestigationConclusionInProposal makes the typed proposal record the
+// terminal source of truth for facts the model already committed as its action
+// rationale. Provider prose remains free-form, but it cannot omit the exact
+// causal identity or rationale after Patrol has accepted them structurally.
+func groundInvestigationConclusionInProposal(content string, basis *investigationProposalBasis) (string, string) {
+ if basis == nil || strings.TrimSpace(content) == "" {
+ return content, ""
+ }
+ reason := strings.Join(strings.Fields(basis.Reason), " ")
+ checkpoint := fmt.Sprintf("Proposal evidence checkpoint: causal resource `%s`; recorded basis: %s", basis.CausalResourceID, reason)
+ rootCause := markdownInvestigationSection(content, "Root Cause")
+ if strings.Contains(strings.ToLower(rootCause), strings.ToLower(basis.CausalResourceID)) &&
+ strings.Contains(strings.ToLower(rootCause), strings.ToLower(reason)) {
+ return content, ""
+ }
+ grounded, ok := appendToMarkdownInvestigationSection(content, "Root Cause", checkpoint)
+ if !ok {
+ separator := "\n\n"
+ if strings.TrimSpace(content) == "" {
+ separator = ""
+ }
+ addition := separator + "### Root Cause\n" + checkpoint
+ return content + addition, addition
+ }
+ return grounded, "\n\n" + checkpoint
+}
+
+func markdownInvestigationSection(content, heading string) string {
+ lines := strings.Split(content, "\n")
+ start := -1
+ for index, line := range lines {
+ trimmed := strings.TrimSpace(line)
+ if start < 0 {
+ if strings.EqualFold(trimmed, "### "+heading) {
+ start = index + 1
+ }
+ continue
+ }
+ if strings.HasPrefix(trimmed, "### ") {
+ return strings.Join(lines[start:index], "\n")
+ }
+ }
+ if start >= 0 {
+ return strings.Join(lines[start:], "\n")
+ }
+ return ""
+}
+
+func appendToMarkdownInvestigationSection(content, heading, addition string) (string, bool) {
+ lines := strings.Split(content, "\n")
+ start := -1
+ insertAt := len(lines)
+ for index, line := range lines {
+ trimmed := strings.TrimSpace(line)
+ if start < 0 {
+ if strings.EqualFold(trimmed, "### "+heading) {
+ start = index + 1
+ }
+ continue
+ }
+ if strings.HasPrefix(trimmed, "### ") {
+ insertAt = index
+ break
+ }
+ }
+ if start < 0 {
+ return content, false
+ }
+ prefix := append([]string(nil), lines[:insertAt]...)
+ for len(prefix) > 0 && strings.TrimSpace(prefix[len(prefix)-1]) == "" {
+ prefix = prefix[:len(prefix)-1]
+ }
+ prefix = append(prefix, "", addition, "")
+ prefix = append(prefix, lines[insertAt:]...)
+ return strings.Join(prefix, "\n"), true
+}
const investigationEvidenceStartRepairSystemPrompt = `
diff --git a/internal/ai/chat/agentic_investigation_budget_w0716_coverage_test.go b/internal/ai/chat/agentic_investigation_budget_w0716_coverage_test.go
index 0a2cb244b3..868c457a1c 100644
--- a/internal/ai/chat/agentic_investigation_budget_w0716_coverage_test.go
+++ b/internal/ai/chat/agentic_investigation_budget_w0716_coverage_test.go
@@ -49,6 +49,53 @@ func TestInvestigationCompletionRequiresSupportedProposalBeforeProse(t *testing.
}
}
+func TestInvestigationProposalCompletionCarriesTypedCausalCheckpoint(t *testing.T) {
+ call := providers.ToolCall{
+ Name: agentcapabilities.PatrolProposeActionToolName,
+ Input: map[string]interface{}{
+ "resource_id": "app-container-client",
+ "causal_resource_id": "app-container-dependency",
+ "capability_name": "restart",
+ "reason": "app-container-dependency is exited and the client health check is failing",
+ },
+ }
+ basis := investigationProposalBasisFromToolCall(call)
+ if basis == nil || basis.CausalResourceID != "app-container-dependency" {
+ t.Fatalf("proposal basis = %#v, want exact causal resource", basis)
+ }
+ prompt := investigationProposalCompletionSystemPrompt(basis)
+ for _, want := range []string{"app-container-dependency", "app-container-client", "is exited", "Root Cause"} {
+ if !strings.Contains(prompt, want) {
+ t.Fatalf("completion prompt missing %q: %s", want, prompt)
+ }
+ }
+}
+
+func TestGroundInvestigationConclusionInProposalRestoresOmittedCausalEvidence(t *testing.T) {
+ basis := &investigationProposalBasis{
+ TargetResourceID: "app-container-client",
+ CausalResourceID: "app-container-dependency",
+ CapabilityName: "restart",
+ Reason: "app-container-dependency is exited and its client is unhealthy",
+ }
+ content := "### Investigation Summary\nClient health is failing.\n\n### Root Cause\nThe precise dependency state is unknown.\n\n### Affected Resources\n`app-container-client`.\n\n### Recommendation\nRestart proposal pending.\n\n### Conclusion\nNEEDS_ATTENTION: pending."
+ grounded, addition := groundInvestigationConclusionInProposal(content, basis)
+ rootCause := markdownInvestigationSection(grounded, "Root Cause")
+ for _, want := range []string{"app-container-dependency", "is exited", "recorded basis"} {
+ if !strings.Contains(rootCause, want) {
+ t.Fatalf("grounded Root Cause missing %q:\n%s", want, grounded)
+ }
+ }
+ if addition == "" {
+ t.Fatal("expected a stream-visible grounding addition")
+ }
+
+ again, duplicate := groundInvestigationConclusionInProposal(grounded, basis)
+ if again != grounded || duplicate != "" {
+ t.Fatalf("grounding must be idempotent; duplicate=%q\n%s", duplicate, again)
+ }
+}
+
func Test_w0716_budget_IsInvestigationEvidenceTool(t *testing.T) {
tests := []struct {
name string
diff --git a/internal/ai/chat/service_investigation.go b/internal/ai/chat/service_investigation.go
index 858dd1eeca..73885d4420 100644
--- a/internal/ai/chat/service_investigation.go
+++ b/internal/ai/chat/service_investigation.go
@@ -2,6 +2,7 @@ package chat
import (
"context"
+ "encoding/json"
"errors"
"fmt"
"strings"
@@ -223,16 +224,29 @@ func (s *Service) ExecuteInvestigationStream(ctx context.Context, req Investigat
}
}
+ proposal, failedAttempts, proposalErr := capture.Outcome()
var contentBuilder strings.Builder
for _, msg := range resultMessages {
if msg.Role == "assistant" && msg.Content != "" {
contentBuilder.WriteString(msg.Content)
}
}
-
- proposal, failedAttempts, proposalErr := capture.Outcome()
+ content := contentBuilder.String()
+ if runErr == nil && proposalErr == nil && proposal != nil {
+ grounded, addition := groundInvestigationConclusionInProposal(content, &investigationProposalBasis{
+ TargetResourceID: proposal.ResourceID,
+ CausalResourceID: proposal.CausalResourceID,
+ CapabilityName: proposal.CapabilityName,
+ Reason: proposal.Reason,
+ })
+ content = grounded
+ if addition != "" {
+ data, _ := json.Marshal(ContentData{Text: addition})
+ callback(StreamEvent{Type: "content", Data: data})
+ }
+ }
result := &InvestigationRunResult{
- Content: contentBuilder.String(),
+ Content: content,
Proposal: proposal,
FailedProposalAttempts: failedAttempts,
InputTokens: loop.GetTotalInputTokens(),
diff --git a/internal/ai/chat/service_tooling_test.go b/internal/ai/chat/service_tooling_test.go
index 3cef9a88c9..039c211e47 100644
--- a/internal/ai/chat/service_tooling_test.go
+++ b/internal/ai/chat/service_tooling_test.go
@@ -1172,10 +1172,11 @@ func TestInvestigationLoopRedactsProposalParamsEverywhereDurable(t *testing.T) {
ID: "p-1",
Name: agentcapabilities.PatrolProposeActionToolName,
Input: map[string]interface{}{
- "resource_id": "vm:42",
- "capability_name": "restart",
- "params": map[string]interface{}{"mode": "graceful"},
- "reason": "recover the stalled web tier",
+ "resource_id": "vm:42",
+ "causal_resource_id": "vm:dependency",
+ "capability_name": "restart",
+ "params": map[string]interface{}{"mode": "graceful"},
+ "reason": "vm:dependency is stopped, stalling the web tier",
},
}},
}})
@@ -1193,7 +1194,7 @@ func TestInvestigationLoopRedactsProposalParamsEverywhereDurable(t *testing.T) {
}
}
}
- callback(providers.StreamEvent{Type: "content", Data: providers.ContentEvent{Text: "diagnosis: restart proposed"}})
+ callback(providers.StreamEvent{Type: "content", Data: providers.ContentEvent{Text: "### Investigation Summary\nRestart proposed.\n\n### Root Cause\nDependency failure.\n\n### Affected Resources\n`vm:42`.\n\n### Recommendation\nRestart pending.\n\n### Conclusion\nNEEDS_ATTENTION: pending."}})
callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{}})
return nil
}
@@ -1261,6 +1262,9 @@ func TestInvestigationLoopRedactsProposalParamsEverywhereDurable(t *testing.T) {
if proposal == nil || proposal.Params["mode"] != "graceful" || proposal.Identity.FindingID != "f-9" || proposal.InvocationID != "p-1" {
t.Fatalf("captured proposal = %#v", proposal)
}
+ if proposal.CausalResourceID != "vm:dependency" {
+ t.Fatalf("captured causal resource = %q, want vm:dependency", proposal.CausalResourceID)
+ }
}
func TestProposalRawInputOverrideNeverLeaksThroughProgressEvents(t *testing.T) {
diff --git a/internal/ai/tools/proposal_capture.go b/internal/ai/tools/proposal_capture.go
index 703570ce2b..fef7c6fe93 100644
--- a/internal/ai/tools/proposal_capture.go
+++ b/internal/ai/tools/proposal_capture.go
@@ -57,12 +57,18 @@ type ProposalIdentity struct {
// CapturedProposal is one validated typed action proposal.
type CapturedProposal struct {
- InvocationID string
- Identity ProposalIdentity
- ResourceID string
- CapabilityName string
- Params map[string]interface{}
- Reason string
+ InvocationID string
+ Identity ProposalIdentity
+ ResourceID string
+ // CausalResourceID is the exact canonical resource whose observed state
+ // established the remediation rationale. It may equal ResourceID when the
+ // affected/action target is also causal. Keeping this identity in the typed
+ // proposal prevents the terminal narrative from collapsing a cross-resource
+ // diagnosis back onto the symptom resource.
+ CausalResourceID string
+ CapabilityName string
+ Params map[string]interface{}
+ Reason string
}
// ProposalCatalog resolves a resource's advertised capabilities for
@@ -156,13 +162,14 @@ func cloneParams(params map[string]interface{}) (map[string]interface{}, error)
return clone, nil
}
-func proposalFingerprint(resourceID, capabilityName, reason string, params map[string]interface{}) (string, error) {
+func proposalFingerprint(resourceID, causalResourceID, capabilityName, reason string, params map[string]interface{}) (string, error) {
payload := struct {
- ResourceID string `json:"resourceId"`
- CapabilityName string `json:"capabilityName"`
- Reason string `json:"reason"`
- Params map[string]interface{} `json:"params"`
- }{resourceID, capabilityName, reason, params}
+ ResourceID string `json:"resourceId"`
+ CausalResourceID string `json:"causalResourceId"`
+ CapabilityName string `json:"capabilityName"`
+ Reason string `json:"reason"`
+ Params map[string]interface{} `json:"params"`
+ }{resourceID, causalResourceID, capabilityName, reason, params}
encoded, err := json.Marshal(payload)
if err != nil {
return "", fmt.Errorf("proposal payload is not fingerprintable")
@@ -189,7 +196,7 @@ func (c *ProposalCapture) RecordFailedAttempt() {
// - distinct ID, valid payload: terminal ambiguity, capture invalidated
// (concurrent execution makes "first" nondeterministic, so neither
// call wins).
-func (c *ProposalCapture) Submit(invocationID, resourceID, capabilityName, reason string, params map[string]interface{}) error {
+func (c *ProposalCapture) Submit(invocationID, resourceID, causalResourceID, capabilityName, reason string, params map[string]interface{}) error {
invocationID = strings.TrimSpace(invocationID)
if invocationID == "" {
c.mu.Lock()
@@ -204,7 +211,7 @@ func (c *ProposalCapture) Submit(invocationID, resourceID, capabilityName, reaso
c.mu.Unlock()
return cloneErr
}
- fingerprint, fingerprintErr := proposalFingerprint(resourceID, capabilityName, reason, params)
+ fingerprint, fingerprintErr := proposalFingerprint(resourceID, causalResourceID, capabilityName, reason, params)
if fingerprintErr != nil {
c.mu.Lock()
c.failedAttempts++
@@ -223,12 +230,13 @@ func (c *ProposalCapture) Submit(invocationID, resourceID, capabilityName, reaso
c.state = proposalCaptureHeld
c.fingerprint = fingerprint
c.proposal = &CapturedProposal{
- InvocationID: invocationID,
- Identity: c.identity.clone(),
- ResourceID: resourceID,
- CapabilityName: capabilityName,
- Params: params,
- Reason: reason,
+ InvocationID: invocationID,
+ Identity: c.identity.clone(),
+ ResourceID: resourceID,
+ CausalResourceID: causalResourceID,
+ CapabilityName: capabilityName,
+ Params: params,
+ Reason: reason,
}
return nil
default: // proposalCaptureHeld
diff --git a/internal/ai/tools/proposal_capture_test.go b/internal/ai/tools/proposal_capture_test.go
index 4e0d82d7e7..f602ed54d6 100644
--- a/internal/ai/tools/proposal_capture_test.go
+++ b/internal/ai/tools/proposal_capture_test.go
@@ -48,10 +48,11 @@ func newInvestigationExecutor(t *testing.T, capture *ProposalCapture) *PulseTool
func proposeArgs() map[string]interface{} {
return map[string]interface{}{
- "resource_id": "vm:42",
- "capability_name": "restart",
- "params": map[string]interface{}{"mode": "graceful"},
- "reason": "recover the stalled web tier",
+ "resource_id": "vm:42",
+ "causal_resource_id": "vm:42",
+ "capability_name": "restart",
+ "params": map[string]interface{}{"mode": "graceful"},
+ "reason": "recover the stalled web tier",
}
}
@@ -267,9 +268,10 @@ func TestActionCapabilitiesCanonicalizeResolvedDockerCoordinate(t *testing.T) {
assert.Contains(t, result.Content[0].Text, `"name":"start"`)
proposalResult := executePropose(t, exec, "proposal-docker", map[string]interface{}{
- "resource_id": rawCoordinate,
- "capability_name": "start",
- "reason": "restore the stopped worker",
+ "resource_id": rawCoordinate,
+ "causal_resource_id": rawCoordinate,
+ "capability_name": "start",
+ "reason": "restore the stopped worker",
})
assert.Contains(t, proposalResult.Content[0].Text, canonicalID)
proposal, failed, outcomeErr := capture.Outcome()
@@ -310,7 +312,7 @@ func TestActionCapabilitiesCanonicalizePulseReadAppContainerCoordinate(t *testin
assert.Contains(t, result.Content[0].Text, `"resource_id":"`+canonicalID+`"`)
proposalResult := executePropose(t, exec, "proposal-pulse-read", map[string]interface{}{
- "resource_id": rawCoordinate, "capability_name": "restart", "reason": "restore container health",
+ "resource_id": rawCoordinate, "causal_resource_id": rawCoordinate, "capability_name": "restart", "reason": "restore container health",
})
assert.Contains(t, proposalResult.Content[0].Text, canonicalID)
proposal, failed, outcomeErr := capture.Outcome()
@@ -363,6 +365,7 @@ func TestProposalExposureProjectorRedactsParams(t *testing.T) {
redacted := agentcapabilities.RedactToolCallArgumentsForExposure(agentcapabilities.PatrolProposeActionToolName, args)
assert.Equal(t, agentcapabilities.RedactedProposalParamsMarker, redacted["params"])
assert.Equal(t, "vm:42", redacted["resource_id"])
+ assert.Equal(t, "vm:42", redacted["causal_resource_id"])
// The transient map used for provider continuation and validation is
// untouched.
if _, ok := args["params"].(map[string]interface{}); !ok {
@@ -383,7 +386,7 @@ func TestCapturedProposalIsImmuneToCallerMutation(t *testing.T) {
args := proposeArgs()
params := args["params"].(map[string]interface{})
- require.NoError(t, capture.Submit("call-a", "vm:42", "restart", "recover", params))
+ require.NoError(t, capture.Submit("call-a", "vm:42", "vm:42", "restart", "recover", params))
// Mutating the caller's map after validation must not change the
// actionable proposal (or its fingerprint identity).
@@ -455,9 +458,10 @@ func TestProposeActionSchemaExposesOnlyModelAuthoredFields(t *testing.T) {
continue
}
assert.ElementsMatch(t,
- []string{"resource_id", "capability_name", "params", "reason"},
+ []string{"resource_id", "causal_resource_id", "capability_name", "params", "reason"},
mapKeys(tool.InputSchema.Properties),
)
+ assert.Contains(t, tool.InputSchema.Required, "causal_resource_id")
return
}
t.Fatal("patrol_propose_action missing from investigation projection")
diff --git a/internal/ai/tools/tools_propose.go b/internal/ai/tools/tools_propose.go
index e10f1d8e74..7f0ef7c171 100644
--- a/internal/ai/tools/tools_propose.go
+++ b/internal/ai/tools/tools_propose.go
@@ -48,6 +48,8 @@ func (e *PulseToolExecutor) registerProposeTools() {
Reference an advertised resource capability (see the resource's capability catalog) and fill only its declared parameters. Never place secrets in params - sensitive parameters are supplied by an operator at approval time.
+Identify the exact canonical causal resource established by the collected evidence. This may equal the action target, but when a dependency or peer caused the finding it must name that different resource. The reason must preserve the causal resource's observed state and explain the causal chain.
+
Submit at most one proposal per investigation. If no safe remediation exists, conclude without proposing.`,
InputSchema: InputSchema{
Type: "object",
@@ -60,6 +62,10 @@ Submit at most one proposal per investigation. If no safe remediation exists, co
Type: "string",
Description: "Advertised capability name on that resource",
},
+ "causal_resource_id": {
+ Type: "string",
+ Description: "Exact canonical resource ID whose observed state establishes the remediation rationale; may equal resource_id",
+ },
"params": {
Type: "object",
Description: "Values for the capability's declared parameters (non-sensitive only)",
@@ -69,7 +75,7 @@ Submit at most one proposal per investigation. If no safe remediation exists, co
Description: "Why this action remediates the finding",
},
},
- Required: []string{"resource_id", "capability_name", "reason"},
+ Required: []string{"resource_id", "causal_resource_id", "capability_name", "reason"},
},
},
Handler: func(ctx context.Context, exec *PulseToolExecutor, args map[string]interface{}) (CallToolResult, error) {
@@ -151,15 +157,16 @@ func (e *PulseToolExecutor) executeProposeAction(ctx context.Context, args map[s
}
resourceID := e.canonicalProposalResourceID(stringArg(args, "resource_id"))
+ causalResourceID := e.canonicalProposalResourceID(stringArg(args, "causal_resource_id"))
capabilityName := strings.TrimSpace(stringArg(args, "capability_name"))
reason := strings.TrimSpace(stringArg(args, "reason"))
params, _ := args["params"].(map[string]interface{})
if params == nil {
params = map[string]interface{}{}
}
- if resourceID == "" || capabilityName == "" || reason == "" {
+ if resourceID == "" || causalResourceID == "" || capabilityName == "" || reason == "" {
capture.RecordFailedAttempt()
- return NewErrorResult(fmt.Errorf("resource_id, capability_name, and reason are required")), nil
+ return NewErrorResult(fmt.Errorf("resource_id, causal_resource_id, capability_name, and reason are required")), nil
}
if err := validateProposalAgainstCatalog(ctx, capture.catalog, resourceID, capabilityName, params); err != nil {
@@ -167,7 +174,7 @@ func (e *PulseToolExecutor) executeProposeAction(ctx context.Context, args map[s
return NewErrorResult(err), nil
}
- if err := capture.Submit(InvocationIDFromContext(ctx), resourceID, capabilityName, reason, params); err != nil {
+ if err := capture.Submit(InvocationIDFromContext(ctx), resourceID, causalResourceID, capabilityName, reason, params); err != nil {
return NewErrorResult(err), nil
}
return NewTextResult(fmt.Sprintf(