Skip to main content

sdivi_patterns/
hint_input.rs

1//! [`PatternHintInput`] — WASM-safe input struct for [`crate::queries::classify_hint`].
2
3use serde::{Deserialize, Serialize};
4
5/// A minimal hint struct for callee-text classification.
6///
7/// This is the pure-compute counterpart to `sdivi_parsing::feature_record::PatternHint`.
8/// It contains only the two fields that [`crate::queries::classify_hint`] inspects:
9/// the tree-sitter `node_kind` and the truncated source `text` of the node.
10///
11/// Foreign extractors (WASM consumers, Meridian) construct `PatternHintInput` directly.
12/// The native pipeline uses `PatternHint` from `sdivi-parsing`; M33 will add a
13/// conversion when the pipeline is wired to `classify_hint`.
14///
15/// `text` is truncated to 256 bytes upstream (per the `PatternHint` contract).
16/// `classify_hint` matches only the callee prefix, so truncation never affects
17/// classification correctness.
18///
19/// # Examples
20///
21/// ```rust
22/// use sdivi_patterns::PatternHintInput;
23///
24/// let hint = PatternHintInput {
25///     node_kind: "call_expression".to_string(),
26///     text: "console.log(\"hello\")".to_string(),
27/// };
28/// assert_eq!(hint.node_kind, "call_expression");
29/// ```
30#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
31pub struct PatternHintInput {
32    /// The tree-sitter node kind (e.g. `"call_expression"`, `"macro_invocation"`).
33    pub node_kind: String,
34    /// Source text of the node, truncated to 256 bytes if the original is longer.
35    pub text: String,
36}