Rules, diagnostics and propagation
Documentation status: tutorial — see Maturity and evidence.
The stock model uses intermediate derived facts to preserve explanations.
A position is ConsistentStockPosition when its declared available quantity is supported by the relation Subtract(onHand, reserved, available).
A position becomes BelowReorderThreshold when the position and the applicable ReorderPolicy share the same product, warehouse and time and LessThan(available, threshold) holds. That intermediate fact then supports ReorderRequired(product, warehouse, time).
Keeping the intermediate fact matters: it preserves the stock position that justified the final recommendation, while the final recommendation remains attached to the product, warehouse and time that require action.
Positive diagnostic facts
Derive InvalidStockPosition when on-hand stock is negative, reserved stock is negative, or reserved stock is greater than on-hand stock.
A positive diagnostic fact is preferable to an invisible failure when the condition must be queried, explained, indexed, exposed in a view, returned by a service or attached to logical justifications. Whether an invalid position should also block persistence is a separate application-policy decision made during operationalization.