qualitygate

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 14 Imported by: 1 module, 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 qualitygate is the model stage that reads an item's title and opening, before anyone reads it whole, and answers its genre, domains, themes, a 1 to 10 quality estimate, a one-line idea, a verdict and a guess at its side. Its prompt and answer schema are prompts.Quality.

The service queues an item's quality task in the write that ends its scan, where no tag or rule places it, so a rule placed before the model always wins. A worker holding a model port runs the task. It stores the dispatch in the write that ends its lease, and follows the dispatch on each later claim until the run answers, so the task holds no worker slot while the run waits. That dispatch-once protocol is modelstage's. When the task ends done, the service appends the gate's decision: pass, drop where the model dropped the item at or above DropFloor, or review. The side gate then reads that decision and the side guess.

The arm asks the same prompt of another model, over items a person placed from review, and keeps each answer at its own stage. It decides nothing, so `ingestion gates agreement` can set two models' answers side by side.

Index

Constants

View Source
const (
	// DefaultModel and DefaultEffort are what the gate's run is asked for
	// where config names neither. The gate reads an opening and answers a
	// short schema, so the smallest model does it.
	DefaultModel  = "haiku"
	DefaultEffort = "medium"
)
View Source
const (
	// Capability is the capability of every quality task.
	Capability = store.StageQuality
	// ArmCapability is the capability of every arm task: the gate's prompt
	// asked of the model that the task names, as a measurement.
	ArmCapability = store.StageQualityArm
	// Producer names the quality gate's outputs, whose version is the
	// prompt's.
	Producer = "quality-gate"
	// DropFloor is the confidence at or above which the model's drop drops
	// an item. Below it, the item waits in review.
	DropFloor = 0.8
)
View Source
const (
	AnswerPass   = "pass"
	AnswerDrop   = "drop"
	AnswerUnsure = "unsure"
)

The verdicts the model answers.

View Source
const (
	CausePass           = "pass"
	CauseDrop           = "drop"
	CauseUnsure         = "unsure"
	CauseBelowDropFloor = "below-drop-floor"
)

Causes of the gate's decision.

View Source
const VerdictPass = "pass"

VerdictPass is the gate's decision that an item earns a full read. Its drop and review are the side gate's verdicts of the same names.

Variables

This section is empty.

Functions

func ArmReplayable

func ArmReplayable(st *store.Store) server.Replayable

ArmReplayable is the arm as a replay runs it: the gate's prompt, asked of the model that the replay names, over each labeled item that the gate answered under that prompt. Each answer is kept at the arm's own stage beside the gate's, and appends no decision, so the item's phase, placement and delivery stay as they are. One arm answers an item under each prompt.

func DecideAfterAnswer

func DecideAfterAnswer(ctx context.Context, tx *store.Tx, task store.Task) error

DecideAfterAnswer appends the gate's decision in the write that ends the item's quality task done, from the answer of its newest done output. It appends nothing where the newest decision already came from that run.

func Decision

func Decision(a Answer, run string) store.Decision

Decision is the gate's decision on an answer that run gave: pass, drop where the model dropped the item at or above DropFloor, and review where it was unsure or its drop fell below the floor.

func NewArmHandler

func NewArmHandler(port modelport.Port, client *worker.Client, settings modelstage.Settings, log *slog.Logger) worker.Handler

NewArmHandler is the worker handler that runs the arm's tasks the same way. Each asks for the model that its task names, at the gate's effort.

func NewHandler

func NewHandler(port modelport.Port, client *worker.Client, settings modelstage.Settings, log *slog.Logger) worker.Handler

NewHandler is the worker handler that runs the gate through port under modelstage's dispatch-once protocol, reading each task's parse through client.

func QueueAfterScan

func QueueAfterScan(ctx context.Context, tx *store.Tx, task store.Task) error

QueueAfterScan queues the item's quality task in the write that ends its scan done, where the scan read the newest parse, no tag or rule places the item, and the item never held a quality task. A connector's first fill holds it past the first item. A later scan queues none. The gate runs again only through a replay that a person confirms, or through `tasks retry` on a failed task.

func Replayable

func Replayable(st *store.Store) server.Replayable

Replayable is the gate as a replay runs it again, such as with a new prompt, over the items it judges. The replay first answers how many items it would run on and the median tokens by kind of the stage's newest stored runs, times that count, and queues only once a person confirms.

Its PlacedByPerson runs the gate over the labeled items, which the gate otherwise never judges again. Its answer and its decision are kept, and the side gate leaves the placement, its delivery and its model read as they are, because a person's placement is final.

Types

type Answer

type Answer struct {
	Genre             string   `json:"genre"`
	Domains           []string `json:"domains"`
	Themes            []string `json:"themes"`
	Quality           int      `json:"quality"`
	Idea              string   `json:"idea"`
	Verdict           string   `json:"verdict"`
	VerdictConfidence float64  `json:"verdict_confidence"`
	Side              string   `json:"side"`
	SideConfidence    float64  `json:"side_confidence"`
}

Answer is the model's answer, as prompts/quality/answer.schema.json holds it. ReadAnswer decodes it.

func ReadAnswer

func ReadAnswer(raw json.RawMessage) (Answer, error)

ReadAnswer checks raw against the answer's schema and decodes it. The schema counts 7.0 as an integer, so quality decodes as a number and is kept whole.

Jump to

Keyboard shortcuts

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