* 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 )
| 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 | */ |
| 576 | function 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 |
no test coverage detected