← Graph

Enforcing boundaries with Packwerk given Rails dynamic calls

question 2 connections

Audience question: when splitting a Rails monolith into Packwerk-enforced domains, static analysis can stop direct constant references but not dynamic object-to-object calls via `has_many`/`belongs_to` or inheritance. How do you force all cross-domain calls through a single gateway/public API? Another audience member answers: dynamically wrap active-record `save`/`update` etc. so attempts to modify a record owned by another engine without going through its service layer raise an exception — enabled in the test env is enough to catch violations in CI.

answer_summary
Packwerk can't catch it; instead wrap ActiveRecord mutation methods at runtime to reject cross-engine writes that bypass the public service API. Enable only in tests.
question Enforcing boundaries with Packwerk given Rails dynamic calls
about
Packwerk tool
Asks about the limits of Packwerk's static analysis.
question Enforcing boundaries with Packwerk given Rails dynamic calls
asked_at
Final audience question, with follow-up from another attendee about active-record boundary hooks.

Provenance