feat(dispatch): implement Middleware base and pipeline executor #338

Merged
freemo merged 3 commits from feature/m1-middleware-pipeline into master 2026-04-01 01:52:12 +00:00
Owner

Summary

  • Implemented Middleware base class (lib/aethyr/core/commands/middleware.rb) with priority ordering (default 500), phase designation (:before_action/:after_action), call(action, context) interface, and class-level register method
  • Implemented MiddlewarePipeline executor (lib/aethyr/core/commands/middleware_pipeline.rb) with Mutex-protected registry, priority-sorted before/after phases, and throw(:halt) chain interruption mechanism
  • Added 19 Cucumber BDD scenarios covering execution order, halt behavior, argument validation, context passing, class-level registration, and edge cases

Closes #105

Implementation Details

  • Thread-safe: Registry is protected by a Mutex; snapshot_middleware extracts before/after lists under the lock, then execution proceeds without holding the lock
  • Immutable defaults: VALID_PHASES is frozen; priority and phase are set at construction time
  • Argument validation: All public methods validate types per CONTRIBUTING.md (nil checks, type verification, value range for phases)
  • Sorbet typed: Both source files use # typed: strict with full sig annotations
  • RuboCop clean: 0 offenses on all new files
  • Full BDD coverage: 19 scenarios, 74 steps, all passing
## Summary - Implemented `Middleware` base class (`lib/aethyr/core/commands/middleware.rb`) with priority ordering (default 500), phase designation (:before_action/:after_action), `call(action, context)` interface, and class-level `register` method - Implemented `MiddlewarePipeline` executor (`lib/aethyr/core/commands/middleware_pipeline.rb`) with Mutex-protected registry, priority-sorted before/after phases, and `throw(:halt)` chain interruption mechanism - Added 19 Cucumber BDD scenarios covering execution order, halt behavior, argument validation, context passing, class-level registration, and edge cases Closes #105 ## Implementation Details - **Thread-safe**: Registry is protected by a Mutex; `snapshot_middleware` extracts before/after lists under the lock, then execution proceeds without holding the lock - **Immutable defaults**: `VALID_PHASES` is frozen; priority and phase are set at construction time - **Argument validation**: All public methods validate types per CONTRIBUTING.md (nil checks, type verification, value range for phases) - **Sorbet typed**: Both source files use `# typed: strict` with full `sig` annotations - **RuboCop clean**: 0 offenses on all new files - **Full BDD coverage**: 19 scenarios, 74 steps, all passing
freemo added this to the v1.0.0 milestone 2026-03-31 05:32:28 +00:00
feat(dispatch): implement Middleware base and pipeline executor
Some checks failed
CI / unit_tests (pull_request) Failing after 21m16s
CI / build (pull_request) Has been skipped
CI / integration_tests (pull_request) Failing after 3m54s
CI / type_check (pull_request) Failing after 3m59s
CI / lint (pull_request) Failing after 9m14s
43b7997e5d
Implemented the Middleware base class with priority ordering, phase
designation (before_action/after_action), and class-level registration.
Added the MiddlewarePipeline executor with priority-sorted before/after
phases and throw(:halt) chain interruption mechanism. Thread-safe
Mutex-protected registry. Full Cucumber BDD coverage including priority
ordering, halt behavior, argument validation, and context passing.

ISSUES CLOSED: #105
freemo force-pushed feature/m1-middleware-pipeline from 43b7997e5d to 00137d6e3d 2026-03-31 19:24:40 +00:00 Compare
freemo force-pushed feature/m1-middleware-pipeline from 00137d6e3d to b71a2d7348 2026-03-31 21:13:39 +00:00 Compare
freemo force-pushed feature/m1-middleware-pipeline from b71a2d7348 to c227b71c3b 2026-04-01 00:18:19 +00:00 Compare
freemo force-pushed feature/m1-middleware-pipeline from c227b71c3b to bfc3984dc9 2026-04-01 01:18:04 +00:00 Compare
freemo merged commit a1df8d4580 into master 2026-04-01 01:52:12 +00:00
freemo deleted branch feature/m1-middleware-pipeline 2026-04-01 01:52:12 +00:00
Sign in to join this conversation.
No reviewers
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#338
No description provided.