MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / rankRequiredFeatures

Function rankRequiredFeatures

src/compute-engine/fungrim/loader.ts:574–586  ·  view source on GitHub ↗

* Order the required features so the MOST DISCRIMINATING one is checked * first, and drop the dispatch-bucket head itself (the rule is only * consulted for nodes that already carry that operator, so it conveys zero * information). Rarity heuristic over generic corpora, rarest first: * special-fu

(
  features: ReadonlyArray<string>,
  bucketHead: string
)

Source from the content-addressed store, hash-verified

572 * first-feature check decides almost every pre-screen (437 of the 474 new
573 * hot-bucket rules carry a rare feature), keeping the per-rule cost at one
574 * or two set lookups per candidate node (Phase-3 M5).
575 */
576function rankRequiredFeatures(
577 features: ReadonlyArray<string>,
578 bucketHead: string
579): ReadonlyArray<string> {
580 const rank = (f: string): number => {
581 if (f.startsWith(FEATURE_SYM_PREFIX)) return 1;
582 // operator feature
583 return HOT_DISPATCH_HEADS.has(f.slice(FEATURE_OP_PREFIX.length)) ? 2 : 0;
584 };
585 return features
586 .filter((f) => f !== FEATURE_OP_PREFIX + bucketHead)
587 .sort((a, b) => rank(a) - rank(b));
588}
589

Callers 1

wrapHotHeadRuleFunction · 0.85

Calls 1

rankFunction · 0.70

Tested by

no test coverage detected