# internal/app/review

Package review runs adversarial provider review and records review evidence.

## ErrReviewRepairPacketInvalid

```go
var ErrReviewRepairPacketInvalid = errors.New("review repair packet cannot be accepted")
```

ErrReviewRepairPacketInvalid is returned when a repaired provider packet cannot be accepted into the current review attempt.

## ErrReviewStartBlocked

```go
var ErrReviewStartBlocked = errors.New("review attempt cannot start")
```

ErrReviewStartBlocked is returned when the current review gate state forbids starting a new provider attempt.

## ErrSpecNotReviewable

```go
var ErrSpecNotReviewable = errors.New("review requires task status review")
```

ErrSpecNotReviewable is returned when review is attempted before build reaches the review gate.

## Run

```go
func Run(ctx context.Context, specs SpecStore, sessions SessionStore, workspace WorkspaceStatus, provider Provider, clock Clock, taskID string) (Output, error)
```

Run executes the review gate for taskID.

## RunWithInput

```go
func RunWithInput(ctx context.Context, specs SpecStore, sessions SessionStore, workspace WorkspaceStatus, provider Provider, clock Clock, input Input) (Output, error)
```

RunWithInput executes the review gate using an explicit review agenda.

## Clock

```go
type Clock interface{ Now() time.Time }
```

Clock supplies review timestamps.

- `Now: func() time.Time`: 

## Input

```go
type Input struct {
	TaskID                  string
	Mode                    review.Mode
	ForceMode               bool
	Passes                  []Pass
	Invariants              map[string]string
	ReviewScope             []string
	ContextSections         []reviewcontext.Section
	ContextMaxBytes         int
	RequiredContextMaxBytes int
	Contract                agentcontract.Contract
	MaxFindings             int
	MinAttackAngles         int
	ReviewDepth             string
	RerunPolicy             string
	ForceReview             bool
	ProviderName            string
	ProviderModel           string
	PrintContext            bool
	HumanReviewed           bool
	RepairPacketPath        string
	Reason                  string
}
```

Input describes the task and review agenda to run.

- `TaskID: string`: 
- `Mode: review.Mode`: 
- `ForceMode: bool`: 
- `Passes: []Pass`: 
- `Invariants: map[string]string`: 
- `ReviewScope: []string`: 
- `ContextSections: []reviewcontext.Section`: 
- `ContextMaxBytes: int`: 
- `RequiredContextMaxBytes: int`: 
- `Contract: agentcontract.Contract`: 
- `MaxFindings: int`: 
- `MinAttackAngles: int`: 
- `ReviewDepth: string`: 
- `RerunPolicy: string`: 
- `ForceReview: bool`: 
- `ProviderName: string`: 
- `ProviderModel: string`: 
- `PrintContext: bool`: 
- `HumanReviewed: bool`: 
- `RepairPacketPath: string`: 
- `Reason: string`: 

## Output

```go
type Output struct {
	TaskID         string                  `json:"task_id"`
	Verdict        string                  `json:"verdict"`
	Mode           review.Mode             `json:"mode,omitempty"`
	Summary        string                  `json:"summary,omitempty"`
	Provider       string                  `json:"provider,omitempty"`
	Model          string                  `json:"model,omitempty"`
	OutputFormat   string                  `json:"output_format,omitempty"`
	Normalizations []string                `json:"normalizations,omitempty"`
	Findings       []review.Finding        `json:"findings"`
	AttackLog      []review.AttackLogEntry `json:"attack_log,omitempty"`
	Budget         review.Budget           `json:"budget,omitempty"`
	Next           string                  `json:"next"`
	Context        string                  `json:"context,omitempty"`
	Repair         *gate.Failure           `json:"repair,omitempty"`
}
```

Output describes a completed review run.

- `TaskID: string` (json:"task_id"): 
- `Verdict: string` (json:"verdict"): 
- `Mode: review.Mode` (json:"mode,omitempty"): 
- `Summary: string` (json:"summary,omitempty"): 
- `Provider: string` (json:"provider,omitempty"): 
- `Model: string` (json:"model,omitempty"): 
- `OutputFormat: string` (json:"output_format,omitempty"): 
- `Normalizations: []string` (json:"normalizations,omitempty"): 
- `Findings: []review.Finding` (json:"findings"): 
- `AttackLog: []review.AttackLogEntry` (json:"attack_log,omitempty"): 
- `Budget: review.Budget` (json:"budget,omitempty"): 
- `Next: string` (json:"next"): 
- `Context: string` (json:"context,omitempty"): 
- `Repair: *gate.Failure` (json:"repair,omitempty"): 

## GateFailure

```go
func (o Output) GateFailure() *gate.Failure
```

GateFailure exposes review blockers to the CLI JSON envelope.

## Pass

```go
type Pass struct {
	ID          string
	Category    string
	Order       int
	Title       string
	Description string
}
```

Pass describes one configured review pass included in the provider prompt.

- `ID: string`: 
- `Category: string`: 
- `Order: int`: 
- `Title: string`: 
- `Description: string`: 

## Provider

```go
type Provider interface {
	Invoke(context.Context, review.Request) (review.Dossier, error)
}
```

Provider is the review provider port.

- `Invoke: func(context.Context, review.Request) (review.Dossier, error)`: 

## SessionStore

```go
type SessionStore interface {
	Append(context.Context, string, session.Entry, string) (session.Session, error)
	AppendTransaction(context.Context, string, string, func(session.Session) ([]session.Entry, error)) (session.Session, error)
	Load(context.Context, string) (session.Session, error)
}
```

SessionStore is the session evidence port used by review.

- `Append: func(context.Context, string, session.Entry, string) (session.Session, error)`: 
- `AppendTransaction: func(context.Context, string, string, func(session.Session) ([]session.Entry, error)) (session.Session, error)`: 
- `Load: func(context.Context, string) (session.Session, error)`: 

## SpecStore

```go
type SpecStore interface {
	Load(context.Context, string) (spec.Model, string, error)
}
```

SpecStore is the spec persistence port used by review.

- `Load: func(context.Context, string) (spec.Model, string, error)`: 

## WorkspaceStatus

```go
type WorkspaceStatus interface {
	ChangedFiles(context.Context) ([]string, error)
	ResolveHead(context.Context) (string, bool, error)
}
```

WorkspaceStatus is the mutation-guard workspace state port.

- `ChangedFiles: func(context.Context) ([]string, error)`: 
- `ResolveHead: func(context.Context) (string, bool, error)`:
