Documentation
¶
Index ¶
- Variables
- func CalculateActivity(accessCounts map[string]int) float64
- func CalculateActivityPredicate(ctx interface{}, inputs []interface{}) ([][]interface{}, error)
- func CalculateEntropy(conflicts int) float64
- func CalculateEntropyPredicate(ctx interface{}, inputs []interface{}) ([][]interface{}, error)
- func CalculateSaliency(input string, keywords []string) float64
- func CalculateSaliencyPredicate(ctx interface{}, inputs []interface{}) ([][]interface{}, error)
- func EstimateTokens(atoms []string) int
- func LoadKernel() (string, error)
- type AtomScore
- type AutoShaveConfig
- type Calculator
- type EASTConfig
- type EASTFrame
- type EASTMetrics
- type KernelRules
- type Loader
- type MemoryManager
- func (m *MemoryManager) SelectAtomsForPruning(atoms map[Tier][]string, strategy ShaveStrategy) []string
- func (m *MemoryManager) ShouldShave(ctx context.Context, stats MemoryStats) bool
- func (m *MemoryManager) WithAutoShave(cfg AutoShaveConfig) *MemoryManager
- func (m *MemoryManager) WithTierConfig(cfg TierConfig) *MemoryManager
- type MemoryStats
- type PathType
- type Profile
- type ShaveStrategy
- type Tier
- type TierConfig
- type TierLevel
- type TierManager
- func (m *TierManager) ClassifyAtoms(atoms []string) map[Tier][]string
- func (m *TierManager) GetBudget(tier Tier) int
- func (m *TierManager) IsWithinBudget(stats MemoryStats) bool
- func (m *TierManager) PruneRequired(stats MemoryStats) map[Tier]int
- func (m *TierManager) WithConfig(cfg TierConfig) *TierManager
Constants ¶
This section is empty.
Variables ¶
var DefaultEASTConfig = EASTConfig{ EntropyThreshold: 0.7, ChaosThreshold: 0.9, SaliencyKeywords: []string{"production", "critical", "security"}, }
var DefaultTierConfig = TierConfig{
SystemBudget: 2000,
GovernanceBudget: 4000,
PlaybookBudget: 8000,
UserBudget: 6000,
}
Functions ¶
func CalculateActivity ¶
CalculateActivity computes activity based on atom access patterns Hot atoms are frequently accessed, cold atoms are rarely used
func CalculateActivityPredicate ¶
func CalculateActivityPredicate(ctx interface{}, inputs []interface{}) ([][]interface{}, error)
calculate_activity_predicate computes activity from access counts
func CalculateEntropy ¶
CalculateEntropy computes entropy based on conflict count High entropy = more contradictions in reasoning frame
func CalculateEntropyPredicate ¶
func CalculateEntropyPredicate(ctx interface{}, inputs []interface{}) ([][]interface{}, error)
calculate_entropy_predicate is used to register calculate_entropy in the engine
func CalculateSaliency ¶
CalculateSaliency determines if input contains high-priority keywords
func CalculateSaliencyPredicate ¶
func CalculateSaliencyPredicate(ctx interface{}, inputs []interface{}) ([][]interface{}, error)
calculate_saliency_predicate checks for keyword matches
func EstimateTokens ¶
EstimateTokens estimates token count for atoms (simplified)
func LoadKernel ¶
LoadKernel returns all embedded kernel rules concatenated
Types ¶
type AtomScore ¶
AtomScore holds an atom with its computed weight
func PruneCandidates ¶
PruneCandidates returns atoms that should be pruned based on coldness and low weight
type AutoShaveConfig ¶
type AutoShaveConfig struct {
Enabled bool
Strategy ShaveStrategy
MinFreeBudget int // Minimum free space to maintain
}
AutoShaveConfig holds configuration for automatic context shaving
func DefaultAutoShaveConfig ¶
func DefaultAutoShaveConfig() AutoShaveConfig
DefaultAutoShaveConfig returns the default auto-shave configuration
type Calculator ¶
type Calculator struct {
// contains filtered or unexported fields
}
Calculator provides EAST calculation as a service
func NewEASTCalculator ¶
func NewEASTCalculator() *Calculator
NewEASTCalculator creates a new EAST calculator with default config
func (*Calculator) Calculate ¶
func (c *Calculator) Calculate(frame *EASTFrame) EASTMetrics
Calculate computes EAST metrics for a frame
func (*Calculator) FullAnalysis ¶
func (c *Calculator) FullAnalysis(frame *EASTFrame) (EASTMetrics, PathType)
FullAnalysis returns both metrics and recommended path
func (*Calculator) GetPath ¶
func (c *Calculator) GetPath(metrics EASTMetrics) PathType
GetPath returns the recommended cognitive path
func (*Calculator) WithConfig ¶
func (c *Calculator) WithConfig(cfg EASTConfig) *Calculator
WithConfig sets custom configuration
type EASTConfig ¶
type EASTConfig struct {
EntropyThreshold float64
ChaosThreshold float64
SaliencyKeywords []string
}
Config holds EAST calculation configuration
type EASTFrame ¶
type EASTFrame struct {
ConflictCount int
AccessCounts map[string]int
Input string
DecisionSource string
}
EASTFrame contains input data for EAST calculation
type EASTMetrics ¶
type EASTMetrics struct {
Entropy float64
Activity float64
Saliency float64
Trust TierLevel
Conflicts int
}
EASTMetrics contains the four cognitive steering metrics
func CalculateEAST ¶
func CalculateEAST(frame *EASTFrame, cfg EASTConfig) EASTMetrics
CalculateEAST computes all four metrics and returns EASTMetrics
type KernelRules ¶
KernelRules contains the embedded framework rules
func (*KernelRules) Combine ¶
func (k *KernelRules) Combine() string
Combine concatenates all kernel rules
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader handles kernel + profile rule loading
type MemoryManager ¶
type MemoryManager struct {
// contains filtered or unexported fields
}
MemoryManager handles automatic context shaving
func NewMemoryManager ¶
func NewMemoryManager() *MemoryManager
NewMemoryManager creates a memory manager with defaults
func (*MemoryManager) SelectAtomsForPruning ¶
func (m *MemoryManager) SelectAtomsForPruning(atoms map[Tier][]string, strategy ShaveStrategy) []string
SelectAtomsForPruning selects atoms to prune based on strategy
func (*MemoryManager) ShouldShave ¶
func (m *MemoryManager) ShouldShave(ctx context.Context, stats MemoryStats) bool
ShouldShave determines if context needs pruning
func (*MemoryManager) WithAutoShave ¶
func (m *MemoryManager) WithAutoShave(cfg AutoShaveConfig) *MemoryManager
WithAutoShave configures automatic shaving behavior
func (*MemoryManager) WithTierConfig ¶
func (m *MemoryManager) WithTierConfig(cfg TierConfig) *MemoryManager
WithTierConfig sets custom tier configuration
type MemoryStats ¶
MemoryStats holds current memory usage per tier
type PathType ¶
type PathType int
PathType determines whether to use fast or slow cognitive path
func DeterminePath ¶
func DeterminePath(metrics EASTMetrics, cfg EASTConfig) PathType
DeterminePath decides fast vs slow cognitive path based on EAST metrics
type Profile ¶
Profile represents a security/business rules profile from Nexus
func DefaultProfile ¶
func DefaultProfile() Profile
DefaultProfile returns a permissive default profile
type ShaveStrategy ¶
type ShaveStrategy int
ShaveStrategy determines which atoms to prune first
const ( ShaveUserFirst ShaveStrategy = iota // Prune T3 before T2 before T1 before T0 ShaveLowWeightFirst // Prune by atom weight regardless of tier ShaveOldestFirst // Prune by timestamp )
type Tier ¶
type Tier int
func ClassifyAtom ¶
ClassifyAtom determines the tier for a single atom
func MemoryTier ¶
MemoryTier determines which tier an atom belongs to
type TierConfig ¶
type TierConfig struct {
SystemBudget int // tokens for T0 (FP32 precision)
GovernanceBudget int // tokens for T1 (FP32 precision)
PlaybookBudget int // tokens for T2 (INT8 precision)
UserBudget int // tokens for T3 (INT8 precision)
}
TierConfig holds memory budget per tier
func (TierConfig) TotalBudget ¶
func (c TierConfig) TotalBudget() int
TotalBudget returns the total memory budget
type TierLevel ¶
type TierLevel int
func DetermineTrust ¶
DetermineTrust assigns a tier level based on decision source
type TierManager ¶
type TierManager struct {
// contains filtered or unexported fields
}
TierManager handles memory allocation per tier
func NewTierManager ¶
func NewTierManager() *TierManager
NewTierManager creates a tier manager with default config
func (*TierManager) ClassifyAtoms ¶
func (m *TierManager) ClassifyAtoms(atoms []string) map[Tier][]string
ClassifyAtoms distributes atoms into tiers based on predicates
func (*TierManager) GetBudget ¶
func (m *TierManager) GetBudget(tier Tier) int
GetBudget returns the budget for a given tier
func (*TierManager) IsWithinBudget ¶
func (m *TierManager) IsWithinBudget(stats MemoryStats) bool
IsWithinBudget checks if current usage is within budget
func (*TierManager) PruneRequired ¶
func (m *TierManager) PruneRequired(stats MemoryStats) map[Tier]int
PruneRequired returns how many tokens need to be pruned per tier
func (*TierManager) WithConfig ¶
func (m *TierManager) WithConfig(cfg TierConfig) *TierManager
WithConfig sets custom tier configuration