policy

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2025 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 AgentTask added in v0.5.0

type AgentTask struct {
	EnrichTask
}

AgentTask represents an agent-type enrichment task

type CommitPolicyAlert added in v0.5.0

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

CommitPolicyAlert represents alert data for commit policy input (matches doc/policy.md format)

type CommitPolicyInput added in v0.5.0

type CommitPolicyInput struct {
	Alert  CommitPolicyAlert `json:"alert"`
	Enrich EnrichResults     `json:"enrich"`
}

CommitPolicyInput represents the input for commit policy evaluation

func NewCommitPolicyInput added in v0.5.0

func NewCommitPolicyInput(a *alert.Alert, enrichResults EnrichResults) CommitPolicyInput

NewCommitPolicyInput creates a CommitPolicyInput from an Alert

type CommitPolicyResult added in v0.5.0

type CommitPolicyResult 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"`
}

CommitPolicyResult represents the result of commit policy evaluation

func (*CommitPolicyResult) ApplyTo added in v0.5.0

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

ApplyTo applies the commit policy result to an alert

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 {
	Query []QueryTask `json:"query"`
	Agent []AgentTask `json:"agent"`
}

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 EnrichResults added in v0.5.0

type EnrichResults map[string]any // key: task ID, value: result data

EnrichResults represents all enrichment task results

type EnrichTask added in v0.5.0

type EnrichTask struct {
	ID     string                   `json:"id"`
	Prompt string                   `json:"prompt,omitempty"` // File path
	Inline string                   `json:"inline,omitempty"` // Inline prompt
	Format types.GenAIContentFormat `json:"format"`           // "text" or "json"
}

EnrichTask represents a generic 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 file path)

func (*EnrichTask) HasPromptFile added in v0.5.0

func (t *EnrichTask) HasPromptFile() bool

HasPromptFile returns true if task uses a prompt 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 QueryTask added in v0.5.0

type QueryTask struct {
	EnrichTask
}

QueryTask represents a query-type enrichment task

type TaskType added in v0.5.0

type TaskType string

TaskType represents the type of enrichment task

const (
	TaskTypeQuery TaskType = "query"
	TaskTypeAgent TaskType = "agent"
)

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

Jump to

Keyboard shortcuts

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