review

package
v0.13.4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package review records a person's verdict on the answers the bot composed in shadow mode, which is what stands between shadow mode and posting (spec 0010 D12, spec 0023).

It reads the answers pkg/respond records and owns only the verdicts. Deciding that the answers are worth posting is left to the person reading the tally: nothing here lifts shadow mode (0023 D7).

Index

Constants

View Source
const Target = 30

Target is how many reviewed answers to real questions 0010 D12 asks for before shadow mode can be lifted (R-ANS-18).

Variables

View Source
var (
	// ErrNotReviewable is returned for an answer that cannot take a verdict:
	// posted, over budget, expired, or not there at all (0023 D3).
	ErrNotReviewable = errors.NewSentinel("review.not_reviewable", "review: not a reviewable shadow answer")

	// ErrCitationsUnjudged is returned when an answer with citations is given
	// no verdict on them (0023 D5).
	ErrCitationsUnjudged = errors.NewSentinel("review.citations_unjudged", "review: the answer's citations need a verdict")

	// ErrNoCitations is returned for a citation verdict on an answer that has
	// none to judge (0023 D5).
	ErrNoCitations = errors.NewSentinel("review.no_citations", "review: the answer has no citations to judge")
)
View Source
var ErrServerRequired = errors.NewSentinel("review.server_required",
	"review: more than one server is configured; name one with --server")

ErrServerRequired is returned when several servers are configured and the reviewer did not name one (spec 0029 D4).

View Source
var ErrUnknownServer = errors.NewSentinel("review.unknown_server", "review: that server is not configured")

ErrUnknownServer is returned for a --server that is not configured.

Functions

func Open

func Open(ctx context.Context, path string) (*respond.Recorder, func() error, error)

Open opens the database at path, the one serve records into (0023 D2), and returns a recorder over it with the function that closes it.

func Server added in v0.11.0

func Server(configured []comms.ID, named string) (comms.ID, error)

Server picks the server a review is for: the one named, which must be configured, or the only one configured. With several configured, naming one is required, so production is never judged by someone who thinks it is stage.

Types

type Item

type Item struct {
	AnswerID int64

	// Question is the question as stored, redacted. Empty, with QuestionExpired
	// set, once the question's retention has passed.
	Question        string
	QuestionExpired bool

	Posture    respond.Posture
	Title      string
	Body       string
	Cited      []answer.Citation
	RecordedAt time.Time

	// Posted reports whether the answer reached the channel, rather than
	// being composed in shadow mode (0025 D8).
	Posted bool
}

Item is one answer as the reviewer sees it (0023 D4).

type Queue

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

Queue walks the reviewable answers, oldest first.

Each Next reads the database afresh rather than a list taken at the start, so an answer serve records mid-review joins the end (0023 D9). Skips live on the Queue and nowhere else: a new run offers them again.

func New

func New(rec *respond.Recorder, space comms.ID) *Queue

New starts a review run over the answers rec records for one server (spec 0029 D4).

func (*Queue) Exclude

func (q *Queue) Exclude(ctx context.Context, id int64) error

Exclude marks an answer as not counting, for a replayed benchmark or calibration question (0023 D5). It is never offered again.

func (*Queue) Next

func (q *Queue) Next(ctx context.Context) (Item, bool, error)

Next returns the oldest reviewable answer not skipped in this run, or false when none is waiting.

func (*Queue) Record

func (q *Queue) Record(ctx context.Context, id int64, v Verdict) error

Record stores a verdict, replacing any earlier one for the same answer.

func (*Queue) Skip

func (q *Queue) Skip(id int64)

Skip holds an answer back for the rest of this run.

func (*Queue) Status

func (q *Queue) Status(ctx context.Context) (Tally, error)

Status is the tally `review status` prints (0023 D7).

type Tally

type Tally struct {
	Target          int
	Reviewed        int
	Answers         int
	Declines        int
	Posted          int
	Correct         int
	CitationsJudged int
	CitationsApt    int
	Excluded        int
	Waiting         int

	// Readers' 👍 and 👎 across every answer, and how many answers have any
	// (spec 0027 D8). Totals only, so no vote sits beside a verdict.
	Helpful    int
	NotHelpful int
	Voted      int
}

Tally is what `review status` reports (0023 D7). Reviewed excludes excluded answers, and Answers and Declines split it.

func (Tally) String

func (t Tally) String() string

String renders the tally for `review status`. It reports the numbers and never whether the gate is met: that judgement is the maintainer's (0023 D7).

type Verdict

type Verdict struct {
	Correct      bool
	CitationsApt *bool
	Note         string
}

Verdict is what the reviewer records (0023 D5). CitationsApt is set exactly when the answer has citations.

Jump to

Keyboard shortcuts

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