Skip to content

Reference & Data Model

The rule engine (system_derived_record)

How Aligia turns an input record into a derived record with provenance.

Input record changes (create · update · delete)
│
▼
Rule checks: “does this change concern me?” (only certain fields)
│ yes
▼
Rule re-reads the source FRESH from the database and computes the target state
│
├─ condition met → desired row(s) with value, date, cost item
├─ condition dropped → no row desired
└─ prerequisite missing (e.g. cost item) → “skip”, change nothing
│
▼
Reconcile against the provenance ledger (system_derived_record)
├─ create-only: create only what is not yet known
└─ reconcile: create · update · remove

Each rule has a fixed key (e.g. time_log.personal_cost) and reacts only to changes to certain fields of its source. It always computes the target state from the current database state, never from the event itself. Two simultaneous changes to the same source are processed one after the other; the later one wins.

Every derived row is recorded in the provenance ledger (system_derived_record): rule key, source record, target record. Per rule and source there is exactly one target row per key. The target row itself additionally carries the source (source_id) and the rule key (rule_key); from these the interface builds the „Quelle“ (source) text with a link to the origin (e.g. „Zeiterfassung · Max Muster vom 20.08.2026“). The ledger is server-side only and not visible; see Derived record.

Policy Create Update Remove Targets
create-only on the first matching event never never actual booking, cost item
reconcile when the condition is met on every relevant change to the source when the condition no longer holds planned item, stock movement

“Remove” means soft delete: the row disappears from the interface and comes back when the condition is met again (the same row is revived).

  • reconcile: The source counts as “no longer present” → the derived planned item or stock movement is removed. If the source is restored, the row is created again.
  • create-only: Nothing. A booked actual booking remains, even if the time log, the purchase or the risk is later deleted. Only deleting the project or the cost item takes the booking along as a cascade (see Locks & delete protection).

If a prerequisite is missing (no cost item of the matching category in the project, no hourly rate, no net price on the good, no date), the rule changes nothing and logs this server-side. Existing derived rows remain unchanged. On the next event at the source it tries again. A missed event (e.g. approval without a personnel cost item) is therefore not caught up automatically as long as the source does not change again.

  • Processing runs asynchronously in the background; derived rows typically appear within seconds, not instantly.
  • A system-generated row may never “move” to another table; that counts as a rule error.