web

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 29 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package web is the status-server backend: the embedded status page SPA, a JSON projection of Findings and FindingRollups, the three human actions (approve, suspend, resume), and an SSE change signal that tells open browsers to refetch.

The exposure contract is deliberately asymmetric: rollup statistics are public (GET /api/rollups and the SSE stream serve without a session), while the findings surface — list, detail, and every action — always requires an authenticated identity (internal/web/auth) holding the RBAC grants (internal/web/authz). The server never writes finding status and never moves a phase: approve records spec.approval and suspend/resume toggle spec.suspend, leaving every phase edge to its owning controller.

The wire types in data.go mirror the status page's TypeScript contract (ui/src/types.ts) field for field; keep the two in lockstep.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionRequest added in v0.5.2

type ActionRequest struct {
	By string `json:"by"`
	At string `json:"at"`
}

ActionRequest is a recorded human retry/expedite request.

type ActiveRun

type ActiveRun struct {
	Kind string `json:"kind"`
	Name string `json:"name"`
}

ActiveRun points at the child currently running.

type Alert

type Alert struct {
	ID        string     `json:"id"`
	URL       string     `json:"url,omitempty"`
	Locations []Location `json:"locations,omitempty"`
}

Alert is one scanner alert folded into the finding.

type Approval

type Approval struct {
	By   string `json:"by"`
	At   string `json:"at"`
	Note string `json:"note,omitempty"`
}

Approval is the recorded human approval.

type Attempts

type Attempts struct {
	Investigation int32 `json:"investigation,omitempty"`
	Remediation   int32 `json:"remediation,omitempty"`
}

Attempts tallies agent runs per stage.

type Budget added in v0.8.0

type Budget struct {
	// Estimated is the investigation's prediction; nil when it made none.
	Estimated *Estimate `json:"estimated,omitempty"`
	// GrantedMaxTurns/GrantedTokenBudget are what the run was allowed.
	GrantedMaxTurns    int32 `json:"grantedMaxTurns,omitempty"`
	GrantedTokenBudget int64 `json:"grantedTokenBudget,omitempty"`
}

Budget is one remediation run's three-way budget picture: what the investigation predicted, what the run was granted, and (via the run's NumTurns and Usage.OutputTokens) what it actually spent. The client computes the over/under from these; the server ships raw figures.

type CloudResource added in v0.8.0

type CloudResource struct {
	Provider    string `json:"provider"`
	Name        string `json:"name"`
	Type        string `json:"type,omitempty"`
	Project     string `json:"project,omitempty"`
	Location    string `json:"location,omitempty"`
	DisplayName string `json:"displayName,omitempty"`
}

CloudResource identifies the cloud resource a finding was raised against.

type Dataset

type Dataset struct {
	GeneratedAt string    `json:"generatedAt"`
	Namespace   string    `json:"namespace,omitempty"`
	Version     string    `json:"version,omitempty"`
	User        *User     `json:"user,omitempty"`
	Findings    []Finding `json:"findings"`
	Rollups     []Rollup  `json:"rollups,omitempty"`
}

Dataset is the payload behind GET /api/findings (everything) and GET /api/rollups (findings empty, no user). It mirrors ui/src/types.ts.

type Enrichment

type Enrichment struct {
	Enhancer   string            `json:"enhancer"`
	Owners     []string          `json:"owners,omitempty"`
	Attributes map[string]string `json:"attributes,omitempty"`
	Markdown   string            `json:"markdown,omitempty"`
	AppliedAt  string            `json:"appliedAt,omitempty"`
}

Enrichment is one enhancer contribution.

type Estimate added in v0.8.0

type Estimate struct {
	MaxTurns    int32 `json:"maxTurns,omitempty"`
	TokenBudget int64 `json:"tokenBudget,omitempty"`
}

Estimate is an investigation's prediction of a remediation's cost.

type EstimateAggregate added in v0.8.0

type EstimateAggregate struct {
	Runs                  int64 `json:"runs,omitempty"`
	PredictedTurns        int64 `json:"predictedTurns,omitempty"`
	ActualTurns           int64 `json:"actualTurns,omitempty"`
	PredictedOutputTokens int64 `json:"predictedOutputTokens,omitempty"`
	ActualOutputTokens    int64 `json:"actualOutputTokens,omitempty"`
}

EstimateAggregate is predicted-against-actual cost over the runs that carried an estimate. Predicted and actual cover the same runs, so the client's skew (actual ÷ predicted - 1) is like-for-like.

type Finding

type Finding struct {
	Name        string      `json:"name"`
	CreatedAt   string      `json:"createdAt,omitempty"`
	Integration string      `json:"integration,omitempty"`
	Source      string      `json:"source,omitempty"`
	Repository  *Repository `json:"repository,omitempty"`
	// CloudResource is set on a finding raised against infrastructure rather
	// than repository code. It is what explains a finding with no repository:
	// the resource carried no ownership labels to resolve one from.
	CloudResource *CloudResource `json:"cloudResource,omitempty"`
	Advisories    []string       `json:"advisories"`
	RuleID        string         `json:"ruleID,omitempty"`
	Title         string         `json:"title,omitempty"`
	Description   string         `json:"description,omitempty"`
	Severity      string         `json:"severity,omitempty"`
	Alerts        []Alert        `json:"alerts,omitempty"`
	// OverflowAlerts counts alerts dropped past the accumulation cap.
	OverflowAlerts  int32          `json:"overflowAlerts,omitempty"`
	Related         []Related      `json:"related,omitempty"`
	Suspend         bool           `json:"suspend,omitempty"`
	Approval        *Approval      `json:"approval,omitempty"`
	Retry           *ActionRequest `json:"retry,omitempty"`
	Expedite        *ActionRequest `json:"expedite,omitempty"`
	Phase           string         `json:"phase,omitempty"`
	PhaseTimes      []PhaseTime    `json:"phaseTimes,omitempty"`
	FirstObservedAt string         `json:"firstObservedAt,omitempty"`
	AccumulateUntil string         `json:"accumulateUntil,omitempty"`
	Tracking        *Tracking      `json:"tracking,omitempty"`
	Owners          []string       `json:"owners,omitempty"`
	Enrichments     []Enrichment   `json:"enrichments,omitempty"`
	Priority        string         `json:"priority,omitempty"`
	Investigation   *Investigation `json:"investigation,omitempty"`
	Remediation     *Remediation   `json:"remediation,omitempty"`
	PullRequest     *PullRequest   `json:"pullRequest,omitempty"`
	Attempts        *Attempts      `json:"attempts,omitempty"`
	// TotalUsage sums token and cost accounting across every attempt of
	// both stages, lifted from the Investigation/Remediation children.
	TotalUsage        *Usage     `json:"totalUsage,omitempty"`
	ActiveRun         *ActiveRun `json:"activeRun,omitempty"`
	LastFailureReason string     `json:"lastFailureReason,omitempty"`
	CompletedAt       string     `json:"completedAt,omitempty"`
	// UserActions are the verbs the requesting user may invoke; the client
	// intersects them with the state machine. Absent means read-only.
	UserActions []string `json:"userActions,omitempty"`
}

Finding is the flattened metadata+spec+status projection of one Finding, plus the requesting user's granted action verbs.

type Granter

type Granter interface {
	Grants(ctx context.Context, id auth.Identity) (authz.Grants, error)
}

Granter resolves what an identity may do; internal/web/authz provides the SubjectAccessReview implementation and the mode-none bypass.

type Investigation

type Investigation struct {
	Name           string   `json:"name,omitempty"`
	Attempt        int32    `json:"attempt,omitempty"`
	Outcome        string   `json:"outcome,omitempty"`
	Recommendation string   `json:"recommendation,omitempty"`
	Confidence     string   `json:"confidence,omitempty"`
	Exploitability string   `json:"exploitability,omitempty"`
	Likelihood     string   `json:"likelihood,omitempty"`
	Impact         string   `json:"impact,omitempty"`
	AwaitApproval  bool     `json:"awaitApproval,omitempty"`
	HoldReasons    []string `json:"holdReasons,omitempty"`
	// Estimate is what this investigation predicted the remediation would
	// cost; the remediation's Budget reports what it was granted and spent.
	Estimate    *Estimate `json:"estimate,omitempty"`
	CompletedAt string    `json:"completedAt,omitempty"`
	Report      string    `json:"report,omitempty"`
	Harness     string    `json:"harness,omitempty"`
	Model       string    `json:"model,omitempty"`
	NumTurns    int32     `json:"numTurns,omitempty"`
	Usage       *Usage    `json:"usage,omitempty"`
	// SessionID is the agent CLI's own session identifier — a correlation key
	// for operators reading model-provider logs, not a handle anything can be
	// fetched with (the CLI session dies with the pod).
	SessionID string `json:"sessionID,omitempty"`
	// Transcript summarises the captured conversation; the turns themselves
	// come from the transcript endpoint.
	Transcript *TranscriptSummary `json:"transcript,omitempty"`
}

Investigation mirrors the Finding's investigation summary, plus the report markdown and run accounting lifted from the Investigation child.

type Location

type Location struct {
	Path      string `json:"path"`
	StartLine int32  `json:"startLine,omitempty"`
	EndLine   int32  `json:"endLine,omitempty"`
	Snippet   string `json:"snippet,omitempty"`
}

Location is one source location an alert points at.

type MonthlyBucket

type MonthlyBucket struct {
	Findings     int64 `json:"findings,omitempty"`
	Runs         int64 `json:"runs,omitempty"`
	CostMicroUSD int64 `json:"costMicroUSD,omitempty"`
}

MonthlyBucket is one month of the total scope's trend line.

type PhaseTime

type PhaseTime struct {
	Phase string `json:"phase"`
	At    string `json:"at"`
}

PhaseTime is one phase-entry log record.

type PullRequest

type PullRequest struct {
	Number   int64  `json:"number"`
	URL      string `json:"url,omitempty"`
	State    string `json:"state,omitempty"`
	MergedAt string `json:"mergedAt,omitempty"`
}

PullRequest is the remediation pull request's lifecycle.

type Related struct {
	Name         string `json:"name"`
	Relationship string `json:"relationship"`
}

Related is one relationship edge, named from this finding's perspective: the CRD stores {from, to}, the wire type carries the other endpoint.

type Remediation

type Remediation struct {
	Name        string  `json:"name,omitempty"`
	Attempt     int32   `json:"attempt,omitempty"`
	Outcome     string  `json:"outcome,omitempty"`
	Success     bool    `json:"success,omitempty"`
	Branch      string  `json:"branch,omitempty"`
	CompletedAt string  `json:"completedAt,omitempty"`
	Report      string  `json:"report,omitempty"`
	Harness     string  `json:"harness,omitempty"`
	Model       string  `json:"model,omitempty"`
	NumTurns    int32   `json:"numTurns,omitempty"`
	Budget      *Budget `json:"budget,omitempty"`
	Usage       *Usage  `json:"usage,omitempty"`
	// SessionID is the agent CLI's own session identifier; see Investigation.
	SessionID string `json:"sessionID,omitempty"`
	// Transcript summarises the captured conversation.
	Transcript *TranscriptSummary `json:"transcript,omitempty"`
}

Remediation mirrors the Finding's remediation summary, plus the report markdown and run accounting lifted from the Remediation child.

type Repository

type Repository struct {
	Type          string `json:"type"`
	URL           string `json:"url"`
	Name          string `json:"name,omitempty"`
	DefaultBranch string `json:"defaultBranch,omitempty"`
}

Repository locates the finding's repository.

type Rollup

type Rollup struct {
	Scope          RollupScope              `json:"scope"`
	FirstProcessed string                   `json:"firstProcessed,omitempty"`
	LastProcessed  string                   `json:"lastProcessed,omitempty"`
	Bucket         RollupBucket             `json:"bucket"`
	Monthly        map[string]MonthlyBucket `json:"monthly,omitempty"`
}

Rollup is one scope's all-time statistics, identified by scope.key ("" is the total scope) — never by object name.

type RollupBucket

type RollupBucket struct {
	Findings        int64                     `json:"findings,omitempty"`
	Phases          map[string]int64          `json:"phases,omitempty"`
	Recommendations map[string]int64          `json:"recommendations,omitempty"`
	Attempts        int64                     `json:"attempts,omitempty"`
	Stages          map[string]StageAggregate `json:"stages,omitempty"`
}

RollupBucket carries the finding-level counters; harness and model scopes carry only stages.

type RollupScope

type RollupScope struct {
	Type string `json:"type"`
	Key  string `json:"key,omitempty"`
}

RollupScope identifies one rollup dimension value.

type Server

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

Server is the status-server backend: the public rollups projection, the authenticated findings projection, the three actions, the SSE change signal, and the embedded SPA.

func NewServer

func NewServer(c client.Client, namespace string, a auth.Authenticator, g Granter, log *slog.Logger) *Server

NewServer builds the backend over the manager's cached client. log may be nil.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler builds the HTTP surface: the split public/authenticated API, the SSE stream, the sign-in routes (when the auth mode has any), and the embedded SPA with client-side-routing fallback.

func (*Server) StartWatch

func (s *Server) StartWatch(ctx context.Context, c cache.Cache) error

StartWatch registers change handlers on the Finding and FindingRollup informers and publishes a debounced findings-changed notification to the SSE broker. It blocks until ctx is cancelled, so it slots straight into a manager runnable — running after the cache has synced and stopping with the manager.

func (*Server) WithTranscripts added in v0.8.2

func (s *Server) WithTranscripts(reader client.Reader, tailer Tailer) *Server

WithTranscripts wires the uncached reader for persisted transcripts and the tailer for live ones. Without it the server still serves everything else; transcripts simply come back empty.

type StageAggregate

type StageAggregate struct {
	Runs                int64              `json:"runs,omitempty"`
	Succeeded           int64              `json:"succeeded,omitempty"`
	Outcomes            map[string]int64   `json:"outcomes,omitempty"`
	InputTokens         int64              `json:"inputTokens,omitempty"`
	OutputTokens        int64              `json:"outputTokens,omitempty"`
	CacheReadTokens     int64              `json:"cacheReadTokens,omitempty"`
	CacheCreationTokens int64              `json:"cacheCreationTokens,omitempty"`
	CostMicroUSD        int64              `json:"costMicroUSD,omitempty"`
	ElapsedMilliseconds int64              `json:"elapsedMilliseconds,omitempty"`
	Turns               int64              `json:"turns,omitempty"`
	Estimate            *EstimateAggregate `json:"estimate,omitempty"`
}

StageAggregate is one stage's raw sums; the client computes rates and averages.

type Tailer added in v0.8.2

type Tailer interface {
	Tail(ctx context.Context, jobName string, fn func(transcript.Turn) error) error
}

Tailer follows a running agent Job's transcript; *jobs.Tailer implements it.

type Tracking

type Tracking struct {
	IssueNumber int64  `json:"issueNumber,omitempty"`
	URL         string `json:"url,omitempty"`
	State       string `json:"state,omitempty"`
}

Tracking links the projected tracking issue.

type TranscriptSummary added in v0.8.2

type TranscriptSummary struct {
	Turns     int32 `json:"turns"`
	Truncated bool  `json:"truncated,omitempty"`
}

TranscriptSummary tells the client whether a run has a conversation worth opening, without shipping it inside the dataset — a finding list carrying every run's full transcript would be orders of magnitude larger than the page needs.

type Turn added in v0.8.2

type Turn struct {
	Seq       int    `json:"seq"`
	At        string `json:"at,omitempty"`
	Role      string `json:"role"`
	Kind      string `json:"kind"`
	Tool      string `json:"tool,omitempty"`
	Text      string `json:"text,omitempty"`
	Truncated bool   `json:"truncated,omitempty"`
}

Turn is one conversation entry on the wire. It mirrors the SPA's TranscriptTurn; keep the two in lockstep.

type Usage added in v0.5.3

type Usage struct {
	InputTokens         int64 `json:"inputTokens,omitempty"`
	OutputTokens        int64 `json:"outputTokens,omitempty"`
	CacheReadTokens     int64 `json:"cacheReadTokens,omitempty"`
	CacheCreationTokens int64 `json:"cacheCreationTokens,omitempty"`
	CostMicroUSD        int64 `json:"costMicroUSD,omitempty"`
}

Usage is token and cost accounting — one run's, or the finding's total across every attempt of both stages. Cost is integer micro-USD, matching the rollup wire type.

type User

type User struct {
	Name     string `json:"name"`
	LoggedIn bool   `json:"loggedIn"`
	// AdminActions are the granted namespace-wide verbs (replay, reset) the
	// user menu renders. Absent means none.
	AdminActions []string `json:"adminActions,omitempty"`
}

User is the signed-in identity the top bar renders.

Directories

Path Synopsis
Package auth resolves who is making a status-server request.
Package auth resolves who is making a status-server request.
Package authz resolves what an identity may do to findings.
Package authz resolves what an identity may do to findings.

Jump to

Keyboard shortcuts

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