Documentation
¶
Index ¶
- Variables
- func CalculateEAST(logicSuccess, entropyCoefficient float64) float64
- func GetSteeringPrompts(magnitude float64) (headerKey, bodyKey string)
- func ShouldInjectParadox(magnitude float64) bool
- type Compiler
- type ContextManager
- func (cm *ContextManager) CalculateContextBudget(totalBudget, fp32Usage int, logicSuccess float64, previousOutputTokens int) int
- func (cm *ContextManager) FilterStrategic(atoms []domain.Atom, currentIntent domain.IntentStr) []domain.Atom
- func (cm *ContextManager) Prune(atoms []domain.Atom, maxTokens int) []domain.Atom
- type PromptConfig
- type PromptOption
- func WithAxioms(a []domain.Atom) PromptOption
- func WithContext(a []domain.Atom) PromptOption
- func WithFacts(f []byte) PromptOption
- func WithGenes(g []domain.DomainGene) PromptOption
- func WithHistory(h []domain.AuditResult) PromptOption
- func WithIntent(i domain.IntentStr) PromptOption
- func WithPass(p int) PromptOption
- func WithPrevious(o string) PromptOption
- func WithRefinement(r *RefinementContext) PromptOption
- func WithSteering(m float64, p bool) PromptOption
- func WithTaskType(t domain.TaskType) PromptOption
- type RefinementContext
- type SteeringPolicy
Constants ¶
This section is empty.
Variables ¶
var ParadoxThreshold = 0.8
ParadoxThreshold is the EAST magnitude above which cognitive paradox injection is triggered. Configurable via config.Policy.ParadoxThreshold (default 0.8).
var SteeringRegistry = []SteeringPolicy{
{
MinMagnitude: 0.8,
HeaderKey: "prompt_header_paradox",
BodyKey: "prompt_body_conservative",
},
{
MinMagnitude: 0.5,
HeaderKey: "prompt_header_strict",
BodyKey: "prompt_body_structured",
},
{
MinMagnitude: 0.0,
HeaderKey: "prompt_header_default",
BodyKey: "prompt_body_creative",
},
}
SteeringRegistry holds the tiered policies for guiding LLM behavior under stress. LLD 5.4: Sorted by MinMagnitude descending. First match where magnitude > MinMagnitude wins.
Functions ¶
func CalculateEAST ¶
CalculateEAST computes the Entropic Activation Steering magnitude (P). LLD 5.4 Formula: P = exp(1 - LogicSuccess) / EntropyCoefficient
func GetSteeringPrompts ¶
GetSteeringPrompts selects the appropriate prompt templates based on the current EAST magnitude.
func ShouldInjectParadox ¶
ShouldInjectParadox returns true if the system should forcefully inject cognitive paradoxes (conflicting imperatives) to induce highly conservative, step-by-step LLM output behavior due to extreme runtime logic failures.
Types ¶
type Compiler ¶
type Compiler struct {
}
Compiler orchestrates prompt assembly based on LLD 5.1/5.2.
type ContextManager ¶
type ContextManager struct {
BaseBuffer int // Default safety margin (e.g., 200 tokens)
ShaveThreshold int // Estimated token count at which Intensive Shaving occurs
}
ContextManager handles token allocation and rule-based pruning for LLM prompts. It ensures the LLM never exceeds its context window while maximizing relevant knowledge.
func NewContextManager ¶
func NewContextManager() *ContextManager
NewContextManager creates a default context manager.
func (*ContextManager) CalculateContextBudget ¶
func (cm *ContextManager) CalculateContextBudget( totalBudget, fp32Usage int, logicSuccess float64, previousOutputTokens int, ) int
CalculateContextBudget determines how many tokens remain for the soft context (INT8 facts). LLD 5.3: It employs "Logic Success Sharpening". As the agent fails logic audits (LogicSuccess drops), the safety buffer increases, restricting the context to force the LLM to focus only on the most critical facts.
func (*ContextManager) FilterStrategic ¶
func (cm *ContextManager) FilterStrategic(atoms []domain.Atom, currentIntent domain.IntentStr) []domain.Atom
FilterStrategic performs the first pass of context pruning according to LLD 5.3. It retains atoms that match the Current Intent, OR are mathematically certain (Weight >= 0.9), OR are global context (no origin intent).
type PromptConfig ¶
type PromptConfig struct {
Intent domain.IntentStr
TaskType domain.TaskType
Context []domain.Atom // Soft Logic (INT8)
Axioms []domain.Atom // Hard Logic (FP32) - Attention Sink
Genes []domain.DomainGene
Facts []byte // N-Quads
SteeringMagnitude float64
InjectParadox bool
RefinementFeedback *RefinementContext
Pass int // Multi-pass iteration
PreviousOutput string
SessionHistory []domain.AuditResult
}
PromptConfig holds all possible inputs for the functional options compiler.
type PromptOption ¶
type PromptOption func(*PromptConfig)
PromptOption defines the functional option pattern.
func WithAxioms ¶
func WithAxioms(a []domain.Atom) PromptOption
func WithContext ¶
func WithContext(a []domain.Atom) PromptOption
func WithFacts ¶
func WithFacts(f []byte) PromptOption
func WithGenes ¶
func WithGenes(g []domain.DomainGene) PromptOption
func WithHistory ¶
func WithHistory(h []domain.AuditResult) PromptOption
func WithPass ¶
func WithPass(p int) PromptOption
func WithPrevious ¶
func WithPrevious(o string) PromptOption
func WithRefinement ¶
func WithRefinement(r *RefinementContext) PromptOption
func WithSteering ¶
func WithSteering(m float64, p bool) PromptOption
func WithTaskType ¶
func WithTaskType(t domain.TaskType) PromptOption
type RefinementContext ¶
type RefinementContext struct {
AuditResult *domain.AuditResult
PreviousDraft interface{}
}
RefinementContext encapsulates audit failures used to correct the LLM.
type SteeringPolicy ¶
type SteeringPolicy struct {
MinMagnitude float64
HeaderKey string // Prompt template key for the system header
BodyKey string // Prompt template key for the body instructions
}
SteeringPolicy defines template keys used for prompt assembly when the agent reaches a specific cognitive pressure threshold.