What a competence record stores
Trigger declares a signal (for example, an error signature or intent label) and optional matching conditions:
RecipeStep describes a single action in the procedure:
Extraction from episodic traces
Competence records are created automatically by the consolidation pipeline (pkg/consolidation/competence.go). The pipeline:
Collect successful episodes with tool graphs
The consolidator scans all episodic records. It selects only those with
outcome: success and a non-empty tool_graph.Group by tool signature
Each episode is assigned a signature derived from its sorted tool names (e.g.,
go_build+go_test+lint). Episodes sharing the same signature are grouped together.Check minimum occurrences
A competence record is only created when a pattern appears in at least 2 successful episodes (
minPatternOccurrences = 2). Single occurrences are ignored.derived_from relations.
Success rate tracking
ThePerformanceStats struct tracks success and failure counts:
How Reinforce and Penalize affect success rate
| Operation | Effect on salience | Effect on success rate |
|---|---|---|
Reinforce | +ReinforcementGain (capped at 1.0) | Not directly modified; success rate is updated by the application when recording outcomes |
Penalize | −amount (floored at MinSalience) | Not directly modified |
success_rate field is intended to be updated by the application layer when outcomes are recorded. The consolidation pipeline initializes it to 1.0 when first creating a competence record from only successful episodes.
Selector and confidence threshold
When a retrieval query includes competence records as candidates, theSelector ranks them using three equally weighted signals:
- Applicability — the record’s
Confidencefield, or a vector similarity score if pgvector is enabled. - Observed success rate — from
PerformanceStats.SuccessRate. - Recency of reinforcement — exponential decay on the time since
last_reinforced_at(30-day half-life).
SelectionConfidenceThreshold, default 0.7) determines whether the selector has enough certainty to recommend the top candidate. If the normalized score gap between the best and second-best candidate falls below this threshold, SelectionResult.NeedsMore is set to true, signaling that user disambiguation or additional context may help.
Vector-based applicability scoring
On the Postgres + pgvector tier (Tier 3 and above), the selector can replace therecord.Confidence proxy with actual embedding similarity:
embedding_endpoint is configured. Configure it in config.yaml:
Example: storing and retrieving a procedure
Competence record lifecycle
Auto-created
Created by the consolidation pipeline from repeated successful tool patterns. Requires no manual authoring.
Success-tracked
Tracks
success_count, failure_count, and success_rate across uses.Revisable
Can be superseded, forked, contested, retracted, or merged like any non-episodic record.
Selector-ranked
Ranked by applicability, success rate, and recency during retrieval.