Documentation
¶
Overview ¶
Package coverage contains APIs for writing coverage profile data at runtime from long-running and/or server programs that do not terminate via os.Exit. Enhanced with LLM oracle integration and advanced fuzzing capabilities.
Index ¶
- func CleanupEnhancedCoverage()
- func ClearCounters() error
- func DemoEnhancedCoverage()
- func GetRuntimeStack() []string
- func InitializeEnhancedCoverage() error
- func LogOracleActivity(activity string, details map[string]interface{})
- func RegisterFuzzingHook(hook func(*CoverageSnapshot, *CoverageGuidance))
- func SetupFuzzingIntegration()
- func TrackFunctionEntry(pkg, fn string)
- func WriteCounters(w io.Writer) error
- func WriteCountersDir(dir string) error
- func WriteMeta(w io.Writer) error
- func WriteMetaDir(dir string) error
- type CachedResult
- type CoverageGuidance
- type CoverageSnapshot
- type CoverageTarget
- type DefaultLLMOracle
- func (o *DefaultLLMOracle) AnalyzeCoveragePattern(ctx context.Context, coverage *CoverageSnapshot) (*PatternAnalysis, error)
- func (o *DefaultLLMOracle) EvaluateTestQuality(ctx context.Context, coverage *CoverageSnapshot, testCase interface{}) (*TestQualityAssessment, error)
- func (o *DefaultLLMOracle) SuggestCoverageTargets(ctx context.Context, coverage *CoverageSnapshot) (*CoverageGuidance, error)
- type EnhancedCoverageCoordinator
- func (c *EnhancedCoverageCoordinator) EvaluateTestQuality(ctx context.Context, testCase interface{}) (*TestQualityAssessment, error)
- func (c *EnhancedCoverageCoordinator) GetCoverageGuidance(ctx context.Context) (*CoverageGuidance, error)
- func (c *EnhancedCoverageCoordinator) GetMetrics() map[string]interface{}
- func (c *EnhancedCoverageCoordinator) GetSnapshots() []*CoverageSnapshot
- func (c *EnhancedCoverageCoordinator) SetEventHandlers(onCoverageChange func(*CoverageSnapshot), ...)
- func (c *EnhancedCoverageCoordinator) SetLLMOracle(oracle LLMOracle)
- func (c *EnhancedCoverageCoordinator) Stop()
- func (c *EnhancedCoverageCoordinator) TakeSnapshot() *CoverageSnapshot
- type FunctionCoverage
- type LLMOracle
- type OracleConfig
- type PackageCoverage
- type PatternAnalysis
- type RateLimiter
- type TestQualityAssessment
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupEnhancedCoverage ¶
func CleanupEnhancedCoverage()
CleanupEnhancedCoverage properly shuts down the enhanced coverage system
func ClearCounters ¶
func ClearCounters() error
ClearCounters clears/resets all coverage counter variables in the currently running program. Enhanced with snapshot preservation.
func DemoEnhancedCoverage ¶
func DemoEnhancedCoverage()
Demo function to showcase enhanced coverage capabilities
func GetRuntimeStack ¶
func GetRuntimeStack() []string
GetRuntimeStack captures current runtime stack for coverage analysis
func InitializeEnhancedCoverage ¶
func InitializeEnhancedCoverage() error
InitializeEnhancedCoverage sets up the enhanced coverage system with LLM oracle
func LogOracleActivity ¶
LogOracleActivity logs oracle activities for debugging
func RegisterFuzzingHook ¶
func RegisterFuzzingHook(hook func(*CoverageSnapshot, *CoverageGuidance))
RegisterFuzzingHook registers a callback for fuzzing coordination
func SetupFuzzingIntegration ¶
func SetupFuzzingIntegration()
SetupFuzzingIntegration configures the enhanced coverage for fuzzing
func TrackFunctionEntry ¶
func TrackFunctionEntry(pkg, fn string)
TrackFunctionEntry records function entry for coverage analysis
func WriteCounters ¶
WriteCounters writes coverage counter-data content for the currently running program to the writer 'w'. Enhanced with real-time LLM analysis.
func WriteCountersDir ¶
WriteCountersDir writes a coverage counter-data file for the currently running program to the directory specified in 'dir'. Enhanced with LLM analysis and guidance.
func WriteMeta ¶
WriteMeta writes the meta-data content (the payload that would normally be emitted to a meta-data file) for the currently running program to the writer 'w'. Enhanced with LLM insights.
func WriteMetaDir ¶
WriteMetaDir writes a coverage meta-data file for the currently running program to the directory specified in 'dir'. Enhanced with LLM oracle insights and additional metadata.
Types ¶
type CachedResult ¶
CachedResult holds cached LLM responses
type CoverageGuidance ¶
type CoverageGuidance struct {
PriorityTargets []CoverageTarget `json:"priority_targets"`
Strategies []string `json:"strategies"`
Rationale string `json:"rationale"`
}
CoverageGuidance provides LLM-suggested fuzzing targets
type CoverageSnapshot ¶
type CoverageSnapshot struct {
Timestamp time.Time `json:"timestamp"`
TotalLines int `json:"total_lines"`
CoveredLines int `json:"covered_lines"`
CoverageRatio float64 `json:"coverage_ratio"`
PackageStats map[string]*PackageCoverage `json:"package_stats"`
FunctionStats map[string]*FunctionCoverage `json:"function_stats"`
HotPaths []string `json:"hot_paths"`
ColdPaths []string `json:"cold_paths"`
CallGraph map[string][]string `json:"call_graph"`
Metadata map[string]interface{} `json:"metadata"`
}
CoverageSnapshot represents a point-in-time coverage state
type CoverageTarget ¶
type CoverageTarget struct {
Package string `json:"package"`
Function string `json:"function"`
Line int `json:"line"`
Priority float64 `json:"priority"`
Reason string `json:"reason"`
Complexity float64 `json:"complexity"`
}
CoverageTarget represents a specific area to focus coverage efforts
type DefaultLLMOracle ¶
type DefaultLLMOracle struct {
// contains filtered or unexported fields
}
DefaultLLMOracle provides a default implementation of LLMOracle This can be extended to integrate with actual LLM services
func NewDefaultLLMOracle ¶
func NewDefaultLLMOracle(config *OracleConfig) *DefaultLLMOracle
NewDefaultLLMOracle creates a new default LLM oracle
func (*DefaultLLMOracle) AnalyzeCoveragePattern ¶
func (o *DefaultLLMOracle) AnalyzeCoveragePattern(ctx context.Context, coverage *CoverageSnapshot) (*PatternAnalysis, error)
AnalyzeCoveragePattern identifies patterns in coverage data
func (*DefaultLLMOracle) EvaluateTestQuality ¶
func (o *DefaultLLMOracle) EvaluateTestQuality(ctx context.Context, coverage *CoverageSnapshot, testCase interface{}) (*TestQualityAssessment, error)
EvaluateTestQuality assesses the quality of a test case
func (*DefaultLLMOracle) SuggestCoverageTargets ¶
func (o *DefaultLLMOracle) SuggestCoverageTargets(ctx context.Context, coverage *CoverageSnapshot) (*CoverageGuidance, error)
SuggestCoverageTargets recommends areas to focus fuzzing efforts
type EnhancedCoverageCoordinator ¶
type EnhancedCoverageCoordinator struct {
// contains filtered or unexported fields
}
Enhanced coverage coordinator with LLM integration
func GetCoordinator ¶
func GetCoordinator() *EnhancedCoverageCoordinator
GetCoordinator returns the global coverage coordinator instance
func (*EnhancedCoverageCoordinator) EvaluateTestQuality ¶
func (c *EnhancedCoverageCoordinator) EvaluateTestQuality(ctx context.Context, testCase interface{}) (*TestQualityAssessment, error)
EvaluateTestQuality uses LLM oracle to assess test quality
func (*EnhancedCoverageCoordinator) GetCoverageGuidance ¶
func (c *EnhancedCoverageCoordinator) GetCoverageGuidance(ctx context.Context) (*CoverageGuidance, error)
GetCoverageGuidance requests LLM-suggested fuzzing targets
func (*EnhancedCoverageCoordinator) GetMetrics ¶
func (c *EnhancedCoverageCoordinator) GetMetrics() map[string]interface{}
GetMetrics returns coordinator metrics
func (*EnhancedCoverageCoordinator) GetSnapshots ¶
func (c *EnhancedCoverageCoordinator) GetSnapshots() []*CoverageSnapshot
GetSnapshots returns recent coverage snapshots
func (*EnhancedCoverageCoordinator) SetEventHandlers ¶
func (c *EnhancedCoverageCoordinator) SetEventHandlers( onCoverageChange func(*CoverageSnapshot), onTestQuality func(*TestQualityAssessment), onGuidance func(*CoverageGuidance), )
SetEventHandlers configures event callbacks
func (*EnhancedCoverageCoordinator) SetLLMOracle ¶
func (c *EnhancedCoverageCoordinator) SetLLMOracle(oracle LLMOracle)
SetLLMOracle configures the LLM oracle for coverage analysis
func (*EnhancedCoverageCoordinator) Stop ¶
func (c *EnhancedCoverageCoordinator) Stop()
Stop shuts down the coordinator
func (*EnhancedCoverageCoordinator) TakeSnapshot ¶
func (c *EnhancedCoverageCoordinator) TakeSnapshot() *CoverageSnapshot
TakeSnapshot captures current coverage state
type FunctionCoverage ¶
type FunctionCoverage struct {
Name string `json:"name"`
Package string `json:"package"`
TotalLines int `json:"total_lines"`
CoveredLines int `json:"covered_lines"`
CoverageRatio float64 `json:"coverage_ratio"`
CallCount int64 `json:"call_count"`
Complexity float64 `json:"complexity"`
LastHit time.Time `json:"last_hit"`
}
FunctionCoverage tracks coverage at function level
type LLMOracle ¶
type LLMOracle interface {
// EvaluateTestQuality assesses the quality of a test case based on coverage patterns
EvaluateTestQuality(ctx context.Context, coverage *CoverageSnapshot, testCase interface{}) (*TestQualityAssessment, error)
// SuggestCoverageTargets recommends areas to focus fuzzing efforts
SuggestCoverageTargets(ctx context.Context, coverage *CoverageSnapshot) (*CoverageGuidance, error)
// AnalyzeCoveragePattern identifies patterns in coverage data
AnalyzeCoveragePattern(ctx context.Context, coverage *CoverageSnapshot) (*PatternAnalysis, error)
}
LLMOracle represents the interface for LLM-assisted coverage analysis
type OracleConfig ¶
type OracleConfig struct {
MaxRequestsPerMinute int `json:"max_requests_per_minute"`
CacheTTL time.Duration `json:"cache_ttl"`
MaxCacheSize int `json:"max_cache_size"`
Model string `json:"model"`
Temperature float64 `json:"temperature"`
MaxTokens int `json:"max_tokens"`
EnableHeuristics bool `json:"enable_heuristics"`
HeuristicWeight float64 `json:"heuristic_weight"`
}
OracleConfig configures the LLM oracle behavior
func LoadOracleConfig ¶
func LoadOracleConfig(configPath string) (*OracleConfig, error)
func (*OracleConfig) Save ¶
func (config *OracleConfig) Save(configPath string) error
type PackageCoverage ¶
type PackageCoverage struct {
Name string `json:"name"`
TotalLines int `json:"total_lines"`
CoveredLines int `json:"covered_lines"`
CoverageRatio float64 `json:"coverage_ratio"`
Functions int `json:"functions"`
Complexity float64 `json:"complexity"`
}
PackageCoverage tracks coverage at package level
type PatternAnalysis ¶
type PatternAnalysis struct {
Patterns []string `json:"patterns"`
Anomalies []string `json:"anomalies"`
Insights []string `json:"insights"`
Recommendations []string `json:"recommendations"`
Confidence float64 `json:"confidence"`
Metadata map[string]string `json:"metadata"`
}
PatternAnalysis contains insights about coverage patterns
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter manages LLM API rate limiting
func (*RateLimiter) Allow ¶
func (r *RateLimiter) Allow() bool
type TestQualityAssessment ¶
type TestQualityAssessment struct {
Score float64 `json:"score"` // 0.0 to 1.0
Rationale string `json:"rationale"` // LLM explanation
Suggestions []string `json:"suggestions"` // Improvement suggestions
Rubric string `json:"rubric"` // Applied rubric
Metadata map[string]string `json:"metadata"` // Additional context
}
TestQualityAssessment contains LLM evaluation of test quality