risk

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package risk provides AI-powered pre-execution risk assessment for cloop tasks. For each task (or the full plan) it asks the provider to output a structured JSON list of findings, each with a severity level, category, rationale, and mitigation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category string

Category describes the type of risk.

const (
	CategoryDataLoss           Category = "data-loss"
	CategorySecurity           Category = "security"
	CategoryIrreversible       Category = "irreversible"
	CategoryBreakingChange     Category = "breaking-change"
	CategoryExternalDependency Category = "external-dependency"
)

type Finding

type Finding struct {
	// Level is the severity: LOW, MEDIUM, HIGH, or CRITICAL.
	Level Level `json:"level"`

	// Category classifies the risk type.
	Category Category `json:"category"`

	// Rationale explains why this is a risk.
	Rationale string `json:"rationale"`

	// Mitigation suggests how to reduce or eliminate the risk.
	Mitigation string `json:"mitigation"`
}

Finding is a single risk finding for a task.

type Level

type Level string

Level is the risk severity.

const (
	LevelLow      Level = "LOW"
	LevelMedium   Level = "MEDIUM"
	LevelHigh     Level = "HIGH"
	LevelCritical Level = "CRITICAL"
)

type RiskReport

type RiskReport struct {
	// TaskID is the numeric task ID (0 if this is a plan-level report).
	TaskID int `json:"task_id,omitempty"`

	// TaskTitle is the title of the assessed task ("(plan)" for plan-level).
	TaskTitle string `json:"task_title"`

	// Findings is the ordered list of risk findings (highest severity first).
	Findings []Finding `json:"findings"`

	// OverallLevel is the highest severity level across all findings.
	OverallLevel Level `json:"overall_level"`
}

RiskReport is the result of assessing a single task or the full plan.

func Assess

func Assess(ctx context.Context, p provider.Provider, model string, plan *pm.Plan, taskID string) ([]*RiskReport, error)

Assess runs a risk assessment for the given tasks using the AI provider.

If taskID is non-empty it must be a numeric task ID; only that task is assessed. If taskID is empty, all pending tasks are assessed and one RiskReport is returned per task. model may be empty (the provider will use its default).

func AssessTask

func AssessTask(ctx context.Context, p provider.Provider, model string, plan *pm.Plan, task *pm.Task) (*RiskReport, error)

AssessTask assesses a single task by value (used by the orchestrator pre-execution check).

func (*RiskReport) HasCritical

func (r *RiskReport) HasCritical() bool

HasCritical reports whether the report contains at least one CRITICAL finding.

Jump to

Keyboard shortcuts

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