Parameterized Rules: Initial broken prototype. Ugly.

Just for discussion (barely discussion at that.) There are a lot of parts of this that I find offensive and need much more work. DO NOT MERGE.
this usually means that query shouldn't be used in such condition, or?