Documentation
¶
Overview ¶
Package state manages persisted scan state for delta scanning.
When --delta is active, stringer saves a record of all signal hashes produced by a scan. On subsequent runs, this state is loaded and used to filter output to only new signals.
Index ¶
- func CollectorsMatch(prev *ScanState, current []string) bool
- func FilterNew(signals []signal.RawSignal, prev *ScanState) []signal.RawSignal
- func FormatDiff(diff *DiffResult, repoPath string, w io.Writer) error
- func Save(repoPath string, s *ScanState) error
- type AnnotatedSignal
- type DiffResult
- type MovedSignal
- type ScanState
- type SignalMeta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollectorsMatch ¶
CollectorsMatch returns true if the previous state's collector list matches the current list (order-independent).
func FilterNew ¶
FilterNew returns only the signals whose hashes are not present in prev. If prev is nil, all signals are considered new. The order of signals is preserved.
func FormatDiff ¶
func FormatDiff(diff *DiffResult, repoPath string, w io.Writer) error
FormatDiff writes a human-readable diff summary to w. The output uses +/- notation similar to git diff.
Types ¶
type AnnotatedSignal ¶
type AnnotatedSignal struct {
SignalMeta
Resolution string // "file_deleted", "moved", or ""
}
AnnotatedSignal extends SignalMeta with resolution context.
func AnnotateRemovedSignals ¶
func AnnotateRemovedSignals(repoPath string, removed []SignalMeta) []AnnotatedSignal
AnnotateRemovedSignals marks removed signals with resolution context. Signals referring to deleted files are marked as "file_deleted". This helps users distinguish between resolved work vs stale signals.
type DiffResult ¶
type DiffResult struct {
Added []SignalMeta // signals in current but not previous
Removed []SignalMeta // signals in previous but not current
Moved []MovedSignal // signals with same title/kind but different location
}
DiffResult holds the comparison between two scans.
func ComputeDiff ¶
func ComputeDiff(prev, current *ScanState) *DiffResult
ComputeDiff compares previous and current scan states. It categorizes signals as added, removed, or moved. Moved detection: if a removed and added signal share the same Title+Kind but differ in FilePath or Line, they are treated as moved rather than added/removed.
type MovedSignal ¶
type MovedSignal struct {
Previous SignalMeta
Current SignalMeta
}
MovedSignal tracks a signal that moved between scans.
type ScanState ¶
type ScanState struct {
Version string `json:"version"`
ScanTimestamp time.Time `json:"scan_timestamp"`
GitHead string `json:"git_head"`
Collectors []string `json:"collectors"`
SignalHashes []string `json:"signal_hashes"`
SignalMetas []SignalMeta `json:"signal_metas,omitempty"`
SignalCount int `json:"signal_count"`
}
ScanState represents persisted state from a previous scan.