Documentation
¶
Overview ¶
Package report computes initiative reports from store data. All computation is SQL-portable (no Dolt system tables).
Package report computes initiative reports from store data. Token reports map token spend to the planning graph (TRD §16).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommitSummary ¶
type CommitSummary struct {
Total int `json:"total"`
ByType map[string]int `json:"by_type"`
ByRepo map[string]int `json:"by_repo"`
UnattributedInWindow int `json:"unattributed_in_window"`
}
CommitSummary aggregates evidence of type "commit".
type Duration ¶
type Duration struct {
Created *time.Time `json:"created,omitempty"`
Executing *time.Time `json:"executing,omitempty"`
DeliveryComplete *time.Time `json:"delivery_complete,omitempty"`
DaysExecuting int `json:"days_executing"`
}
Duration tracks initiative lifecycle timing.
type InitiativeTokens ¶
type InitiativeTokens struct {
InitiativeID string `json:"initiative_id"`
Title string `json:"title"`
Totals TokenTotals `json:"totals"`
RMIs []RMITokens `json:"rmis,omitempty"`
}
InitiativeTokens is spend for one initiative.
type ModelTokens ¶
type ModelTokens struct {
Model string `json:"model"`
Totals TokenTotals `json:"totals"`
}
ModelTokens is spend for one model.
type PhaseReport ¶
type PhaseReport struct {
PhaseID string `json:"phase_id"`
Title string `json:"title"`
Theme string `json:"theme,omitempty"`
Status string `json:"status"`
RMIsTotal int `json:"rmis_total"`
RMIsComplete int `json:"rmis_completed"`
}
PhaseReport is one phase's summary.
type RMISummary ¶
type RMISummary struct {
Total int `json:"total"`
Completed int `json:"completed"`
RequiredCompleted int `json:"required_completed"`
InProgress int `json:"in_progress"`
Ready int `json:"ready"`
Blocked int `json:"blocked"`
}
RMISummary counts RMIs by status.
type RMITokens ¶
type RMITokens struct {
RMIID string `json:"rmi_id"`
Title string `json:"title"`
PhaseID string `json:"phase_id,omitempty"`
Totals TokenTotals `json:"totals"`
}
RMITokens is spend for one RMI.
type RepoSummary ¶
RepoSummary counts participating repositories.
type Report ¶
type Report struct {
InitiativeID string `json:"initiative_id"`
Title string `json:"title"`
Status string `json:"status"`
Duration Duration `json:"duration"`
Phases []PhaseReport `json:"phases"`
Repos RepoSummary `json:"repos"`
RMIs RMISummary `json:"rmis"`
Commits CommitSummary `json:"commits"`
Releases []Release `json:"releases"`
}
Report is the full initiative report (TRD §10).
type TokenPeriod ¶
type TokenPeriod struct {
Start time.Time `json:"start"`
End time.Time `json:"end"`
Label string `json:"label,omitempty"` // e.g., "2026-Q3"
}
TokenPeriod defines the report time range.
func ParseQuarter ¶
func ParseQuarter(q string) (TokenPeriod, error)
ParseQuarter parses a quarter string (e.g., "2026-Q3") into a period.
type TokenReport ¶
type TokenReport struct {
// Mode is "initiative" or "period"
Mode string `json:"mode"`
// Initiative is set when Mode == "initiative"
InitiativeID string `json:"initiative_id,omitempty"`
InitiativeTitle string `json:"initiative_title,omitempty"`
// Period defines the time range
Period TokenPeriod `json:"period"`
// Totals across all attributed events
Totals TokenTotals `json:"totals"`
// ByInitiative groups spend by initiative (period mode)
ByInitiative []InitiativeTokens `json:"by_initiative,omitempty"`
// ByRMI groups spend by RMI (initiative mode)
ByRMI []RMITokens `json:"by_rmi,omitempty"`
// ByModel groups spend by model
ByModel []ModelTokens `json:"by_model"`
// Residual is spend attributed to repository but not RMI
Residual TokenTotals `json:"residual"`
// Unmanaged is spend from workspaces not in the registry
Unmanaged TokenTotals `json:"unmanaged"`
// Coverage is managed spend / total spend
Coverage float64 `json:"coverage"`
// SessionCount is the number of unique sessions
SessionCount int `json:"session_count"`
// EventCount is the number of token events processed
EventCount int `json:"event_count"`
}
TokenReport is the token attribution report for an initiative or period.
func GenerateInitiativeTokenReport ¶
func GenerateInitiativeTokenReport( ctx context.Context, s store.Store, source tokens.Source, initiativeID string, ) (*TokenReport, error)
GenerateInitiativeTokenReport computes token spend for a single initiative.
func GeneratePeriodTokenReport ¶
func GeneratePeriodTokenReport( ctx context.Context, s store.Store, source tokens.Source, period TokenPeriod, ) (*TokenReport, error)
GeneratePeriodTokenReport computes token spend for a time period.
func (*TokenReport) MarkdownTokenReport ¶
func (r *TokenReport) MarkdownTokenReport() string
MarkdownTokenReport renders the token report as Markdown.
type TokenTotals ¶
type TokenTotals struct {
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
CacheReadTokens int64 `json:"cache_read_tokens"`
CacheCreationTokens int64 `json:"cache_creation_tokens"`
TotalTokens int64 `json:"total_tokens"`
CostUSD float64 `json:"cost_usd"`
}
TokenTotals aggregates token counts and cost.