-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
Enhance the learning capture system to annotate failed command error messages with entities from the knowledge graph using existing terraphim_automata Aho-Corasick matching. This makes learn query semantically aware -- enabling searches by entity type/label, not just raw text.
Context
- Plan:
plans/quickner-terraphim-learning-integration.md(Phase 1) - The learning system (
terraphim_github_runner::learning) already capturesFailureTracker,SuccessPattern, andApplicableLessonrecords terraphim_automata::matcher::find_matches()already provides fast Aho-Corasick matching against KG terms- These two systems are not yet connected
Current Behaviour
learn capturerecords failed command + error output as plain textlearn query "pattern"does basic text matching against stored failures- No entity-level annotation on error messages
- No ability to filter by entity type (e.g. "show all failures involving
cargo clippy" requires exact string match)
Proposed Behaviour
- When
learn capturerecords a failed command + error output, runterraphim_automata::find_matches()against the error text using the active role's thesaurus - Store matched entities (term, normalised_term, positions) alongside
FailureTrackerrecords - Enhance
learn queryto support entity-based filtering:learn query --entity "cargo"-- find failures where "cargo" was matched as a KG entitylearn query --label "CLI Tool"-- find failures annotated with a specific entity label
- Existing plain-text
learn query "pattern"continues to work unchanged
Implementation Notes
Data Model Changes
Add to FailureTracker:
pub struct AnnotatedFailure {
// existing fields...
pub matched_entities: Vec<MatchedEntity>,
}
pub struct MatchedEntity {
pub term: String,
pub label: String, // from NormalizedTerm
pub positions: Vec<(usize, usize)>,
}Integration Points
learn capture/learn hook: After recording failure, callfind_matches(error_text, thesaurus, true)to annotatelearn query: Add--entityand--labelfilter flagslearn list: Optionally display matched entities alongside each entry- Thesaurus loading: Use the command thesaurus from
learning/thesaurus.rsplus the active role's KG thesaurus
Pre-seeded Command Thesaurus
The existing learning/thesaurus.rs already contains normalised command patterns (cargo, git, npm, docker, etc.). These become the entity dictionary for annotation -- no additional KG setup required.
Acceptance Criteria
-
learn captureannotates error messages with matched KG entities -
learn hook(PostToolUse integration) also annotates -
learn query --entity <term>filters by matched entity -
learn query --label <label>filters by entity label/type - Existing
learn query "text"behaviour unchanged -
learn listshows entity annotations when present - Unit tests for annotation pipeline
- Integration test: capture a failure, verify entities extracted, query by entity
Estimated Effort
2-3 days
Relates To
- Quickner evaluation: https://github.com/terraphim/quickner (Phase 2 would use this for spaCy/CoNLL export)
- Knowledge base entry:
knowledge/external/learning-rust/quickner-fast-ner-annotator-rust.md
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request