1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! Hooks for RLM event capture by external agents.
//!
//! This module defines structured events that external systems (like
//! terraphim-agent) can subscribe to for learning capture, security auditing,
//! and observability without tight coupling to the execution engine.
//!
//! ## Usage
//!
//! ```rust,ignore
//! use terraphim_rlm::hooks::{ValidationEvent, emit_validation_event};
//!
//! // Events are logged at warn level and can be captured by agent hooks.
//! emit_validation_event(ValidationEvent {
//! input: "ls -la".to_string(),
//! unknown_terms: vec!["ls".to_string(), "la".to_string()],
//! matched_terms: vec!["list".to_string()],
//! retry_count: 1,
//! passed: false,
//! });
//! ```
use ;
/// A validation event emitted when KG validation runs on a command.
///
/// External agents (terraphim-agent, security monitors) can capture these
/// events via log scraping or a registered callback to build learning
/// databases and security audit trails.
/// Emit a validation event for external capture.
///
/// Currently logs at `warn` level with structured fields suitable for
/// log-based agents. In future, this could dispatch to a registered callback
/// or event bus.