Add event sourcing with Verbs for audit trail and replay capability#316
Open
Add event sourcing with Verbs for audit trail and replay capability#316
Conversation
This implements a hybrid event sourcing architecture using Verbs by Thunk. Eloquent remains the source of truth for reads (Filament, API, status page), while Verbs captures all state changes for audit trails and replay capability. ## New Files ### State Classes (4) - `src/Verbs/States/ComponentState.php` - `src/Verbs/States/ComponentGroupState.php` - `src/Verbs/States/IncidentState.php` - `src/Verbs/States/ScheduleState.php` ### Event Classes (20) - Components: Created, Updated, Deleted, StatusChanged - ComponentGroups: Created, Updated, Deleted - Incidents: Created, Updated, Deleted, UpdateRecorded, ComponentAttached/Detached - Schedules: Created, Updated, Deleted, Completed, UpdateRecorded, ComponentAttached/Detached ### Migration - `database/migrations/2026_01_12_000000_initialize_verbs_events.php` Creates initial Verbs events for existing data ## Modified Files ### Action Classes All create/update/delete actions now fire Verbs events instead of direct Eloquent operations. The events handle persistence and dispatch existing webhook events via `Verbs::unlessReplaying()`. ### Filament Pages All Filament create/edit pages now use action classes to ensure state changes are captured by Verbs. The Components widget status toggle also fires ComponentStatusChanged events. ### Models Removed `$dispatchesEvents` from Component and Incident models since webhook events are now dispatched from Verbs event handlers. Co-Authored-By: Claude Opus 4.5 <[email protected]>
joelbutcher
reviewed
Jan 29, 2026
| public function handle(CreateComponentRequestData $data): Component | ||
| { | ||
| return Component::create($component->toArray()); | ||
| return ComponentCreated::commit( |
Collaborator
There was a problem hiding this comment.
@jbrooksuk why Event::commit(..) over Event::fire(...)?
Collaborator
There was a problem hiding this comment.
Ah never mind, read the docs XD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
New Dependencies
hirethunk/verbs- Event sourcing packageNew State Classes (4)
Track current state of each resource:
ComponentState- status history, incident/schedule associationsComponentGroupState- component membershipsIncidentState- status history, affected components, updatesScheduleState- affected components, updatesNew Event Classes (20)
Capture all state changes:
Modified Action Classes
All create/update/delete actions now fire Verbs events. Events handle:
apply()handle()Verbs::unlessReplaying()Modified Filament Pages
All create/edit pages route through action classes to ensure Verbs captures changes:
Migration
2026_01_12_000000_initialize_verbs_events.phpcreates initial events for existing data:php artisan migratedown()methodTest plan
🤖 Generated with Claude Code