investigation

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package investigation is the investigation-controller's engine: it turns Enhanced findings into analysis agent runs and routes their verdicts.

The gate reconciler admits findings once the accumulation window is closed and the minimum age has passed, resolves the covering Forge, materializes the SHA-pinned Repository artifact, and creates one immutable Investigation child per attempt (the create is the lease). The investigation reconciler grants bounded-concurrency slots in severity-priority order (internal/schedule), launches the agent Job (credential-less artifact flow), and — when the Job completes — applies the envelope's investigation event: child status, the Finding's summary and scheduling priority, and the verdict routing (Queued / AwaitingApproval / Dismissed / HandedOff / Failed, with retry reverts to Enhanced while attempts remain).

Index

Constants

View Source
const InvestigationPhaseIndex = "status.phase"

InvestigationPhaseIndex indexes Investigations by status.phase for the scheduler's slot accounting.

Variables

This section is empty.

Functions

This section is empty.

Types

type GateReconciler

type GateReconciler struct {
	client.Client
	// Forges resolves the covering Forge (read-only here; tokens are minted
	// by source-controller for the artifact and remediation-controller for
	// pushes).
	Forges *forge.Store
	// Namespace the findings live in.
	Namespace string
	// MinAge a finding must reach before investigation picks it up.
	MinAge time.Duration
	// Parameters bound the analysis stage (model/turns/budget), from flags.
	Parameters v1alpha1.AgentParameters
	// Now is the clock seam; nil means time.Now.
	Now func() time.Time
	// Log receives diagnostics; nil discards.
	Log *slog.Logger
}

GateReconciler admits Enhanced findings into investigation: gates on the accumulation window and minimum age, resolves the Forge, materializes the Repository artifact, and creates the Investigation child (the lease).

func (*GateReconciler) Reconcile

func (r *GateReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile gates one finding.

func (*GateReconciler) SetupWithManager

func (r *GateReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager wires the gate: Findings, plus Forge and Repository watches that re-queue affected findings (an operator adding a Forge must revive parked findings without human action; a Repository turning Ready resumes its finding).

type InvestigationReconciler

type InvestigationReconciler struct {
	client.Client
	// Runner creates and observes agent Jobs (in the agents namespace).
	Runner Runner
	// Namespace the CRs live in.
	Namespace string
	// MaxConcurrent bounds simultaneously running investigations.
	MaxConcurrent int
	// MaxAttempts bounds analysis attempts per finding before Failed.
	MaxAttempts int32
	// ConfidenceThreshold gates automated remediation queueing.
	ConfidenceThreshold float64
	// Aging lifts long-waiting investigations.
	Aging schedule.AgingPolicy
	// Now is the clock seam; nil means time.Now.
	Now func() time.Time
	// Log receives diagnostics; nil discards.
	Log *slog.Logger
}

InvestigationReconciler grants bounded slots to pending investigations (severity-priority order), launches the agent Job, and applies the result when the Job completes.

func (*InvestigationReconciler) Reconcile

func (r *InvestigationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile handles both the singleton scheduling request and per-object runs.

func (*InvestigationReconciler) SetupWithManager

func (r *InvestigationReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager wires the reconciler: Investigations, plus agent-Job completions mapped back (by owner label, filtered to this kind), all also fanned into the singleton scheduling request.

type Runner

type Runner interface {
	Create(ctx context.Context, spec jobs.Spec) (string, error)
	Result(ctx context.Context, jobName string) ([]envelope.Event, error)
	Status(ctx context.Context, jobName string) (jobs.Status, error)
	Delete(ctx context.Context, jobName string) error
}

Runner is the slice of the jobs client this controller needs.

Jump to

Keyboard shortcuts

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