Skip to content

Commit b493b64

Browse files
committed
test(search): end-to-end guard from source prose to a findable body match
The DeusData#518/DeusData#519 tests so far each cover one layer: extraction produces the docstring, the store indexes it into nodes_fts.body, the delta merge writes the same columns, and the query returns Section and Module. Nothing yet proved the layers connect. This indexes a real temporary repository -- a README.md whose section body runs well past the 500-byte cap, plus a META.yaml with a top-level description -- through the full pipeline, then asserts both prose words are matchable in the `body` column. It is also the guard on the size budget. build_def_props drops an oversized field ATOMICALLY, so a section body that did not fit the 2 KB properties buffer would vanish without a trace and every narrower test would still pass. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 01c7e54 commit b493b64

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

‎tests/test_pipeline.c‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12528,6 +12528,71 @@ TEST(pipeline_delta_patch_indexes_docstring_into_fts_body) {
1252812528
PASS();
1252912529
}
1253012530

12531+
12532+
/* End-to-end for #518/#519: source → docstring → properties JSON → nodes_fts
12533+
* `body` → findable. Each layer has its own test; this one proves they connect.
12534+
* It is also the guard on the size budget: build_def_props drops an oversized
12535+
* field ATOMICALLY, so a 500-byte section body that did not fit the 2 KB
12536+
* properties buffer would vanish silently and every narrower test would still
12537+
* pass. */
12538+
TEST(pipeline_markdown_and_config_prose_reaches_fts_body) {
12539+
char tmp[256];
12540+
snprintf(tmp, sizeof(tmp), "/tmp/cbm_prose_XXXXXX");
12541+
ASSERT_NOT_NULL(cbm_mkdtemp(tmp));
12542+
char path[512];
12543+
char dbpath[512];
12544+
snprintf(dbpath, sizeof(dbpath), "%s/prose.db", tmp);
12545+
12546+
/* A section body well past the 500-byte cap, so the truncating path — the
12547+
* one that produces the longest properties JSON — is what gets indexed. */
12548+
snprintf(path, sizeof(path), "%s/README.md", tmp);
12549+
FILE *f = fopen(path, "w");
12550+
ASSERT_NOT_NULL(f);
12551+
fprintf(f, "# Installation\n\nThe phlogiston bootstrap provisions a workstation.\n");
12552+
for (int i = 0; i < 40; i++) {
12553+
fprintf(f, "Filler prose line %d that pads the section well past the cap.\n", i);
12554+
}
12555+
fclose(f);
12556+
12557+
snprintf(path, sizeof(path), "%s/META.yaml", tmp);
12558+
f = fopen(path, "w");
12559+
ASSERT_NOT_NULL(f);
12560+
fprintf(f, "name: widget\ndescription: Aggregates quicksilver telemetry per shard.\n");
12561+
fclose(f);
12562+
12563+
/* One code file so the run is a normal index rather than a docs-only edge. */
12564+
snprintf(path, sizeof(path), "%s/main.go", tmp);
12565+
f = fopen(path, "w");
12566+
ASSERT_NOT_NULL(f);
12567+
fprintf(f, "package main\n\nfunc main() {}\n");
12568+
fclose(f);
12569+
12570+
cbm_pipeline_t *p = cbm_pipeline_new(tmp, dbpath, CBM_MODE_FULL);
12571+
ASSERT_NOT_NULL(p);
12572+
ASSERT_EQ(cbm_pipeline_run(p), 0);
12573+
cbm_pipeline_free(p);
12574+
12575+
cbm_store_t *s = cbm_store_open_path(dbpath);
12576+
ASSERT_NOT_NULL(s);
12577+
sqlite3_stmt *st = NULL;
12578+
ASSERT_EQ(sqlite3_prepare_v2(cbm_store_get_db(s),
12579+
"SELECT COUNT(*) FROM nodes_fts WHERE nodes_fts MATCH ?1", -1, &st,
12580+
NULL),
12581+
SQLITE_OK);
12582+
const char *cases[] = {"body:phlogiston", "body:quicksilver"};
12583+
for (size_t i = 0; i < sizeof(cases) / sizeof(cases[0]); i++) {
12584+
sqlite3_reset(st);
12585+
sqlite3_bind_text(st, 1, cases[i], -1, SQLITE_TRANSIENT);
12586+
ASSERT_EQ(sqlite3_step(st), SQLITE_ROW);
12587+
ASSERT_GT(sqlite3_column_int(st, 0), 0);
12588+
}
12589+
sqlite3_finalize(st);
12590+
cbm_store_close(s);
12591+
12592+
th_rmtree(tmp);
12593+
PASS();
12594+
}
12595+
1253112596
SUITE(pipeline) {
1253212597
RUN_TEST(pipeline_lsp_surface_persisted_and_body_edit_invariant);
1253312598
/* Index lock */
@@ -12846,6 +12911,7 @@ SUITE(pipeline) {
1284612911
RUN_TEST(pipeline_ensemble_routing_settings_targets);
1284712912
RUN_TEST(pipeline_ensemble_routing_unterminated_item_is_safe);
1284812913
RUN_TEST(pipeline_delta_patch_indexes_docstring_into_fts_body);
12914+
RUN_TEST(pipeline_markdown_and_config_prose_reaches_fts_body);
1284912915
}
1285012916

1285112917
/* Focused semantic-manifest and publication contracts. Kept separate from the

0 commit comments

Comments
 (0)