Documentation
¶
Overview ¶
Copyright 2026 Teradata
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2026 Teradata ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2026 Teradata ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2026 Teradata ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2026 Teradata ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2026 Teradata ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2026 Teradata ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- func GetPatternDomain(ctx context.Context) string
- func GetPatternName(ctx context.Context) string
- func GetVariant(ctx context.Context) string
- func LoadPatternLibrary(path string) (*loomv1.PatternLibrary, error)
- func NewCanarySelector(controlVariant string, treatmentVariant string, treatmentPercentage float64) prompts.VariantSelector
- func WithPatternDomain(ctx context.Context, domain string) context.Context
- func WithPatternMetadata(ctx context.Context, patternName, variant, domain string) context.Context
- func WithPatternName(ctx context.Context, patternName string) context.Context
- func WithVariant(ctx context.Context, variant string) context.Context
- type CanaryTestConfig
- type CommonError
- type Example
- type ExecutionPlan
- type ExecutionPlannerFunc
- type HotReloadConfig
- type HotReloader
- type IntentCategory
- type IntentClassifierFunc
- type LLMClassifierConfig
- type LLMReRankerConfig
- type Library
- func (lib *Library) AddSearchPath(path string)
- func (lib *Library) ClearCache()
- func (lib *Library) FilterByBackendType(backendType string) []PatternSummary
- func (lib *Library) FilterByCategory(category string) []PatternSummary
- func (lib *Library) FilterByDifficulty(difficulty string) []PatternSummary
- func (lib *Library) ListAll() []PatternSummary
- func (lib *Library) Load(name string) (*Pattern, error)
- func (lib *Library) Search(query string) []PatternSummary
- func (lib *Library) WithTracer(tracer observability.Tracer) *Library
- type Orchestrator
- func (o *Orchestrator) ClassifyIntent(userMessage string, ctxData map[string]interface{}) (IntentCategory, float64)
- func (o *Orchestrator) GetLibrary() *Library
- func (o *Orchestrator) GetRoutingRecommendation(intent IntentCategory) string
- func (o *Orchestrator) PlanExecution(intent IntentCategory, userMessage string, ctxData map[string]interface{}) (*ExecutionPlan, error)
- func (o *Orchestrator) RecommendPattern(userMessage string, intent IntentCategory) (string, float64)
- func (o *Orchestrator) RecordPatternUsage(ctx context.Context, patternName string, agentID string, success bool, ...)
- func (o *Orchestrator) SetExecutionPlanner(planner ExecutionPlannerFunc)
- func (o *Orchestrator) SetIntentClassifier(classifier IntentClassifierFunc)
- func (o *Orchestrator) SetLLMProvider(provider types.LLMProvider)
- func (o *Orchestrator) WithTracer(tracer observability.Tracer) *Orchestrator
- func (o *Orchestrator) WithTracker(tracker *learning.PatternEffectivenessTracker) *Orchestrator
- type Parameter
- type Pattern
- type PatternABTestingLibrary
- func (l *PatternABTestingLibrary) ClearCache()
- func (l *PatternABTestingLibrary) ListAll() []PatternSummary
- func (l *PatternABTestingLibrary) Load(ctx context.Context, name string) (*Pattern, error)
- func (l *PatternABTestingLibrary) LoadForSession(ctx context.Context, name string, sessionID string) (*Pattern, error)
- func (l *PatternABTestingLibrary) LoadWithVariant(ctx context.Context, name string, variant string) (*Pattern, error)
- type PatternEntryYAML
- type PatternLibrarySpecYAML
- type PatternLibraryYAML
- type PatternMetadata
- type PatternMetadataYAML
- type PatternRuleYAML
- type PatternSummary
- type PatternUpdateCallback
- type PlannedStep
- type Syntax
- type SyntaxOperator
- type Template
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPatternDomain ¶
GetPatternDomain retrieves the pattern domain from context. Returns empty string if no domain is set.
func GetPatternName ¶
GetPatternName retrieves the pattern name from context. Returns empty string if no pattern name is set.
func GetVariant ¶
GetVariant retrieves the pattern variant from context. Returns empty string if no variant is set.
func LoadPatternLibrary ¶
func LoadPatternLibrary(path string) (*loomv1.PatternLibrary, error)
LoadPatternLibrary loads a pattern library configuration from a YAML file
func NewCanarySelector ¶
func NewCanarySelector(controlVariant string, treatmentVariant string, treatmentPercentage float64) prompts.VariantSelector
NewCanarySelector creates a WeightedSelector for canary testing. This is a convenience function for the common 90/10 split.
Example:
selector := patterns.NewCanarySelector("control", "treatment", 0.10)
// Routes 10% to treatment, 90% to control
func WithPatternDomain ¶
WithPatternDomain adds a pattern domain to the context. This should be set when a pattern is about to be executed.
Example:
ctx = patterns.WithPatternDomain(ctx, "sql")
func WithPatternMetadata ¶
WithPatternMetadata is a convenience function that sets all pattern metadata in the context at once (name, variant, domain).
Example:
ctx = patterns.WithPatternMetadata(ctx, "sql.joins.optimize", "control", "sql")
func WithPatternName ¶
WithPatternName adds a pattern name to the context. This should be set when a pattern is about to be executed.
Example:
ctx = patterns.WithPatternName(ctx, "sql.joins.optimize")
func WithVariant ¶
WithVariant adds a pattern variant to the context. This should be set when a pattern variant is selected for execution.
Example:
ctx = patterns.WithVariant(ctx, "control") pattern, _ := library.LoadWithVariant(ctx, "sql.joins.optimize", "control")
Types ¶
type CanaryTestConfig ¶
type CanaryTestConfig struct {
PatternName string // Base pattern name (e.g., "sql.joins.optimize")
ControlVariant string // Usually "control" or "default"
TreatmentVariant string // Usually "treatment" or version number
TrafficPercentage float64 // 0.10 for 10% canary
DurationMinutes int // 30 for 30-minute canary test
}
CanaryTestConfig represents a canary test configuration. This is a specialized A/B test with 90/10 traffic split.
type CommonError ¶
type CommonError struct {
Error string `yaml:"error" json:"error"`
Cause string `yaml:"cause" json:"cause"`
Solution string `yaml:"solution" json:"solution"`
}
CommonError documents frequently encountered errors and solutions.
type Example ¶
type Example struct {
Name string `yaml:"name" json:"name"`
Description string `yaml:"description" json:"description"`
Parameters map[string]interface{} `yaml:"parameters" json:"parameters"`
ExpectedResult string `yaml:"expected_result" json:"expected_result"`
Notes string `yaml:"notes,omitempty" json:"notes,omitempty"`
}
Example provides a complete worked example with parameters and expected results.
type ExecutionPlan ¶
type ExecutionPlan struct {
Intent IntentCategory `json:"intent"`
Description string `json:"description"`
Steps []PlannedStep `json:"steps"`
Reasoning string `json:"reasoning"`
PatternName string `json:"pattern_name,omitempty"` // Recommended pattern to use
}
ExecutionPlan represents a planned sequence of operations. The orchestrator creates this plan based on classified intent.
type ExecutionPlannerFunc ¶
type ExecutionPlannerFunc func(intent IntentCategory, userMessage string, context map[string]interface{}) (*ExecutionPlan, error)
ExecutionPlannerFunc is a pluggable function for execution planning. Backends can provide custom planners for domain-specific execution strategies.
type HotReloadConfig ¶
type HotReloadConfig struct {
Enabled bool // Enable hot-reload
DebounceMs int // Debounce delay in milliseconds (default: 500ms)
Logger *zap.Logger // Logger for reload events
OnUpdate PatternUpdateCallback // Callback for pattern updates (optional)
}
HotReloadConfig configures hot-reload behavior for pattern library.
type HotReloader ¶
type HotReloader struct {
// contains filtered or unexported fields
}
HotReloader manages hot-reload for pattern library files.
func NewHotReloader ¶
func NewHotReloader(library *Library, config HotReloadConfig) (*HotReloader, error)
NewHotReloader creates a new hot-reloader for the pattern library.
func (*HotReloader) ManualReload ¶
func (hr *HotReloader) ManualReload(patternName string) error
ManualReload triggers a manual reload of a specific pattern. Useful for programmatic reload (e.g., after API-based pattern creation).
func (*HotReloader) Start ¶
func (hr *HotReloader) Start(ctx context.Context) error
Start begins watching for pattern file changes.
func (*HotReloader) WithTracer ¶
func (hr *HotReloader) WithTracer(tracer observability.Tracer) *HotReloader
WithTracer sets the observability tracer for the hot-reloader.
type IntentCategory ¶
type IntentCategory string
IntentCategory represents the classified intent of a user request. This is used by the orchestrator for routing and pattern selection.
const ( // Generic intent categories (backend-agnostic) IntentSchemaDiscovery IntentCategory = "schema_discovery" IntentDataQuality IntentCategory = "data_quality" IntentDataTransform IntentCategory = "data_transform" IntentAnalytics IntentCategory = "analytics" IntentRelationshipQuery IntentCategory = "relationship_query" IntentQueryGeneration IntentCategory = "query_generation" IntentDocumentSearch IntentCategory = "document_search" IntentAPICall IntentCategory = "api_call" IntentUnknown IntentCategory = "unknown" )
type IntentClassifierFunc ¶
type IntentClassifierFunc func(userMessage string, context map[string]interface{}) (IntentCategory, float64)
IntentClassifierFunc is a pluggable function for intent classification. Backends can provide custom classifiers for domain-specific intent detection.
func NewLLMIntentClassifier ¶
func NewLLMIntentClassifier(config *LLMClassifierConfig) IntentClassifierFunc
NewLLMIntentClassifier creates an LLM-based intent classifier. Returns an IntentClassifierFunc that can be plugged into the orchestrator.
Example usage:
llmClassifier := NewLLMIntentClassifier(config) orchestrator.SetIntentClassifier(llmClassifier)
type LLMClassifierConfig ¶
type LLMClassifierConfig struct {
// LLM provider to use for classification (should be configured with fast model like Haiku)
LLMProvider types.LLMProvider
// Enable caching of classifications (recommended)
EnableCache bool
// Cache TTL (default: 15 minutes)
CacheTTL time.Duration
}
LLMClassifierConfig configures the LLM intent classifier
func DefaultLLMClassifierConfig ¶
func DefaultLLMClassifierConfig(llm types.LLMProvider) *LLMClassifierConfig
DefaultLLMClassifierConfig returns sensible defaults. Note: The LLM provider should be pre-configured with a fast model (e.g., claude-haiku-3-5) for low-latency classification.
type LLMReRankerConfig ¶ added in v1.0.2
type LLMReRankerConfig struct {
// LLM provider to use for re-ranking
LLMProvider types.LLMProvider
// Enable caching of re-ranking results
EnableCache bool
// Cache TTL (default: 30 minutes - longer than intent classification)
CacheTTL time.Duration
}
LLMReRankerConfig configures the LLM-based pattern re-ranker
func DefaultLLMReRankerConfig ¶ added in v1.0.2
func DefaultLLMReRankerConfig(llm types.LLMProvider) *LLMReRankerConfig
DefaultLLMReRankerConfig returns sensible defaults for re-ranking
type Library ¶
type Library struct {
// contains filtered or unexported fields
}
Library manages pattern loading, caching, and search. It supports both embedded patterns (compiled into binary) and filesystem patterns (loaded at runtime).
func NewLibrary ¶
NewLibrary creates a new pattern library. If embeddedFS is provided, patterns will be loaded from embedded filesystem. If patternsDir is provided, patterns will be loaded from filesystem. Both can be provided - embedded patterns are checked first, then filesystem.
func (*Library) AddSearchPath ¶
AddSearchPath adds a custom search path for pattern discovery.
func (*Library) ClearCache ¶
func (lib *Library) ClearCache()
ClearCache clears the in-memory pattern cache. Useful for testing or hot-reloading patterns.
func (*Library) FilterByBackendType ¶
func (lib *Library) FilterByBackendType(backendType string) []PatternSummary
FilterByBackendType returns patterns for a specific backend type.
func (*Library) FilterByCategory ¶
func (lib *Library) FilterByCategory(category string) []PatternSummary
FilterByCategory returns patterns matching the specified category.
func (*Library) FilterByDifficulty ¶
func (lib *Library) FilterByDifficulty(difficulty string) []PatternSummary
FilterByDifficulty returns patterns matching the specified difficulty level.
func (*Library) ListAll ¶
func (lib *Library) ListAll() []PatternSummary
ListAll returns metadata for all available patterns. Results are cached for performance.
func (*Library) Load ¶
Load reads a pattern by name. Patterns are cached after first load for performance. Searches in order: cache → embedded FS → filesystem.
func (*Library) Search ¶
func (lib *Library) Search(query string) []PatternSummary
Search performs free-text search across pattern metadata. Tokenizes the query and matches individual keywords for better recall.
func (*Library) WithTracer ¶
func (lib *Library) WithTracer(tracer observability.Tracer) *Library
WithTracer sets the observability tracer for the library.
type Orchestrator ¶
type Orchestrator struct {
// contains filtered or unexported fields
}
Orchestrator performs intent classification and execution planning. It's the top-level routing layer that determines which tools/patterns to use.
func NewOrchestrator ¶
func NewOrchestrator(library *Library) *Orchestrator
NewOrchestrator creates a new orchestrator with the given library.
func (*Orchestrator) ClassifyIntent ¶
func (o *Orchestrator) ClassifyIntent(userMessage string, ctxData map[string]interface{}) (IntentCategory, float64)
ClassifyIntent analyzes user message and determines intent category. Returns intent category and confidence score (0.0-1.0). Uses pluggable classifier if set, otherwise uses default keyword-based classifier.
func (*Orchestrator) GetLibrary ¶
func (o *Orchestrator) GetLibrary() *Library
GetLibrary returns the pattern library.
func (*Orchestrator) GetRoutingRecommendation ¶
func (o *Orchestrator) GetRoutingRecommendation(intent IntentCategory) string
GetRoutingRecommendation provides intelligent routing suggestions. This helps the LLM choose the most efficient tool/pattern combination.
func (*Orchestrator) PlanExecution ¶
func (o *Orchestrator) PlanExecution(intent IntentCategory, userMessage string, ctxData map[string]interface{}) (*ExecutionPlan, error)
PlanExecution creates an execution plan based on classified intent. Uses pluggable planner if set, otherwise uses default generic planner.
func (*Orchestrator) RecommendPattern ¶
func (o *Orchestrator) RecommendPattern(userMessage string, intent IntentCategory) (string, float64)
RecommendPattern suggests a pattern from the library based on user message and intent. Returns pattern name and confidence score (0.0-1.0).
func (*Orchestrator) RecordPatternUsage ¶
func (o *Orchestrator) RecordPatternUsage( ctx context.Context, patternName string, agentID string, success bool, costUSD float64, latency time.Duration, errorType string, llmProvider string, llmModel string, )
RecordPatternUsage records pattern usage metrics to the effectiveness tracker. This should be called after a pattern is executed to capture success/failure, cost, latency, etc.
Parameters:
- ctx: Context containing pattern metadata (variant, domain via context helpers)
- patternName: Name of the pattern that was executed
- agentID: ID of the agent that executed the pattern
- success: Whether execution succeeded
- costUSD: Cost of execution in USD
- latency: Execution duration
- errorType: Type of error if failed (empty if success)
- llmProvider: LLM provider used (e.g., "anthropic", "bedrock")
- llmModel: LLM model used (e.g., "claude-3-5-sonnet-20241022")
The method extracts variant and domain from context using GetPatternMetadata(). If no tracker is configured, this is a no-op.
func (*Orchestrator) SetExecutionPlanner ¶
func (o *Orchestrator) SetExecutionPlanner(planner ExecutionPlannerFunc)
SetExecutionPlanner sets a custom execution planner function. Backends can provide domain-specific planners for optimized execution.
func (*Orchestrator) SetIntentClassifier ¶
func (o *Orchestrator) SetIntentClassifier(classifier IntentClassifierFunc)
SetIntentClassifier sets a custom intent classifier function. Backends can provide domain-specific classifiers for better accuracy.
func (*Orchestrator) SetLLMProvider ¶ added in v1.0.2
func (o *Orchestrator) SetLLMProvider(provider types.LLMProvider)
SetLLMProvider sets the LLM provider for pattern re-ranking. When set, enables hybrid approach: fast keyword matching + LLM re-ranking for ambiguous cases.
func (*Orchestrator) WithTracer ¶
func (o *Orchestrator) WithTracer(tracer observability.Tracer) *Orchestrator
WithTracer sets the observability tracer for the orchestrator.
func (*Orchestrator) WithTracker ¶
func (o *Orchestrator) WithTracker(tracker *learning.PatternEffectivenessTracker) *Orchestrator
WithTracker sets the pattern effectiveness tracker for the orchestrator. When set, the orchestrator will record pattern usage metrics after execution.
type Parameter ¶
type Parameter struct {
Name string `yaml:"name" json:"name"`
Type string `yaml:"type" json:"type"` // "string", "number", "array", "object"
Required bool `yaml:"required" json:"required"`
Description string `yaml:"description" json:"description"`
Example string `yaml:"example" json:"example"`
DefaultValue string `yaml:"default,omitempty" json:"default,omitempty"`
}
Parameter defines a single parameter used in pattern templates.
type Pattern ¶
type Pattern struct {
// Metadata
Name string `yaml:"name" json:"name"`
Title string `yaml:"title" json:"title"`
Description string `yaml:"description" json:"description"`
Category string `yaml:"category" json:"category"` // e.g., "analytics", "etl", "ml", "rest_api"
Difficulty string `yaml:"difficulty" json:"difficulty"` // "beginner", "intermediate", "advanced"
BackendType string `yaml:"backend_type" json:"backend_type"` // "sql", "rest", "document", etc.
// Use cases and related patterns
UseCases []string `yaml:"use_cases" json:"use_cases"`
RelatedPatterns []string `yaml:"related_patterns,omitempty" json:"related_patterns,omitempty"`
// Pattern definition
Parameters []Parameter `yaml:"parameters" json:"parameters"`
Templates map[string]Template `yaml:"templates" json:"templates"`
Examples []Example `yaml:"examples" json:"examples"`
CommonErrors []CommonError `yaml:"common_errors,omitempty" json:"common_errors,omitempty"`
BestPractices string `yaml:"best_practices,omitempty" json:"best_practices,omitempty"`
// Backend-specific syntax documentation (optional)
Syntax *Syntax `yaml:"syntax,omitempty" json:"syntax,omitempty"`
// Backend-specific function name (e.g., Teradata nPath, Postgres jsonb_path_query)
BackendFunction string `yaml:"backend_function,omitempty" json:"backend_function,omitempty"`
}
Pattern represents a comprehensive execution pattern definition. Patterns encapsulate domain knowledge for complex operations (SQL, REST APIs, document processing, etc.). This is backend-agnostic - SQL patterns, REST API patterns, document patterns all use this structure.
func (*Pattern) FormatForLLM ¶
FormatForLLM formats the pattern for LLM injection. Returns concise, actionable representation optimized for token efficiency. Target: <2000 tokens per pattern.
type PatternABTestingLibrary ¶
type PatternABTestingLibrary struct {
// contains filtered or unexported fields
}
PatternABTestingLibrary wraps a pattern Library with automatic variant selection. This enables A/B testing and canary deployments for patterns.
Canary testing is implemented as A/B testing with weighted selection:
- Control version (current): 90% traffic
- Treatment version (new): 10% traffic
Example:
library := patterns.NewLibrary()
selector := prompts.NewWeightedSelector(map[string]int{
"control": 90,
"treatment": 10,
}, 0)
abLibrary := patterns.NewPatternABTestingLibrary(library, selector)
// Automatically routes 10% to treatment variant
pattern, _ := abLibrary.LoadForSession(ctx, "sql.joins.optimize", "sess-123")
func NewPatternABTestingLibrary ¶
func NewPatternABTestingLibrary(underlying *Library, selector prompts.VariantSelector) *PatternABTestingLibrary
NewPatternABTestingLibrary creates an A/B testing wrapper around a pattern library.
func (*PatternABTestingLibrary) ClearCache ¶
func (l *PatternABTestingLibrary) ClearCache()
ClearCache clears the underlying library's pattern cache. This forces patterns to be reloaded on next access.
func (*PatternABTestingLibrary) ListAll ¶
func (l *PatternABTestingLibrary) ListAll() []PatternSummary
ListAll lists all pattern summaries (including variants) from the underlying library.
func (*PatternABTestingLibrary) Load ¶
Load retrieves a pattern with automatic variant selection based on context. Uses "default" as session ID if not found in context.
func (*PatternABTestingLibrary) LoadForSession ¶
func (l *PatternABTestingLibrary) LoadForSession(ctx context.Context, name string, sessionID string) (*Pattern, error)
LoadForSession retrieves a pattern with variant selection based on session ID. This enables deterministic A/B testing - same session always gets same variant.
func (*PatternABTestingLibrary) LoadWithVariant ¶
func (l *PatternABTestingLibrary) LoadWithVariant(ctx context.Context, name string, variant string) (*Pattern, error)
LoadWithVariant retrieves a specific pattern variant (bypasses selector). This is useful for:
- Explicit variant selection (manual A/B testing)
- Rollback scenarios (force control variant)
- Testing specific variants
type PatternEntryYAML ¶
type PatternEntryYAML struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
TriggerConditions []string `yaml:"trigger_conditions"`
Template string `yaml:"template"`
Example string `yaml:"example"`
Rule *PatternRuleYAML `yaml:"rule"`
Priority int `yaml:"priority"`
Tags []string `yaml:"tags"`
}
type PatternLibrarySpecYAML ¶
type PatternLibrarySpecYAML struct {
Entries []PatternEntryYAML `yaml:"entries"`
}
type PatternLibraryYAML ¶
type PatternLibraryYAML struct {
APIVersion string `yaml:"apiVersion"`
Kind string `yaml:"kind"`
Metadata PatternMetadataYAML `yaml:"metadata"`
Spec PatternLibrarySpecYAML `yaml:"spec"`
}
PatternLibraryYAML represents the YAML structure for pattern library configuration
type PatternMetadata ¶
PatternMetadata is a convenience struct for extracting all pattern metadata from context.
func GetPatternMetadata ¶
func GetPatternMetadata(ctx context.Context) PatternMetadata
GetPatternMetadata extracts all pattern metadata from context. Returns a PatternMetadata struct with all available information.
Example:
metadata := patterns.GetPatternMetadata(ctx)
if metadata.Name != "" {
// Pattern metadata available
}
type PatternMetadataYAML ¶
type PatternRuleYAML ¶
type PatternSummary ¶
type PatternSummary struct {
Name string `json:"name"`
Title string `json:"title"`
Description string `json:"description"` // Truncated for listing
Category string `json:"category"`
Difficulty string `json:"difficulty"`
BackendType string `json:"backend_type"`
UseCases []string `json:"use_cases"`
BackendFunction string `json:"backend_function,omitempty"`
}
PatternSummary provides lightweight metadata for catalog listing.
type PatternUpdateCallback ¶
PatternUpdateCallback is called when a pattern is created, modified, or deleted. Parameters: eventType (create/modify/delete), patternName, filePath, error (if validation failed).
type PlannedStep ¶
type PlannedStep struct {
ToolName string `json:"tool_name"`
Params map[string]string `json:"params"`
Description string `json:"description"`
PatternHint string `json:"pattern_hint,omitempty"` // Suggested pattern to apply
}
PlannedStep represents a single step in an execution plan.
type Syntax ¶
type Syntax struct {
Description string `yaml:"description" json:"description"`
Operators []SyntaxOperator `yaml:"operators" json:"operators"`
}
Syntax documents pattern-specific syntax rules (e.g., nPath pattern operators, JSONPath syntax).
type SyntaxOperator ¶
type SyntaxOperator struct {
Symbol string `yaml:"symbol" json:"symbol"`
Meaning string `yaml:"meaning" json:"meaning"`
Example string `yaml:"example" json:"example"`
}
SyntaxOperator describes a single pattern syntax operator.
type Template ¶
type Template struct {
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Content string `yaml:"content,omitempty" json:"content,omitempty"` // Template content (SQL, JSON, etc.)
SQL string `yaml:"sql,omitempty" json:"sql,omitempty"` // Alternative field for "content"
RequiredParameters []string `yaml:"required_parameters,omitempty" json:"required_parameters,omitempty"`
OutputFormat string `yaml:"output_format,omitempty" json:"output_format,omitempty"` // "table", "json", "text"
}
Template represents a parameterized execution template with placeholders. For SQL: SQL string with {{param}} placeholders For REST: request body template For Documents: query template
func (*Template) UnmarshalYAML ¶
UnmarshalYAML handles both simple string templates and rich template objects