.TH "ttypt/lemma.h" 3 "lemma" \" -*- nroff -*- .ad l .nh .SH NAME ttypt/lemma.h \- lemma — corm-backed full-text index\&. .SH SYNOPSIS .br .PP \fR#include \fP .br \fR#include \fP .br \fR#include \fP .br .SS "Data Structures" .in +1c .ti -1c .RI "struct \fBlemma_rank_ctx\fP" .br .RI "Context for the lemma_rank FTS score function\&. " .in -1c .SS "Macros" .in +1c .ti -1c .RI "#define \fBLEMMA_AXIS_TEXT_FIELD\fP 'text'" .br .RI "Canonical single-facet field for the store/unstore/readback adapters\&. " .in -1c .SS "Typedefs" .in +1c .ti -1c .RI "typedef struct lemma_db \fBlemma_db_t\fP" .br .RI "Opaque full-text index handle\&. " .in -1c .SS "Functions" .in +1c .ti -1c .RI "int \fBlemma_fold\fP (char *out, size_t outsz, const char *in)" .br .RI "Fold a UTF-8 string to lowercase, preserving accents\&. " .ti -1c .RI "\fBlemma_db_t\fP * \fBlemma_open\fP (unsigned mask)" .br .RI "Open an index\&. " .ti -1c .RI "void * \fBrec_axis_open\fP (const char *spec)" .br .RI "Open a lemma index from an opaque spec string\&. " .ti -1c .RI "void \fBlemma_close\fP (\fBlemma_db_t\fP *db)" .br .RI "Close the index and free all resources\&. " .ti -1c .RI "void \fBlemma_clear\fP (\fBlemma_db_t\fP *db)" .br .RI "Drop all entries; the handle stays valid\&. " .ti -1c .RI "int \fBlemma_index\fP (\fBlemma_db_t\fP *db, const char *field, const char *row_id, const char *value)" .br .RI "Index every token of \fRvalue\fP under (field, row_id)\&. " .ti -1c .RI "int \fBlemma_index_ref\fP (\fBlemma_db_t\fP *db, const char *field, rec_ref_t row_id, const char *value)" .br .RI "rec_ref_t-native convenience wrapper for lemma_index\&. " .ti -1c .RI "int \fBlemma_unindex\fP (\fBlemma_db_t\fP *db, const char *field, const char *row_id)" .br .RI "Remove every posting for (field, row_id) plus the doc side-table\&. " .ti -1c .RI "int \fBlemma_unindex_ref\fP (\fBlemma_db_t\fP *db, const char *field, rec_ref_t row_id)" .br .RI "rec_ref_t-native convenience wrapper for lemma_unindex\&. " .ti -1c .RI "int \fBrec_axis_store\fP (void *ctx, const char *spec, rec_ref_t ref, const char *value)" .br .RI "Store a ref's whole value text (rec_axis_store convention)\&. " .ti -1c .RI "int \fBrec_axis_unstore\fP (void *ctx, rec_ref_t ref)" .br .RI "Remove a ref's stored doc (rec_axis_unstore)\&. " .ti -1c .RI "int \fBrec_axis_readback\fP (void *ctx, rec_ref_t ref, char **blob_out, size_t *n_out)" .br .RI "Read a ref's stored (folded) text (rec_axis_readback)\&. " .ti -1c .RI "uint32_t \fBlemma_query\fP (\fBlemma_db_t\fP *db, const char *field, const char *query, uint32_t out_hd, int *handled)" .br .RI "Query: every token of \fRquery\fP must prefix-match in \fRfield\fP\&. " .ti -1c .RI "uint32_t \fBlemma_query_phrase\fP (\fBlemma_db_t\fP *db, const char *field, const char *query, uint32_t out_hd, int *handled)" .br .RI "Phrase query: prefix-match with contiguous subsequence ordering\&. " .ti -1c .RI "int \fBrec_axis_fill_tokens\fP (\fBlemma_db_t\fP *db, const char *field, const char *query, int phrase, rec_set_t *out)" .br .RI "Recall-kernel lexical filler (adapter contract, see rec\&.h)\&. " .ti -1c .RI "int \fBlemma_rank\fP (struct \fBlemma_rank_ctx\fP *ctx, rec_ref_t ref, float *score)" .br .RI "FTS score function for the recall-kernel rank loop\&. " .ti -1c .RI "void \fBlemma_tokenize\fP (const char *folded, void(*cb)(const char *tok, size_t len, void *user), void *user)" .br .RI "Tokenize non-whitespace word tokens in \fRfolded\fP\&. " .ti -1c .RI "int \fBlemma_list_normalize\fP (const char *input, char *out, size_t out_sz)" .br .RI "Normalize a newline-separated token list\&. " .ti -1c .RI "int \fBlemma_list_contains\fP (const char *list, const char *token)" .br .RI "Check if a newline-separated list contains \fRtoken\fP\&. " .ti -1c .RI "int \fBlemma_list_append\fP (char *out, size_t out_sz, const char *token)" .br .RI "Append a token to a newline-separated list if not already present\&. " .ti -1c .RI "const lemma_tok_vocab_t * \fBlemma_tok_vocab_default\fP (void)" .br .RI "Initialize or obtain the shared global/default vocabulary\&. " .ti -1c .RI "lemma_tok_vocab_t * \fBlemma_tok_vocab_new\fP (const lemma_tok_vocab_t *base)" .br .RI "Create a dynamic vocabulary instance (optionally extending a base vocab)\&. " .ti -1c .RI "void \fBlemma_tok_vocab_free\fP (lemma_tok_vocab_t *v)" .br .RI "Free a dynamic vocabulary instance\&. " .ti -1c .RI "int \fBlemma_tok_vocab_load_file\fP (lemma_tok_vocab_t *v, const char *filepath)" .br .RI "Load additional words from a plaintext wordlist file into a dynamic vocabulary\&. " .ti -1c .RI "int \fBlemma_tok_encode\fP (const lemma_tok_vocab_t *vocab, const char *src, size_t src_len, uint16_t *dst, size_t dst_cap, size_t *dst_len)" .br .RI "Encode a text string losslessly into an array of 16-bit token IDs\&. " .ti -1c .RI "int \fBlemma_tok_decode\fP (const lemma_tok_vocab_t *vocab, const uint16_t *tokens, size_t n_tokens, char *dst, size_t dst_cap, size_t *bytes_written)" .br .RI "Decode an array of 16-bit token IDs losslessly into a character buffer\&. " .ti -1c .RI "int \fBlemma_tok_vocab_match\fP (const lemma_tok_vocab_t *vocab, const char *term, int max_edit_distance, uint16_t *out_token_ids, size_t out_cap, size_t *out_count)" .br .RI "Query the vocabulary for fuzzy or substring matching token IDs (Tier 1)\&. " .ti -1c .RI "int \fBlemma_tok_is_word\fP (const lemma_tok_vocab_t *vocab, uint16_t token_id)" .br .RI "Check if a token ID represents a searchable word (vs delimiter/whitespace/raw byte)\&. " .ti -1c .RI "int \fBlemma_levenshtein\fP (const char *s1, size_t l1, const char *s2, size_t l2)" .br .RI "Compute Levenshtein edit distance between two strings\&. " .ti -1c .RI "int \fBlemma_index_tokens\fP (\fBlemma_db_t\fP *db, const char *field, const char *row_id, const uint16_t *tokens, size_t n_tokens)" .br .RI "Index a pre-tokenized token stream under (field, row_id)\&. " .ti -1c .RI "uint32_t \fBlemma_query_fuzzy\fP (\fBlemma_db_t\fP *db, const char *field, const char *query, int max_edit_distance, uint32_t out_hd, int *handled)" .br .RI "Fuzzy query: match with Levenshtein edit distance tolerance\&. " .ti -1c .RI "int \fBrec_axis_store_typed\fP (void *ctx, const char *spec, rec_ref_t ref, const void *blob, size_t len, uint32_t qtype)" .br .RI "Conventional typed axis store plugin export for libcorm\&. " .in -1c .SH "Detailed Description" .PP lemma — corm-backed full-text index\&. A generic inverted index over (field, token) → row_id\&. It knows nothing about rows, schemas, or the application: callers choose which fields to index and interpret row_ids\&. Match semantics are word-token based with prefix expansion: a query token must match the start of an indexed token\&. Multiple tokens in a query are ANDed\&. .SH "Macro Definition Documentation" .PP .SS "#define LEMMA_AXIS_TEXT_FIELD 'text'" .PP Canonical single-facet field for the store/unstore/readback adapters\&. RECALL-KERNEL\&.md, Phase 2A per-axis role "lemma": the whole value string's text\&. Multi-facet indexing stays raw native (lemma_index / lemma_unindex per field)\&. .SH "Function Documentation" .PP .SS "void lemma_clear (\fBlemma_db_t\fP * db)" .PP Drop all entries; the handle stays valid\&. .PP \fBParameters\fP .RS 4 \fIdb\fP Index handle\&. .RE .PP .SS "void lemma_close (\fBlemma_db_t\fP * db)" .PP Close the index and free all resources\&. .PP \fBParameters\fP .RS 4 \fIdb\fP Index handle\&. .RE .PP .SS "int lemma_fold (char * out, size_t outsz, const char * in)" .PP Fold a UTF-8 string to lowercase, preserving accents\&. Accent-sensitive search: ASCII A-Z and the Latin-1 Supplement uppercase letters are lowercased; all other bytes are copied verbatim\&. The fold is locale-independent (no iconv, no setlocale) and never grows the output, so it fits whenever outsz > strlen(in)\&. .PP \fBParameters\fP .RS 4 \fIout\fP Output buffer\&. .br \fIoutsz\fP Capacity of \fRout\fP\&. .br \fIin\fP Input string\&. .RE .PP \fBReturns\fP .RS 4 Number of bytes written, or -1 if the output buffer is too small (the caller falls back to raw comparison)\&. .RE .PP .SS "int lemma_index (\fBlemma_db_t\fP * db, const char * field, const char * row_id, const char * value)" .PP Index every token of \fRvalue\fP under (field, row_id)\&. Duplicate tokens collapse automatically\&. .PP \fBParameters\fP .RS 4 \fIdb\fP Index handle\&. .br \fIfield\fP Field name\&. .br \fIrow_id\fP Row id string\&. .br \fIvalue\fP Text to tokenize and index\&. .RE .PP \fBReturns\fP .RS 4 0 on success, -1 on invalid arguments\&. .RE .PP .SS "int lemma_index_ref (\fBlemma_db_t\fP * db, const char * field, rec_ref_t row_id, const char * value)" .PP rec_ref_t-native convenience wrapper for lemma_index\&. Shared with libjoint/libsepal/libislet's rec_axis_fill_* functions at the id-uniformity boundary: formats row_id as the canonical decimal string lemma_rank/rec_axis_fill_tokens expect and calls lemma_index\&. This does not change lemma's storage or key format, and does not remove the generic string-row_id path (lemma_index proper) — it only saves every rec_ref_t-keyed caller from doing its own decimal formatting before indexing\&. Same return contract as lemma_index\&. .PP \fBParameters\fP .RS 4 \fIdb\fP Index handle\&. .br \fIfield\fP Field name\&. .br \fIrow_id\fP Row ref\&. .br \fIvalue\fP Text to tokenize and index\&. .RE .PP \fBReturns\fP .RS 4 0 on success, -1 on invalid arguments\&. .RE .PP .SS "int lemma_index_tokens (\fBlemma_db_t\fP * db, const char * field, const char * row_id, const uint16_t * tokens, size_t n_tokens)" .PP Index a pre-tokenized token stream under (field, row_id)\&. Enforces Selective Lexical Indexing: only Word tokens (lemma_tok_is_word) generate inverted index postings, filtering delimiters and whitespace\&. Stores the token sequence for ultra-fast phrase adjacency checking without duplicate folded string tables\&. .PP \fBParameters\fP .RS 4 \fIdb\fP Index handle\&. .br \fIfield\fP Field name\&. .br \fIrow_id\fP Row id string\&. .br \fItokens\fP Array of token IDs\&. .br \fIn_tokens\fP Count of tokens\&. .RE .PP \fBReturns\fP .RS 4 0 on success, -1 on invalid arguments\&. .RE .PP .SS "int lemma_levenshtein (const char * s1, size_t l1, const char * s2, size_t l2)" .PP Compute Levenshtein edit distance between two strings\&. .PP \fBParameters\fP .RS 4 \fIs1\fP First string\&. .br \fIl1\fP Length of first string\&. .br \fIs2\fP Second string\&. .br \fIl2\fP Length of second string\&. .RE .PP \fBReturns\fP .RS 4 Levenshtein distance (insertions, deletions, substitutions)\&. .RE .PP .SS "int lemma_list_append (char * out, size_t out_sz, const char * token)" .PP Append a token to a newline-separated list if not already present\&. .PP \fBParameters\fP .RS 4 \fIout\fP Destination list buffer\&. .br \fIout_sz\fP Capacity of \fRout\fP\&. .br \fItoken\fP Token to append\&. .RE .PP \fBReturns\fP .RS 4 0 on success, -1 on buffer overflow\&. .RE .PP .SS "int lemma_list_contains (const char * list, const char * token)" .PP Check if a newline-separated list contains \fRtoken\fP\&. .PP \fBParameters\fP .RS 4 \fIlist\fP Newline-separated list\&. .br \fItoken\fP Token to find\&. .RE .PP \fBReturns\fP .RS 4 1 if present, 0 otherwise\&. .RE .PP .SS "int lemma_list_normalize (const char * input, char * out, size_t out_sz)" .PP Normalize a newline-separated token list\&. Splits on newlines/CR, trims tokens, and appends deduplicated non-empty tokens into \fRout\fP separated by ' .br '\&. .PP \fBParameters\fP .RS 4 \fIinput\fP Input list\&. .br \fIout\fP Destination buffer\&. .br \fIout_sz\fP Capacity of \fRout\fP\&. .RE .PP \fBReturns\fP .RS 4 0 on success, -1 on buffer overflow\&. .RE .PP .SS "\fBlemma_db_t\fP * lemma_open (unsigned mask)" .PP Open an index\&. .PP \fBParameters\fP .RS 4 \fImask\fP Corm hash mask (0 = corm default)\&. .RE .PP \fBReturns\fP .RS 4 New index handle, or NULL on failure\&. .RE .PP .SS "uint32_t lemma_query (\fBlemma_db_t\fP * db, const char * field, const char * query, uint32_t out_hd, int * handled)" .PP Query: every token of \fRquery\fP must prefix-match in \fRfield\fP\&. Matching row_ids are stored as "row_id" → "" into out_hd (a caller-opened corm; duplicates collapse)\&. *handled is set to 1 when the query produced at least one token, 0 for an empty/zero-token query (no-op — the caller should treat it as "matches everything")\&. .PP \fBParameters\fP .RS 4 \fIdb\fP Index handle\&. .br \fIfield\fP Field name\&. .br \fIquery\fP Query string\&. .br \fIout_hd\fP Caller-opened corm handle for result rows\&. .br \fIhandled\fP 1 when the query had ≥1 token, else 0\&. .RE .PP \fBReturns\fP .RS 4 Number of matches written\&. .RE .PP .SS "uint32_t lemma_query_fuzzy (\fBlemma_db_t\fP * db, const char * field, const char * query, int max_edit_distance, uint32_t out_hd, int * handled)" .PP Fuzzy query: match with Levenshtein edit distance tolerance\&. Query tokens match terms within \fRmax_edit_distance\fP\&. Matches are ANDed\&. .PP \fBParameters\fP .RS 4 \fIdb\fP Index handle\&. .br \fIfield\fP Field name\&. .br \fIquery\fP Query string\&. .br \fImax_edit_distance\fP Maximum Levenshtein distance (e\&.g\&. 1 or 2)\&. .br \fIout_hd\fP Caller-opened corm handle for result rows\&. .br \fIhandled\fP 1 when query had >= 1 token, else 0\&. .RE .PP \fBReturns\fP .RS 4 Number of matches written\&. .RE .PP .SS "uint32_t lemma_query_phrase (\fBlemma_db_t\fP * db, const char * field, const char * query, uint32_t out_hd, int * handled)" .PP Phrase query: prefix-match with contiguous subsequence ordering\&. Every token of \fRquery\fP must prefix-match in \fRfield\fP, AND the tokens must occur in the indexed text as a contiguous subsequence (in query order)\&. Line breaks and punctuation are token separators, so a phrase may span lines\&. A single-token query behaves exactly like lemma_query\&. The contract is otherwise identical to lemma_query\&. .PP \fBParameters\fP .RS 4 \fIdb\fP Index handle\&. .br \fIfield\fP Field name\&. .br \fIquery\fP Query string\&. .br \fIout_hd\fP Caller-opened corm handle for result rows\&. .br \fIhandled\fP 1 when the query had ≥1 token, else 0\&. .RE .PP \fBReturns\fP .RS 4 Number of matches written\&. .RE .PP .SS "int lemma_rank (struct \fBlemma_rank_ctx\fP * ctx, rec_ref_t ref, float * score)" .PP FTS score function for the recall-kernel rank loop\&. score = ctx->matched / token_count of the folded field text of decimal(ref) (shorter docs rank higher on ties)\&. The caller must have indexed by its decimal ref\&. Compatible with rec_score_fn via a caller adapter\&. The score may exceed 1\&.0 when matched > doc tokens\&. .PP \fBParameters\fP .RS 4 \fIctx\fP Rank context\&. .br \fIref\fP Row ref\&. .br \fIscore\fP Receives the score\&. .RE .PP \fBReturns\fP .RS 4 0 ok; -1 on NULL args, an unknown (field, row), or a zero-token document (the rank loop skips the ref)\&. .RE .PP .SS "int lemma_tok_decode (const lemma_tok_vocab_t * vocab, const uint16_t * tokens, size_t n_tokens, char * dst, size_t dst_cap, size_t * bytes_written)" .PP Decode an array of 16-bit token IDs losslessly into a character buffer\&. Reconstructs the exact original text\&. .PP \fBParameters\fP .RS 4 \fIvocab\fP Vocabulary handle (or NULL for default)\&. .br \fItokens\fP Array of token IDs\&. .br \fIn_tokens\fP Count of tokens\&. .br \fIdst\fP Destination character buffer\&. .br \fIdst_cap\fP Capacity of \fRdst\fP in bytes\&. .br \fIbytes_written\fP Receives the number of bytes written (excluding NUL)\&. .RE .PP \fBReturns\fP .RS 4 0 on success, -1 on invalid token ID, -2 on buffer overflow\&. .RE .PP .SS "int lemma_tok_encode (const lemma_tok_vocab_t * vocab, const char * src, size_t src_len, uint16_t * dst, size_t dst_cap, size_t * dst_len)" .PP Encode a text string losslessly into an array of 16-bit token IDs\&. Words matching DAFSA/lexicon emit their Word Token IDs (256\&.\&.32767)\&. Known delimiters emit Delimiter Token IDs\&. Fallback: bytes are emitted directly as byte primitives (0\&.\&.255)\&. Guaranteed 100% invertible: lemma_tok_decode(vocab, tokens, n, out, cap, NULL) == src\&. .PP \fBParameters\fP .RS 4 \fIvocab\fP Vocabulary handle (or NULL for default)\&. .br \fIsrc\fP Source text\&. .br \fIsrc_len\fP Length of source text in bytes\&. .br \fIdst\fP Destination array for token IDs\&. .br \fIdst_cap\fP Capacity of \fRdst\fP in uint16_t elements\&. .br \fIdst_len\fP Receives the number of tokens written\&. .RE .PP \fBReturns\fP .RS 4 0 on success, -1 on buffer overflow or NULL args\&. .RE .PP .SS "int lemma_tok_is_word (const lemma_tok_vocab_t * vocab, uint16_t token_id)" .PP Check if a token ID represents a searchable word (vs delimiter/whitespace/raw byte)\&. .PP \fBParameters\fP .RS 4 \fIvocab\fP Vocabulary handle\&. .br \fItoken_id\fP Token ID\&. .RE .PP \fBReturns\fP .RS 4 1 if token is a searchable word, 0 otherwise\&. .RE .PP .SS "const lemma_tok_vocab_t * lemma_tok_vocab_default (void )" .PP Initialize or obtain the shared global/default vocabulary\&. .PP \fBReturns\fP .RS 4 Shared vocabulary handle, or NULL on failure\&. .RE .PP .SS "int lemma_tok_vocab_load_file (lemma_tok_vocab_t * v, const char * filepath)" .PP Load additional words from a plaintext wordlist file into a dynamic vocabulary\&. .PP \fBParameters\fP .RS 4 \fIv\fP Dynamic vocabulary instance\&. .br \fIfilepath\fP Path to plaintext file (one word per line)\&. .RE .PP \fBReturns\fP .RS 4 0 on success, -1 on failure\&. .RE .PP .SS "int lemma_tok_vocab_match (const lemma_tok_vocab_t * vocab, const char * term, int max_edit_distance, uint16_t * out_token_ids, size_t out_cap, size_t * out_count)" .PP Query the vocabulary for fuzzy or substring matching token IDs (Tier 1)\&. Finds all Word Token IDs within Levenshtein distance \fRmax_edit_distance\fP of \fRterm\fP (or matching prefix/substring)\&. .PP \fBParameters\fP .RS 4 \fIvocab\fP Vocabulary handle (or NULL for default)\&. .br \fIterm\fP Query term (folded via lemma_fold)\&. .br \fImax_edit_distance\fP Maximum Levenshtein distance (0 = exact/prefix, 1 or 2 = fuzzy)\&. .br \fIout_token_ids\fP Destination array for matching token IDs\&. .br \fIout_cap\fP Capacity of \fRout_token_ids\fP\&. .br \fIout_count\fP Receives count of matching token IDs\&. .RE .PP \fBReturns\fP .RS 4 0 on success, -1 on buffer overflow or NULL args\&. .RE .PP .SS "lemma_tok_vocab_t * lemma_tok_vocab_new (const lemma_tok_vocab_t * base)" .PP Create a dynamic vocabulary instance (optionally extending a base vocab)\&. .PP \fBParameters\fP .RS 4 \fIbase\fP Optional base vocabulary (can be NULL or \fBlemma_tok_vocab_default()\fP)\&. .RE .PP \fBReturns\fP .RS 4 New vocabulary instance\&. .RE .PP .SS "void lemma_tokenize (const char * folded, void(* cb )(const char *tok, size_t len, void *user), void * user)" .PP Tokenize non-whitespace word tokens in \fRfolded\fP\&. Iterates non-whitespace word tokens in \fRfolded\fP and invokes cb(token, len, user) for each\&. .PP \fBParameters\fP .RS 4 \fIfolded\fP Folded text to tokenize\&. .br \fIcb\fP Callback invoked per token\&. .br \fIuser\fP Opaque user pointer passed to \fRcb\fP\&. .RE .PP .SS "int lemma_unindex (\fBlemma_db_t\fP * db, const char * field, const char * row_id)" .PP Remove every posting for (field, row_id) plus the doc side-table\&. The differential inverse of lemma_index (Phase 2A \fR\fBrec_axis_unstore\fP\fP mechanism; RECALL-KERNEL\&.md "rec_axis_store convention"): index → unindex leaves zero residual postings for the row and no doc entry, at a cost ∝ tokens of the row (never O(store), never a scan — the doc side-table is walked backwards to recover the exact posting keys)\&. Idempotent: an absent (field, row) reads as 0, not an error\&. Zero new stored state; memory-only\&. .PP \fBParameters\fP .RS 4 \fIdb\fP Index handle\&. .br \fIfield\fP Field name\&. .br \fIrow_id\fP Row id string\&. .RE .PP \fBReturns\fP .RS 4 0 on success, -1 on invalid arguments\&. .RE .PP .SS "int lemma_unindex_ref (\fBlemma_db_t\fP * db, const char * field, rec_ref_t row_id)" .PP rec_ref_t-native convenience wrapper for lemma_unindex\&. Same id-uniformity boundary as lemma_index_ref: formats row_id as the canonical decimal string internally\&. Same return contract as lemma_unindex\&. .PP \fBParameters\fP .RS 4 \fIdb\fP Index handle\&. .br \fIfield\fP Field name\&. .br \fIrow_id\fP Row ref\&. .RE .PP \fBReturns\fP .RS 4 0 on success, -1 on invalid arguments\&. .RE .PP .SS "int rec_axis_fill_tokens (\fBlemma_db_t\fP * db, const char * field, const char * query, int phrase, rec_set_t * out)" .PP Recall-kernel lexical filler (adapter contract, see rec\&.h)\&. The exact set of refs whose row_id matches \fRquery\fP in \fRfield\fP\&. The consumer must index by its own decimal rec_ref_t (lemma_index(db, field, "42", value)) — the filler pushes the parsed ids and lemma_rank reverses the mapping\&. Semantics are identical to lemma_query (phrase=0) / lemma_query_phrase (phrase=1)\&. Refs are appended to \fRout\fP (additive) and the set is sealed (0 = ok)\&. .PP \fBParameters\fP .RS 4 \fIdb\fP Index handle\&. .br \fIfield\fP Field name\&. .br \fIquery\fP Query string\&. .br \fIphrase\fP Non-zero for phrase semantics\&. .br \fIout\fP rec_set_t to append matching refs to\&. .RE .PP \fBReturns\fP .RS 4 0 ok; -1 on NULL args or when a matched row_id is not strictly decimal or cannot be represented as a rec_ref_t (> UINT32_MAX) (fill aborts; raw entry points still serve non-numeric stores)\&. Zero-token or empty queries yield a sealed empty set (mirrors the handled=0 no-op)\&. .RE .PP .SS "void * rec_axis_open (const char * spec)" .PP Open a lemma index from an opaque spec string\&. Follows the rec_axis_open convention (RECALL-KERNEL\&.md, optional CLI-open convention, not part of libcorm's core rec_query registry API)\&. Returns the ctx a caller then passes to rec_axis_set_ctx() — the lemma_db_t* directly\&. Two spec shapes (2B-2): .IP "\(bu" 2 decimal mask (or empty/NULL): the \fBlemma_open()\fP mask, 0 = corm default — a plain in-memory index, nothing seeded\&. .IP "\(bu" 2 a path (contains '/'): the 2B-2 primary-seeded rebuild\&. The directory is scanned for a \fR\&.roster\fP sidecar (written by the corm CLI's roster persistence); the primary corm store it prefixes is opened (\fR:a:s\fP raw and \fR:a:u\fP decimal alike) and every record is re-indexed under the canonical \fRtext\fP field\&. A rebuild emits a one-line budget note (docs + ms) on stderr so callers can measure (mm-plan U4)\&. A path whose sidecar is missing or whose primary cannot be opened warns loudly and falls back to an empty memory index — it never silently serves stale or empty results\&. .PP .PP \fBParameters\fP .RS 4 \fIspec\fP Spec string as described above\&. .RE .PP \fBReturns\fP .RS 4 A lemma_db_t* usable as the rec_axis ctx, or NULL on failure\&. .RE .PP .SS "int rec_axis_readback (void * ctx, rec_ref_t ref, char ** blob_out, size_t * n_out)" .PP Read a ref's stored (folded) text (rec_axis_readback)\&. One malloc'd buffer holding the stored (folded — lowercased, accent-preserving) text as one NUL-joined entry; n_out counts the display chars; absent → NULL/0, still 0; NULL out args → -1\&. Not kernel API, not in the rec_axis_t vtable; dlsym'd like rec_axis_open\&. .PP \fBParameters\fP .RS 4 \fIctx\fP Index handle (the lemma_db_t*)\&. .br \fIref\fP Row ref\&. .br \fIblob_out\fP Receives the malloc'd text buffer (caller frees)\&. .br \fIn_out\fP Receives the display char count\&. .RE .PP \fBReturns\fP .RS 4 0 on success, -1 on error\&. .RE .PP .SS "int rec_axis_store (void * ctx, const char * spec, rec_ref_t ref, const char * value)" .PP Store a ref's whole value text (rec_axis_store convention)\&. Phase 2A store contract (RECALL-KERNEL\&.md "rec_axis_store convention", optional CLI-specific — not libcorm core API)\&. The consumer passes (ref, value) blindly; lemma stores the WHOLE value string's text under LEMMA_AXIS_TEXT_FIELD (replace-in-place: store erases any previous entry for the ref first, so a ref owns exactly one doc)\&. Not kernel API, not in the rec_axis_t vtable; dlsym'd like rec_axis_open\&. .PP \fBParameters\fP .RS 4 \fIctx\fP Index handle (the lemma_db_t*)\&. .br \fIspec\fP Reserved — always NULL\&. .br \fIref\fP Row ref\&. .br \fIvalue\fP Whole value string to index\&. .RE .PP \fBReturns\fP .RS 4 0 ok; -1 with errno=EINVAL on bad args/empty value; ctx NULL → -1\&. .RE .PP .SS "int rec_axis_unstore (void * ctx, rec_ref_t ref)" .PP Remove a ref's stored doc (rec_axis_unstore)\&. Removes the ref's entry under LEMMA_AXIS_TEXT_FIELD; idempotent: absent → 0\&. Not kernel API, not in the rec_axis_t vtable; dlsym'd like rec_axis_open\&. .PP \fBParameters\fP .RS 4 \fIctx\fP Index handle (the lemma_db_t*)\&. .br \fIref\fP Row ref\&. .RE .PP \fBReturns\fP .RS 4 0 on success; ctx NULL → -1\&. .RE .PP .SH "Author" .PP Generated automatically by Doxygen for lemma from the source code\&.