draftcheck

package
v0.7.7-dev.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package draftcheck is AI Review's check of a finished draft: before a draft is handed back, AI Review reads its rendered package with the release rubric that stage S5 of the pipeline will ask at publish, so the person knows before Submit what AI Review will flag, and asks the draft question set (pkg/judge DraftQuestions) about whether the draft does the task it was drafted for. Beside the two, with no judge, it reads the runner tools the instruction calls for against the grants the manifest declares (pkg/toolgrant), which stage S6 holds a version for at publish.

The registry's POST /model-input/check asks through this package with the deployment's key, for a hosted draft's job credential or platform staff; the CLI asks through it with the person's own key for a local draft, so both ask exactly what the pipeline asks. It reads the package as the pipeline does: the manifest as its canonical JSON (read as agent.yaml), the packs it ships declared beside the content, and every text file.

Index

Constants

View Source
const (
	MaxFiles = 32
	// MaxBytes is the most text the check reads over every file: eight of
	// the rubric's 8 KiB chunks, the scan route's own bound. A check asks
	// about every chunk and the manifest's, up to three times each, so the
	// bound is what keeps one call's judge requests near thirty.
	MaxBytes = 8 * judge.ChunkSize
)

Bounds on a package the check reads: a draft is a manifest, an instruction of about a screen, a README and a licence.

Variables

View Source
var (
	// ErrNotADraft: no agent.yaml, one that does not parse, or no
	// instruction file.
	ErrNotADraft = errors.New("draftcheck: not a draft package")
	// ErrTooLarge: more than MaxFiles files or MaxBytes bytes of text.
	ErrTooLarge = errors.New("draftcheck: the package is past the check's bounds")
)

The refusals of a package the check will not read. Their texts name what is wrong and never quote the package.

Functions

This section is empty.

Types

type Checker

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

Checker asks both halves of the check. It is safe for concurrent use.

func New

func New(a judge.Asker) *Checker

New builds a Checker over an Asker: a *judge.Client, the registry's paced one, or a fake.

func (*Checker) Check

func (c *Checker) Check(ctx context.Context, p Package) (Result, error)

Check reads a finished draft with the release rubric and the draft set. Its error is Read's, for a package it will not read; a judge that cannot answer is a verdict of not scanned on the half it failed, never an error.

func (*Checker) Model

func (c *Checker) Model() string

Model is the pinned model id the answers come from.

func (*Checker) QuestionSet

func (c *Checker) QuestionSet() string

QuestionSet is the draft set's hash.

func (*Checker) RubricHash

func (c *Checker) RubricHash() string

RubricHash is the release rubric's hash, the one S5 records.

type File

type File struct {
	Path    string
	Content string
}

File is one text file of the rendered package.

type Finding

type Finding struct {
	ID       string
	Score    int
	Path     string
	Severity string
}

Finding is one rubric question S5 would record as a finding at publish: its id, its score, the file whose chunk scored highest, and the severity the gate would give it. A high one holds the version for a person; a medium one is a note, shown on the report of a version that publishes (ruleset 0.3.0 or later).

type Package

type Package struct {
	Description string
	Files       []File
}

Package is a finished draft as the check reads it: the person's description, and every text file of the rendered package, agent.yaml among them.

type Reading

type Reading struct {
	// ManifestJSON is the canonical manifest, read as agent.yaml.
	ManifestJSON []byte
	// Ships is the valid names of the packs the manifest ships.
	Ships []string
	// Instruction is the text of the instruction file the manifest names.
	Instruction string
	// Files is every file, sorted by path.
	Files []judge.RubricFile
	// Ungranted is each runner tool the instruction calls for that the
	// manifest does not grant, as S6 reads it at publish: one is enough
	// for S6 to send the version to a person. Empty when every tool it
	// names is granted.
	Ungranted []toolgrant.Missing
}

Reading is a package as the check reads it.

func Read

func Read(p Package) (Reading, error)

Read turns a package into what the check reads. It refuses a package past the bounds (ErrTooLarge), one that is not a draft (ErrNotADraft), and one with a path that is not relative and clean, named twice, or a file that is not UTF-8.

type Result

type Result struct {
	Rubric Rubric
	// Draft is the draft set's answer.
	Draft judge.DraftResult
	// Model is the pinned model id both answers came from.
	Model string
	// Usage is both halves' requests and tokens, for the record; never a
	// price (AI Review is 1 credit a draft).
	Usage judge.Usage
	// Ungranted is Read's: the tools the instruction calls for that the
	// manifest does not grant. It needs no judge, so it is answered even
	// when both halves are not scanned.
	Ungranted []toolgrant.Missing
}

Result is the check's answer.

type Rubric

type Rubric struct {
	// Verdict is pass, flagged (some finding is high, which the gate sends
	// to a person), or not scanned (the judge could not answer for the whole
	// package). A pass may carry medium findings: notes the report shows.
	Verdict judge.Verdict
	// Scores are per rubric id, 0 to 3; empty when not scanned.
	Scores   map[string]int
	Findings []Finding
	// Hash is the rubric hash S5 records under the same model and shape.
	Hash string
	// Failure is a Failure word when not scanned; Err what went wrong,
	// for the caller's own log. Err never travels.
	Failure string
	Err     error
}

Rubric is the release rubric's answer about the package.

Jump to

Keyboard shortcuts

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