MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / doc_candidate_rows_for

Function doc_candidate_rows_for

tests/test_pipeline.c:22038–22068  ·  view source on GitHub ↗

Count a section's stored doc -> code candidates (section QN containing * heading) and check each row's shape: a function within the top * CBM_SEM_DOC_TOP_K (top: the best of them), score at or above the floor, p * the curve of its kind and position at two decimals, never a test * function. Returns -1 on a bad row. */

Source from the content-addressed store, hash-verified

22036 * the curve of its kind and position at two decimals, never a test
22037 * function. Returns -1 on a bad row. */
22038static int doc_candidate_rows_for(cbm_store_t *s, const char *heading, char *top, size_t top_sz) {
22039 sqlite3_stmt *st = NULL;
22040 if (sqlite3_prepare_v2(cbm_store_get_db(s),
22041 "SELECT target_qn, rank, score, p, evidence FROM doc_link_candidates "
22042 "WHERE instr(section_qn, ?1) > 0 ORDER BY rank",
22043 -1, &st, NULL) != SQLITE_OK) {
22044 return -1;
22045 }
22046 sqlite3_bind_text(st, 1, heading, -1, SQLITE_TRANSIENT);
22047 int n = 0;
22048 bool ok = true;
22049 bool have_top = false;
22050 while (ok && sqlite3_step(st) == SQLITE_ROW) {
22051 const char *target = (const char *)sqlite3_column_text(st, 0);
22052 int rank = sqlite3_column_int(st, 1);
22053 double score = sqlite3_column_double(st, 2);
22054 double p = sqlite3_column_double(st, 3);
22055 bool is_function = false;
22056 double want = doc_row_want((const char *)sqlite3_column_text(st, 4),
22057 CBM_SEM_DOC_FMT_MARKDOWN, (float)score, &is_function);
22058 ok = target && rank >= 1 && (!is_function || rank <= CBM_SEM_DOC_TOP_K) &&
22059 score >= (double)CBM_SEM_DOC_MIN_SCORE && p == want && !strstr(target, ".Test");
22060 if (ok && is_function && !have_top && top) {
22061 snprintf(top, top_sz, "%s", target);
22062 have_top = true;
22063 }
22064 n++;
22065 }
22066 sqlite3_finalize(st);
22067 return ok ? n : -1;
22068}
22069
22070/* The doc -> code candidate fixture: six Go config families, a test whose
22071 * comment is the section's own text, and a README with a Mail-configuration

Callers 1

test_pipeline.cFile · 0.85

Calls 2

cbm_store_get_dbFunction · 0.85
doc_row_wantFunction · 0.85

Tested by

no test coverage detected