Documentation
¶
Overview ¶
Package web is the status-server backend: the embedded status page SPA, a JSON projection of Findings, FindingRollups and the Forge/Integration configuration, the per-finding human actions (approve, retry, expedite, suspend, resume), the integration actions (backfill, and the replay and reset demo tooling), and an SSE change signal that tells open browsers to refetch.
Every data route requires an identity (internal/web/auth) holding the matching RBAC grant (internal/web/authz): native get on findings for the findings surface (list, detail, transcripts), on findingrollups for metrics (GET /api/rollups and /api/rollups/repositories), on integrations for the configuration view, and the custom verbs for each action. The SSE stream needs any one of the read grants. Only auth mode none (an explicit "authentication disabled") opens everything; with no auth configuration at all nothing is served. The server writes spec only (spec.approval, spec.retry, spec.expedite, spec.suspend on Findings; spec.backfill, spec.replay, spec.reset on Integrations). It never writes status and never moves a phase: every phase edge belongs 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
- func RegisterIndexes(ctx context.Context, idx client.FieldIndexer) error
- func RunFindingIndexer(obj client.Object) []string
- type ActionRequest
- type ActiveRun
- type Alert
- type Approval
- type Attempts
- type BackfillDecisionWire
- type BackfillRequestWire
- type BackfillRequestsPayload
- type BackfillStatus
- type Budget
- type CloudResource
- type ConfigDataset
- type Dataset
- type EnhancerConfig
- type Enrichment
- type Estimate
- type EstimateAggregate
- type Finding
- type FindingFacets
- type FindingSuggestions
- type FindingSummary
- type FindingsPage
- type ForgeConfig
- type GitHubLink
- type GitHubRepositoriesPayload
- type Granter
- type IntegrationConfig
- type Investigation
- type InvestigationSummary
- type Location
- type MonthlyBucket
- type PhaseTime
- type PresignedURL
- type PullRequest
- type RedeliveryStatus
- type Related
- type Remediation
- type RemediationSummary
- type RepositoriesPayload
- type Repository
- type RepositoryAccess
- type RepositoryAccessPayload
- type RepositoryBackfill
- type RepositoryBackfillResult
- type RepositoryCount
- type RepositoryMatch
- type RepositoryPage
- type RepositoryRollup
- type RepositorySummary
- type Rollup
- type RollupBucket
- type RollupScope
- type Server
- func (s *Server) Handler() http.Handler
- func (s *Server) LookupConnectable(ctx context.Context, name string) (ghlink.Integration, bool)
- func (s *Server) StartWatch(ctx context.Context, c cache.Cache) error
- func (s *Server) WithArchive(store archive.Store, ttl time.Duration) *Server
- func (s *Server) WithBackfillCooldown(d time.Duration) *Server
- func (s *Server) WithGitHub(users githubUsers, links *ghlink.Linker) *Server
- func (s *Server) WithRepositoryAccess(c accessChecker) *Server
- func (s *Server) WithTranscripts(reader client.Reader, tailer Tailer) *Server
- type StageAggregate
- type Tailer
- type Tracking
- type TranscriptSummary
- type Turn
- type Usage
- type User
Constants ¶
const ( // DefaultBackfillCooldown is how long after a one-repository backfill // ran that the repositories page refuses another for the same // repository. DefaultBackfillCooldown = 24 * time.Hour )
const DefaultPresignTTL = 5 * time.Minute
DefaultPresignTTL is how long a presigned archive URL lives when the operator configures none. Short, because the URL is a bearer capability: whoever holds it can read the object until it expires.
const RunFindingIndex = "patchy.web/finding"
RunFindingIndex is the cache field index the detail projection looks a finding's Investigation/Remediation children up by (the finding label), so a detail request is an index hit rather than a namespace scan.
Variables ¶
This section is empty.
Functions ¶
func RegisterIndexes ¶ added in v0.10.0
func RegisterIndexes(ctx context.Context, idx client.FieldIndexer) error
RegisterIndexes installs the child-run index on the manager's cache. Call before the manager starts; the fake-client tests install the same extractor via WithIndex.
func RunFindingIndexer ¶ added in v0.10.0
RunFindingIndexer extracts the owning finding's name from a child run.
Types ¶
type ActionRequest ¶ added in v0.5.2
ActionRequest is a recorded human retry/expedite request.
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 BackfillDecisionWire ¶ added in v0.16.0
type BackfillDecisionWire struct {
Verdict string `json:"verdict"`
By string `json:"by"`
At string `json:"at"`
Reason string `json:"reason,omitempty"`
}
BackfillDecisionWire is an operator's verdict.
type BackfillRequestWire ¶ added in v0.16.0
type BackfillRequestWire struct {
Name string `json:"name"`
Integration string `json:"integration"`
RequestedBy string `json:"requestedBy"`
RequestedAt string `json:"requestedAt,omitempty"`
Repositories []string `json:"repositories,omitempty"`
// Via is backfill, maintained or requested.
Via string `json:"via"`
GitHubLogin string `json:"githubLogin,omitempty"`
Phase string `json:"phase,omitempty"`
Attempts int32 `json:"attempts,omitempty"`
LastRunAt string `json:"lastRunAt,omitempty"`
CompletedAt string `json:"completedAt,omitempty"`
Listed int32 `json:"listed,omitempty"`
Ingested int32 `json:"ingested,omitempty"`
Truncated bool `json:"truncated,omitempty"`
Error string `json:"error,omitempty"`
Decision *BackfillDecisionWire `json:"decision,omitempty"`
}
BackfillRequestWire is one BackfillRequest as the page renders it. It mirrors ui/src/types.ts.
type BackfillRequestsPayload ¶ added in v0.16.0
type BackfillRequestsPayload struct {
GeneratedAt string `json:"generatedAt"`
Requests []BackfillRequestWire `json:"requests"`
// CanDecide reports the backfill grant: the caller may approve or deny
// requests awaiting a decision.
CanDecide bool `json:"canDecide"`
}
BackfillRequestsPayload is the payload behind GET /api/backfill-requests.
type BackfillStatus ¶ added in v0.10.0
type BackfillStatus struct {
// Request names the BackfillRequest; Phase is its phase.
Request string `json:"request,omitempty"`
Phase string `json:"phase,omitempty"`
LastRunAt string `json:"lastRunAt,omitempty"`
Listed int32 `json:"listed,omitempty"`
Ingested int32 `json:"ingested,omitempty"`
Truncated bool `json:"truncated,omitempty"`
Error string `json:"error,omitempty"`
// RequestedBy/RequestedAt describe the request; Pending marks one the
// controller has not attempted yet. A failed attempt clears it so the
// trigger re-enables for a corrected request.
RequestedBy string `json:"requestedBy,omitempty"`
RequestedAt string `json:"requestedAt,omitempty"`
Pending bool `json:"pending,omitempty"`
}
BackfillStatus is the Integration's latest BackfillRequest, as the trigger button renders it.
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 ConfigDataset ¶ added in v0.10.0
type ConfigDataset struct {
GeneratedAt string `json:"generatedAt"`
Namespace string `json:"namespace,omitempty"`
Forges []ForgeConfig `json:"forges"`
Integrations []IntegrationConfig `json:"integrations"`
Enhancers []EnhancerConfig `json:"enhancers"`
}
ConfigDataset is the payload behind GET /api/config: the configured Forges, Integrations and enhancers the configuration view renders. It mirrors ui/src/types.ts. The route requires an identity holding native get on integrations.
type Dataset ¶
type Dataset struct {
GeneratedAt string `json:"generatedAt"`
Namespace string `json:"namespace,omitempty"`
Version string `json:"version,omitempty"`
User *User `json:"user,omitempty"`
// Rollups is the metrics summary: the total, every model and harness
// shard, and the top repositories by findings. Repository shards grow
// with the estate, so the rest page through GET /api/rollups/repositories.
Rollups []Rollup `json:"rollups,omitempty"`
// RepositoryCount is how many repository shards exist in all.
RepositoryCount int `json:"repositoryCount,omitempty"`
}
Dataset is the payload behind GET /api/rollups: the metrics summary, plus the namespace, version and user the top bar renders. The findings list is FindingsPage (GET /api/findings). It mirrors ui/src/types.ts.
type EnhancerConfig ¶ added in v0.10.0
type EnhancerConfig struct {
// ID is the enhancer's attribution id, as it appears on enrichments.
ID string `json:"id"`
// Integration names the Integration carrying the enhancer's config.
Integration string `json:"integration,omitempty"`
Enabled bool `json:"enabled"`
// Ambiguous marks a singleton capability enabled by more than one
// Integration. The enhancer chain refuses that configuration, so the
// view surfaces it rather than picking one.
Ambiguous bool `json:"ambiguous,omitempty"`
}
EnhancerConfig is one context-enhancer instance derived from the Integrations. The static-context enhancer is absent because it is a context-controller command-line flag, invisible from the cluster configuration this view projects.
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 full flattened metadata+spec+status projection of one Finding, the payload behind GET /api/findings/{name}. It is the summary's superset (same JSON keys for the shared fields; the lockstep tests pin both), plus the unbounded detail the list drops.
type FindingFacets ¶ added in v0.15.0
type FindingFacets struct {
Total int `json:"total"`
Open int `json:"open"`
Running int `json:"running"`
Suspended int `json:"suspended"`
// Phases, Severities and Verdicts count findings by value; a finding
// without one (no phase yet, no verdict yet) counts in none.
Phases map[string]int `json:"phases,omitempty"`
Severities map[string]int `json:"severities,omitempty"`
Verdicts map[string]int `json:"verdicts,omitempty"`
// Repositories are the ones with most findings, heaviest first.
Repositories []RepositoryCount `json:"repositories,omitempty"`
// RepositoryCount is how many distinct repositories have findings.
RepositoryCount int `json:"repositoryCount"`
}
FindingFacets counts every finding in the namespace, whatever the filters: what the phase rail and the filter's suggestions show.
type FindingSuggestions ¶ added in v0.15.0
type FindingSuggestions struct {
// Matched is how many findings the filters match with the term as the
// text search: what picking "Search for …" would list.
Matched int `json:"matched"`
// Repositories are the best matches for the term by name, ranked as
// ui/src/typeahead.ts ranks them; the heaviest when the term is empty.
Repositories []RepositoryCount `json:"repositories"`
// RepositoryTotal is how many repositories match the term in all.
RepositoryTotal int `json:"repositoryTotal"`
// Prefix and Contains size the "repositories starting with" and
// "repositories containing" filters for the term (filters aside).
Prefix RepositoryMatch `json:"prefix"`
Contains RepositoryMatch `json:"contains"`
}
FindingSuggestions is the payload behind GET /api/findings/suggest: the filter's type-ahead for one typed term.
type FindingSummary ¶ added in v0.10.0
type FindingSummary 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 the row's identity when there is no
// repository to name.
CloudResource *CloudResource `json:"cloudResource,omitempty"`
Advisories []string `json:"advisories"`
RuleID string `json:"ruleID,omitempty"`
Title string `json:"title,omitempty"`
Severity string `json:"severity,omitempty"`
Suspend bool `json:"suspend,omitempty"`
Phase string `json:"phase,omitempty"`
FirstObservedAt string `json:"firstObservedAt,omitempty"`
AccumulateUntil string `json:"accumulateUntil,omitempty"`
Owners []string `json:"owners,omitempty"`
Priority string `json:"priority,omitempty"`
Investigation *InvestigationSummary `json:"investigation,omitempty"`
Remediation *RemediationSummary `json:"remediation,omitempty"`
PullRequest *PullRequest `json:"pullRequest,omitempty"`
Attempts *Attempts `json:"attempts,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"`
}
FindingSummary is the trimmed per-finding projection the list payload carries: what the findings table, filters, and stat tiles render, and nothing whose size is unbounded (description, alert snippets, enrichment markdown, run reports). The payload behind GET /api/findings scales with page size × row size, so the row stays bounded; everything else moves to the per-finding detail route.
type FindingsPage ¶ added in v0.15.0
type FindingsPage struct {
GeneratedAt string `json:"generatedAt"`
Namespace string `json:"namespace,omitempty"`
Version string `json:"version,omitempty"`
User *User `json:"user,omitempty"`
// Findings is the requested page, most severe first.
Findings []FindingSummary `json:"findings"`
// Matched is how many findings match the filters, across every page.
Matched int `json:"matched"`
// NextCursor continues the list after this page; absent on the last.
NextCursor string `json:"nextCursor,omitempty"`
// Facets summarise every finding, filters aside. First page only.
Facets *FindingFacets `json:"facets,omitempty"`
}
FindingsPage is the payload behind GET /api/findings. It mirrors ui/src/types.ts.
type ForgeConfig ¶ added in v0.10.0
type ForgeConfig struct {
Name string `json:"name"`
Provider string `json:"provider"`
BaseURL string `json:"baseURL,omitempty"`
Orgs []string `json:"orgs,omitempty"`
Repositories []string `json:"repositories,omitempty"`
SecretRef string `json:"secretRef,omitempty"`
Interval string `json:"interval,omitempty"`
Suspend bool `json:"suspend,omitempty"`
// Ready is the Ready condition's status (True/False/Unknown); empty
// when the controller has not reported yet.
Ready string `json:"ready,omitempty"`
// ReadyMessage carries the condition message when not ready.
ReadyMessage string `json:"readyMessage,omitempty"`
}
ForgeConfig is one Forge's configuration surface.
type GitHubLink ¶ added in v0.16.0
type GitHubLink struct {
Integration string `json:"integration"`
Host string `json:"host"`
Login string `json:"login,omitempty"`
Connected bool `json:"connected"`
}
GitHubLink is one connectable Integration as the user menu and the repositories page see it. It mirrors ui/src/types.ts.
type GitHubRepositoriesPayload ¶ added in v0.16.0
type GitHubRepositoriesPayload struct {
Integration string `json:"integration"`
Login string `json:"login"`
Repositories []ghuser.Repository `json:"repositories"`
Truncated bool `json:"truncated,omitempty"`
}
GitHubRepositoriesPayload is the payload behind GET /api/github/repositories.
type Granter ¶
Granter resolves what an identity may do; internal/web/authz provides the SubjectAccessReview implementation and the mode-none bypass.
type IntegrationConfig ¶ added in v0.10.0
type IntegrationConfig struct {
Name string `json:"name"`
Provider string `json:"provider"`
WebhookPath string `json:"webhookPath,omitempty"`
SecretRef string `json:"secretRef,omitempty"`
Interval string `json:"interval,omitempty"`
Suspend bool `json:"suspend,omitempty"`
Ready string `json:"ready,omitempty"`
ReadyMessage string `json:"readyMessage,omitempty"`
Capabilities []string `json:"capabilities,omitempty"`
// Redelivery reports the last failed-delivery sweep.
Redelivery *RedeliveryStatus `json:"redelivery,omitempty"`
// Backfill reports the last manual backfill and any pending request.
Backfill *BackfillStatus `json:"backfill,omitempty"`
// BackfillSupported reports whether the backfill trigger can do
// anything here (github provider with code scanning enabled).
BackfillSupported bool `json:"backfillSupported,omitempty"`
}
IntegrationConfig is one Integration's configuration surface, including the backfill trigger's state.
type Investigation ¶
type Investigation struct {
InvestigationSummary
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"`
// ReportArchived reports that the full, untruncated report is in the run
// archive (the archive route's "report" object).
ReportArchived bool `json:"reportArchived,omitempty"`
}
Investigation is the summary plus the report markdown and run accounting lifted from the Investigation child. Detail route only.
type InvestigationSummary ¶ added in v0.10.0
type InvestigationSummary 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"`
}
InvestigationSummary mirrors the Finding's own investigation status: the bounded verdict fields the list rows render (recommendation, confidence).
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 PresignedURL ¶ added in v0.14.0
PresignedURL is the archive route's response: a URL the browser GETs directly from the bucket, and when it stops working.
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 RedeliveryStatus ¶ added in v0.10.0
type RedeliveryStatus struct {
LastSweepAt string `json:"lastSweepAt,omitempty"`
Scanned int32 `json:"scanned,omitempty"`
Redelivered int32 `json:"redelivered,omitempty"`
Truncated bool `json:"truncated,omitempty"`
Error string `json:"error,omitempty"`
}
RedeliveryStatus mirrors status.redelivery.
type Related ¶
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 {
RemediationSummary
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"`
// ReportArchived reports that the full, untruncated report is in the run
// archive (the archive route's "report" object).
ReportArchived bool `json:"reportArchived,omitempty"`
// PatchAvailable reports that the change is in the run archive as a
// `git am`-able patch (the archive route's "patch" object).
PatchAvailable bool `json:"patchAvailable,omitempty"`
}
Remediation is the summary plus the report markdown and run accounting lifted from the Remediation child. Detail route only.
type RemediationSummary ¶ added in v0.10.0
type RemediationSummary 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"`
}
RemediationSummary mirrors the Finding's own remediation status.
type RepositoriesPayload ¶ added in v0.15.0
type RepositoriesPayload struct {
GeneratedAt string `json:"generatedAt"`
Repositories []RepositorySummary `json:"repositories"`
// CanBackfill reports whether the caller holds the backfill grant: the
// page shows the button, or the request flow.
CanBackfill bool `json:"canBackfill"`
// CanBackfillMaintained reports the backfill-maintained grant: with a
// linked GitHub identity, the button works on repositories the caller
// maintains.
CanBackfillMaintained bool `json:"canBackfillMaintained,omitempty"`
// CanRequestBackfill reports that the caller may file a backfill request
// for an operator to decide (anyone who can view findings).
CanRequestBackfill bool `json:"canRequestBackfill"`
// CooldownSeconds is how long after a repository's backfill ran that
// another is refused.
CooldownSeconds int64 `json:"cooldownSeconds"`
// GitHub lists the Integrations the caller may link a GitHub account
// through; absent when linking is off.
GitHub []GitHubLink `json:"github,omitempty"`
// AccessCheck reports whether the integration-controller's access check
// is configured.
AccessCheck bool `json:"accessCheck"`
}
RepositoriesPayload is the payload behind GET /api/repositories. It mirrors ui/src/types.ts.
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 RepositoryAccess ¶ added in v0.15.0
type RepositoryAccess struct {
Name string `json:"name"`
// Skipped is "known" for a repository patchy has seen (findings or a
// rollup), which is never probed.
Skipped string `json:"skipped,omitempty"`
Integrations []repoaccess.IntegrationAccess `json:"integrations,omitempty"`
Forge *repoaccess.ForgeAccess `json:"forge,omitempty"`
// BackfillIntegration is the Integration a backfill would be stamped
// on; empty when none can read the alerts.
BackfillIntegration string `json:"backfillIntegration,omitempty"`
}
RepositoryAccess is one repository's access verdict.
type RepositoryAccessPayload ¶ added in v0.15.0
type RepositoryAccessPayload struct {
// Available is false when no access check is configured.
Available bool `json:"available"`
// Error reports a failed check (the integration-controller unreachable,
// say); the rows then show it rather than a verdict.
Error string `json:"error,omitempty"`
Repositories []RepositoryAccess `json:"repositories"`
}
RepositoryAccessPayload is the payload behind GET /api/repositories/access.
type RepositoryBackfill ¶ added in v0.15.0
type RepositoryBackfill struct {
// Request names the BackfillRequest.
Request string `json:"request,omitempty"`
Integration string `json:"integration"`
RequestedBy string `json:"requestedBy,omitempty"`
RequestedAt string `json:"requestedAt,omitempty"`
// Phase is the request's phase (AwaitingApproval, Pending, Complete,
// Failed, Denied); Via is how it was authorized.
Phase string `json:"phase,omitempty"`
Via string `json:"via,omitempty"`
// Pending marks an open request: not walked yet, or waiting for an
// operator.
Pending bool `json:"pending,omitempty"`
// DecisionReason is an operator's note on a decided request.
DecisionReason string `json:"decisionReason,omitempty"`
// The outcome of the request's last run; the counts cover the whole
// request, not this repository alone.
LastRunAt string `json:"lastRunAt,omitempty"`
Listed int32 `json:"listed,omitempty"`
Ingested int32 `json:"ingested,omitempty"`
Error string `json:"error,omitempty"`
}
RepositoryBackfill is a backfill request that covers the repository: an exact entry or an "owner/" prefix naming it, or a pending request with no filter at all.
type RepositoryBackfillResult ¶ added in v0.15.0
type RepositoryBackfillResult struct {
Integration string `json:"integration"`
// Request names the BackfillRequest created or covering the repository.
Request string `json:"request,omitempty"`
// Outcome is "requested" (a new request that runs at once),
// "awaiting-approval" (a new request an operator decides), or "covered"
// (an open request already includes it).
Outcome string `json:"outcome"`
}
RepositoryBackfillResult answers a one-repository backfill.
type RepositoryCount ¶ added in v0.15.0
RepositoryCount is one repository and how many findings name it.
type RepositoryMatch ¶ added in v0.15.0
type RepositoryMatch struct {
Repositories int `json:"repositories"`
Findings int `json:"findings"`
}
RepositoryMatch is how many repositories a repository-name term matches, and how many findings name them.
type RepositoryPage ¶ added in v0.14.0
type RepositoryPage struct {
// Total is how many repositories matched (all of them without q/key).
Total int `json:"total"`
// Of is how many repository shards exist at all.
Of int `json:"of"`
Offset int `json:"offset"`
// Repositories is the requested page, in the requested order.
Repositories []Rollup `json:"repositories"`
// Aggregate sums every match (not just the page) when aggregate=1.
Aggregate *Rollup `json:"aggregate,omitempty"`
// Rank is the 1-based position by findings closed, for a key= lookup.
Rank int `json:"rank,omitempty"`
}
RepositoryPage is the payload behind GET /api/rollups/repositories. It mirrors ui/src/types.ts.
type RepositoryRollup ¶ added in v0.15.0
type RepositoryRollup struct {
Findings int64 `json:"findings"`
LastProcessed string `json:"lastProcessed,omitempty"`
}
RepositoryRollup is the slice of a repository shard the page shows.
type RepositorySummary ¶ added in v0.15.0
type RepositorySummary struct {
Name string `json:"name"`
// Findings counts the repository's current findings; Phases splits them
// by phase (a finding with no phase yet counts in Findings only).
Findings int `json:"findings"`
Phases map[string]int `json:"phases,omitempty"`
// Rollup is the repository's all-time shard, when one exists.
Rollup *RepositoryRollup `json:"rollup,omitempty"`
// Backfill is the latest backfill request naming the repository.
Backfill *RepositoryBackfill `json:"backfill,omitempty"`
// BackfillAvailableAt is when the cooldown lets the repository be
// backfilled again; absent when it may be now.
BackfillAvailableAt string `json:"backfillAvailableAt,omitempty"`
}
RepositorySummary is one tracked repository's state.
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 ¶
RollupScope identifies one rollup dimension value.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the status-server backend: the findings projection, the metrics summary and repository rollup query, the actions, the SSE change signal, and the embedded SPA. Every data route needs an authorised identity.
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 ¶
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) LookupConnectable ¶ added in v0.16.0
LookupConnectable resolves one connectable Integration by name; the linker's Lookup.
func (*Server) StartWatch ¶
StartWatch starts the findings mirror (findingstore.go), registers change handlers on the Finding/FindingRollup and Integration/Forge informers, and publishes debounced findings-changed / config-changed notifications to the SSE broker. It blocks until ctx is cancelled, so it fits a manager runnable: it runs after the cache has synced and stops with the manager.
func (*Server) WithArchive ¶ added in v0.14.0
WithArchive lets the server presign archived run objects. Without it the archive route answers 404, and archived transcripts cannot be played back.
func (*Server) WithBackfillCooldown ¶ added in v0.16.0
WithBackfillCooldown sets the one-repository backfill cooldown; <= 0 keeps the default.
func (*Server) WithGitHub ¶ added in v0.16.0
WithGitHub wires the GitHub link: the integration-controller's user endpoints and the linker over the link cookies. Either nil leaves the feature off.
func (*Server) WithRepositoryAccess ¶ added in v0.15.0
WithRepositoryAccess wires the integration-controller's repository-access endpoint. Without it the repositories page still shows counts, and says the access check is unavailable.
func (*Server) WithTranscripts ¶ added in v0.8.2
WithTranscripts wires the uncached reader for persisted transcripts and the tailer for live ones. Without it the server still serves everything else; transcripts 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"`
// Archived reports that the conversation is in the run archive: the
// transcript stream answers `archived`, and the client plays the turns
// back from the archive route's "transcript" object.
Archived bool `json:"archived,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"`
// ID pairs a tool_use turn with its tool_result.
ID string `json:"id,omitempty"`
// Path is the file a tool call targets.
Path string `json:"path,omitempty"`
// Syntax is a render hint for Text: "diff", "shell", or empty (infer
// from Path).
Syntax string `json:"syntax,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 demo-tooling verbs (replay, reset) the
// user menu renders. Absent means none.
AdminActions []string `json:"adminActions,omitempty"`
// ConfigView reports native get on integrations: whether the
// configuration view is reachable for this user.
ConfigView bool `json:"configView,omitempty"`
// IntegrationActions are the granted integration-scoped verbs
// (backfill, replay, reset) the configuration view's triggers check.
IntegrationActions []string `json:"integrationActions,omitempty"`
// MaintainedActions are the granted scoped maintainer verbs
// (backfill-maintained, approve-maintained, expedite-maintained). The
// user menu hints "Connect GitHub" when these are held with no link.
MaintainedActions []string `json:"maintainedActions,omitempty"`
// GitHub lists the Integrations the user may link a GitHub account
// through, and whether they have. Absent when linking is off.
GitHub []GitHubLink `json:"github,omitempty"`
}
User is the signed-in identity the top bar renders.
Source Files
¶
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 in the status server's namespace.
|
Package authz resolves what an identity may do in the status server's namespace. |
|
Package ghlink is the status page's "Connect GitHub" link: an optional GitHub identity a signed-in user attaches, per github Integration, through that Integration's GitHub App user-to-server OAuth flow (PKCE).
|
Package ghlink is the status page's "Connect GitHub" link: an optional GitHub identity a signed-in user attaches, per github Integration, through that Integration's GitHub App user-to-server OAuth flow (PKCE). |