revalidate

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package revalidate periodically re-runs the gates over cached artifacts and evicts any that now produce a definitive block verdict.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Interval        time.Duration // how often the sweep ticks
	RevalidateAfter time.Duration // an entry is due when now-last_validated > this
	BatchSize       int           // max entries processed per tick
}

Config tunes the sweep loop.

type EvictReason

type EvictReason struct {
	Gate      string // gate.GateCVE | GateMalware | GateImageScan | GateSupply
	Reason    string // "cve_found" | "malware_found" | "denylisted" | ...
	BlockedBy string // "cve" | "malware" | "denylist" | "supply_chain"
	Engine    string // malware engine, when applicable
	Signature string // malware signature, when applicable
	Findings  []gate.CVEFinding
}

EvictReason carries why an entry was evicted, for telemetry.

type Outcome

type Outcome int

Outcome is the per-entry decision a Revalidator returns.

const (
	Keep  Outcome = iota // still clean → bump last_validated
	Evict                // definitive non-clean verdict → remove + record event
	Retry                // could not check (scanner down) → leave untouched
)

type RevalidationStore

type RevalidationStore interface {
	DueForRevalidation(before int64, limit int) ([]cache.RevalEntry, error)
	MarkValidated(ref *gate.PackageRef, ts int64) error
	Invalidate(ref *gate.PackageRef) error
}

RevalidationStore is the slice of the cache the sweep depends on. *cache.LocalCache satisfies it.

type Revalidator

type Revalidator interface {
	Revalidate(ctx context.Context, e cache.RevalEntry) (Outcome, *EvictReason)
}

Revalidator re-runs the applicable checks for one cached entry.

func NewPackageRevalidator

func NewPackageRevalidator(cve gate.CVEScanner, policy gate.PolicyDecider, av gate.AVScanner) Revalidator

NewPackageRevalidator builds a Revalidator for package ecosystems. Any of the scanners may be nil (that check is skipped).

type Sweeper

type Sweeper struct {
	// contains filtered or unexported fields
}

Sweeper periodically re-validates due cache entries and evicts failures.

func NewSweeper

func NewSweeper(store RevalidationStore, revalidators map[string]Revalidator, recorder gate.Recorder, cfg Config, logger zerolog.Logger) *Sweeper

NewSweeper builds a sweeper. revalidators is keyed by ecosystem; entries whose ecosystem has no revalidator are skipped.

func (*Sweeper) Close

func (s *Sweeper) Close()

Close stops the loop and waits for it to exit. Safe to call once.

func (*Sweeper) Start

func (s *Sweeper) Start()

Start launches the background loop. Safe to call multiple times — only the first call has any effect (subsequent calls are no-ops via sync.Once).

func (*Sweeper) SweepOnceForTest

func (s *Sweeper) SweepOnceForTest(ctx context.Context)

SweepOnceForTest runs a single sweep synchronously. Exposed for integration tests that drive the sweep deterministically instead of waiting on the ticker.

Jump to

Keyboard shortcuts

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