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

Function read_metadata_version

src/pipeline/artifact.c:273–294  ·  view source on GitHub ↗

Read schema_version from artifact.json. Returns -1 if missing/invalid. */

Source from the content-addressed store, hash-verified

271
272/* Read schema_version from artifact.json. Returns -1 if missing/invalid. */
273static int read_metadata_version(const char *repo_path) {
274 char meta_path[CBM_SZ_4K];
275 artifact_path(meta_path, sizeof(meta_path), repo_path, CBM_ARTIFACT_META);
276
277 size_t len = 0;
278 char *json = read_file_alloc(meta_path, &len);
279 if (!json) {
280 return CBM_NOT_FOUND;
281 }
282
283 yyjson_doc *doc = yyjson_read(json, len, 0);
284 free(json);
285 if (!doc) {
286 return CBM_NOT_FOUND;
287 }
288
289 yyjson_val *root = yyjson_doc_get_root(doc);
290 yyjson_val *ver = yyjson_obj_get(root, "schema_version");
291 int version = ver ? yyjson_get_int(ver) : CBM_NOT_FOUND;
292 yyjson_doc_free(doc);
293 return version;
294}
295
296/* Read original_size from artifact.json. Returns 0 on error. */
297static size_t read_metadata_original_size(const char *repo_path) {

Callers 2

cbm_artifact_importFunction · 0.85
cbm_artifact_existsFunction · 0.85

Calls 2

artifact_pathFunction · 0.85
read_file_allocFunction · 0.85

Tested by

no test coverage detected