Documentation
¶
Index ¶
- func ComponentsFromUsage(usage any) []string
- func Enabled() bool
- type Capture
- func (cap *Capture) AttributeComponentErrors()
- func (cap *Capture) Complete(success bool, validationJSON string)
- func (cap *Capture) Event() *GenerationEvent
- func (cap *Capture) RecordComponentsUsed(components []string)
- func (cap *Capture) RecordError(err GenerationError)
- func (cap *Capture) RecordFileGenerated(path string)
- func (cap *Capture) SetKit(kit string)
- type Collector
- type ComponentError
- type GenerationError
- type GenerationEvent
- type ListOptions
- type SQLiteStore
- func (s *SQLiteStore) Close() error
- func (s *SQLiteStore) CountBySuccess(ctx context.Context, since time.Time) (total, successes int, err error)
- func (s *SQLiteStore) DeleteBefore(ctx context.Context, before time.Time) (int64, error)
- func (s *SQLiteStore) Get(ctx context.Context, id string) (*GenerationEvent, error)
- func (s *SQLiteStore) List(ctx context.Context, opts ListOptions) ([]*GenerationEvent, error)
- func (s *SQLiteStore) Save(ctx context.Context, event *GenerationEvent) error
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComponentsFromUsage ¶
ComponentsFromUsage converts a ComponentUsage struct (or any struct with bool fields prefixed "Use") into a string slice of component names. For example, UseModal=true becomes "modal".
Types ¶
type Capture ¶
type Capture struct {
// contains filtered or unexported fields
}
Capture accumulates data for a single generation event.
func NoopCapture ¶
func NoopCapture() *Capture
NoopCapture returns a capture that silently discards all data.
func (*Capture) AttributeComponentErrors ¶
func (cap *Capture) AttributeComponentErrors()
AttributeComponentErrors runs attribution logic on accumulated errors. Call this before Complete() to populate ComponentErrors. Safe to call multiple times; last call wins (overwrites previous results).
func (*Capture) Complete ¶
Complete finalises the capture, computes duration, and stores the event. It is always safe to call (noop if disabled).
func (*Capture) Event ¶
func (cap *Capture) Event() *GenerationEvent
Event returns the underlying event (for testing). Returns nil on noop captures.
func (*Capture) RecordComponentsUsed ¶
RecordComponentsUsed sets the components involved in this generation.
func (*Capture) RecordError ¶
func (cap *Capture) RecordError(err GenerationError)
RecordError adds an error to the capture.
func (*Capture) RecordFileGenerated ¶
RecordFileGenerated adds a generated file path. TODO: not yet wired into gen.go/auth.go integration points.
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector tracks generation events. Safe to use even when disabled (noop).
func NewCollector ¶
func NewCollector() *Collector
NewCollector opens the telemetry store. Returns a disabled (but valid) collector if telemetry is off or the store cannot be opened. The returned pointer is always non-nil — telemetry must not break generation.
func NewCollectorWithStore ¶
NewCollectorWithStore creates a collector with a custom store (for testing).
func (*Collector) RunRetention ¶
RunRetention deletes events older than retentionDays.
func (*Collector) StartCapture ¶
StartCapture begins tracking a generation command. The returned Capture accumulates data until Complete() is called. If the collector is disabled the Capture is a silent noop.
type ComponentError ¶
type ComponentError struct {
Component string `json:"component"`
Phase string `json:"phase"`
Message string `json:"message"`
File string `json:"file,omitempty"`
}
ComponentError links an error to a specific component.
func AttributeErrors ¶
func AttributeErrors(errors []GenerationError, componentsUsed []string) []ComponentError
AttributeErrors scans GenerationErrors and matches them to components by checking file paths (e.g. "components/modal/modal.go") and error messages (e.g. "modal.New: invalid size"). Only components listed in componentsUsed are considered.
type GenerationError ¶
type GenerationError struct {
Phase string `json:"phase"` // "generation", "compilation", "runtime", "template"
File string `json:"file,omitempty"` // file where error occurred
Line int `json:"line,omitempty"` // line number
Message string `json:"message"` // error message
Context string `json:"context,omitempty"` // surrounding code or context
}
GenerationError records a single error captured during generation.
type GenerationEvent ¶
type GenerationEvent struct {
ID string `json:"id"`
Timestamp time.Time `json:"timestamp"`
Command string `json:"command"` // "gen resource", "gen view", "gen auth", "gen schema"
Inputs map[string]any `json:"inputs"` // command args as key-value
Kit string `json:"kit,omitempty"` // e.g. "multi", "single"
LvtVersion string `json:"lvt_version"` // version of lvt used
Success bool `json:"success"` // whether generation succeeded
ValidationJSON string `json:"validation,omitempty"` // JSON of validator.ValidationResult
Errors []GenerationError `json:"errors,omitempty"` // errors captured during generation
DurationMs int64 `json:"duration_ms"` // wall-clock duration
FilesGenerated []string `json:"files_generated,omitempty"` // paths of generated files
ComponentsUsed []string `json:"components_used,omitempty"` // component packages involved
ComponentErrors []ComponentError `json:"component_errors,omitempty"` // errors attributed to components
}
GenerationEvent records a single code generation invocation.
type ListOptions ¶
ListOptions controls filtering when listing events.
type SQLiteStore ¶
type SQLiteStore struct {
// contains filtered or unexported fields
}
SQLiteStore implements Store using SQLite via modernc.org/sqlite.
func OpenSQLite ¶
func OpenSQLite(dbPath string) (*SQLiteStore, error)
OpenSQLite opens (or creates) a telemetry database at the given path.
func (*SQLiteStore) Close ¶
func (s *SQLiteStore) Close() error
func (*SQLiteStore) CountBySuccess ¶
func (*SQLiteStore) DeleteBefore ¶
func (*SQLiteStore) Get ¶
func (s *SQLiteStore) Get(ctx context.Context, id string) (*GenerationEvent, error)
func (*SQLiteStore) List ¶
func (s *SQLiteStore) List(ctx context.Context, opts ListOptions) ([]*GenerationEvent, error)
func (*SQLiteStore) Save ¶
func (s *SQLiteStore) Save(ctx context.Context, event *GenerationEvent) error
type Store ¶
type Store interface {
Save(ctx context.Context, event *GenerationEvent) error
Get(ctx context.Context, id string) (*GenerationEvent, error)
List(ctx context.Context, opts ListOptions) ([]*GenerationEvent, error)
CountBySuccess(ctx context.Context, since time.Time) (total, successes int, err error)
DeleteBefore(ctx context.Context, before time.Time) (int64, error)
Close() error
}
Store persists and retrieves generation events.