review

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package review closes the loop around agent work: every completed agent task gets ONE review by a second agent, and a request_changes verdict can mint fix tasks. The reviewer only contributes findings — everything downstream (verdict bookkeeping, fix-task fan-out, dedup) is mechanical.

Loop safety is structural: reviews are never reviewed (the sweeper only reviews the "agent" type), each task is reviewed at most once (the review:<task-id> dedup key), and fix tasks minted from findings are bounded by the pool's budget guard, which counts every enqueue — reviews included — against the daily cap.

Index

Constants

View Source
const (

	// ConsumerKey is the sweeper's identity in the watermarks table: the
	// persisted cursor shared by every sweeper over the same database, so
	// agent tasks completed while no sweeper was running still get their
	// review when the next pool starts.
	ConsumerKey = "review-sweeper"
)

Variables

This section is empty.

Functions

func FixDedupKey

func FixDedupKey(review task.ID, findingTitle string) string

FixDedupKey is the dedup identity of the fix task for one finding of one review: the same finding re-reported by the same review never spawns a second fix task.

func ReviewDedupKey

func ReviewDedupKey(reviewed task.ID) string

ReviewDedupKey is the dedup identity of the review of one task: exactly one review per reviewed task, forever.

Types

type SweepStats

type SweepStats struct {
	// Facts is the number of new facts consumed.
	Facts int
	// ReviewsEnqueued counts fresh review tasks this sweep created.
	ReviewsEnqueued int
	// ReviewsKnown counts completed agent tasks whose review task already
	// existed (dedup hit — the review ran, or is pending, elsewhere).
	ReviewsKnown int
	// FixesEnqueued counts fresh fix tasks minted from findings.
	FixesEnqueued int
	// Skipped counts completions that could not yield a review (foreign
	// payload shape, vanished task record).
	Skipped int
}

SweepStats summarizes one sweep pass.

type Sweeper

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

Sweeper turns the journal's completion facts into review work. It is safe for concurrent use (a mutex serializes sweeps; ticks and the --once drain watcher may call it from different goroutines).

func NewSweeper

func NewSweeper(ctx context.Context, store queue.Store, cfg SweeperConfig) (*Sweeper, error)

NewSweeper returns a sweeper over store. The cursor resumes from the persisted checkpoint — completions recorded while no sweeper was running are reviewed on the next start. A first run bootstraps at the journal head: completions that predate the sweeper are not replayed (same semantics as the papdashboard bridge; review the gap via `tq show`, or rewind with `tq watermarks set review-sweeper SEQ`).

func (*Sweeper) Sweep

func (s *Sweeper) Sweep(ctx context.Context) (SweepStats, error)

Sweep consumes new facts since the last pass and enqueues review (and, with Autofix, fix) tasks. Idempotent by dedup: calling it twice never duplicates work, so a replayed page (crash between consumption and checkpoint) re-hits dedup keys instead of minting duplicates. The cursor checkpoints after each page; a failed checkpoint stops the sweep — facts are never consumed past an unpersisted cursor.

type SweeperConfig

type SweeperConfig struct {
	// Model, when set, is written into every review payload (and fix task).
	Model string
	// Autofix, when true, mints an agent fix task per finding of every
	// request_changes review. Off by default: verdict-only mode is the safe
	// first step; autofix closes the loop autonomously.
	Autofix bool
	// Log receives one summary line per sweep. nil logs nothing.
	Log *slog.Logger
	// PageSize bounds one fact-stream page; 0 selects the default.
	PageSize int
}

SweeperConfig controls one Sweeper.

Jump to

Keyboard shortcuts

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