runner

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Example (ShardedUsage)

helper used in some debugging — kept here so future tests can adopt it.

fmt.Println("kunji validate -f keys.txt --sharded")

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatViolations added in v1.2.1

func FormatViolations(vs []Threshold, stats RunStats) string

FormatViolations renders a human-readable list of violated thresholds for CI logs.

func Match added in v1.2.1

func Match(exprs []FilterExpr, result *models.ValidationResult) bool

Match reports whether result satisfies every expression. A nil/empty exprs matches everything.

Types

type FilterExpr added in v1.2.1

type FilterExpr struct {
	Field     string
	Op        string // "=" or "!="
	Values    []string
	IsNumeric bool
}

FilterExpr is a parsed filter clause.

Syntax: "field=value" or "field!=value". value can be a single string or a comma-separated list ("openai,stripe") which is treated as "any of these". Currently supported fields: provider, is_valid, status_code, error_code, key.

func ParseFilterExprs added in v1.2.1

func ParseFilterExprs(raw []string) ([]FilterExpr, error)

ParseFilterExprs parses the raw --filter arguments into a slice of expressions. Returns an error for unknown fields or malformed input.

An empty input returns a nil slice, which matches everything (no filter).

type RunStats added in v1.2.1

type RunStats struct {
	Total     int
	Valid     int
	Invalid   int
	RateLimit int
	Errored   int
	Skipped   int
}

RunStats is the aggregate of a finished run, used for CI threshold checks. All counts are absolute; percentages are computed inside Evaluate.

type Runner

type Runner struct {
	Threads        int
	Proxy          string
	Retries        int
	Timeout        int
	OutFile        string
	ManualProvider string
	ManualCategory string
	Resume         bool
	MinKeyLength   int
	OnlyValid      bool
	MinBalance     float64
	DeepScan       bool
	NoCache        bool
	SkipMetadata   bool
	CanaryCheck    bool
	Password       string
	Bench          bool
	Quiet          bool
	Format         string
	Factory        *validators.ValidatorFactory
	Detector       *validators.Detector
	ProxyRotator   *client.ProxyRotator

	Sinks []sink.Sink

	// FilterExprs is the parsed --filter argument. Empty means "no filter".
	FilterExprs []FilterExpr
	// Audit is the audit logger. nil disables audit logging.
	Audit *audit.Logger
	// History is the run history logger. nil disables history persistence.
	History *history.Logger
	// RunID is the unique identifier stamped on every history record.
	RunID string
	// Thresholds holds parsed --fail-if conditions. Empty disables CI mode.
	Thresholds []Threshold
	// Stats tracks aggregate run counters. Populated during runInternal;
	// intended for the CI threshold evaluator.
	Stats RunStats
	// EmitDedupe suppresses duplicate (provider, key, is_valid) emits in the
	// JSONL stream. The first emission wins; subsequent identical results
	// during the same run are dropped silently.
	EmitDedupe bool

	// Sharded enables per-provider worker pools. When true, detection happens
	// once at the feeder and each provider gets its own small worker pool,
	// reducing contention on the proxy rotator and per-provider rate
	// limiter. Off by default.
	Sharded bool
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner(threads int, proxy string, retries int, timeout int, out string, manualProv string, manualCat string, resume bool, onlyValid bool, minBalance float64, skipMetadata bool, canaryCheck bool) (*Runner, error)

func NewRunnerWithOptions added in v1.2.0

func NewRunnerWithOptions(threads int, proxy string, retries int, timeout int, out string, manualProv string, manualCat string, resume bool, onlyValid bool, minBalance float64, skipMetadata bool, canaryCheck bool, factoryOpts validators.FactoryOptions) (*Runner, error)

NewRunnerWithOptions is the configurable constructor. factoryOpts controls the positive-cache layer (persistent on/off) and whether caching is disabled entirely (--no-cache).

func (*Runner) GetKeyStream added in v1.0.8

func (r *Runner) GetKeyStream(singleKey, keyFile string) (io.ReadCloser, int, error)

func (*Runner) PreflightProxyCheck added in v1.0.8

func (r *Runner) PreflightProxyCheck()

func (*Runner) Run

func (r *Runner) Run(keyReader io.Reader, totalKeys int)

func (*Runner) RunSource added in v1.2.0

func (r *Runner) RunSource(ctx context.Context, src source.Source)

RunSource pulls keys from a Source plugin and feeds them into the validation pipeline as if they came from a single reader. The Source's Total() is used when non-zero so the progress bar reflects the real key count; otherwise a streaming run is launched (totalKeys=0).

type Threshold added in v1.2.1

type Threshold struct {
	Metric   string // "invalid" | "valid" | "error" | "rate_limit" | "skipped" | "total"
	Op       string // ">" | "<" | ">=" | "<="
	Value    float64
	Percent  bool
	RawInput string
}

Threshold is one parsed "metric op value" clause from --fail-if.

invalid > 5%      (5 percent of total)
invalid > 100     (100 absolute invalid keys)
valid >= 50       (at least 50 valid keys)

func Evaluate added in v1.2.1

func Evaluate(thresholds []Threshold, stats RunStats) (violated []Threshold, ok bool)

Evaluate checks every threshold against stats and returns the violations. ok is true when no thresholds were violated.

func ParseThreshold added in v1.2.1

func ParseThreshold(raw string) (Threshold, error)

ParseThreshold parses one --fail-if argument of the form:

metric op value[%]    e.g. invalid > 5%,  valid >= 10, error < 1%

Whitespace around metric/op/value is optional.

func ParseThresholds added in v1.2.1

func ParseThresholds(raw []string) ([]Threshold, error)

ParseThresholds parses every --fail-if argument.

func (Threshold) String added in v1.2.1

func (t Threshold) String() string

Jump to

Keyboard shortcuts

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