Documentation
¶
Overview ¶
Package activity is the desktop app's user-facing audit log. Any backend subsystem — a source refresh, a session launch, an action run, a config reload — records a well-formed Event through a Recorder, and the frontend records its own via the ActivityService. Events persist in the pipeline SQLite store and surface, newest first, in the Activity view.
The ergonomic constructors (RefreshFailed, SessionCreated, AutoAction, …) are the "mixin" surface: an emit site names what happened and passes the few facts it has, and the constructor assembles the category, severity, and human copy. New event shapes are added as new constructors, not new call-site formatting.
Index ¶
- Constants
- Variables
- func CategoryNames() []string
- func SeverityNames() []string
- type Category
- type Event
- func ActionFailed(label, reason string) Event
- func ActionRun(label, detail string) Event
- func AutoAction(label, rule, target string) Event
- func ConfigReloaded(file string, actions int) Event
- func FlowRuntimeFailed(flowID string, err error) Event
- func RefreshFailed(source, reason string) Event
- func ScheduleRun(name, workspace, status, detail string) Event
- func SessionCreateFailed(name, repo, step, reason string, retry map[string]string) Event
- func SessionCreated(name, agent, repo string) Event
- type ItemLink
- type Link
- type RecordInput
- type Recorder
- type Severity
Constants ¶
const ( MetadataLinkURL = "link.url" MetadataLinkItemProfileID = "link.item.profileId" MetadataLinkItemSourceKind = "link.item.sourceKind" MetadataLinkItemSourceScope = "link.item.sourceScope" MetadataLinkItemExternalID = "link.item.externalId" )
Link metadata uses link.url for an external destination and the link.item.* group for one internal inbox reference.
Variables ¶
var ErrInvalidCategory = fmt.Errorf("not a valid Category, try [%s]", strings.Join(_CategoryNames, ", "))
var ErrInvalidSeverity = fmt.Errorf("not a valid Severity, try [%s]", strings.Join(_SeverityNames, ", "))
Functions ¶
func CategoryNames ¶
func CategoryNames() []string
CategoryNames returns a list of possible string values of Category.
func SeverityNames ¶
func SeverityNames() []string
SeverityNames returns a list of possible string values of Severity.
Types ¶
type Category ¶
type Category string
Category is the semantic bucket of an event. It drives the Activity view's filter pills and, for non-error events, the row's icon and accent color.
ENUM(refresh, session, auto_action, action, config, system)
const ( // CategoryRefresh is a Category of type refresh. CategoryRefresh Category = "refresh" // CategorySession is a Category of type session. CategorySession Category = "session" // CategoryAutoAction is a Category of type auto_action. CategoryAutoAction Category = "auto_action" // CategoryAction is a Category of type action. CategoryAction Category = "action" // CategoryConfig is a Category of type config. CategoryConfig Category = "config" // CategorySystem is a Category of type system. CategorySystem Category = "system" )
func ParseCategory ¶
ParseCategory attempts to convert a string to a Category.
func (*Category) AppendText ¶
AppendText appends the textual representation of itself to the end of b (allocating a larger slice if necessary) and returns the updated slice.
Implementations must not retain b, nor mutate any bytes within b[:len(b)].
func (Category) IsValid ¶
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (Category) MarshalText ¶
MarshalText implements the text marshaller method.
func (*Category) UnmarshalText ¶
UnmarshalText implements the text unmarshaller method.
type Event ¶
type Event struct {
ID int64 `json:"id"`
CreatedAt int64 `json:"createdAt"`
Category Category `json:"category"`
Severity Severity `json:"severity"`
Title string `json:"title"`
Body string `json:"body,omitempty"`
Source string `json:"source,omitempty"`
// Metadata is opaque to storage. Keys under "link." are reserved for the
// Activity view's generic destinations; other keys carry event-specific
// data such as a retryable session draft.
Metadata map[string]string `json:"metadata,omitempty"`
}
Event is one activity-log entry. ID and CreatedAt are assigned by the store on append; constructors and callers leave them zero. CreatedAt is unix milliseconds (see the activity_event migration for why milliseconds).
func ActionFailed ¶
ActionFailed records an action (auto or manual) that failed, capturing the error reason.
func ActionRun ¶
ActionRun records a manually confirmed action that succeeded. detail is an optional command/summary line.
func AutoAction ¶
AutoAction records an automatic action applied without confirmation. rule is the action/rule id and target the item it acted on.
func ConfigReloaded ¶
ConfigReloaded records a config file reload, reporting the resulting action count.
func FlowRuntimeFailed ¶
FlowRuntimeFailed records a flow the engine could not put into service. The last known-good version of that flow keeps running, which is exactly why this has to be recorded: without it the failure is invisible and the app silently executes an older graph than the one on disk.
func RefreshFailed ¶
RefreshFailed records a source refresh that errored, capturing the reason (an error string or stderr excerpt).
func ScheduleRun ¶
status is schedule.Status's string form rather than the type: the audit log is a sink every subsystem writes to and takes no dependency on any of them, so an unrecognized status records as plain info instead of failing.
func SessionCreateFailed ¶
SessionCreateFailed records a session the app accepted and could not create. Unlike ActionFailed there is nothing to show afterwards, so retry carries the submitted form and makes the row the way back to it (ADR a-failed-session-creation-is-a-retryable-draft).
func SessionCreated ¶
SessionCreated records a hive session created by an action. agent and repo are optional and folded into the metadata line when present.
type ItemLink ¶
ItemLink is the stable source identity of an inbox item. All fields travel together because an external id can be repeated across profiles and sources.
type Link ¶
Link declares the destinations associated with an activity event. URL opens outside the app. Item identifies an inbox row to select inside the app.
type RecordInput ¶
type RecordInput struct {
Category string `json:"category"`
Severity string `json:"severity"`
Title string `json:"title"`
Body string `json:"body"`
Source string `json:"source"`
Metadata map[string]string `json:"metadata"`
}
RecordInput is the frontend-facing shape for recording an event over the Wails boundary. Category and severity are plain strings resolved (case -insensitively) by RecordInput.Event; empty values default to system/info.
type Severity ¶
type Severity string
Severity is the emphasis of an event, independent of its category: a refresh that failed is Category=refresh, Severity=error. It selects error/auto row styling and bridges to the toast system's matching severities.
ENUM(info, success, warning, error, auto)
const ( // SeverityInfo is a Severity of type info. SeverityInfo Severity = "info" // SeveritySuccess is a Severity of type success. SeveritySuccess Severity = "success" // SeverityWarning is a Severity of type warning. SeverityWarning Severity = "warning" // SeverityError is a Severity of type error. SeverityError Severity = "error" // SeverityAuto is a Severity of type auto. SeverityAuto Severity = "auto" )
func ParseSeverity ¶
ParseSeverity attempts to convert a string to a Severity.
func (*Severity) AppendText ¶
AppendText appends the textual representation of itself to the end of b (allocating a larger slice if necessary) and returns the updated slice.
Implementations must not retain b, nor mutate any bytes within b[:len(b)].
func (Severity) IsValid ¶
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (Severity) MarshalText ¶
MarshalText implements the text marshaller method.
func (*Severity) UnmarshalText ¶
UnmarshalText implements the text unmarshaller method.