history

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package history provides persistent storage for analysis results over time. This enables blast radius trends, hotspot evolution, and coupling drift tracking.

History is stored in a separate SQLite database (.contextception/history.sqlite) to keep it independent from the index, which gets rebuilt frequently.

Index

Constants

View Source
const HistoryFile = "history.sqlite"

HistoryFile is the filename of the history database.

Variables

This section is empty.

Functions

func HistoryPath

func HistoryPath(repoRoot string) string

HistoryPath returns the path to the history database for a repo.

Types

type BlastDistribution

type BlastDistribution struct {
	Level   string  `json:"level"`
	Count   int     `json:"count"`
	Percent float64 `json:"percent"`
}

BlastDistribution shows what percentage of runs had each blast level.

type BlastRadiusTrend

type BlastRadiusTrend struct {
	Date   string `json:"date"`
	Level  string `json:"level"`
	Files  int    `json:"files"`
	Branch string `json:"branch,omitempty"`
}

BlastRadiusTrend returns blast radius levels over time.

type FileRiskHistory

type FileRiskHistory struct {
	Date       string `json:"date"`
	BlastLevel string `json:"blast_level"`
	Status     string `json:"status"`
}

FileRiskHistory shows how a file's blast radius has changed over time.

type HotspotFrequency

type HotspotFrequency struct {
	File     string `json:"file"`
	Count    int    `json:"count"`
	LastSeen string `json:"last_seen"`
}

HotspotFrequency represents how often a file appears as a hotspot.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store manages the historical analysis database.

func Open

func Open(repoRoot string) (*Store, error)

Open opens or creates the history database.

func (*Store) Close

func (s *Store) Close() error

Close closes the database.

func (*Store) GetBlastDistribution

func (s *Store) GetBlastDistribution(since time.Time) ([]BlastDistribution, error)

GetBlastDistribution returns the distribution of blast radius levels.

func (*Store) GetBlastRadiusTrend

func (s *Store) GetBlastRadiusTrend(limit int, branch string) ([]BlastRadiusTrend, error)

GetBlastRadiusTrend returns the last N analysis runs' blast radius.

func (*Store) GetFileRiskHistory

func (s *Store) GetFileRiskHistory(filePath string, limit int) ([]FileRiskHistory, error)

GetFileRiskHistory returns the risk history for a specific file.

func (*Store) GetHotspotEvolution

func (s *Store) GetHotspotEvolution(limit int, since time.Time) ([]HotspotFrequency, error)

GetHotspotEvolution returns files that appear most frequently as hotspots.

func (*Store) RecordRun

func (s *Store) RecordRun(report *model.ChangeReport, commitSHA, branch string) (int64, error)

RecordRun stores a change report in the history database.

func (*Store) RunCount

func (s *Store) RunCount() (int, error)

RunCount returns the total number of recorded runs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL