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

Function te_classify_rules

src/mcp/test_impact_engine.c:235–271  ·  view source on GitHub ↗

First pass: the rules. A path no rule matches is decided after the * snapshot (te_classify_unmatched). Returns whether the snapshot is needed: * a run-all rule decides everything without it. */

Source from the content-addressed store, hash-verified

233 * snapshot (te_classify_unmatched). Returns whether the snapshot is needed:
234 * a run-all rule decides everything without it. */
235static bool te_classify_rules(te_ctx_t *c, bool *need_snapshot, bool **unmatched) {
236 size_t count = 0;
237 const cbm_change_file_t *files = cbm_changes_files(c->changes, &count);
238 int rule_count = 0;
239 const cbm_test_rule_t *rules = cbm_test_policy_rules(c->policy, &rule_count);
240 *unmatched = cbm_arena_calloc(&c->arena, count + 1);
241 if (!*unmatched) {
242 return te_oom(c);
243 }
244 bool run_all = false;
245 c->activation_complete = true;
246 for (size_t i = 0; i < count; i++) {
247 const char *path = (const char *)files[i].path;
248 const cbm_test_rule_t *rule = NULL;
249 if (!cbm_test_policy_match_path(c->policy, path, &rule)) {
250 c->activation_complete = false;
251 if (!te_fallback(c, CBM_TEST_RESULT_FALLBACK_POLICY_EVALUATION_FAILED, path)) {
252 return false;
253 }
254 continue;
255 }
256 if (!rule) {
257 (*unmatched)[i] = true;
258 continue;
259 }
260 int index = (int)(rule - rules);
261 if (!te_match(c, index)) {
262 return false;
263 }
264 run_all = run_all || rule->action == CBM_TEST_RULE_RUN_ALL;
265 if (rule->action == CBM_TEST_RULE_REFERENCING_TESTS && !te_fixture_path(c, path, index)) {
266 return false;
267 }
268 }
269 *need_snapshot = !run_all && c->fallback_count == 0;
270 return true;
271}
272
273static bool te_in_ledger(te_ctx_t *c, const char *path) {
274 const cbm_pinned_tree_view_t *view = cbm_pinned_tree_view(c->tree);

Callers 1

te_stepsFunction · 0.85

Calls 8

cbm_changes_filesFunction · 0.85
cbm_test_policy_rulesFunction · 0.85
cbm_arena_callocFunction · 0.85
te_oomFunction · 0.85
te_fallbackFunction · 0.85
te_matchFunction · 0.85
te_fixture_pathFunction · 0.85

Tested by

no test coverage detected