drift

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package drift implements C-O3's sampled, full-fetch semantic validation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PeriodicJobs

func PeriodicJobs(config Config) []*river.PeriodicJob

Types

type Config

type Config struct {
	// InstallationID selects the GitHub installation and cached rows sampled.
	InstallationID int64
	// Period controls how often River schedules a detector pass.
	Period time.Duration
	// SampleSize bounds the number of entities inspected per pass.
	SampleSize int
	// PageSize bounds pagination used by full-fetch comparisons.
	PageSize int
	// ResolvedRetention controls how long resolved findings remain queryable.
	ResolvedRetention time.Duration
	// RetentionBatchSize bounds resolved-finding deletes per transaction.
	RetentionBatchSize int
	// Now supplies detector time; it defaults to time.Now.
	Now func() time.Time
	// Observer receives divergence and persistence signals.
	Observer Observer
}

type DetectArgs

type DetectArgs struct {
	InstallationID int64 `json:"installation_id"`
	SampleSize     int   `json:"sample_size"`
}

func (DetectArgs) Kind

func (DetectArgs) Kind() string

type LogObserver

type LogObserver struct{}

func (LogObserver) Divergence

func (LogObserver) Divergence(
	_ context.Context,
	finding *dbgen.DriftFinding,
)

func (LogObserver) PersistentDivergence

func (LogObserver) PersistentDivergence(
	_ context.Context,
	finding *dbgen.DriftFinding,
)

type Observer

type Observer interface {
	Divergence(context.Context, *dbgen.DriftFinding)
	PersistentDivergence(context.Context, *dbgen.DriftFinding)
}

type Observers

type Observers []Observer

func (Observers) Divergence

func (observers Observers) Divergence(
	ctx context.Context,
	finding *dbgen.DriftFinding,
)

func (Observers) PersistentDivergence

func (observers Observers) PersistentDivergence(
	ctx context.Context,
	finding *dbgen.DriftFinding,
)

type Options

type Options struct {
	Pool          *pgxpool.Pool
	REST          *gh.RESTClient
	GraphQL       *gh.GraphQLClient
	Config        Config
	CacheObserver store.CacheObserver
}

type Service

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

func New

func New(options Options) (*Service, error)

func (*Service) Detect

func (s *Service) Detect(
	ctx context.Context,
	args DetectArgs,
) ([]dbgen.DriftFinding, error)

func (*Service) PeriodicJobs

func (s *Service) PeriodicJobs() []*river.PeriodicJob

func (*Service) RegisterWorker

func (s *Service) RegisterWorker(workers *river.Workers)

func (*Service) SetRiverClient

func (s *Service) SetRiverClient(client *river.Client[pgx.Tx])

Jump to

Keyboard shortcuts

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