Skip to content

Conversation

@jbrooksuk
Copy link
Member

Summary

  • Implements hybrid event sourcing using Verbs by Thunk
  • Eloquent remains the source of truth for reads (Filament, API, status page)
  • Verbs captures all state changes for audit trails and replay capability
  • Includes migration to initialize events for existing data

Changes

New Dependencies

  • hirethunk/verbs - Event sourcing package

New State Classes (4)

Track current state of each resource:

  • ComponentState - status history, incident/schedule associations
  • ComponentGroupState - component memberships
  • IncidentState - status history, affected components, updates
  • ScheduleState - affected components, updates

New Event Classes (20)

Capture all state changes:

  • Components: Created, Updated, Deleted, StatusChanged
  • ComponentGroups: Created, Updated, Deleted
  • Incidents: Created, Updated, Deleted, UpdateRecorded, ComponentAttached/Detached
  • Schedules: Created, Updated, Deleted, Completed, UpdateRecorded, ComponentAttached/Detached

Modified Action Classes

All create/update/delete actions now fire Verbs events. Events handle:

  1. State updates via apply()
  2. Eloquent persistence via handle()
  3. Webhook dispatch via Verbs::unlessReplaying()

Modified Filament Pages

All create/edit pages route through action classes to ensure Verbs captures changes:

  • Component, ComponentGroup, Incident, Schedule pages
  • Components widget status toggle

Migration

2026_01_12_000000_initialize_verbs_events.php creates initial events for existing data:

  • Runs automatically on php artisan migrate
  • Skips if events already exist (idempotent)
  • Supports rollback via down() method

Test plan

  • All 356 existing tests pass
  • Verify events are created when using API endpoints
  • Verify events are created when using Filament dashboard
  • Verify webhook events still fire correctly
  • Test migration on database with existing data

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants