investigation

package
v0.11.7 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 30 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 FindingPhaseIndex = "status.phase"

FindingPhaseIndex is the field index over status.phase, registered by the gate: its Forge watch re-gates only Enhanced findings, and without the index that selection is a full informer-store scan per Forge event.

View Source
const InvestigationPhaseIndex = "status.phase"

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

Variables

This section is empty.

Functions

func FindingPhaseIndexer added in v0.10.0

func FindingPhaseIndexer(obj client.Object) []string

FindingPhaseIndexer extracts the index value; findings with no phase yet are left out. Exported so fake-client tests register the same recipe.

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
	// Concurrency is the number of findings gated in parallel; <=1 means
	// serial. Safe to raise: child names are deterministic per attempt, the
	// create tolerates AlreadyExists, and the phase advance runs under
	// conflict retry — two racing reconciles converge on one lease.
	Concurrency int
	// 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).

The Forge watch is the fan-out bomb of this controller — one Forge event re-queues every Enhanced finding — so it is bounded twice: the phase field index turns the selection from a full scan into a lookup, and the generation predicate drops the status-only Forge updates (the source controller's validation writes) that cannot change resolution. Forge resolution reads spec alone, so only spec changes (and create/delete) can revive a parked 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
	// InvestigateHarness/InvestigateModel are the harness id and canonical
	// model the analysis stage runs on, resolved at startup; the Job carries
	// them so its pod runs the harness its runner image was built for.
	InvestigateHarness string
	InvestigateModel   string
	// Now is the clock seam; nil means time.Now.
	Now func() time.Time

	// Log receives diagnostics; nil discards.
	Log *slog.Logger
	// contains filtered or unexported fields
}

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) (jobs.RunOutput, 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