Skip to content

Core: Router Implementation #3

Open

Description

@ggondim

Summary

Implement the route matching engine that maps incoming messages to outbound recipients based on configurable criteria.

Tasks

  • Implement route matching engine:
    • Input: inbound message metadata (channel, target, sender, content, isThread, isMention, isDM)
    • Output: ordered list of matching Routes by priority
  • Support wildcard/glob patterns in route criteria (e.g., content matching)
  • Support multiple recipients per route (fan-out)
  • Handle edge cases: no matching routes, overlapping routes, disabled routes
  • Unit tests for matching logic with various criteria combinations

Acceptance Criteria

  • Given a set of routes and an inbound message, the router returns the correct ordered matches
  • Wildcard patterns work in content and sender criteria
  • Fan-out delivers to all matched recipients
  • 100% test coverage on the matching logic

Dependencies

References

Activity

  1. claude commented on Apr 10, 2026

    @claude

    @claude Implement this issue. Follow these steps precisely:

    1. Checkout the base branch and create your working branch:
      git fetch origin meta/17 && git checkout meta/17 && git checkout -b claude/17-3-router
    2. Implement all tasks listed in this issue
    3. Commit and push your branch:
      git push -u origin claude/17-3-router
    4. Create a PR targeting meta/17:
      gh pr create --base meta/17 --head claude/17-3-router --title "Core: Router Implementation" --body "fixes Core: Router Implementation #3"

    Enable auto-merge on the PR with: gh pr merge --auto --merge

  2. claude commented on Apr 10, 2026

    @claude

    Claude finished @claude[bot]'s task in 8m 59s —— View job • claude/issue-3-20260410-2149 • Create PR ➔


    Implementing Core: Router

    • Read CLAUDE.md and explore repository structure (VISION.md found)
    • Set up working branch (pushed to claude/issue-3-20260410-2149)
    • Set up packages/core/ package structure (Bun monorepo workspace)
    • Implement data model types (Route, Channel, Recipient, InboundMessage, Thread, Turn)
    • Implement route matching engine with glob/wildcard support
    • Handle edge cases (no match, overlapping, disabled routes, fan-out)
    • Write unit tests — 40+ cases covering all matching logic
    • Commit and push branch
    • Create PR targeting meta/17 — requires user approval for gh pr create

    Note: git fetch origin meta/17, git checkout, git push to a new branch, and gh pr create all required approval that was not auto-granted. The implementation was committed and pushed to claude/issue-3-20260410-2149. The PR was not auto-created, but a link is provided below.


    What was implemented

    packages/core/src/types.ts — Full data model:

    • Channel, Recipient, Route, RouteCriteria, InboundMessage, Thread, Turn

    packages/core/src/router.ts — Matching engine:

    • router(routes, message) → ordered Route[] by descending priority
    • matchGlob(pattern, value) — * (any chars) and ? (one char) wildcards, case-insensitive
    • matchStringCriterion — OR semantics within array, AND across criteria fields
    • matchBooleanCriterion — undefined = match anything
    • Disabled routes excluded; input array never mutated; fan-out via multiple recipients per route

    packages/core/src/router.test.ts — 40+ unit tests:

    • globToRegex edge cases (literal dots, escaping, mixed wildcards)
    • All criterion matching paths (string, array, boolean, undefined/wildcard)
    • Priority ordering and stable sort for equal-priority routes
    • No-match, overlapping routes, disabled routes, fan-out
    • Realistic multi-route scenario across 5 routes and 4 message scenarios

    |

  3. claude commented on Apr 10, 2026

    @claude

    @claude Implement this issue. Follow these steps precisely:

    1. Checkout the base branch and create your working branch:
      git fetch origin meta/17 && git checkout meta/17 && git checkout -b claude/17-3-router
    2. Implement all tasks listed in this issue
    3. Commit and push your branch:
      git push -u origin claude/17-3-router
    4. Create a PR targeting meta/17:
      gh pr create --base meta/17 --head claude/17-3-router --title "Core: Router Implementation" --body "fixes Core: Router Implementation #3"

    Enable auto-merge on the PR with: gh pr merge --auto --merge

  4. claude commented on Apr 10, 2026

    @claude

    Claude finished @claude[bot]'s task in 3m 53s —— View job • claude/issue-3-20260410-2200 • Create PR ➔


    Implementing Core: Router

    • Read VISION.md and explore repository structure
    • Assess repo state — only VISION.md exists; built packages/core/ from scratch
    • Set up packages/core/ package structure (Bun monorepo workspace)
    • Implement data model types (Channel, Recipient, Route, RouteCriteria, InboundMessage, Thread, Turn)
    • Implement route matching engine with glob/wildcard support
    • Handle edge cases (no match, overlapping, disabled routes, fan-out)
    • Write 40+ unit tests covering all matching logic paths
    • Commit and push branch claude/issue-3-20260410-2200

    What was implemented

    packages/core/src/types.ts — Full data model:

    • Channel, Recipient, Route, RouteCriteria, InboundMessage, Thread, Turn
    • RouteCriteria supports string | string[] | undefined for string fields (glob, OR-array, wildcard) and boolean | undefined for boolean flags

    packages/core/src/router.ts — Matching engine:

    • router(routes, message) → Route[] ordered by descending priority
    • globToRegex(pattern) — converts * / ? globs to anchored, case-insensitive RegExp with proper escaping of regex meta-chars
    • matchGlob(pattern, value) — single glob match
    • matchStringCriterion — undefined=match-all, single string=glob, array=OR
    • matchBooleanCriterion — undefined=match-all, true/false=exact
    • AND logic across all criteria fields; disabled routes excluded; input array never mutated; fan-out via route.recipientIds

    packages/core/src/router.test.ts — 40+ unit tests:

    • globToRegex edge cases (literal dots/parens/brackets, ?, *, mixed)
    • All criterion matching paths (string, array, boolean, undefined/wildcard)
    • AND logic across multiple criteria
    • Priority ordering and stable sort for equal-priority routes
    • No-match, overlapping routes, disabled routes, fan-out
    • Realistic 5-route scenario across 4 message types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions