Documentation
¶
Overview ¶
Package cortex provides content-aware gate system (Claw Compactor's Cortex detection).
Package cortex provides content-aware gate system.
Index ¶
- type ASTProcessor
- type AlwaysCondition
- type AnyCondition
- type BudgetProcessor
- type CompositeCondition
- type ContentStats
- type ContentType
- type ContentTypeCondition
- type ContrastiveProcessor
- type DetectionResult
- type Detector
- type EntropyProcessor
- type FeatureCondition
- type Gate
- type GateCondition
- type GateRegistry
- type GistProcessor
- type GoalDrivenProcessor
- type HierarchicalProcessor
- type LLMEvalProcessor
- type Language
- type LanguageCondition
- type LayerGate
- type LayerProcessor
- type NgramProcessor
- type NotCondition
- type PerplexityProcessor
- type SizeCondition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ASTProcessor ¶
type ASTProcessor struct{}
ASTProcessor preserves AST structure.
func (*ASTProcessor) Name ¶
func (p *ASTProcessor) Name() string
type AlwaysCondition ¶
type AlwaysCondition struct{}
AlwaysCondition always matches.
func (AlwaysCondition) Match ¶
func (c AlwaysCondition) Match(content string, detection DetectionResult) bool
type AnyCondition ¶
type AnyCondition struct {
Conditions []GateCondition
}
AnyCondition combines conditions with OR logic.
func (AnyCondition) Match ¶
func (c AnyCondition) Match(content string, detection DetectionResult) bool
Match implements GateCondition.
type BudgetProcessor ¶
type BudgetProcessor struct{}
BudgetProcessor enforces token budget.
func (*BudgetProcessor) Name ¶
func (p *BudgetProcessor) Name() string
type CompositeCondition ¶
type CompositeCondition struct {
Conditions []GateCondition
}
CompositeCondition combines multiple conditions with AND logic.
func (CompositeCondition) Match ¶
func (c CompositeCondition) Match(content string, detection DetectionResult) bool
Match implements GateCondition.
type ContentStats ¶
type ContentStats struct {
TotalLines int
TotalChars int
NonEmptyLines int
CommentLines int
CodeLines int
BlankLines int
AvgLineLength float64
HasAnsiCodes bool
HasUnicode bool
Entropy float64
}
ContentStats provides statistics about the content.
type ContentType ¶
type ContentType int
ContentType represents the detected content type.
const ( Unknown ContentType = iota SourceCode BuildLog TestOutput StructuredData NaturalLanguage BinaryData )
func (ContentType) String ¶
func (c ContentType) String() string
type ContentTypeCondition ¶
type ContentTypeCondition struct {
Types []ContentType
}
ContentTypeCondition matches by content type.
func (ContentTypeCondition) Match ¶
func (c ContentTypeCondition) Match(content string, detection DetectionResult) bool
Match implements GateCondition.
type ContrastiveProcessor ¶
type ContrastiveProcessor struct{}
ContrastiveProcessor uses contrastive learning.
func (*ContrastiveProcessor) Name ¶
func (p *ContrastiveProcessor) Name() string
type DetectionResult ¶
type DetectionResult struct {
ContentType ContentType
Language Language
Confidence float64
Features map[string]bool
Stats ContentStats
}
DetectionResult contains content detection results.
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
Detector provides content type detection.
func (*Detector) Detect ¶
func (d *Detector) Detect(content string) DetectionResult
Detect analyzes content and returns detection results.
func (*Detector) DetectFile ¶
func (d *Detector) DetectFile(path string, content string) DetectionResult
DetectFile analyzes a file and returns detection results.
type EntropyProcessor ¶
type EntropyProcessor struct{}
EntropyProcessor reduces high-entropy content.
func (*EntropyProcessor) Name ¶
func (p *EntropyProcessor) Name() string
type FeatureCondition ¶
FeatureCondition matches by content features.
func (FeatureCondition) Match ¶
func (c FeatureCondition) Match(content string, detection DetectionResult) bool
Match implements GateCondition.
type Gate ¶
type Gate interface {
// ShouldApply returns true if the layer should be applied.
ShouldApply(content string, detection DetectionResult) bool
// Priority returns the gate priority (lower = higher priority).
Priority() int
// Name returns the gate name.
Name() string
}
Gate determines if a layer should be applied to content.
type GateCondition ¶
type GateCondition interface {
Match(content string, detection DetectionResult) bool
}
GateCondition determines if content matches criteria.
type GateRegistry ¶
type GateRegistry struct {
// contains filtered or unexported fields
}
GateRegistry manages all layer gates.
func NewGateRegistry ¶
func NewGateRegistry() *GateRegistry
NewGateRegistry creates a new gate registry.
func (*GateRegistry) Analyze ¶
func (r *GateRegistry) Analyze(content string) DetectionResult
Analyze returns detection info without processing.
func (*GateRegistry) ApplyGates ¶
func (r *GateRegistry) ApplyGates(content string) (string, int)
ApplyGates runs applicable gates on content and returns processed result.
func (*GateRegistry) GetApplicableGates ¶
func (r *GateRegistry) GetApplicableGates(content string) []string
GetApplicableGates returns list of gates that apply to content.
func (*GateRegistry) Register ¶
func (r *GateRegistry) Register(gate Gate)
Register adds a gate to the registry.
type GistProcessor ¶
type GistProcessor struct{}
GistProcessor creates content gists.
func (*GistProcessor) Name ¶
func (p *GistProcessor) Name() string
type GoalDrivenProcessor ¶
type GoalDrivenProcessor struct{}
GoalDrivenProcessor analyzes query intent.
func (*GoalDrivenProcessor) Name ¶
func (p *GoalDrivenProcessor) Name() string
type HierarchicalProcessor ¶
type HierarchicalProcessor struct{}
HierarchicalProcessor creates summaries.
func (*HierarchicalProcessor) Name ¶
func (p *HierarchicalProcessor) Name() string
type LLMEvalProcessor ¶
type LLMEvalProcessor struct{}
LLMEvalProcessor uses LLM evaluation.
func (*LLMEvalProcessor) Name ¶
func (p *LLMEvalProcessor) Name() string
type LanguageCondition ¶
type LanguageCondition struct {
Languages []Language
}
LanguageCondition matches by programming language.
func (LanguageCondition) Match ¶
func (c LanguageCondition) Match(content string, detection DetectionResult) bool
Match implements GateCondition.
type LayerGate ¶
type LayerGate struct {
// contains filtered or unexported fields
}
LayerGate is a gate for a specific compression layer.
func DefaultGates ¶
func DefaultGates() []*LayerGate
DefaultGates returns the default set of layer gates.
func NewLayerGate ¶
func NewLayerGate(name string, priority int, condition GateCondition, layer LayerProcessor) *LayerGate
NewLayerGate creates a new layer gate.
func (*LayerGate) ShouldApply ¶
func (g *LayerGate) ShouldApply(content string, detection DetectionResult) bool
ShouldApply implements Gate.
type LayerProcessor ¶
LayerProcessor processes content for a layer.
type NgramProcessor ¶
type NgramProcessor struct{}
NgramProcessor deduplicates n-grams.
func (*NgramProcessor) Name ¶
func (p *NgramProcessor) Name() string
type NotCondition ¶
type NotCondition struct {
Condition GateCondition
}
NotCondition negates a condition.
func (NotCondition) Match ¶
func (c NotCondition) Match(content string, detection DetectionResult) bool
Match implements GateCondition.
type PerplexityProcessor ¶
type PerplexityProcessor struct{}
PerplexityProcessor filters low-perplexity content.
func (*PerplexityProcessor) Name ¶
func (p *PerplexityProcessor) Name() string
type SizeCondition ¶
type SizeCondition struct {
MinLines int
MaxLines int
MinChars int
MaxChars int
MinTokens int
MaxTokens int
}
SizeCondition matches by content size.
func (SizeCondition) Match ¶
func (c SizeCondition) Match(content string, detection DetectionResult) bool
Match implements GateCondition.