Skip to content

mallond/rules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The World's Smallest Rules Engine

A small functional Rule Engine - simple maybe an understatement...

image

History

  • 02/08/16 Original Javascript without AI
  • 06/25/24 New Typescript version with AI

Intro

Simplicity is elegance. This rule engine is NOT forward chaining, backward chaining, nor is this an inference engine. What it is, is a pragmatic reactive engine. Simply stated, when there is a condition, execute an action -- most assuredly in a stateless manner.

Prime directives, and ables ...

  • Stateless
  • Simple input, output, and process
  • Asynchronous non-blocking invocations
  • Rules to be self contained and serializable to a database (persistable)
  • Rules to be versioned (versionable)
  • Rules to be inventoried and stored in a library (sharable)
  • Rules can be modified on-the-fly (adaptable)
  • Rules can be unit tested independently (testable)
  • Crazy fast

Martin Fowler on Rule Engines

AI 06/25/24

Much has changed in the last 9 years this simple example was created. We are in the AI Age and Prompts can do much of the work. It is the intention of this code to be used with AI prompts to generate versionalble rule-sets.

// Rule Abilities 
{ables: [persistable, versionable, shareable, adaptable, testable, chainable, reusable, extensible]}

AI Assisted Code Generation Claude Sonnet 3.5

Upload Example Code and let AI create executable examples

image

Cloude Sonnet 3.5 Generated New Code

image

Done-Done, like it Worked!

  • Use your imagination
  • Upgrade Existing Code
  • Use AI

A few Use Cases for Usage

  • Validations
  • Mappings
  • Calculations
  • Batch processing
  • Automated business rules - decision engine
  • Automation of sequential events and process
  • Home security, sprinkler systems, and darn maybe your car...

Benefits

  • Repository of rules
  • Traceability
  • Modify the rule not the code
  • Dynamic changeability - conditions change so do the execution
  • Easy to understand and modify
  • Extensible
  • Maintainable
  • Reusable
  • Chainable
  • Micro foot print and scalable

Design - IPO (Input Process Output)

image