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

Function gd_generation

src/store/store_graph_digest.c:526–562  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

524}
525
526static bool gd_generation(gd_context_t *g) {
527 gd_text_t key, value;
528 if (!gd_read_text(g, 0, &key) || !gd_read_text(g, 1, &value)) {
529 return false;
530 }
531 if (gd_text_eq(key, "db_uid")) {
532 if (g->have_uid || value.length != 16) {
533 return gd_fail(g, CBM_STORE_GRAPH_DIGEST_SCHEMA);
534 }
535 for (size_t i = 0; i < value.length; i++) {
536 unsigned char c = value.data[i];
537 if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f'))) {
538 return gd_fail(g, CBM_STORE_GRAPH_DIGEST_SCHEMA);
539 }
540 }
541 g->have_uid = true;
542 } else if (gd_text_eq(key, "mutation_gen")) {
543 if (g->have_counter || value.length == 0 || value.length > 20 ||
544 (value.length > 1 && value.data[0] == '0')) {
545 return gd_fail(g, CBM_STORE_GRAPH_DIGEST_SCHEMA);
546 }
547 uint64_t number = 0;
548 for (size_t i = 0; i < value.length; i++) {
549 unsigned char c = value.data[i];
550 if (c < '0' || c > '9') {
551 return gd_fail(g, CBM_STORE_GRAPH_DIGEST_SCHEMA);
552 }
553 uint64_t digit = (uint64_t)(c - '0');
554 if (number > (UINT64_MAX - digit) / 10) {
555 return gd_fail(g, CBM_STORE_GRAPH_DIGEST_SCHEMA);
556 }
557 number = number * 10 + digit;
558 }
559 g->have_counter = true;
560 }
561 return true;
562}
563
564static bool gd_column_value(gd_context_t *g, int index, const gd_column_t *column) {
565 int sql_type = sqlite3_column_type(g->stmt, index);

Callers 1

gd_table_rowsFunction · 0.85

Calls 3

gd_read_textFunction · 0.85
gd_text_eqFunction · 0.85
gd_failFunction · 0.85

Tested by

no test coverage detected