engine

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package engine implements the Gaslit orchestration: the panel state, the debate pipeline, budget accounting, and instrumentation. It depends on the pure feature packages (core, drift, aggregation, scoring, persist) and is re-exported by the module root's public `gaslit` facade.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithLLMScorer

func WithLLMScorer(m model.BaseModel[*schema.Message]) core.Option

WithLLMScorer uses m for the NLI/consistency check, independent of the moderator model. The default LLM scorer already uses Config.ConsistencyModel.

func WithLexicalScorer

func WithLexicalScorer() core.Option

WithLexicalScorer swaps the consistency check to the deterministic LexicalScorer (zero extra model calls). Use it while debugging the pipeline; switch back to an LLM scorer for final benchmark runs.

Types

type Gaslit

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

Gaslit orchestrates a panel of debater agents under a supervising moderator. Instances are built with New and safe for concurrent use across debates.

func New

func New(ctx context.Context, cfg core.Config, opts ...core.Option) (*Gaslit, error)

New builds a Gaslit engine from a Config. Every unset field receives a default; see core.Config and the Option helpers. At least one agent is required, and agent names must be unique. Concurrent calls to Debate on the same engine are safe.

func (*Gaslit) Baseline

func (g *Gaslit) Baseline(ctx context.Context, question string, options []string, opts ...core.CallOption) (map[string]*core.Answer, error)

Baseline collects each agent's initial position on the question.

func (*Gaslit) CCI

func (g *Gaslit) CCI(ctx context.Context, agent adk.Agent, statement, question string, opts ...core.CallOption) (*core.DiagnosticResult, error)

CCI runs a standalone Confidence/Consistency probe against any agent on a given statement. The agent does not need to be part of the panel. Confidence defaults to the agent's self-reported confidence in the statement; override it with WithConfidenceCall.

func (*Gaslit) CrossExamine

func (g *Gaslit) CrossExamine(ctx context.Context, question string, before map[string]*core.Answer, opts ...core.CallOption) error

CrossExamine runs one cross-examination round against the given positions.

func (*Gaslit) Debate

func (g *Gaslit) Debate(ctx context.Context, question string, options []string, opts ...core.CallOption) (*core.FullDebateSummary, error)

Debate runs a full panel evaluation on the given question:

  1. Collects each agent's baseline position and confidence.
  2. Cross-examines panelists (moderator-led or protocol-driven).
  3. Re-collects each agent's final position.
  4. Detects drift and attributes influence between agents.
  5. Grills the agents selected by the active GrillStrategy.

Options are labeled A, B, C, ... in order (or via WithOptionLabelsCall). Pass an empty options slice for open-ended questions. When verbose is true, phase progress is logged through the configured logger.

func (*Gaslit) DebateMany

func (g *Gaslit) DebateMany(ctx context.Context, questions []string, optionsList [][]string, opts ...core.CallOption) ([]*core.FullDebateSummary, error)

DebateMany runs a debate for each (question, options) pair in order, reusing the panel's conversation state so agents carry context across questions.

func (*Gaslit) DebateN

func (g *Gaslit) DebateN(ctx context.Context, question string, options []string, rounds int, opts ...core.CallOption) (*core.FullDebateSummary, error)

DebateN runs a Debate with a specific number of (cross-examine → evaluate) rounds, overriding the engine's MaxRounds for this call.

func (*Gaslit) DriftAnalysis

func (g *Gaslit) DriftAnalysis(before, after map[string]*core.Answer, options []string, opts ...core.CallOption) core.DriftVerdict

DriftAnalysis computes the drift verdict between before and after positions using the engine's configured metric, thresholds, and attribution strategy.

func (*Gaslit) Evaluate

func (g *Gaslit) Evaluate(ctx context.Context, options []string, opts ...core.CallOption) (map[string]*core.Answer, error)

Evaluate re-collects each agent's final position after cross-examination.

func (*Gaslit) Grill

func (g *Gaslit) Grill(ctx context.Context, agentName, claim, question string, opts ...core.CallOption) (*core.DiagnosticResult, error)

Grill runs a grilling diagnostic against a registered panelist on a claim.

func (*Gaslit) Rescore

Rescore re-runs the configured consistency scorer over each diagnostic's stored arguments (R1 vs R2) and then reclassifies it. It does not re-run the baseline or debate — only the scoring/quadrant step — so it is the right tool for iterating on the rubric against a saved FullDebateSummary without burning fresh model calls on the debate itself.

The active scorer comes from the per-call options (see WithConsistencyScorerCall) or the engine configuration; budget, pacing, and call accounting apply to model-backed scorers.

func (*Gaslit) Stats

func (g *Gaslit) Stats() core.InstrumentationStats

Stats returns a snapshot of the engine's instrumentation counters.

func (*Gaslit) Stream

func (g *Gaslit) Stream(ctx context.Context, question string, options []string, opts ...core.CallOption) (<-chan core.StreamEvent, error)

Stream runs a full debate and emits events as they occur.

type StreamEvent

type StreamEvent = core.StreamEvent

Stream runs Debate and streams each milestone over a channel as it happens. The caller must drain the channel; it is closed when the debate finishes.

Jump to

Keyboard shortcuts

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