v0.4.0 release

v0.4.0 release

November 9, 2022

v0.4.0 is a major rewrite of large parts of the library.

This is a breaking release. Take special care to test your rules if you want to upgrade.

Overlays #

Overlays were intended to work as a layered filesystem, but in reality this only worked with assertions and positive matchers. They have now been completely rewritten to work with all existing matchers and track both assertions and retractions correctly.

Breaking change: only the current (top-most) overlay may be used for asserting and retracting facts. Doing this with a lower overlay will cause undefined behaviour. It may be implemented in a future release, or the restriction may become enforced if no good solution is found.

A lower overlay is again available for modification once the higher one goes out of scope.

Timelines #

Breaking change: the timeline functionality has been removed. It may return in a future release.

Aggregates #

Aggregates were introduced as an experimental feature in the 0.3.x lineage. They went through a number of redesigns and the API is now stable.

Performance #

Matchers with variables should now be faster when the variables are already bound by preceding matchers.

Consider the rule:

forall {
	has :P, :symmetric, true
	has :X, :P, :Y
}

During rule compilation the second matcher must be connected to the most generic alpha memory {_, _, _}, because all three triple elements are variables. However, using this alpha is wasteful in beta activation, because in that context P is already bound to a value, and we would be iterating through a lot of facts which are guaranteed to not match. In 0.4.0, the join nodes can make use of this information to find a more selective pre-filtered set of facts given the already bound variables.

In addition to this, a number of other performance improvements have been made.

Other known breaking changes #

Network#select now returns a live enumerator instead of an Array. If you want to alter the fact set while iterating over it, capture it with #to_a first.

Network#each is now favoured over #select. #select is not formally deprecated but it may be in the future.