apiaudit

package
v0.1.4 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

Index

Constants

View Source
const (
	StatusPass     = "pass"
	StatusWarning  = "warning"
	StatusFail     = "fail"
	StatusUnknown  = "unknown"
	StatusObserved = "observed"
)
View Source
const DefaultSeedanceModel = "doubao-seedance-2-0-260128"

Variables

View Source
var DefaultSeedanceModels = []string{
	DefaultSeedanceModel,
	"doubao-seedance-2-0-fast-260128",
	"doubao-seedance-2-0-mini-260615",
}

Functions

func SupportedProtocols

func SupportedProtocols() []string

func WriteReport

func WriteReport(outputDir string, report Report) error

Types

type CaseDefinition

type CaseDefinition struct {
	ID            string        `json:"id"`
	Name          string        `json:"name"`
	Dimension     string        `json:"dimension"`
	Protocol      string        `json:"protocol"`
	Type          string        `json:"type"`
	Default       bool          `json:"default"`
	Disabled      bool          `json:"disabled"`
	ExecutionMode string        `json:"execution_mode"`
	Severity      string        `json:"severity"`
	Spec          testspec.Spec `json:"spec"`
}

func LoadSuite

func LoadSuite(root, suite string) ([]CaseDefinition, error)

func SelectCases

func SelectCases(cases []CaseDefinition, ids []string, all bool) ([]CaseDefinition, error)

type CaseResult

type CaseResult struct {
	Verification testspec.Verdict      `json:"verification"`
	Observation  *testspec.Observation `json:"observation,omitempty"`
	ID           string                `json:"id"`
	Name         string                `json:"name"`
	Dimension    string                `json:"dimension"`
	Protocol     string                `json:"protocol"`
	Model        string                `json:"model"`
	Status       string                `json:"status"`
	Severity     string                `json:"severity"`
	ElapsedMS    int64                 `json:"elapsed_ms"`
	Evidence     string                `json:"evidence"`
	HTTPStatus   int                   `json:"http_status,omitempty"`
	Usage        map[string]any        `json:"usage,omitempty"`
	Metrics      map[string]any        `json:"metrics,omitempty"`
	Exchanges    []HTTPExchange        `json:"exchanges,omitempty"`
	ArtifactDir  string                `json:"artifact_dir,omitempty"`
}

func RedactCaseResult

func RedactCaseResult(result CaseResult, apiKey string) CaseResult

RedactCaseResult returns a safe copy for machine-readable progress events. Reports use the same redaction path before anything is written to disk.

func RunCase

func RunCase(ctx context.Context, doer HTTPDoer, config RunConfig, planned PlannedRun) (CaseResult, error)

RunCase is the CLI presentation boundary for the same runtime used by desktop.

type DimensionSummary

type DimensionSummary struct {
	Dimension string `json:"dimension"`
	SummaryCounts
}

type HTTPDoer

type HTTPDoer interface {
	Do(*http.Request) (*http.Response, error)
}

type HTTPExchange

type HTTPExchange struct {
	Method       string         `json:"method"`
	URL          string         `json:"url"`
	RequestBody  map[string]any `json:"request_body,omitempty"`
	StatusCode   int            `json:"status_code,omitempty"`
	ResponseBody string         `json:"response_body,omitempty"`
}

type PlannedRun

type PlannedRun struct {
	Case     CaseDefinition
	Model    string
	ResultID string
}

func ExpandRuns

func ExpandRuns(config RunConfig, cases []CaseDefinition) ([]PlannedRun, error)

type Report

type Report struct {
	Title       string             `json:"title"`
	GeneratedAt time.Time          `json:"generated_at"`
	Suite       string             `json:"suite"`
	BaseURL     string             `json:"base_url"`
	Model       string             `json:"model"`
	Overall     string             `json:"overall"`
	Verdict     string             `json:"verdict"`
	Summary     SummaryCounts      `json:"summary"`
	Notices     []ReportNotice     `json:"notices,omitempty"`
	Dimensions  []DimensionSummary `json:"dimensions"`
	Failures    []CaseResult       `json:"failures,omitempty"`
	Warnings    []CaseResult       `json:"warnings,omitempty"`
	Results     []CaseResult       `json:"results"`
	APIKey      string             `json:"-"`
}

func BuildReport

func BuildReport(config RunConfig, results []CaseResult) Report

type ReportNotice

type ReportNotice struct {
	Title string   `json:"title"`
	Body  string   `json:"body"`
	Items []string `json:"items,omitempty"`
}

type RunConfig

type RunConfig struct {
	Seed         uint64
	Inputs       map[string]json.RawMessage
	Suite        string
	BaseURL      string
	APIKey       string
	Model        string
	Models       []string
	OutputDir    string
	DryRun       bool
	PollInterval time.Duration
	Timeout      time.Duration
}

type SummaryCounts

type SummaryCounts struct {
	Observed int `json:"observed"`
	Pass     int `json:"pass"`
	Warning  int `json:"warning"`
	Fail     int `json:"fail"`
	Unknown  int `json:"unknown"`
}

Jump to

Keyboard shortcuts

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