Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildConversationContext ¶
func BuildConversationContext(messages []ConversationMessage) string
BuildConversationContext formats conversation history for the policy judge. System messages are excluded. Tool outputs are replaced with "[tool output redacted]".
Types ¶
type ApplicablePolicy ¶
type ApplicablePolicy struct {
ID string // Kubernetes resource name (e.g., "mp1-abc123")
Manifest types.MessagePolicyManifest
}
ApplicablePolicy pairs a policy's Kubernetes resource name with its manifest.
type ConversationMessage ¶
type ConversationMessage struct {
Role string // "user", "assistant", "tool", "system"
Content string
ToolCalls []ToolCallInfo
ToolCallID string
}
ConversationMessage represents a message in conversation history for policy evaluation.
type Helper ¶
type Helper struct {
// contains filtered or unexported fields
}
func (*Helper) EvaluateMessage ¶
func (h *Helper) EvaluateMessage(ctx context.Context, policies []ApplicablePolicy, conversationHistory []ConversationMessage, targetMessage string, direction types.PolicyDirection) []MessagePolicyViolation
EvaluateMessage runs all applicable policies against a message in parallel. Returns a slice of violations (empty if all policies pass). Never returns an error; LLM failures are treated as violations (fail closed).
func (*Helper) GetApplicablePolicies ¶
func (h *Helper) GetApplicablePolicies(user kuser.Info, direction types.PolicyDirection) ([]ApplicablePolicy, error)
GetApplicablePolicies returns all policies that apply to the given user and direction.
type MessagePolicyViolation ¶
type MessagePolicyViolation struct {
PolicyID string
PolicyName string
PolicyDefinition string
Explanation string
}
MessagePolicyViolation is the result when a message violates a policy. nolint:revive
type ToolCallInfo ¶
ToolCallInfo contains the name and arguments of a tool call.