/* engram_text.h — text handling for the engram: query tokenization, candidate * token hygiene, word-boundary matching, and the text-damage signature. * * WHY THIS FILE EXISTS * -------------------- * These functions lived in el_runtime.c, which is a 2026-05-03 build shim that * was scheduled for deletion, never retired, and grew to 20,527 lines. They do * not belong there: they touch no EL value type and no engram store type. They * are plain C over / operating on char buffers, and they are * a concern of their own — so they get a translation unit of their own. * * Adding a new text helper? Add it HERE, not to el_runtime.c. A new .c costs * exactly one line in lang/runtime/SOURCES, and every build path picks it up. * Placement is a LINK-TIME concern: the compiler cannot tell which .c a symbol * came from (builtin_arity is an arity guard, not a dispatch table), so a * function defined here is exactly as linkable as one defined in el_runtime.c. */ #ifndef ENGRAM_TEXT_H #define ENGRAM_TEXT_H #include #ifdef __cplusplus extern "C" { #endif /* Max bytes per query token, including the NUL. */ #define ENGRAM_QTOK_LEN 256 /* Split q on whitespace into up to ENGRAM_MAX_QTOKENS distinct * (case-insensitive) tokens. Returns the token count. Over-long tokens are * truncated to ENGRAM_QTOK_LEN-1; over-count tokens are ignored. */ int engram_tokenize_query(const char* q, char toks[][ENGRAM_QTOK_LEN], int maxtok); /* Trim leading/trailing non-alphanumerics, then accept only tokens whose core * is alphanumeric plus '-' and '_' with at least 3 letters. This subsumes the * quoted-title guard (2026-07-25) and the "