Skip to content

Core: Router Implementation - #21

Merged
ggondim merged 2 commits into
meta/17from
claude/issue-3-20260410-2149
Apr 10, 2026
Merged

Core: Router Implementation#21
ggondim merged 2 commits into
meta/17from
claude/issue-3-20260410-2149

Conversation

@ggondim

Copy link
Copy Markdown
Contributor

fixes#3

github-actionsBotand others added 2 commits April 10, 2026 21:58
Adds the `@openthreads/core` package with:
- **Data model types** (`types.ts`): Channel, Recipient, Route,
RouteCriteria, InboundMessage, Thread, Turn — derived from VISION.md.
- **Route matching engine** (`router.ts`):
- `router(routes, message)` — filters enabled routes whose criteria all
match the inbound message, then returns them sorted by descending
priority (highest-priority first).
- Glob/wildcard support via `globToRegex` / `matchGlob` (`*` = any
chars, `?` = one char; regex metacharacters are escaped so literal
dots in channel/user IDs behave correctly).
- Per-field AND semantics; array criteria use OR (any pattern matches).
- Boolean criteria (`isThread`, `isMention`, `isDM`) accept undefined
as "match everything".
- Disabled routes are always excluded.
- Multiple recipients per route (fan-out) are preserved on each result.
- Input array is never mutated (sort operates on a copy produced by
filter).
- **Unit tests** (`router.test.ts`): 40+ cases covering glob edge-cases,
criterion matching, priority ordering, stable sort, fan-out, overlapping
routes, disabled routes, no-match, and a realistic multi-route scenario.
Co-authored-by: claude[bot] <claude[bot]@users.noreply.github.com>
@ggondim
ggondim merged commit cd8ee0b into meta/17Apr 10, 2026
@claudeclaudeBot mentioned this pull request Apr 10, 2026
16 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@ggondim