Documentation
¶
Overview ¶
internal/autofix/analyzer.go
internal/autofix/dev.go
internal/autofix/interfaces.go
internal/autofix/models.go
internal/autofix/watcher.go
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnalysisResult ¶
type AnalysisResult struct {
Explanation string `json:"explanation"`
RootCause string `json:"root_cause"`
Confidence float64 `json:"confidence"` // A score from 0.0 to 1.0.
Patch string `json:"patch"` // The patch in unified diff format.
}
AnalysisResult encapsulates the output from the Analyzer component. It includes the LLM's explanation of the bug, a proposed patch, and a confidence score.
type Analyzer ¶
type Analyzer struct {
// contains filtered or unexported fields
}
Analyzer is a component of the self-healing system responsible for Phase 2: analyzing a crash report (PostMortem) and the relevant source code to generate a potential fix in the form of a patch.
func NewAnalyzer ¶
NewAnalyzer creates a new instance of the Analyzer. It requires a logger, an LLM client for code generation, and the project's root directory to resolve file paths.
func (*Analyzer) GeneratePatch ¶
func (a *Analyzer) GeneratePatch(ctx context.Context, report PostMortem) (*AnalysisResult, error)
GeneratePatch is the primary method of the Analyzer. It takes a post-mortem report, reads the source code, constructs a detailed prompt for the LLM, and parses the LLM's response to produce a structured `AnalysisResult` containing the proposed patch and an explanation.
type AnalyzerInterface ¶
type AnalyzerInterface interface {
// GeneratePatch takes a post-mortem report and returns a structured analysis
// result, including a proposed patch.
GeneratePatch(ctx context.Context, report PostMortem) (*AnalysisResult, error)
}
AnalyzerInterface defines the contract for a component that can analyze a crash report and generate a potential fix.
type DASTRequest ¶
type DASTRequest struct {
Timestamp time.Time `json:"timestamp"`
Method string `json:"method"`
URL string `json:"url"`
RawRequest string `json:"raw_request,omitempty"`
}
DASTRequest represents an HTTP request captured from a dynamic analysis tool's log, which can be correlated with a crash to identify the trigger.
type Developer ¶
type Developer struct {
// contains filtered or unexported fields
}
Developer is a component of the self-healing system responsible for Phase 3: validating a proposed patch in an isolated environment using a test-driven development (TDD) cycle and, if successful, automating the Git workflow to create a pull request.
func NewDeveloper ¶
func NewDeveloper(logger *zap.Logger, llmClient schemas.LLMClient, cfg *config.AutofixConfig, sourceProjectRoot string) (*Developer, error)
NewDeveloper creates and initializes a new instance of the Developer. It authenticates with the configured GitHub token to ensure it can create pull requests.
func (*Developer) ValidateAndCommit ¶
func (d *Developer) ValidateAndCommit(ctx context.Context, report PostMortem, analysis *AnalysisResult) error
ValidateAndCommit orchestrates the entire auto-fix process. It prepares an isolated workspace, generates a new test case to reproduce the panic, applies the provided patch, and runs the test suite to validate the fix. If successful, it creates a pull request.
type DeveloperInterface ¶
type DeveloperInterface interface {
// ValidateAndCommit takes a post-mortem report and an analysis result,
// then orchestrates the TDD validation cycle and Git workflow.
ValidateAndCommit(ctx context.Context, report PostMortem, analysis *AnalysisResult) error
}
DeveloperInterface defines the contract for a component that can validate a proposed patch and, if successful, commit it and create a pull request.
type PostMortem ¶
type PostMortem struct {
IncidentID string `json:"incident_id"`
CrashTime time.Time `json:"crash_time"`
PanicMessage string `json:"panic_message"`
FilePath string `json:"file_path"` // Relative to the project root.
LineNumber int `json:"line_number"`
FullStackTrace string `json:"full_stack_trace"`
TriggeringRequest *DASTRequest `json:"triggering_request,omitempty"`
}
PostMortem is a structured report that captures all relevant information about an application crash, including the panic message, stack trace, and the HTTP request that likely triggered it.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher monitors application logs for crashes and generates a post-mortem report. It tails the application log file, detects panic events, and collects relevant information like the stack trace, file path, and line number of the crash.
func NewWatcher ¶
func NewWatcher(logger *zap.Logger, cfg config.Interface, reportChan chan<- PostMortem, projectRoot string) (*Watcher, error)
NewWatcher initializes and returns a new Watcher service. It takes a logger, configuration, a channel for sending reports, and the project root directory. It returns an error if the application log file is not configured.
type WatcherInterface ¶
type WatcherInterface interface {
// Start begins the monitoring process. It is a blocking call that should be
// run in a separate goroutine.
Start(ctx context.Context) error
}
WatcherInterface defines the contract for a component that monitors for application crashes and generates post-mortem reports.