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

Function cbm_adr_validate_content

src/store/store.c:5814–5846  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5812}
5813
5814int cbm_adr_validate_content(const char *content, char *errbuf, int errbuf_size) {
5815 cbm_adr_sections_t sections = cbm_adr_parse_sections(content);
5816 char missing[CBM_SZ_256] = "";
5817 int mlen = 0;
5818 int nmissing = 0;
5819
5820 for (int c = 0; c < canonical_section_count; c++) {
5821 bool found = false;
5822 for (int i = 0; i < sections.count; i++) {
5823 if (strcmp(sections.keys[i], canonical_sections[c]) == 0) {
5824 found = true;
5825 break;
5826 }
5827 }
5828 if (!found) {
5829 if (mlen > 0) {
5830 mlen += snprintf(missing + mlen, sizeof(missing) - mlen, ", ");
5831 }
5832 mlen += snprintf(missing + mlen, sizeof(missing) - mlen, "%s", canonical_sections[c]);
5833 nmissing++;
5834 }
5835 }
5836 cbm_adr_sections_free(&sections);
5837
5838 if (nmissing > 0) {
5839 snprintf(errbuf, errbuf_size,
5840 "missing required sections: %s. All 6 required: PURPOSE, STACK, ARCHITECTURE, "
5841 "PATTERNS, TRADEOFFS, PHILOSOPHY",
5842 missing);
5843 return CBM_STORE_ERR;
5844 }
5845 return CBM_STORE_OK;
5846}
5847
5848int cbm_adr_validate_section_keys(const char **keys, int count, char *errbuf, int errbuf_size) {
5849 char invalid[CBM_SZ_256] = "";

Callers 1

test_store_arch.cFile · 0.85

Calls 2

cbm_adr_parse_sectionsFunction · 0.85
cbm_adr_sections_freeFunction · 0.85

Tested by

no test coverage detected