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

Function coverage_path_freshness

src/mcp/mcp.c:4117–4150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4115}
4116
4117static const char *coverage_path_freshness(cbm_store_t *store, const char *project,
4118 const char *root_path, const char *rel_path,
4119 bool *outside) {
4120 *outside = false;
4121 if (!root_path || !root_path[0]) {
4122 return "unavailable";
4123 }
4124 char abs_path[CBM_SZ_4K];
4125 int n = snprintf(abs_path, sizeof(abs_path), "%s%s%s", root_path,
4126 root_path[strlen(root_path) - 1U] == '/' ? "" : "/", rel_path);
4127 if (n < 0 || (size_t)n >= sizeof(abs_path)) {
4128 return "unavailable";
4129 }
4130 struct stat st;
4131 if (stat(abs_path, &st) != 0) {
4132 return "missing";
4133 }
4134 if (!cbm_path_within_root(root_path, abs_path)) {
4135 *outside = true;
4136 return "outside_project";
4137 }
4138
4139 cbm_file_hash_t hash = {0};
4140 int rc = cbm_store_get_file_hash(store, project, rel_path, &hash);
4141 if (rc == CBM_STORE_NOT_FOUND) {
4142 return "not_tracked";
4143 }
4144 if (rc != CBM_STORE_OK) {
4145 return "unavailable";
4146 }
4147 bool matches = hash.mtime_ns == coverage_stat_mtime_ns(&st) && hash.size == st.st_size;
4148 cbm_store_clear_file_hash(&hash);
4149 return matches ? "metadata_match" : "metadata_changed";
4150}
4151
4152static void coverage_add_ranges(yyjson_mut_doc *doc, yyjson_mut_val *row, const char *detail) {
4153 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