east

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package east implements EAST (Entropy-Activity-Steering-Throttling), the OODA v4 generative/research path. It is an extension to the deterministic core OODA loop (sdk/ooda): callers that want creative/steered generation opt into this package explicitly.

It depends only on the public sdk/ooda surface (CognitiveFrame, EASTState, Atom, TrustTier) and is never imported by the core, sdk, or adapters.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrT0Violation is returned when a Tier 0 (kernel axiom) violation is detected.
	ErrT0Violation = fmt.Errorf("T0 violation: immediate halt")
	// ErrMaxRefinementIterations is returned when refinement exceeds max iterations.
	ErrMaxRefinementIterations = fmt.Errorf("max refinement iterations exceeded")
	// ErrChaosThreshold is returned when entropy exceeds chaos threshold (0.9).
	ErrChaosThreshold = fmt.Errorf("chaos threshold exceeded: entropy too high")
)
View Source
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. Sorted by MinMagnitude descending; first match where magnitude > MinMagnitude wins.

Functions

func CalculateActivity

func CalculateActivity(atoms []ooda.Atom) map[string]int

CalculateActivity builds a usage map from atoms accessed during Orient.

func CalculateEAST

func CalculateEAST(logicSuccess, entropyCoefficient float64) float64

CalculateEAST computes the Entropic Activation Steering magnitude (P): P = exp(1 - LogicSuccess) / EntropyCoefficient.

func CalculateEntropy

func CalculateEntropy(conflictCount, totalRules int) float64

CalculateEntropy computes entropy from conflict count and total rules. Returns 0.0 (no conflicts) to 1.0 (all rules conflicted).

func CalculateMagnitude

func CalculateMagnitude(state *ooda.EASTState) float64

CalculateMagnitude computes the steering formula: P = exp(1-L) / N.

func ClassifyTrustTier

func ClassifyTrustTier(source string) ooda.TrustTier

ClassifyTrustTier determines the trust tier from the decision source.

func DetectConflicts

func DetectConflicts(context []ooda.Atom, axioms []ooda.Atom) int

DetectConflicts counts atoms that contradict AttentionSink axioms. A conflict occurs when an atom with Weight < 0.5 contradicts an axiom with Weight = 1.0.

func GetSteeringPrompts

func GetSteeringPrompts(magnitude float64) (headerKey, bodyKey string)

GetSteeringPrompts selects the appropriate prompt templates based on the current EAST magnitude.

func IsSaliencyHigh

func IsSaliencyHigh(saliency []string) bool

IsSaliencyHigh returns true if the saliency signals indicate high priority.

func IsSaliencyKnown

func IsSaliencyKnown(saliency []string) bool

IsSaliencyKnown returns true if the saliency signals include a known pattern.

func MeasureSaliency

func MeasureSaliency(input string) []string

MeasureSaliency evaluates input importance based on keyword detection. Returns a list of saliency signals found in the input.

func RunOODAEAST

func RunOODAEAST(ctx context.Context, frame *ooda.CognitiveFrame) (*ooda.CognitiveFrame, error)

RunOODAEAST executes the OODA loop with EAST steering for generation tasks. Includes entropy measurement, fast-path routing, Datalog validation, and Teacher-Student retry.

Flow: Observe → Orient → Plan → [EAST routes] → Decide(opt) → Act → Validate + EAST post-act.

EAST post-act behaviors:

  • Validate: Datalog rule check (quality_gate, validation_rule, generic_pattern)
  • Route: E decides HALT/RETRY/ACCEPT
  • Retry: Teacher-Student loop with feedback injection (max 3)

func ShouldInjectParadox

func ShouldInjectParadox(state *ooda.EASTState) bool

ShouldInjectParadox returns true if steering magnitude exceeds the configured paradox threshold. Falls back to the default (0.8) when unset. Callers should compute magnitude first (see CalculateMagnitude) — order in RunOODAEAST guarantees Magnitude is set before Decide.

func Steer

func Steer(state *ooda.EASTState, frame *ooda.CognitiveFrame) ooda.ExecutionPath

Steer determines the execution path based on EAST metrics.

func SteerKB

func SteerKB(ctx context.Context, state *ooda.EASTState, frame *ooda.CognitiveFrame, reasoner ports.ReasoningPort) ooda.ExecutionPath

SteerKB determines the execution path by querying Datalog rules directly (14-east.dl). Falls back to in-memory Steer if ReasoningPort is nil.

func Temperature

func Temperature(state *ooda.EASTState) float64

Temperature returns the recommended LLM temperature based on steering magnitude.

func UpdateEntropy

func UpdateEntropy(oldEntropy float64, violations, totalRules int) float64

UpdateEntropy adjusts entropy based on validation results. New entropy = old entropy + (violations / total rules).

Types

type SteeringPolicy

type SteeringPolicy struct {
	MinMagnitude float64
	HeaderKey    string
	BodyKey      string
}

SteeringPolicy defines template keys used for prompt assembly when the agent reaches a specific cognitive pressure threshold.

Jump to

Keyboard shortcuts

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