The business rule engine
Every serious SaaS application eventually needs to enforce rules that are not about permissions. Not whether you can do something, but whether you are allowed to do that much of it. Tier limits, age requirements, consumption caps. Dawnshard has a general-purpose engine for this, and it sits cleanly between RBAC and the operation.
What we built
The business rule engine evaluates policy constraints after RBAC passes and before an operation completes. RBAC asks whether an actor is permitted to perform an action. The business rule engine asks a different question: given that the actor is permitted, does this operation fall within the rules that apply to them?
Rules are compiled into a versioned bundle. That bundle is published to make it active, and the active bundle is held in memory once loaded. Every evaluation after that hits the in-memory bundle directly, not the database.
Rules are jurisdiction-aware. A bundle can carry global defaults alongside country-level and subdivision-level overrides. At evaluation time the engine merges those layers, with the most specific jurisdiction winning. A global age floor of 16 can be overridden for a specific jurisdiction where different requirements apply, without touching any other jurisdiction.
The problem it solves
Permission systems handle access. They are not a natural fit for the kind of policy that changes by account tier, by jurisdiction, or over time as a product evolves. Baking tier logic into service code works once. By the third tier it is scattered, and changing a limit means tracking down every place that assumption lives.
The versioning requirement came from a real operational need. Rules that govern what subscribers can do need an audit trail. You need to be able to say what bundle was active at any given time, roll back to a previous version if something was wrong, and deploy changes deliberately rather than editing live data. Tracking bundle compilation as a step in that process is what makes the audit trail reliable.
The challenge
The design problem was how to fold this into the existing service layer without bolting it on as special handling. The rest of the system has consistent, clean paths through RBAC and into the base service. Introducing a separate policy check that sat outside that shape would have created exactly the kind of inconsistency the whole architecture is trying to avoid.
The answer was to run evaluation through the standard CRUD paths and make the evaluator itself pluggable. New rule types register as evaluators against a key. The engine checks the compiled bundle for the current operation, finds the applicable evaluators, and runs them. Downstream applications can register their own evaluators without modifying the core, and they do not have to manage which evaluators get called. The bundle defines what applies; the engine finds and calls the right handlers.
The same shape also covers feature flags, which solve a similar targeting problem in a different direction. Feature flags are not about enforcing limits, they are about selectively enabling behaviour across regions, tiers, or account segments. The targeting mechanics are the same: jurisdiction, account type level, operation. A different kind of thing using the same infrastructure.
What makes this different
Most applications implement tier enforcement inline. A service checks a limit, a route handler checks a flag, a scheduled job checks a quota. Each check makes sense in isolation, and together they form a policy layer that nobody intentionally designed.
Here the policy layer is explicit and versioned. Every rule that applies to a given actor and operation exists in one compiled bundle. Publishing a new bundle is the mechanism for changing policy, which means changes are deliberate, traceable, and reversible. Rollback is not an emergency procedure. It is a first-class operation.
The jurisdiction model also means a downstream application can express rules like "16 in Australia, 13 in the US" without adding conditional logic to the service. The rule data carries the jurisdiction scope. The engine handles the merge.
What this unlocks
For Plan.Make.Trace specifically, the most immediate application will be consumption-based limits. When a workshop runs out of batch credits, the business rule engine is what enforces that cleanly, through the same evaluator path as everything else, without special-casing the batch service.
More broadly, any downstream application built on Dawnshard can express its own policy through this system. It can register custom evaluators, define its own rule types, and deploy bundles independently. None of that requires changes to the core, and none of it affects other applications on the same foundation.
What's next
The next post covers the channel and notification system: how Dawnshard dispatches messages across different delivery mechanisms without the domain code caring which one is in use.
Liked this post? Tap the heart to let us know.
Get early access
Be the first to hear about early access, roadmap updates, and exclusive early adopter pricing.
Join the early access list