arkency
Read post

Ingress is not the owner of the invariant

A polemic response to Brandon Weaver's 'Callbacks Are Not Invariants' post, agreeing on the diagnosis (Rails callbacks are problematic) but disputing the cure. The author argues that Weaver's Command/Transaction Script pattern still spreads the invariant across multiple layers (runtime check, row lock, DB constraint) rather than giving it a single owner. The proposed alternative uses an aggregate model where the domain object owns the invariant, produces a typed domain event (past tense, result payload), and persists that event atomically in the same transaction as the state change — making effects always replayable. The author also critiques Weaver's naming: calling a Transaction Script a 'command' and ActiveSupport::Notifications a 'domain event' installs a misleading mental model for large teams. The post demonstrates both a bare ActiveRecord implementation and a RailsEventStore version, and argues that persisting domain facts from day one is record-path hygiene, not event sourcing overkill.

    #architecture#rails#domain-driven-design
Jun 18•13m read time•From blog.arkency.com
Post cover image
Table of contents
We agree about the diseaseA name that promises more than it deliversCore: ingress doesn’t own the invariantWhat it looks like when an invariant has an ownerAnd if you don’t want to write it by handWhere Weaver is right — and what I’m not sayingLanding
768 Impressions
arkency's image
arkency

Arkency Blog offers insights, tutorials, and updates on Ruby on Rails development, domain-driven des...

0 Followers

•

19 Upvotes

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard