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

Function write_sem_family

tests/test_pipeline.c:21724–21752  ·  view source on GitHub ↗

Under memory pressure the semantic pass tokenizes, counts and vectorizes * in headroom-sized batches of functions (tokenizing twice) instead of * holding every function's tokens at once. The graph must not be able to * tell: the same repo indexed with CBM_SEM_BATCH=5 (forced batches, 30 * functions -> 6 batches) yields byte-identical node vectors, token vectors * and SEMANTICALLY_RELATED edge

Source from the content-addressed store, hash-verified

21722 * and SEMANTICALLY_RELATED edges. Rows are compared by qualified name, never
21723 * by node id: parallel extraction hands out ids in worker order. */
21724static void write_sem_family(const char *base, const char *file, const char *subject) {
21725 char path[512];
21726 snprintf(path, sizeof(path), "%s/%s", base, file);
21727 char body[4096];
21728 snprintf(body, sizeof(body),
21729 "package main\n\n"
21730 "// Parse%sConfig reads the %s config file and returns the parsed %s config.\n"
21731 "func Parse%sConfig(path string) (*%sConfig, error) {\n"
21732 "\treturn Load%sConfig(path)\n}\n\n"
21733 "// Load%sConfig loads the %s config from disk and validates it.\n"
21734 "func Load%sConfig(path string) (*%sConfig, error) {\n"
21735 "\tcfg := &%sConfig{}\n\tValidate%sConfig(cfg)\n\treturn cfg, nil\n}\n\n"
21736 "// Validate%sConfig checks the %s config for missing fields.\n"
21737 "func Validate%sConfig(cfg *%sConfig) bool {\n\treturn cfg != nil\n}\n\n"
21738 "// Write%sConfig serializes the %s config back to disk.\n"
21739 "func Write%sConfig(path string, cfg *%sConfig) error {\n"
21740 "\tValidate%sConfig(cfg)\n\treturn nil\n}\n\n"
21741 /* A near-duplicate of Load: same doc, same body, same calls -- the
21742 * pair the pass must relate, in every venue. */
21743 "// Load%sConfigFile loads the %s config from disk and validates it.\n"
21744 "func Load%sConfigFile(path string) (*%sConfig, error) {\n"
21745 "\tcfg := &%sConfig{}\n\tValidate%sConfig(cfg)\n\treturn cfg, nil\n}\n\n"
21746 "type %sConfig struct{ Name string }\n",
21747 subject, subject, subject, subject, subject, subject, subject, subject, subject,
21748 subject, subject, subject, subject, subject, subject, subject, subject, subject,
21749 subject, subject, subject, subject, subject, subject, subject, subject, subject,
21750 subject);
21751 th_write_file(path, body);
21752}
21753
21754/* Step both statements in lockstep; every column of every row must match. */
21755static bool sem_same_rows(sqlite3 *a, sqlite3 *b, const char *sql, int *rows) {

Callers 2

test_pipeline.cFile · 0.85

Calls 1

th_write_fileFunction · 0.85

Tested by

no test coverage detected