SmartGare
Backend modules

Business rules

Product-declared domains, effective time, version lifecycle, and exact or contextual resolution.

The Rules module stores station-tunable policy as effective-dated versions. Product code declares what a rule domain means; station administrators create rule identities and content inside those declared domains.

Domain declaration

A RuleDomainDefinition declares:

  • stable code and JSON content schema;
  • effective-input kind: LOCAL_DATE, LOCAL_DATE_TIME, or EXACT_INSTANT;
  • consuming capability and mandatory flag;
  • allowed scope dimensions and total precedence;
  • fixed content elements.

Declarations are validated at startup. Unknown or ambiguous domains, scope dimensions, context keys, precedence, and JSON pointers stop startup.

Lifecycle

Only drafts are mutable. Approval revalidates content and canonical scope and publishes RuleVersionScheduled, not an early activation event.

Activation atomically closes the prior active version for the same rule and scope. Every successful lifecycle move records actor, time, before/after state, and reason.

Time semantics

Local inputs are interpreted against the configured IANA station timezone. Nonexistent or ambiguous local times are refused rather than shifted or guessed. Exact instants never depend on host time.

Intervals include effectiveAt and exclude inactivatedAt. A successor closes its predecessor at the approved instant even when the scheduler runs later.

Resolution

ModeAnswer
Exact scopeOne rule, canonical scope, and instant → Resolved or None
ContextualMatch every eligible scope, order by declared precedence, return winner plus explanation candidates

Consumers call RuleResolver through the published module API and never interpret empty collections as defaults.

Engine shipped; production domains pending

No production policy domain is declared yet. The lifecycle and resolver are delivered, but station policy content does not exist until product code adds its domain definition.

On this page