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

Function build_base_battery

tests/repro/repro_grammar_build.c:131–178  ·  view source on GitHub ↗

── Structural-base battery (dims 1-4) ────────────────────────────────────── * * Runs the four core invariants on valid input. No defs-present assertion. * Used for REQUIREMENTS, GITIGNORE, GITATTRIBUTES, SSHCONFIG where the spec * has no func_types, class_types, or labelled var_types that yield defs. * Returns 0 on PASS, 1 on FAIL. */

Source from the content-addressed store, hash-verified

129 * Returns 0 on PASS, 1 on FAIL.
130 */
131static int build_base_battery(const char *lang_tag, const char *src,
132 CBMLanguage lang, const char *file) {
133 const char *RED = tf_red();
134 const char *RST = tf_reset();
135
136 /* 1. extract-clean */
137 if (inv_extract_clean(src, lang, file) != 1) {
138 printf(" %sFAIL%s [%s] extract-clean: NULL result or has_error set\n",
139 RED, RST, lang_tag);
140 return 1;
141 }
142
143 CBMFileResult *r = inv_rx(src, lang, file);
144 if (!r) {
145 printf(" %sFAIL%s [%s] inv_rx returned NULL after clean extract\n",
146 RED, RST, lang_tag);
147 return 1;
148 }
149
150 int fails = 0;
151
152 /* 2. labels-valid */
153 int bad_labels = inv_count_bad_labels(r);
154 if (bad_labels != 0) {
155 printf(" %sFAIL%s [%s] labels-valid: %d def(s) with invalid label\n",
156 RED, RST, lang_tag, bad_labels);
157 fails++;
158 }
159
160 /* 3. fqn-wellformed */
161 int bad_fqns = inv_count_bad_fqns(r);
162 if (bad_fqns != 0) {
163 printf(" %sFAIL%s [%s] fqn-wellformed: %d def(s) with malformed QN\n",
164 RED, RST, lang_tag, bad_fqns);
165 fails++;
166 }
167
168 /* 4. ranges-valid */
169 int bad_ranges = inv_count_bad_ranges(r);
170 if (bad_ranges != 0) {
171 printf(" %sFAIL%s [%s] ranges-valid: %d def(s) with invalid range\n",
172 RED, RST, lang_tag, bad_ranges);
173 fails++;
174 }
175
176 cbm_free_result(r);
177 return fails ? 1 : 0;
178}
179
180/* ── Structural battery with defs-present (dims 1-5) ────────────────────────
181 *

Callers 1

Calls 8

tf_redFunction · 0.85
tf_resetFunction · 0.85
inv_extract_cleanFunction · 0.85
inv_rxFunction · 0.85
inv_count_bad_labelsFunction · 0.85
inv_count_bad_fqnsFunction · 0.85
inv_count_bad_rangesFunction · 0.85
cbm_free_resultFunction · 0.85

Tested by

no test coverage detected