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

Function namespace_admission_run

tests/test_pipeline.c:12610–12668  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12608}
12609
12610static namespace_admission_result namespace_admission_run(namespace_admission_fixture *f,
12611 const char *watch, const char *source,
12612 int expected_files) {
12613 namespace_admission_result result = {
12614 .rc = -1, .errors = -1, .format = -1, .route = CBM_INCREMENTAL_ROUTE_NONE};
12615 cbm_pipeline_incremental_test_reset_faults();
12616 cbm_pipeline_t *pipeline = cbm_pipeline_new(f->root, f->db, CBM_MODE_FULL);
12617 if (!pipeline)
12618 return result;
12619 result.rc = cbm_pipeline_run(pipeline);
12620 result.route = cbm_pipeline_incremental_test_last_route();
12621 result.migrated = cbm_pipeline_had_format_migration(pipeline);
12622 cbm_file_error_t *errors = NULL;
12623 cbm_pipeline_get_file_errors(pipeline, &errors, &result.errors);
12624 const char *project = cbm_pipeline_project_name(pipeline);
12625 int n = project ? snprintf(result.project, sizeof(result.project), "%s", project) : -1;
12626 cbm_store_t *store = result.rc == 0 && n > 0 && (size_t)n < sizeof(result.project)
12627 ? cbm_store_open_path(f->db)
12628 : NULL;
12629 if (store) {
12630 cbm_node_t *files = NULL;
12631 int file_count = 0;
12632 bool file_query = cbm_store_find_nodes_by_label(store, project, "File", &files,
12633 &file_count) == CBM_STORE_OK;
12634 int watched_files = 0;
12635 for (int i = 0; file_query && i < file_count; i++)
12636 if (files[i].file_path && strcmp(files[i].file_path, watch) == 0)
12637 watched_files++;
12638 cbm_store_free_nodes(files, file_count);
12639 bool positive = python_module_exact_lsp_edge(store, project, "control.keep", "Function",
12640 "control.target", "Function");
12641 bool hashes = namespace_admission_exact_hash(store, project, "control.py",
12642 namespace_admission_control) &&
12643 namespace_admission_exact_hash(store, project, watch, source);
12644 bool format_ok = cbm_store_get_format_version(store, &result.format) == CBM_STORE_OK;
12645 cbm_lsp_surface_row_t *rows = NULL;
12646 int row_count = 0;
12647 bool row_query =
12648 cbm_store_get_lsp_surfaces(store, project, &rows, &row_count) == CBM_STORE_OK;
12649 int matches = 0;
12650 for (int i = 0; row_query && i < row_count; i++) {
12651 if (!rows[i].rel_path || strcmp(rows[i].rel_path, watch) != 0)
12652 continue;
12653 matches++;
12654 if (rows[i].defs_json && !result.json)
12655 result.json = strdup(rows[i].defs_json);
12656 }
12657 cbm_store_free_lsp_surfaces(rows, row_count);
12658 bool python_row = matches == 1 && result.json &&
12659 cbm_lsp_surface_python_change(result.json, result.json) == 0 &&
12660 cbm_lsp_surface_python_change(result.json, NULL) == 1;
12661 result.healthy = result.errors == 0 && file_query && file_count == expected_files &&
12662 watched_files == 1 && positive && hashes && format_ok &&
12663 result.format == CBM_INDEX_FORMAT_VERSION && row_query && python_row;
12664 cbm_store_close(store);
12665 }
12666 cbm_pipeline_free(pipeline);
12667 return result;

Callers 1

test_pipeline.cFile · 0.85

Tested by

no test coverage detected