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
freemo force-pushed feature/m1-lifecycle-hooks from 231ed62582
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
to d4ad67752c
Some checks failed
CI / lint (pull_request) Successful in 9m26s
CI / integration_tests (pull_request) Failing after 11m58s
CI / unit_tests (pull_request) Failing after 47m26s
CI / type_check (pull_request) Successful in 19m52s
CI / build (pull_request) Has been skipped
2026-03-31 18:45:03 +00:00
Compare
freemo force-pushed feature/m1-lifecycle-hooks from d4ad67752c
Some checks failed
CI / lint (pull_request) Successful in 9m26s
CI / integration_tests (pull_request) Failing after 11m58s
CI / unit_tests (pull_request) Failing after 47m26s
CI / type_check (pull_request) Successful in 19m52s
CI / build (pull_request) Has been skipped
to f33982665e
Some checks failed
CI / type_check (pull_request) Failing after 14m52s
CI / integration_tests (pull_request) Failing after 16m14s
CI / lint (pull_request) Successful in 20m24s
CI / unit_tests (pull_request) Failing after 39m43s
CI / build (pull_request) Has been skipped
2026-03-31 19:21:33 +00:00
Compare
freemo force-pushed feature/m1-lifecycle-hooks from f33982665e
Some checks failed
CI / type_check (pull_request) Failing after 14m52s
CI / integration_tests (pull_request) Failing after 16m14s
CI / lint (pull_request) Successful in 20m24s
CI / unit_tests (pull_request) Failing after 39m43s
CI / build (pull_request) Has been skipped
to 6270741a38
Some checks failed
CI / type_check (pull_request) Successful in 46s
CI / lint (pull_request) Successful in 1m17s
CI / integration_tests (pull_request) Failing after 4m39s
CI / unit_tests (pull_request) Successful in 21m52s
CI / build (pull_request) Has been skipped
2026-03-31 21:13:38 +00:00
Compare
freemo force-pushed feature/m1-lifecycle-hooks from 6270741a38
Some checks failed
CI / type_check (pull_request) Successful in 46s
CI / lint (pull_request) Successful in 1m17s
CI / integration_tests (pull_request) Failing after 4m39s
CI / unit_tests (pull_request) Successful in 21m52s
CI / build (pull_request) Has been skipped
to 9a52108ea1
Some checks failed
CI / type_check (pull_request) Successful in 43s
CI / lint (pull_request) Successful in 1m12s
CI / integration_tests (pull_request) Failing after 1m56s
CI / unit_tests (pull_request) Successful in 21m3s
CI / build (pull_request) Has been skipped
2026-04-01 00:54:13 +00:00
Compare
freemo force-pushed feature/m1-lifecycle-hooks from 9a52108ea1
Some checks failed
CI / type_check (pull_request) Successful in 43s
CI / lint (pull_request) Successful in 1m12s
CI / integration_tests (pull_request) Failing after 1m56s
CI / unit_tests (pull_request) Successful in 21m3s
CI / build (pull_request) Has been skipped
to b570dbe54d
Some checks failed
CI / type_check (pull_request) Successful in 41s
CI / lint (pull_request) Successful in 1m12s
CI / integration_tests (pull_request) Failing after 1m57s
CI / unit_tests (pull_request) Successful in 21m18s
CI / build (pull_request) Has been skipped
2026-04-01 01:16:58 +00:00
Compare
freemo force-pushed feature/m1-lifecycle-hooks from b570dbe54d
Some checks failed
CI / type_check (pull_request) Successful in 41s
CI / lint (pull_request) Successful in 1m12s
CI / integration_tests (pull_request) Failing after 1m57s
CI / unit_tests (pull_request) Successful in 21m18s
CI / build (pull_request) Has been skipped
to 9b3d7e1cf1
Some checks failed
CI / type_check (pull_request) Successful in 43s
CI / lint (pull_request) Successful in 1m16s
CI / integration_tests (pull_request) Failing after 1m25s
CI / unit_tests (pull_request) Successful in 20m57s
CI / build (pull_request) Has been skipped
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.