Rails on Rules
I was developing a framework/plugin for Ruby on Rails to enable and promote rule-based web development.
Rails on Rules is a Ruby library that provides application developers with an easy-to-use rule engine. Rule-based development can dramatically decrease the time it takes to develop a sophisticated application, while at the same time increasing the speed a development team can make simple and complicated local or application-wide changes.
Rails on Rules is stuck at the pre-alpha stage of development. There isn't any Rails-specific functionality, it's simply a Ruby library.
Status Updates
December 21, 2008
I'm learning git, and decided to create a git repository for the rules code as practice. I created a tarball from the repository (using the "git archive" command, cool!) and have created a public rules repository on GitHub as well.
I won't be making any improvements to the code in the forseeable future, but if someone finds it useful and wants to improve it they can fork the public GitHub repo and publish their changes (if they're generous enough to do so).
June 19, 2007
I've implemented the rule lookup cache in the rule engine. The engine is now looking really good... it still needs more tests and more polish, but it's at the point where it needs some real use. So at this point I am switching my focus to writing an application using the rule engine to help me work out the Rails-side API. I am thinking of starting with the D2W-like task-oriented templates.
For your information, some historical perspective on D2W:
June 18, 2007
The rule engine is alive! I found more time to work on this during WWDC and on the way home, and I now have lookups running through the engine. This includes caching of qualifier objects in the engine and caching of qualifier evaluation in the context. I abandoned the DNF transformations to the qualifiers. Down the road, something along those lines might be considered again as an optimization, but I think the approach I'm taking now is better than what I had before.
Currently, I'm not caching the result of lookups in the context, this is an obvious and important thing to do, and will be done once I've done more testing and further improved the test suite.
Gotta stay agile!
June 15, 2007
I've had little time to code during WWDC, but I have managed to complete the algorithm that converts any qualifier graph into DNF with no nesting. ie: an array of AndQualiifiers containing only KeyValueQualifiers and KeyComparisonQualifiers.
June 4, 2007
I am currently experimenting with algorithms and data structures for representing and evaluting rules. I have done limited research into existing implementations, because I also want this project to help me discover what works and what doesn't on my own.
In order to make evaluation of rules perform better than linear in the number of rules, I will convert the rules' clauses into qualifier graphs, as in EOQualifier and friends in EOF/D2W. I found a BSD-licensed implementation of qualifiers in TapKit, which I intend to adapt for my needs. TapKit's qualifier classes assume you're using their base classes for database-backed objects, whereas I don't want the engine to be limited to working with objects descending from a certain class.
My current idea is to convert all supplied rules into DNF (disjunctive normal form / sum of products) clauses, and building a separate tree for each RHS key from those clauses weighted by the frequency of the conjuncts.
Goals
Make it easy to take advantage of rules in "traditional" Rails applications - it mustn't be an all-or-nothing proposition.
Make it easy for developers to create and maintain rules.
Make it easy for developers to debug rules.
Support rapid-turnaround (don't require app restarts to reload rules).
Ship base rules that add value immediately for any developer that starts incorporating rules into their application.
Perform well.
Be well documented and easy to understand for developers new to rule-based development.
Make rule-based development attractive to developers using other languages/frameworks.
Plan
I am here: First, I need to design and implement the rule engine.
Then, I need to make something compelling that uses the rule engine.
Then, I need to make it easy for other developers to use and extend that something.
Then, I need to promote the solution. (This document is the start of that effort)