Documentation
¶
Index ¶
- func DriftFingerprint(configPath string) (string, error)
- func RenderHTML(path string, report *Report) error
- func SaveSnapshot(dir, name string, report *Report) (string, error)
- type AgentBudget
- type AnchorRetentionReport
- type BudgetControllerReport
- type CheckpointPolicyReport
- type CompareReport
- type ContextComponent
- type CostlyPrompt
- type Detector
- type DetectorConfig
- type DetectorRule
- type Finding
- type GenerateOptions
- type IntentProfile
- type LayerSummary
- type QualityReport
- type QualitySignal
- type Report
- type Snapshot
- type Summary
- type TurnMetric
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DriftFingerprint ¶ added in v0.28.0
DriftFingerprint returns a stable fingerprint of the active config.
func RenderHTML ¶ added in v0.28.0
RenderHTML writes a lightweight dashboard HTML report.
Types ¶
type AgentBudget ¶ added in v0.28.0
type AgentBudget struct {
Agent string `json:"agent"`
Commands int64 `json:"commands"`
Original int64 `json:"original_tokens"`
Saved int64 `json:"saved_tokens"`
ReductionPct float64 `json:"reduction_pct"`
EstimatedUS float64 `json:"estimated_cost_usd"`
SavingsUS float64 `json:"estimated_savings_usd"`
}
AgentBudget allocates usage/savings budgets across agents.
type AnchorRetentionReport ¶ added in v0.28.0
type AnchorRetentionReport struct {
SignalsFound int64 `json:"signals_found"`
SignalDensityPct float64 `json:"signal_density_pct"`
EstimatedKeepRate float64 `json:"estimated_keep_rate_pct"`
Grade string `json:"grade"`
}
AnchorRetentionReport scores how well critical anchors are preserved.
type BudgetControllerReport ¶ added in v0.28.0
type BudgetControllerReport struct {
CurrentReductionPct float64 `json:"current_reduction_pct"`
QualityScore float64 `json:"quality_score"`
RecommendedMode string `json:"recommended_mode"`
Bands map[string]float64 `json:"bands"`
DecaySchedule []int `json:"decay_schedule"`
}
BudgetControllerReport provides adaptive budget recommendations (LLMLingua/LazyLLM style).
type CheckpointPolicyReport ¶ added in v0.28.0
type CheckpointPolicyReport struct {
RecommendedTriggers []string `json:"recommended_triggers"`
ObservedBands map[string]int64 `json:"observed_bands"`
Notes []string `json:"notes"`
}
CheckpointPolicyReport mirrors imported checkpoint-trigger strategy in TokMan form.
type CompareReport ¶ added in v0.28.0
type CompareReport struct {
BaseName string `json:"base_name"`
CandidateName string `json:"candidate_name"`
ComparedAt time.Time `json:"compared_at"`
DeltaSavedTokens int64 `json:"delta_saved_tokens"`
DeltaReductionPct float64 `json:"delta_reduction_pct"`
DeltaQualityScore float64 `json:"delta_quality_score"`
DeltaParseFailures int64 `json:"delta_parse_failures"`
DriftChanged bool `json:"drift_changed"`
Verdict string `json:"verdict"`
}
CompareReport shows the deltas between two snapshots.
func Compare ¶ added in v0.28.0
func Compare(base, candidate *Snapshot) CompareReport
Compare computes high-level deltas between snapshots.
type ContextComponent ¶ added in v0.28.0
type ContextComponent struct {
Kind string `json:"kind"`
CommandCount int64 `json:"command_count"`
OriginalTokens int64 `json:"original_tokens"`
SavedTokens int64 `json:"saved_tokens"`
AvgRelatedFiles float64 `json:"avg_related_files"`
BundledRatioPct float64 `json:"bundled_ratio_pct"`
OverheadRatioPct float64 `json:"overhead_ratio_pct"`
}
ContextComponent captures context metadata overhead by source kind.
type CostlyPrompt ¶ added in v0.28.0
type CostlyPrompt struct {
Command string `json:"command"`
Count int64 `json:"count"`
Original int64 `json:"original_tokens"`
Saved int64 `json:"saved_tokens"`
EstimatedUS float64 `json:"estimated_cost_usd"`
}
CostlyPrompt captures the highest-cost command prompts.
type Detector ¶ added in v0.28.0
type Detector interface {
ID() string
Run(tr *tracking.Tracker, window string, summary Summary) ([]Finding, error)
}
Detector evaluates audit data and returns findings.
func DefaultDetectors ¶ added in v0.28.0
func DefaultDetectors() []Detector
DefaultDetectors returns built-in waste detectors.
type DetectorConfig ¶ added in v0.28.0
type DetectorConfig struct {
Detectors map[string]DetectorRule
}
DetectorConfig controls detector activation and severity filtering.
func LoadDetectorConfig ¶ added in v0.28.0
func LoadDetectorConfig(configPath string) (DetectorConfig, error)
LoadDetectorConfig reads [audit.detectors] config from tokman config file.
func (DetectorConfig) AllowedSeverity ¶ added in v0.28.0
func (c DetectorConfig) AllowedSeverity(id, severity string) bool
AllowedSeverity checks per-detector minimum severity.
func (DetectorConfig) Enabled ¶ added in v0.28.0
func (c DetectorConfig) Enabled(id string) bool
Enabled returns whether detector is enabled.
type DetectorRule ¶ added in v0.28.0
DetectorRule config entry for one detector.
type Finding ¶ added in v0.28.0
type Finding struct {
ID string `json:"id"`
Severity string `json:"severity"`
Description string `json:"description"`
EstimatedWaste int64 `json:"estimated_waste_tokens"`
EstimatedWasteD float64 `json:"estimated_waste_usd"`
Recommendation string `json:"recommendation"`
}
Finding is a detected waste/risk pattern.
type GenerateOptions ¶ added in v0.28.0
type GenerateOptions struct {
ConfigPath string
}
GenerateOptions controls optional audit behavior.
type IntentProfile ¶ added in v0.28.0
type IntentProfile struct {
Intent string `json:"intent"`
Commands int64 `json:"commands"`
Original int64 `json:"original_tokens"`
Saved int64 `json:"saved_tokens"`
ReductionPct float64 `json:"reduction_pct"`
}
IntentProfile summarizes compression quality by inferred task intent.
type LayerSummary ¶ added in v0.28.0
type LayerSummary struct {
LayerName string `json:"layer_name"`
TotalSaved int64 `json:"total_saved"`
AvgSaved float64 `json:"avg_saved"`
CallCount int64 `json:"call_count"`
}
LayerSummary reports per-layer effectiveness in window.
type QualityReport ¶ added in v0.28.0
type QualityReport struct {
Score float64 `json:"score"`
Band string `json:"band"`
Signals []QualitySignal `json:"signals"`
}
QualityReport is an aggregate health score for token optimization quality.
type QualitySignal ¶ added in v0.28.0
type QualitySignal struct {
Name string `json:"name"`
Weight float64 `json:"weight"`
Score float64 `json:"score"`
Description string `json:"description"`
}
QualitySignal is a weighted quality indicator.
type Report ¶ added in v0.28.0
type Report struct {
GeneratedAt time.Time `json:"generated_at"`
Days int `json:"days"`
DriftFingerprint string `json:"drift_fingerprint"`
Summary Summary `json:"summary"`
TurnAnalytics []TurnMetric `json:"turn_analytics"`
CostlyPrompts []CostlyPrompt `json:"costly_prompts"`
IntentProfiles []IntentProfile `json:"intent_profiles"`
AgentBudgets []AgentBudget `json:"agent_budgets"`
BudgetController BudgetControllerReport `json:"budget_controller"`
AnchorRetention AnchorRetentionReport `json:"anchor_retention"`
WasteFindings []Finding `json:"waste_findings"`
ContextOverhead []ContextComponent `json:"context_overhead"`
Quality QualityReport `json:"quality"`
CheckpointPolicy CheckpointPolicyReport `json:"checkpoint_policy"`
TopLayers []LayerSummary `json:"top_layers"`
Recommendations []string `json:"recommendations"`
}
Report is TokMan's consolidated optimization audit view.
func GenerateWithOptions ¶ added in v0.28.0
func GenerateWithOptions(tracker *tracking.Tracker, days int, opts GenerateOptions) (*Report, error)
GenerateWithOptions builds the audit report with additional runtime options.
type Snapshot ¶ added in v0.28.0
type Snapshot struct {
Name string `json:"name"`
CreatedAt time.Time `json:"created_at"`
Fingerprint string `json:"fingerprint"`
Report Report `json:"report"`
}
Snapshot stores a named point-in-time audit for drift/validation comparisons.
func LoadSnapshot ¶ added in v0.28.0
LoadSnapshot loads a stored audit snapshot.
type Summary ¶ added in v0.28.0
type Summary struct {
CommandCount int64 `json:"command_count"`
Original int64 `json:"original_tokens"`
Filtered int64 `json:"filtered_tokens"`
Saved int64 `json:"saved_tokens"`
ReductionPct float64 `json:"reduction_pct"`
AvgExecMs float64 `json:"avg_exec_ms"`
ParseFailures int64 `json:"parse_failures"`
}
Summary contains top-line metrics for the selected window.
type TurnMetric ¶ added in v0.28.0
type TurnMetric struct {
ID int64 `json:"id"`
Command string `json:"command"`
Timestamp time.Time `json:"timestamp"`
Original int64 `json:"original_tokens"`
Saved int64 `json:"saved_tokens"`
Reduction float64 `json:"reduction_pct"`
EstimatedUS float64 `json:"estimated_cost_usd"`
}
TurnMetric is per-command turn-level analytics.