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

Function dm_namespace_published

tests/test_doc_mentions.c:319–346  ·  view source on GitHub ↗

Check the persisted layer and the public status. No assertion here may skip * the caller's environment restoration or fixture cleanup. */

Source from the content-addressed store, hash-verified

317/* Check the persisted layer and the public status. No assertion here may skip
318 * the caller's environment restoration or fixture cleanup. */
319static bool dm_namespace_published(const char *db, const char *project, bool valid,
320 const char *label) {
321 char props[512], inside_reason[64], conflict_reason[64];
322 int healthy = 0, inside = 0, conflict = 0;
323 dm_edge(db, "Healthy.Uses", "Healthy.Target", props, sizeof(props), &healthy);
324 dm_edge(db, "Bad.FromBad", "Healthy.Target", props, sizeof(props), &inside);
325 dm_edge(db, "Healthy.TriesHidden", "Healthy.Hidden", props, sizeof(props), &conflict);
326 dm_row(db, "Bad.cs", "global::Good.Target", inside_reason, sizeof(inside_reason), NULL, 0);
327 dm_row(db, "Healthy.cs", "Hidden", conflict_reason, sizeof(conflict_reason), NULL, 0);
328 int errors = dm_count(db, "SELECT COUNT(*) FROM doc_link_unresolved WHERE reason = 'error'");
329 char *status = dm_index_status(project, false);
330 const char *block = dm_doc_links_block(status);
331 bool status_ok = block && strstr(block, "\n status: ok");
332 int from_bad = dm_mentions_from(db, "Bad.FromBad");
333 bool inside_ok = valid
334 ? inside == 1 && from_bad == 1 && !inside_reason[0]
335 : inside == 0 && from_bad == 0 && strcmp(inside_reason, "graph_gap") == 0;
336 bool conflict_ok = valid ? conflict == 1 && !conflict_reason[0]
337 : conflict == 0 && strcmp(conflict_reason, "graph_gap") == 0;
338 bool correct = errors == 0 && healthy == 1 && inside_ok && conflict_ok && status_ok;
339 fprintf(stderr,
340 "doc namespace published case=%s valid=%d errors=%d healthy=%d inside=%d "
341 "inside_reason=%s conflict=%d conflict_reason=%s status_ok=%d correct=%d\n",
342 label, valid, errors, healthy, inside, inside_reason, conflict, conflict_reason,
343 status_ok, correct);
344 free(status);
345 return correct;
346}
347
348TEST(doc_mentions_cs_namespace_publication) {
349 char tmp[256] = "/tmp/cbm_dm_ns_XXXXXX";

Callers 1

Calls 6

dm_edgeFunction · 0.85
dm_rowFunction · 0.85
dm_countFunction · 0.85
dm_index_statusFunction · 0.85
dm_doc_links_blockFunction · 0.85
dm_mentions_fromFunction · 0.85

Tested by

no test coverage detected