Documentation
¶
Index ¶
- Constants
- Variables
- func ColorBar(value, maxVal, width int) string
- func ColorSavings(pct float64) string
- func ColorTier(tier string) string
- func ComputeULMENHash(symbols []store.Symbol) string
- func ExportMermaid(calls []store.Call, title string) string
- func FormatBar(value, maxVal, width int) string
- func FormatSeparator(width int) string
- func FormatSparkline(values []float64) string
- func FormatTable(headers []string, rows [][]string) string
- func IsTerminal() bool
- func PrintError(msg string)
- func PrintFiltered(output string, verbose int)
- func PrintFlows(w io.Writer, symbol string, flows []store.Flow)
- func RunGain(tracker *telemetry.Tracker, args []string) error
- func TierLabel(pct float64) string
- func ValidateULMENHash(hash string, symbols []store.Symbol) bool
- type ACCP
- type ContextFrame
- type GainStats
- type HAKAIEncoder
- func (e *HAKAIEncoder) EncodeCall(c store.Call) error
- func (e *HAKAIEncoder) EncodeChurn(path string, churn float64) error
- func (e *HAKAIEncoder) EncodeCritical(s store.CriticalSymbol) error
- func (e *HAKAIEncoder) EncodeRank(path string, rank float64) error
- func (e *HAKAIEncoder) EncodeSymbol(s store.Symbol) error
- func (e *HAKAIEncoder) WriteHeader() error
- type SovereignContext
- type SovereignState
- type SovereignWrapper
- func (s *SovereignWrapper) EmitCall(c store.Call) error
- func (s *SovereignWrapper) EmitChurn(path string, churn float64) error
- func (s *SovereignWrapper) EmitRank(path string, rank float64) error
- func (s *SovereignWrapper) EmitSymbol(sym store.Symbol) error
- func (s *SovereignWrapper) Flush() error
- func (s *SovereignWrapper) GetState() SovereignState
- func (s *SovereignWrapper) SetACCP(accp *ACCP)
- func (s *SovereignWrapper) SetState(state SovereignState)
- func (s *SovereignWrapper) TrackTokens(count int)
- func (s *SovereignWrapper) Write(p []byte) (n int, err error)
- func (s *SovereignWrapper) WriteHeader() error
Constants ¶
const ( DefaultThresholdWarm = 500 DefaultThresholdCold = 2000 )
Default thresholds for state transitions.
const ProtocolHeader = "#!SOV/1"
ProtocolHeader is the versioned prefix for the Sovereign Context Protocol.
Variables ¶
var ( HeaderStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("12")) SuccessStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("10")) ErrorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("9")) DimStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("8")) StatStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("14")) WarnStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("11")) GreenStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("10")) YellowStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("11")) RedStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("9")) )
Functions ¶
func ColorBar ¶
ColorBar returns a colored impact bar (green filled, dim empty). Guarantees at least 1 filled block when value > 0.
func ColorSavings ¶
ColorSavings returns a savings percentage string colored by tier. ≥70% green, 30-70% yellow, <30% red.
func ComputeULMENHash ¶
ComputeULMENHash generates a deterministic SHA-256 hash for a set of symbols.
func ExportMermaid ¶
ExportMermaid formats a slice of calls into a Mermaid graph string.
func FormatSeparator ¶
FormatSeparator returns a horizontal separator line.
func FormatSparkline ¶
FormatSparkline renders a sparkline from a slice of values. Uses Unicode block characters ▁▂▃▄▅▆▇█.
func FormatTable ¶
FormatTable formats data as a simple aligned table. Handles ANSI-colored cells correctly for alignment.
func PrintFiltered ¶
PrintFiltered prints filtered output with optional verbosity header.
func PrintFlows ¶
PrintFlows displays data flow origins in a styled table.
Types ¶
type ACCP ¶
type ACCP struct {
ThresholdWarm int
ThresholdCold int
TotalTokens int
Frames []ContextFrame
}
ACCP (Adaptive Context Compression Protocol) manages token density and state transitions.
func (*ACCP) DetermineState ¶
func (a *ACCP) DetermineState(tokens int) SovereignState
DetermineState returns the appropriate SovereignState based on the provided token count.
func (*ACCP) RegisterFrame ¶
RegisterFrame adds a new frame to the ACCP window and updates the total token count.
type ContextFrame ¶
ContextFrame represents a unit of context (e.g., a file) in the sliding window.
type GainStats ¶
type GainStats struct {
TotalSaved int
AvgSavings float64
TotalCommands int
HoursReclaimed float64
}
GainStats holds high-level metrics for the Gain dashboard.
type HAKAIEncoder ¶
type HAKAIEncoder struct {
State SovereignState
// contains filtered or unexported fields
}
HAKAIEncoder implements the High-density Adaptive Knowledge Atlas Integration format. It provides a high-density, token-efficient wire format for code symbols and relationships.
func NewHAKAIEncoder ¶
func NewHAKAIEncoder(w io.Writer) *HAKAIEncoder
NewHAKAIEncoder creates a new HAKAI encoder writing to w.
func (*HAKAIEncoder) EncodeCall ¶
func (e *HAKAIEncoder) EncodeCall(c store.Call) error
EncodeCall encodes a caller relationship row. Format: C|PathID|CallerName
func (*HAKAIEncoder) EncodeChurn ¶
func (e *HAKAIEncoder) EncodeChurn(path string, churn float64) error
EncodeChurn encodes a churn metric row. Format: K|PathID|Churn
func (*HAKAIEncoder) EncodeCritical ¶
func (e *HAKAIEncoder) EncodeCritical(s store.CriticalSymbol) error
EncodeCritical encodes a critical symbol row. Format: X|PathID|Name|Centrality|Fragility
func (*HAKAIEncoder) EncodeRank ¶
func (e *HAKAIEncoder) EncodeRank(path string, rank float64) error
EncodeRank encodes a Pagerank metric row. Format: R|PathID|Rank
func (*HAKAIEncoder) EncodeSymbol ¶
func (e *HAKAIEncoder) EncodeSymbol(s store.Symbol) error
EncodeSymbol encodes a symbol row. Format: S|PathID|Name|Type|StartLine|StartCol|Signature|Doc
func (*HAKAIEncoder) WriteHeader ¶
func (e *HAKAIEncoder) WriteHeader() error
WriteHeader writes the HAKAI protocol header.
type SovereignContext ¶
type SovereignContext interface {
io.Writer
SetState(state SovereignState)
GetState() SovereignState
EmitSymbol(s store.Symbol) error
EmitCall(c store.Call) error
EmitRank(path string, rank float64) error
EmitChurn(path string, churn float64) error
}
SovereignContext defines the interface for state-aware context management.
type SovereignState ¶
type SovereignState string
SovereignState defines the data density tier for context frames.
const ( HOT SovereignState = "HOT" WARM SovereignState = "WARM" COLD SovereignState = "COLD" )
type SovereignWrapper ¶
type SovereignWrapper struct {
Writer io.Writer
Encoder *HAKAIEncoder
State SovereignState
ACCP *ACCP
// contains filtered or unexported fields
}
SovereignWrapper wraps an io.Writer to provide state-aware context generation.
func NewSovereignWrapper ¶
func NewSovereignWrapper(w io.Writer) *SovereignWrapper
NewSovereignWrapper creates a new wrapper around the provided writer.
func (*SovereignWrapper) EmitCall ¶
func (s *SovereignWrapper) EmitCall(c store.Call) error
EmitCall emits a call relationship according to the current state.
func (*SovereignWrapper) EmitChurn ¶
func (s *SovereignWrapper) EmitChurn(path string, churn float64) error
EmitChurn emits a churn metric if the state is not COLD.
func (*SovereignWrapper) EmitRank ¶
func (s *SovereignWrapper) EmitRank(path string, rank float64) error
EmitRank emits a Pagerank metric if the state is not COLD.
func (*SovereignWrapper) EmitSymbol ¶
func (s *SovereignWrapper) EmitSymbol(sym store.Symbol) error
EmitSymbol emits a symbol according to the current state.
func (*SovereignWrapper) Flush ¶
func (s *SovereignWrapper) Flush() error
Flush emits all buffered COLD hashes.
func (*SovereignWrapper) GetState ¶
func (s *SovereignWrapper) GetState() SovereignState
GetState returns the current context state.
func (*SovereignWrapper) SetACCP ¶
func (s *SovereignWrapper) SetACCP(accp *ACCP)
SetACCP attaches an ACCP engine to the wrapper.
func (*SovereignWrapper) SetState ¶
func (s *SovereignWrapper) SetState(state SovereignState)
SetState updates the current context state and synchronizes the encoder.
func (*SovereignWrapper) TrackTokens ¶
func (s *SovereignWrapper) TrackTokens(count int)
TrackTokens updates the ACCP engine with the number of tokens emitted and adjusts the state if necessary.
func (*SovereignWrapper) Write ¶
func (s *SovereignWrapper) Write(p []byte) (n int, err error)
Write implements io.Writer by delegating to the underlying writer. It updates the internal token count to prevent seal bypasses using a lossless accumulator.
func (*SovereignWrapper) WriteHeader ¶
func (s *SovereignWrapper) WriteHeader() error
WriteHeader writes the Sovereign protocol header and current state.