reporting

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package reporting exposes the safe, presentation-neutral report read model used by overview, report, desktop, and CLI adapters.

Index

Constants

View Source
const (
	CurrentSchemaVersion       = 1
	CurrentDetailSchemaVersion = 1
	// MaxSnapshotReports is the published latest-first report-list boundary.
	// Storage ports must never return more entries in one snapshot.
	MaxSnapshotReports = 100
)

Variables

View Source
var (
	ErrUnavailable  = errors.New("reporting service unavailable")
	ErrInconsistent = errors.New("reporting data is inconsistent")
)
View Source
var ErrGenerationInvalid = errors.New("reporting: invalid generation request")
View Source
var ErrInvalidWatermark = errors.New("invalid report watermark")
View Source
var ErrReportWrite = errors.New("reporting: report write failed")

ErrReportWrite marks the only generation failure that may have committed. Loading and computation failures never require a second report read.

View Source
var ErrUnsupportedExport = errors.New("unsupported report export format")
View Source
var ErrUnsupportedExportLocale = errors.New("unsupported report export locale")

Functions

func EntryFailed

func EntryFailed(entry domain.RunEntrySnapshot, results []domain.Result) bool

EntryFailed applies the same measured verdict and SLA rules used by reports before the run host decides whether to start the next plan item.

Types

type CaseDetail

type CaseDetail struct {
	CaseID         string                        `json:"case_id"`
	Revision       uint64                        `json:"revision"`
	Key            string                        `json:"key"`
	Name           string                        `json:"name"`
	Dimension      string                        `json:"dimension"`
	Protocol       domain.Protocol               `json:"protocol"`
	Severity       domain.CaseSeverity           `json:"severity"`
	Verification   domain.VerificationSummary    `json:"verification"`
	Metrics        map[string]domain.MetricValue `json:"metrics"`
	SummaryResult  *domain.Result                `json:"summary_result,omitempty"`
	RequestResults []domain.Result               `json:"request_results"`
}

type Catalog

type Catalog interface {
	ListReportProjections(context.Context) ([]ReportProjection, error)
}

Catalog supplies one bounded storage read. ReportProjection contains only scalar values that the reporting application service is allowed to expose.

type Detail

type Detail struct {
	SchemaVersion            int                          `json:"schema_version"`
	Source                   ReportSource                 `json:"source"`
	Report                   domain.Report                `json:"report"`
	RequestResults           []domain.Result              `json:"request_results"`
	Entries                  []EntryDetail                `json:"entries"`
	UnassignedRequestResults []domain.Result              `json:"unassigned_request_results"`
	Performance              *quicktest.PerformanceReport `json:"performance,omitempty"`
	PerformanceSummary       *PerformanceSummary          `json:"performance_summary,omitempty"`
	DimensionStatistics      []DimensionStatistic         `json:"dimension_statistics,omitempty"`
}

Detail is the complete machine-readable report view. Report contains the sealed conclusion and case-level results; RequestResults contains the load and protocol observations used to derive the aggregate metrics.

type DimensionStatistic

type DimensionStatistic struct {
	Dimension              string   `json:"dimension"`
	CaseCount              uint64   `json:"case_count"`
	PassedCaseCount        uint64   `json:"passed_case_count"`
	FailedCaseCount        uint64   `json:"failed_case_count"`
	ObservedCaseCount      uint64   `json:"observed_case_count"`
	IndeterminateCaseCount uint64   `json:"indeterminate_case_count"`
	NotRunCaseCount        uint64   `json:"not_run_case_count"`
	PassRatePercent        *float64 `json:"pass_rate_percent"`
}

DimensionStatistic counts each frozen (entry, case) once, independently of load.

type DocumentCatalog

type DocumentCatalog interface {
	Catalog
	GetReport(context.Context, string) (domain.Report, error)
	ListResults(context.Context, string) ([]domain.Result, error)
}

DocumentCatalog exposes the sealed report and its request-level results. Large provider payloads remain behind the redacted evidence/artifact boundary.

type EntryDetail

type EntryDetail struct {
	Performance   json.RawMessage               `json:"performance,omitempty"`
	WarmupCount   uint32                        `json:"warmup_count"`
	Settings      testspec.RunSettings          `json:"settings"`
	EntryID       string                        `json:"entry_id"`
	TargetKind    domain.PlanTargetKind         `json:"target_kind"`
	TargetID      string                        `json:"target_id"`
	Name          string                        `json:"name"`
	Key           string                        `json:"key"`
	Protocol      domain.Protocol               `json:"protocol"`
	Parameters    map[string]json.RawMessage    `json:"parameters"`
	Load          domain.LoadProfile            `json:"load"`
	Seed          uint64                        `json:"seed"`
	Status        domain.EntryReportStatus      `json:"status"`
	Conclusion    domain.ReportConclusion       `json:"conclusion"`
	Verification  domain.VerificationSummary    `json:"verification"`
	SLA           map[string]domain.MetricValue `json:"sla"`
	Metrics       map[string]domain.MetricValue `json:"metrics"`
	Timeline      []json.RawMessage             `json:"timeline"`
	Distributions []json.RawMessage             `json:"distributions"`
	Cases         []CaseDetail                  `json:"cases"`
}

type ExportFormat

type ExportFormat string
const (
	ExportJSON         ExportFormat = "json"
	ExportHTML         ExportFormat = "html"
	ExportPNG          ExportFormat = "png"
	ExportPDF          ExportFormat = "pdf"
	DefaultWatermark                = "rhzs"
	MaxWatermarkLength              = 64
)

type ExportedDocument

type ExportedDocument struct {
	Filename   string `json:"filename"`
	MediaType  string `json:"media_type"`
	DataBase64 string `json:"data_base64"`
}

ExportedDocument is safe for JSON/Wails transport. Encoding the bytes here keeps JavaScript bindings stable across platforms and Wails versions.

type GenerationProgress

type GenerationProgress struct {
	Sequence  uint64 `json:"sequence"`
	RunID     string `json:"run_id"`
	Phase     string `json:"phase"`
	Processed uint64 `json:"processed"`
	Total     uint64 `json:"total"`
	ElapsedMS uint64 `json:"elapsed_ms"`
	ReportID  string `json:"report_id,omitempty"`
}

GenerationProgress describes real work; an unknown total is zero and must be presented as an indeterminate phase, never as an estimated percentage.

type GenerationSnapshot

type GenerationSnapshot struct {
	SchemaVersion int                  `json:"schema_version"`
	Runs          []GenerationProgress `json:"runs"`
}

type GenerationTiming

type GenerationTiming struct {
	RunID    string
	Phase    string
	Duration time.Duration
}

type Generator

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

func NewGenerator

func NewGenerator(dependencies GeneratorDependencies) (*Generator, error)

func (*Generator) Generate

func (generator *Generator) Generate(ctx context.Context, runID string) (generationErr error)

func (*Generator) GenerationSnapshot

func (generator *Generator) GenerationSnapshot() GenerationSnapshot

func (*Generator) SubscribeProgress

func (generator *Generator) SubscribeProgress(observer func(GenerationProgress)) func()

type GeneratorClock

type GeneratorClock interface {
	Now() time.Time
}

type GeneratorDependencies

type GeneratorDependencies struct {
	Repository ReportRepository
	Clock      GeneratorClock
	IDFactory  ReportIDFactory
	Timing     func(GenerationTiming)
}

type PerformanceSummary

type PerformanceSummary struct {
	ItemCount            uint64                             `json:"item_count"`
	MeasuredItemCount    uint64                             `json:"measured_item_count"`
	CompletedItemCount   uint64                             `json:"completed_item_count"`
	Completed            uint64                             `json:"completed"`
	Succeeded            uint64                             `json:"succeeded"`
	Failed               uint64                             `json:"failed"`
	TimedOut             uint64                             `json:"timed_out"`
	PromptTokens         uint64                             `json:"prompt_tokens"`
	CompletionTokens     uint64                             `json:"completion_tokens"`
	CachedTokens         uint64                             `json:"cached_tokens"`
	SuccessRatePercent   *float64                           `json:"success_rate_percent"`
	CacheRatePercent     *float64                           `json:"cache_rate_percent"`
	TotalDurationMS      float64                            `json:"total_duration_ms"`
	SuccessfulRequestQPS *float64                           `json:"successful_request_qps"`
	SamplesComplete      bool                               `json:"samples_complete"`
	TTFT                 *quicktest.PerformanceLatencySlice `json:"ttft"`
	E2E                  *quicktest.PerformanceLatencySlice `json:"e2e"`
}

PerformanceSummary is a read-time view of sealed steady-state observations. It does not replace an item's historical metrics, SLO or capacity verdict.

type QuickPerformanceCatalog

type QuickPerformanceCatalog interface {
	ListQuickPerformanceReportSummaries(context.Context) ([]quicktest.PerformanceArchiveSummary, error)
	GetQuickPerformanceReport(context.Context, string) (quicktest.PerformanceReport, error)
}

type ReportIDFactory

type ReportIDFactory func(time.Time) (string, error)

type ReportProjection

type ReportProjection struct {
	PassedCaseCount        int64
	VerifiedCaseCount      int64
	ObservedCaseCount      int64
	IndeterminateCaseCount int64
	ID                     string
	RunID                  string
	GeneratedAt            time.Time
	RunStatus              domain.RunStatus
	PlanName               string
	ModelName              string
	ChannelName            string
	Passed                 bool
	Verdict                string
	IssueCount             int64
	CaseCount              int64
	FailedCaseCount        int64
	AttachmentCount        int64
}

type ReportRepository

type ReportRepository interface {
	GetRun(context.Context, string) (domain.Run, error)
	RunExecutionOrigin(context.Context, string) (*domain.ExecutionOrigin, error)
	ListResults(context.Context, string) ([]domain.Result, error)
	ListEvidence(context.Context, string) ([]domain.Evidence, error)
	CreateReport(context.Context, domain.Report) error
}

type ReportSource

type ReportSource string
const (
	SourceRun              ReportSource = "run"
	SourceQuickPerformance ReportSource = "quick_performance"
)

type Service

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

func New

func New(catalog Catalog) Service

func (Service) Detail

func (service Service) Detail(ctx context.Context, reportID string) (Detail, error)

func (Service) Export

func (service Service) Export(ctx context.Context, reportID string, format ExportFormat, watermark string) (ExportedDocument, error)

func (Service) ExportLocalized

func (service Service) ExportLocalized(ctx context.Context, reportID string, format ExportFormat, watermark, locale string) (ExportedDocument, error)

func (Service) Snapshot

func (service Service) Snapshot(ctx context.Context) (Snapshot, error)

type Snapshot

type Snapshot struct {
	SchemaVersion int       `json:"schema_version"`
	Reports       []Summary `json:"reports"`
}

type Summary

type Summary struct {
	PassedCaseCount        uint64           `json:"passed_case_count"`
	VerifiedCaseCount      uint64           `json:"verified_case_count"`
	ObservedCaseCount      uint64           `json:"observed_case_count"`
	IndeterminateCaseCount uint64           `json:"indeterminate_case_count"`
	Source                 ReportSource     `json:"source"`
	ID                     string           `json:"id"`
	RunID                  string           `json:"run_id,omitempty"`
	GeneratedAt            time.Time        `json:"generated_at"`
	RunStatus              domain.RunStatus `json:"run_status"`
	PlanName               string           `json:"plan_name"`
	ModelName              string           `json:"model_name"`
	ChannelName            string           `json:"channel_name"`
	Passed                 bool             `json:"passed"`
	Verdict                string           `json:"verdict"`
	IssueCount             uint64           `json:"issue_count"`
	CaseCount              uint64           `json:"case_count"`
	FailedCaseCount        uint64           `json:"failed_case_count"`
	AttachmentCount        uint64           `json:"attachment_count"`
}

func SummarizeQuickPerformance

func SummarizeQuickPerformance(report quicktest.PerformanceArchiveSummary) (Summary, error)

SummarizeQuickPerformance preserves the archived conclusion in list projections.

Jump to

Keyboard shortcuts

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