lmjtfy.git / packages / rules / src / README.md

Chapter 6½: inside rules/src

Two files. lib.rs is the whole engine and every rule, in about 500 lines, and it reads well from top to bottom:

  1. The vocabulary. Kind (yes-or-no, pick, how-much, how-likely), Fact (everything that can be known about a question), Value, and Source (who teaches a fact: Jev, the LLM, or Jev again).
  2. What a rule can say. Test (a fact is a value, or is known), and Then: an End (stop with this), an Effect (go and make a call), or a Note (show this; list it).
  3. RULES. The rules themselves, as data. This is the list in chapter 6, and the one place to change what the site does.
  4. Known. What has been learned so far about one question.
  5. Network. compile builds the Rete network from the rules; next and decide say what to do; alpha, join and used are what the diagram draws.

tests.rs holds the engine to its promises, including the one that matters most: every way the Jev facts can fall ends with something to show or something to do (every_way_the_jev_facts_can_fall_ends_or_does_something).

Try it. cargo test -p rules runs them, offline, in well under a second.

FileWhat
lib.rsFacts, tests, rules, RULES, Known, and the Network that compiles and runs them.
tests.rsThe engine's tests: each kind of question takes its path, rules share the tests they have in common, a failed test fails what follows it, and every answerable outcome is covered.

← Previous: Chapter 6, rules/ · Up: rules · Next: Chapter 7, ask/ →