policy

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Contents

type Contents map[string]string

Contents is a map of file paths to their policy data (Rego).

type EnrichPolicyResult added in v0.5.0

type EnrichPolicyResult struct {
	Prompts []EnrichTask `json:"prompts"`
}

EnrichPolicyResult represents the result of enrich policy evaluation

func (*EnrichPolicyResult) EnsureTaskIDs added in v0.5.0

func (r *EnrichPolicyResult) EnsureTaskIDs()

EnsureTaskIDs ensures all tasks have IDs

func (*EnrichPolicyResult) TaskCount added in v0.5.0

func (r *EnrichPolicyResult) TaskCount() int

TaskCount returns the total number of tasks

type EnrichResult added in v0.7.0

type EnrichResult struct {
	ID     string `json:"id"`
	Prompt string `json:"prompt"` // Actual prompt text used
	Result any    `json:"result"` // Task execution result
}

EnrichResult represents a single enrichment task result with metadata

type EnrichResults added in v0.5.0

type EnrichResults []EnrichResult

EnrichResults represents all enrichment task results as an array

type EnrichTask added in v0.5.0

type EnrichTask struct {
	ID       string                   `json:"id"`
	Template string                   `json:"template,omitempty"` // Template file path
	Params   map[string]any           `json:"params,omitempty"`   // Template parameters
	Inline   string                   `json:"inline,omitempty"`   // Inline prompt
	Format   types.GenAIContentFormat `json:"format"`             // "text" or "json"
}

EnrichTask represents a prompt-based enrichment task definition

func (*EnrichTask) EnsureID added in v0.5.0

func (t *EnrichTask) EnsureID()

EnsureID ensures the task has an ID, generating one if necessary

func (*EnrichTask) GetPromptContent added in v0.5.0

func (t *EnrichTask) GetPromptContent() string

GetPromptContent returns the prompt content (inline or template path)

func (*EnrichTask) HasTemplateFile added in v0.7.0

func (t *EnrichTask) HasTemplateFile() bool

HasTemplateFile returns true if task uses a template file

func (*EnrichTask) Validate added in v0.5.0

func (t *EnrichTask) Validate() error

Validate checks if the task configuration is valid

type QueryFunc

type QueryFunc func(ctx context.Context, query string, data any, result any, queryOptions ...opaq.QueryOption) error

type TestData

type TestData struct {
	// Metafiles is the metadata (README) of the test data that is generated by the AI.
	Metafiles map[types.AlertSchema]map[string]string
	// Data is the test data that is from the original alert or modified.
	Data map[types.AlertSchema]map[string]any
}

func NewTestData

func NewTestData() *TestData

func (*TestData) Add

func (x *TestData) Add(schema types.AlertSchema, filename string, data any)

func (*TestData) Clone

func (x *TestData) Clone() *TestData

func (TestData) LogValue

func (x TestData) LogValue() slog.Value

type TestDataSet

type TestDataSet struct {
	Detect *TestData `json:"detect"`
	Ignore *TestData `json:"ignore"`
}

func NewTestDataSet

func NewTestDataSet() *TestDataSet

func (*TestDataSet) Test

func (x *TestDataSet) Test(ctx context.Context, queryFunc QueryFunc) []error

type TriagePolicyAlert added in v0.7.0

type TriagePolicyAlert struct {
	ID       types.AlertID     `json:"id"`
	Schema   types.AlertSchema `json:"schema"`
	Metadata alert.Metadata    `json:"metadata"`
	Data     any               `json:"data"`
}

TriagePolicyAlert represents alert data for triage policy input (matches doc/policy.md format)

type TriagePolicyInput added in v0.7.0

type TriagePolicyInput struct {
	Alert  TriagePolicyAlert `json:"alert"`
	Enrich EnrichResults     `json:"enrich"`
}

TriagePolicyInput represents the input for triage policy evaluation

func NewTriagePolicyInput added in v0.7.0

func NewTriagePolicyInput(a *alert.Alert, enrichResults EnrichResults) TriagePolicyInput

NewTriagePolicyInput creates a TriagePolicyInput from an Alert

type TriagePolicyResult added in v0.7.0

type TriagePolicyResult struct {
	Title       string               `json:"title,omitempty"`
	Description string               `json:"description,omitempty"`
	Channel     string               `json:"channel,omitempty"`
	Attr        []alert.Attribute    `json:"attr,omitempty"`
	Publish     types.PublishType    `json:"publish,omitempty"`
	Topic       types.KnowledgeTopic `json:"topic,omitempty"`
}

TriagePolicyResult represents the result of triage policy evaluation

func (*TriagePolicyResult) ApplyTo added in v0.7.0

func (r *TriagePolicyResult) ApplyTo(a *alert.Alert)

ApplyTo applies the triage policy result to an alert

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL