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

Function coverage_path_freshness

src/mcp/mcp.c:4086–4119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4084}
4085
4086static const char *coverage_path_freshness(cbm_store_t *store, const char *project,
4087 const char *root_path, const char *rel_path,
4088 bool *outside) {
4089 *outside = false;
4090 if (!root_path || !root_path[0]) {
4091 return "unavailable";
4092 }
4093 char abs_path[CBM_SZ_4K];
4094 int n = snprintf(abs_path, sizeof(abs_path), "%s%s%s", root_path,
4095 root_path[strlen(root_path) - 1U] == '/' ? "" : "/", rel_path);
4096 if (n < 0 || (size_t)n >= sizeof(abs_path)) {
4097 return "unavailable";
4098 }
4099 struct stat st;
4100 if (stat(abs_path, &st) != 0) {
4101 return "missing";
4102 }
4103 if (!cbm_path_within_root(root_path, abs_path)) {
4104 *outside = true;
4105 return "outside_project";
4106 }
4107
4108 cbm_file_hash_t hash = {0};
4109 int rc = cbm_store_get_file_hash(store, project, rel_path, &hash);
4110 if (rc == CBM_STORE_NOT_FOUND) {
4111 return "not_tracked";
4112 }
4113 if (rc != CBM_STORE_OK) {
4114 return "unavailable";
4115 }
4116 bool matches = hash.mtime_ns == coverage_stat_mtime_ns(&st) && hash.size == st.st_size;
4117 cbm_store_clear_file_hash(&hash);
4118 return matches ? "metadata_match" : "metadata_changed";
4119}
4120
4121static void coverage_add_ranges(yyjson_mut_doc *doc, yyjson_mut_val *row, const char *detail) {
4122 if (!detail || !detail[0]) {

Callers 1

Calls 5

cbm_path_within_rootFunction · 0.85
cbm_store_get_file_hashFunction · 0.85
coverage_stat_mtime_nsFunction · 0.85
statClass · 0.70

Tested by

no test coverage detected