feat(lifecycle): add HookEvent and LifecycleHooks registry #340

Merged
freemo merged 2 commits from feature/m1-lifecycle-hooks into master 2026-04-01 01:52:55 +00:00
Owner

Summary

Closes #83

Implements the foundational lifecycle hooks system for the Aethyr MUD framework:

  • HookEvent — Immutable data class carrying type (Symbol), source (Object), data (Hash), and cancelled (Boolean) fields. Both the event object and its data hash are frozen on creation.

  • LifecycleHooks — Singleton registry module providing thread-safe on/once/off/emit methods with Mutex-protected callback storage. Callbacks fire in registration order; one-shot callbacks auto-remove after first invocation.

Changes

File Description
lib/aethyr/core/components/lifecycle/hook_event.rb HookEvent immutable data class
lib/aethyr/core/components/lifecycle/lifecycle_hooks.rb LifecycleHooks registry with on/once/off/emit
tests/unit/lifecycle_hooks.feature 20 BDD scenarios covering all acceptance criteria
tests/unit/step_definitions/lifecycle_hooks_steps.rb Step definitions with custom :symbol ParameterType

Testing

  • 20 scenarios, 64 steps — all passing
  • Covers: registration, emission, one-shot callbacks, removal, immutability, argument validation, registration order, and return values
  • Rubocop: 0 offenses on all new files
  • Thread-safety via Mutex-protected callback storage
## Summary Closes #83 Implements the foundational lifecycle hooks system for the Aethyr MUD framework: - **`HookEvent`** — Immutable data class carrying `type` (Symbol), `source` (Object), `data` (Hash), and `cancelled` (Boolean) fields. Both the event object and its data hash are frozen on creation. - **`LifecycleHooks`** — Singleton registry module providing thread-safe `on`/`once`/`off`/`emit` methods with Mutex-protected callback storage. Callbacks fire in registration order; one-shot callbacks auto-remove after first invocation. ## Changes | File | Description | |------|-------------| | `lib/aethyr/core/components/lifecycle/hook_event.rb` | HookEvent immutable data class | | `lib/aethyr/core/components/lifecycle/lifecycle_hooks.rb` | LifecycleHooks registry with on/once/off/emit | | `tests/unit/lifecycle_hooks.feature` | 20 BDD scenarios covering all acceptance criteria | | `tests/unit/step_definitions/lifecycle_hooks_steps.rb` | Step definitions with custom `:symbol` ParameterType | ## Testing - 20 scenarios, 64 steps — all passing - Covers: registration, emission, one-shot callbacks, removal, immutability, argument validation, registration order, and return values - Rubocop: 0 offenses on all new files - Thread-safety via Mutex-protected callback storage
freemo added this to the v1.0.0 milestone 2026-03-31 05:46:46 +00:00
feat(lifecycle): add HookEvent and LifecycleHooks registry
Some checks failed
CI / type_check (pull_request) Failing after 20m36s
CI / lint (pull_request) Failing after 20m43s
CI / unit_tests (pull_request) Failing after 20m46s
CI / build (pull_request) Has been skipped
CI / integration_tests (pull_request) Failing after 3m56s
231ed62582
Implemented the HookEvent immutable data class with type, source, data, and
cancelled fields, and the LifecycleHooks singleton registry with thread-safe
on/once/off/emit methods using Mutex-protected callback storage. Added
comprehensive Cucumber BDD scenarios covering registration, emission,
one-shot callbacks, removal, immutability, and argument validation.

ISSUES CLOSED: #83
freemo force-pushed feature/m1-lifecycle-hooks from 231ed62582 to d4ad67752c 2026-03-31 18:45:03 +00:00 Compare
freemo force-pushed feature/m1-lifecycle-hooks from d4ad67752c to f33982665e 2026-03-31 19:21:33 +00:00 Compare
freemo force-pushed feature/m1-lifecycle-hooks from f33982665e to 6270741a38 2026-03-31 21:13:38 +00:00 Compare
freemo force-pushed feature/m1-lifecycle-hooks from 6270741a38 to 9a52108ea1 2026-04-01 00:54:13 +00:00 Compare
freemo force-pushed feature/m1-lifecycle-hooks from 9a52108ea1 to b570dbe54d 2026-04-01 01:16:58 +00:00 Compare
freemo force-pushed feature/m1-lifecycle-hooks from b570dbe54d to 9b3d7e1cf1 2026-04-01 01:25:11 +00:00 Compare
freemo merged commit 77041274d8 into master 2026-04-01 01:52:55 +00:00
freemo deleted branch feature/m1-lifecycle-hooks 2026-04-01 01:52:56 +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.

Dependencies

No dependencies set.

Reference: aethyr/Aethyr#340
No description provided.