Commit 7046aef
authored
feat(eligibility-rules): implement deterministic community eligibility rules engine
Implements issue #384. Adds the @guildpass/eligibility-rules package at
packages/eligibility-rules with:
- EligibilityRule discriminated union (equals, exists, in, gte, lte,
all, any, not)
- parseEligibilityRule: validates untrusted input against the rule
grammar with configurable depth and node-count limits
- evaluateEligibilityRule: evaluates a rule tree against a caller-
supplied facts object, returning a structured eligibility decision
- Dot-separated fact path resolution that safely handles missing
segments and null mid-path values
- explain mode that collects stable machine-readable denial reasons
- Configurable and exported DEFAULT_ELIGIBILITY_RULE_LIMITS
- No database, HTTP or external runtime dependencies
- 90 unit tests covering all predicates, nesting, missing fields,
type mismatches, boundary cases, depth/node limits and explain mode
pnpm typecheck, pnpm build and pnpm test all pass across the monorepo.
Closes #3841 parent cfd31fd commit 7046aef
5 files changed
Lines changed: 1500 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
0 commit comments