# internal/app/report

Package report aggregates workspace-level task metrics.

## Run

```go
func Run(ctx context.Context, store SpecStore, sessions SessionStore) (Output, error)
```

Run aggregates spec records by status and session evidence by task.

## ArchiveAwareSpecStore

```go
type ArchiveAwareSpecStore interface {
	ListAll(context.Context) ([]spec.Record, error)
}
```

ArchiveAwareSpecStore can include archived terminal specs in reports.

- `ListAll: func(context.Context) ([]spec.Record, error)`: 

## Metrics

```go
type Metrics struct {
	FirstAttemptPassRate      float64        `json:"first_attempt_pass_rate"`
	FirstAttemptPasses        int            `json:"first_attempt_passes"`
	FirstAttemptTotal         int            `json:"first_attempt_total"`
	RecoveryConvergenceRate   float64        `json:"recovery_convergence_rate"`
	RecoveredTasks            int            `json:"recovered_tasks"`
	RecoveryTotal             int            `json:"recovery_total"`
	ChallengeOverrideRate     float64        `json:"challenge_override_rate"`
	ChallengeOverrides        int            `json:"challenge_overrides"`
	ReviewChallengeTotal      int            `json:"review_challenge_total"`
	ReviewPassRate            float64        `json:"review_pass_rate"`
	ReviewPasses              int            `json:"review_passes"`
	ReviewTotal               int            `json:"review_total"`
	ReviewDossierCoverage     float64        `json:"review_dossier_coverage"`
	ReviewDossierTotal        int            `json:"review_dossier_total"`
	ReviewFindingsTotal       int            `json:"review_findings_total"`
	ReviewOpenBlockersTotal   int            `json:"review_open_blockers_total"`
	ReviewAttackAnglesTotal   int            `json:"review_attack_angles_total"`
	ReviewModeDistribution    map[string]int `json:"review_mode_distribution,omitempty"`
	WorkspaceBaselineCoverage float64        `json:"workspace_baseline_coverage"`
	WorkspaceBaselineTasks    int            `json:"workspace_baseline_tasks"`
	SessionTotal              int            `json:"session_total"`
	BlockedGateDistribution   map[string]int `json:"blocked_gate_distribution,omitempty"`
}
```

Metrics captures the reporting surface scafld uses to judge protocol quality.

- `FirstAttemptPassRate: float64` (json:"first_attempt_pass_rate"): 
- `FirstAttemptPasses: int` (json:"first_attempt_passes"): 
- `FirstAttemptTotal: int` (json:"first_attempt_total"): 
- `RecoveryConvergenceRate: float64` (json:"recovery_convergence_rate"): 
- `RecoveredTasks: int` (json:"recovered_tasks"): 
- `RecoveryTotal: int` (json:"recovery_total"): 
- `ChallengeOverrideRate: float64` (json:"challenge_override_rate"): 
- `ChallengeOverrides: int` (json:"challenge_overrides"): 
- `ReviewChallengeTotal: int` (json:"review_challenge_total"): 
- `ReviewPassRate: float64` (json:"review_pass_rate"): 
- `ReviewPasses: int` (json:"review_passes"): 
- `ReviewTotal: int` (json:"review_total"): 
- `ReviewDossierCoverage: float64` (json:"review_dossier_coverage"): 
- `ReviewDossierTotal: int` (json:"review_dossier_total"): 
- `ReviewFindingsTotal: int` (json:"review_findings_total"): 
- `ReviewOpenBlockersTotal: int` (json:"review_open_blockers_total"): 
- `ReviewAttackAnglesTotal: int` (json:"review_attack_angles_total"): 
- `ReviewModeDistribution: map[string]int` (json:"review_mode_distribution,omitempty"): 
- `WorkspaceBaselineCoverage: float64` (json:"workspace_baseline_coverage"): 
- `WorkspaceBaselineTasks: int` (json:"workspace_baseline_tasks"): 
- `SessionTotal: int` (json:"session_total"): 
- `BlockedGateDistribution: map[string]int` (json:"blocked_gate_distribution,omitempty"): 

## Output

```go
type Output struct {
	Total    int                 `json:"total"`
	ByStatus map[spec.Status]int `json:"by_status"`
	Metrics  Metrics             `json:"metrics"`
}
```

Output summarizes workspace task counts and session-derived product metrics.

- `Total: int` (json:"total"): 
- `ByStatus: map[spec.Status]int` (json:"by_status"): 
- `Metrics: Metrics` (json:"metrics"): 

## SessionStore

```go
type SessionStore interface {
	List(context.Context) ([]session.Session, error)
}
```

SessionStore lists session ledgers used for evidence-derived metrics.

- `List: func(context.Context) ([]session.Session, error)`: 

## SpecStore

```go
type SpecStore interface {
	List(context.Context) ([]spec.Record, error)
}
```

SpecStore is the spec listing port used by reports.

- `List: func(context.Context) ([]spec.Record, error)`:
