Implement RouteEntry data model and CommandRouter.register API #100

Open
opened 2026-03-15 04:13:13 +00:00 by freemo · 1 comment
Owner

Metadata

  • Commit Message: feat(dispatch): implement RouteEntry and CommandRouter.register
  • Branch: feature/m1-command-router

Background and Context

RouteEntry encapsulates a command registration: the action class, priority, required
permission level, and metadata. CommandRouter.register is the public API for adding
commands to the trie.

Expected Behavior

  • RouteEntry stores action_class, priority, min_permission, and metadata
  • CommandRouter.register(keyword, action_class, **opts) inserts into the trie
  • Multiple keywords can register the same action class (aliases)
  • Registration happens at class load time

Acceptance Criteria

  • RouteEntry data class with accessors
  • CommandRouter singleton with register method
  • Alias support (multiple keywords for one action)
  • BDD scenarios for registration and lookup

Subtasks

  • Implement RouteEntry data class
  • Implement CommandRouter singleton with register method
  • Support alias registration
  • Write Cucumber scenarios

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the
    Commit Message in Metadata exactly.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata.
  • The commit is submitted as a pull request to master, reviewed, and merged.
## Metadata - **Commit Message**: `feat(dispatch): implement RouteEntry and CommandRouter.register` - **Branch**: `feature/m1-command-router` ## Background and Context `RouteEntry` encapsulates a command registration: the action class, priority, required permission level, and metadata. `CommandRouter.register` is the public API for adding commands to the trie. ## Expected Behavior - `RouteEntry` stores `action_class`, `priority`, `min_permission`, and `metadata` - `CommandRouter.register(keyword, action_class, **opts)` inserts into the trie - Multiple keywords can register the same action class (aliases) - Registration happens at class load time ## Acceptance Criteria - `RouteEntry` data class with accessors - `CommandRouter` singleton with `register` method - Alias support (multiple keywords for one action) - BDD scenarios for registration and lookup ## Subtasks - [x] Implement RouteEntry data class - [x] Implement CommandRouter singleton with register method - [x] Support alias registration - [x] Write Cucumber scenarios ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged**.
freemo added this to the (deleted) milestone 2026-03-15 04:13:13 +00:00
freemo self-assigned this 2026-03-15 04:25:23 +00:00
freemo modified the milestone from (deleted) to v1.0.0 2026-03-16 00:28:02 +00:00
Author
Owner

Implementation Notes

Design Decisions

  • RouteEntry uses **opts with DEFAULTS constant to keep parameter lists under rubocop limits
  • CommandRouter is a thread-safe Singleton with Mutex-protected registration
  • All command strings and aliases lowercased and deduplicated on creation
  • regex_routes tracked separately for dispatch fallback chain

Code Locations

  • Aethyr::Core::Commands::RouteEntry in lib/aethyr/core/commands/route_entry.rb
  • Aethyr::Core::Commands::CommandRouter in lib/aethyr/core/commands/command_router.rb

Test Results

  • 16 BDD scenarios, all passing
  • Rubocop: 0 offenses
## Implementation Notes ### Design Decisions - RouteEntry uses `**opts` with DEFAULTS constant to keep parameter lists under rubocop limits - CommandRouter is a thread-safe Singleton with Mutex-protected registration - All command strings and aliases lowercased and deduplicated on creation - regex_routes tracked separately for dispatch fallback chain ### Code Locations - `Aethyr::Core::Commands::RouteEntry` in `lib/aethyr/core/commands/route_entry.rb` - `Aethyr::Core::Commands::CommandRouter` in `lib/aethyr/core/commands/command_router.rb` ### Test Results - 16 BDD scenarios, all passing - Rubocop: 0 offenses
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference: aethyr/Aethyr#100
No description provided.