kbs 0.0.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/deploy-github-pages.yml +52 -0
  3. data/CHANGELOG.md +68 -2
  4. data/README.md +291 -362
  5. data/docs/advanced/custom-persistence.md +775 -0
  6. data/docs/advanced/debugging.md +726 -0
  7. data/docs/advanced/index.md +8 -0
  8. data/docs/advanced/performance.md +865 -0
  9. data/docs/advanced/testing.md +827 -0
  10. data/docs/api/blackboard.md +1157 -0
  11. data/docs/api/engine.md +1047 -0
  12. data/docs/api/facts.md +1212 -0
  13. data/docs/api/index.md +12 -0
  14. data/docs/api/rules.md +1104 -0
  15. data/docs/architecture/blackboard.md +544 -0
  16. data/docs/architecture/index.md +277 -0
  17. data/docs/architecture/network-structure.md +343 -0
  18. data/docs/architecture/rete-algorithm.md +737 -0
  19. data/docs/assets/css/custom.css +83 -0
  20. data/docs/assets/images/blackboard-architecture.svg +136 -0
  21. data/docs/assets/images/compiled-network.svg +101 -0
  22. data/docs/assets/images/fact-assertion-flow.svg +117 -0
  23. data/docs/assets/images/fact-rule-relationship.svg +65 -0
  24. data/docs/assets/images/fact-structure.svg +42 -0
  25. data/docs/assets/images/inference-cycle.svg +47 -0
  26. data/docs/assets/images/kb-components.svg +43 -0
  27. data/docs/assets/images/kbs.jpg +0 -0
  28. data/docs/assets/images/pattern-matching-trace.svg +136 -0
  29. data/docs/assets/images/rete-network-layers.svg +96 -0
  30. data/docs/assets/images/rule-structure.svg +44 -0
  31. data/docs/assets/images/system-layers.svg +69 -0
  32. data/docs/assets/images/trading-signal-network.svg +139 -0
  33. data/docs/assets/js/mathjax.js +17 -0
  34. data/docs/examples/index.md +223 -0
  35. data/docs/guides/blackboard-memory.md +589 -0
  36. data/docs/guides/dsl.md +1321 -0
  37. data/docs/guides/facts.md +652 -0
  38. data/docs/guides/getting-started.md +385 -0
  39. data/docs/guides/index.md +23 -0
  40. data/docs/guides/negation.md +529 -0
  41. data/docs/guides/pattern-matching.md +561 -0
  42. data/docs/guides/persistence.md +451 -0
  43. data/docs/guides/variable-binding.md +491 -0
  44. data/docs/guides/writing-rules.md +914 -0
  45. data/docs/index.md +155 -0
  46. data/docs/installation.md +156 -0
  47. data/docs/quick-start.md +221 -0
  48. data/docs/what-is-a-fact.md +694 -0
  49. data/docs/what-is-a-knowledge-base.md +350 -0
  50. data/docs/what-is-a-rule.md +833 -0
  51. data/examples/.gitignore +1 -0
  52. data/examples/README.md +2 -2
  53. data/examples/advanced_example.rb +2 -2
  54. data/examples/advanced_example_dsl.rb +224 -0
  55. data/examples/ai_enhanced_kbs.rb +1 -1
  56. data/examples/ai_enhanced_kbs_dsl.rb +538 -0
  57. data/examples/blackboard_demo_dsl.rb +50 -0
  58. data/examples/car_diagnostic.rb +1 -1
  59. data/examples/car_diagnostic_dsl.rb +54 -0
  60. data/examples/concurrent_inference_demo.rb +5 -6
  61. data/examples/concurrent_inference_demo_dsl.rb +362 -0
  62. data/examples/csv_trading_system.rb +1 -1
  63. data/examples/csv_trading_system_dsl.rb +525 -0
  64. data/examples/iot_demo_using_dsl.rb +1 -1
  65. data/examples/portfolio_rebalancing_system.rb +2 -2
  66. data/examples/portfolio_rebalancing_system_dsl.rb +613 -0
  67. data/examples/redis_trading_demo_dsl.rb +177 -0
  68. data/examples/rule_source_demo.rb +123 -0
  69. data/examples/run_all.rb +50 -0
  70. data/examples/run_all_dsl.rb +49 -0
  71. data/examples/stock_trading_advanced.rb +1 -1
  72. data/examples/stock_trading_advanced_dsl.rb +404 -0
  73. data/examples/temp_dsl.txt +9392 -0
  74. data/examples/timestamped_trading.rb +1 -1
  75. data/examples/timestamped_trading_dsl.rb +258 -0
  76. data/examples/trading_demo.rb +1 -1
  77. data/examples/trading_demo_dsl.rb +322 -0
  78. data/examples/working_demo.rb +1 -1
  79. data/examples/working_demo_dsl.rb +160 -0
  80. data/lib/kbs/blackboard/engine.rb +3 -3
  81. data/lib/kbs/blackboard/fact.rb +1 -1
  82. data/lib/kbs/condition.rb +1 -1
  83. data/lib/kbs/decompiler.rb +204 -0
  84. data/lib/kbs/dsl/knowledge_base.rb +101 -2
  85. data/lib/kbs/dsl/variable.rb +1 -1
  86. data/lib/kbs/dsl.rb +3 -1
  87. data/lib/kbs/{rete_engine.rb → engine.rb} +42 -1
  88. data/lib/kbs/fact.rb +1 -1
  89. data/lib/kbs/version.rb +1 -1
  90. data/lib/kbs.rb +15 -13
  91. data/mkdocs.yml +181 -0
  92. metadata +74 -9
  93. data/examples/stock_trading_system.rb.bak +0 -563
data/mkdocs.yml ADDED
@@ -0,0 +1,181 @@
1
+ # MkDocs Configuration for KBS Documentation
2
+ site_name: KBS - Knowledge-Based Systems for Ruby
3
+ site_description: A Ruby implementation of the RETE algorithm for production rule systems with persistent blackboard memory
4
+ site_author: Dewayne VanHoozer
5
+ site_url: https://madbomber.github.io/kbs
6
+ copyright: Copyright © 2024 Dewayne VanHoozer
7
+
8
+ # Repository information
9
+ repo_name: madbomber/kbs
10
+ repo_url: https://github.com/madbomber/kbs
11
+ edit_uri: edit/main/docs/
12
+
13
+ # Configuration
14
+ theme:
15
+ name: material
16
+
17
+ # Color scheme - Default to light mode
18
+ palette:
19
+ # Palette toggle for light mode (default)
20
+ - scheme: default
21
+ primary: deep purple
22
+ accent: purple
23
+ toggle:
24
+ icon: material/brightness-7
25
+ name: Switch to dark mode
26
+
27
+ # Palette toggle for dark mode
28
+ - scheme: slate
29
+ primary: deep purple
30
+ accent: purple
31
+ toggle:
32
+ icon: material/brightness-4
33
+ name: Switch to light mode
34
+
35
+ # Typography
36
+ font:
37
+ text: Roboto
38
+ code: Roboto Mono
39
+
40
+ # Theme features
41
+ features:
42
+ # Navigation
43
+ - navigation.instant
44
+ - navigation.tracking
45
+ - navigation.tabs
46
+ - navigation.tabs.sticky
47
+ - navigation.sections
48
+ - navigation.path
49
+ - navigation.indexes
50
+ - navigation.top
51
+
52
+ # Table of contents
53
+ - toc.follow
54
+
55
+ # Search
56
+ - search.suggest
57
+ - search.highlight
58
+ - search.share
59
+
60
+ # Header
61
+ - header.autohide
62
+
63
+ # Content
64
+ - content.code.copy
65
+ - content.code.annotate
66
+ - content.tabs.link
67
+ - content.tooltips
68
+ - content.action.edit
69
+ - content.action.view
70
+
71
+ # Plugins
72
+ plugins:
73
+ - search:
74
+ separator: '[\s\-,:!=\[\]()"`/]+|\.(?!\d)|&[lg]t;|(?!\b)(?=[A-Z][a-z])'
75
+
76
+ # Extensions
77
+ markdown_extensions:
78
+ # Python Markdown
79
+ - abbr
80
+ - admonition
81
+ - attr_list
82
+ - def_list
83
+ - footnotes
84
+ - md_in_html
85
+ - toc:
86
+ permalink: true
87
+ title: On this page
88
+
89
+ # Python Markdown Extensions
90
+ - pymdownx.arithmatex:
91
+ generic: true
92
+ - pymdownx.betterem:
93
+ smart_enable: all
94
+ - pymdownx.caret
95
+ - pymdownx.details
96
+ - pymdownx.emoji:
97
+ emoji_generator: !!python/name:material.extensions.emoji.to_svg
98
+ emoji_index: !!python/name:material.extensions.emoji.twemoji
99
+ - pymdownx.highlight:
100
+ anchor_linenums: true
101
+ line_spans: __span
102
+ pygments_lang_class: true
103
+ - pymdownx.inlinehilite
104
+ - pymdownx.keys
105
+ - pymdownx.magiclink:
106
+ repo_url_shorthand: true
107
+ user: madbomber
108
+ repo: kbs
109
+ - pymdownx.mark
110
+ - pymdownx.smartsymbols
111
+ - pymdownx.superfences:
112
+ custom_fences:
113
+ - name: mermaid
114
+ class: mermaid
115
+ format: !!python/name:pymdownx.superfences.fence_code_format
116
+ - pymdownx.tabbed:
117
+ alternate_style: true
118
+ - pymdownx.tasklist:
119
+ custom_checkbox: true
120
+ - pymdownx.tilde
121
+
122
+ # Extra CSS and JavaScript
123
+ extra_css:
124
+ - assets/css/custom.css
125
+
126
+ extra_javascript:
127
+ - assets/js/mathjax.js
128
+ - https://polyfill.io/v3/polyfill.min.js?features=es6
129
+ - https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
130
+
131
+ # Social media and extra configuration
132
+ extra:
133
+ social:
134
+ - icon: fontawesome/brands/github
135
+ link: https://github.com/madbomber/kbs
136
+ name: KBS on GitHub
137
+ - icon: fontawesome/solid/gem
138
+ link: https://rubygems.org/gems/kbs
139
+ name: KBS on RubyGems
140
+
141
+ version:
142
+ provider: mike
143
+
144
+ # Navigation
145
+ nav:
146
+ - Home:
147
+ - index.md
148
+ - What is aKnowledge Base?: what-is-a-knowledge-base.md
149
+ - What is a Fact?: what-is-a-fact.md
150
+ - What is a Rule?: what-is-a-rule.md
151
+ - Installation: installation.md
152
+ - Quick Start: quick-start.md
153
+ - Architecture:
154
+ - architecture/index.md
155
+ - RETE Algorithm: architecture/rete-algorithm.md
156
+ - Blackboard System: architecture/blackboard.md
157
+ - Network Structure: architecture/network-structure.md
158
+ - Guides:
159
+ - guides/index.md
160
+ - Getting Started: guides/getting-started.md
161
+ - Writing Rules: guides/writing-rules.md
162
+ - DSL Reference: guides/dsl.md
163
+ - Working with Facts: guides/facts.md
164
+ - Pattern Matching: guides/pattern-matching.md
165
+ - Variable Binding: guides/variable-binding.md
166
+ - Negation: guides/negation.md
167
+ - Blackboard Memory: guides/blackboard-memory.md
168
+ - Persistence Options: guides/persistence.md
169
+ - Examples: examples/index.md
170
+ - Advanced:
171
+ - advanced/index.md
172
+ - Performance Tuning: advanced/performance.md
173
+ - Custom Persistence: advanced/custom-persistence.md
174
+ - Debugging: advanced/debugging.md
175
+ - Testing Rules: advanced/testing.md
176
+ - API Reference:
177
+ - api/index.md
178
+ - ReteEngine: api/engine.md
179
+ - Facts: api/facts.md
180
+ - Rules: api/rules.md
181
+ - Blackboard: api/blackboard.md
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dewayne VanHoozer
@@ -13,14 +13,14 @@ dependencies:
13
13
  name: sqlite3
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
- - - "~>"
16
+ - - ">="
17
17
  - !ruby/object:Gem::Version
18
18
  version: '1.6'
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
- - - "~>"
23
+ - - ">="
24
24
  - !ruby/object:Gem::Version
25
25
  version: '1.6'
26
26
  - !ruby/object:Gem::Dependency
@@ -68,7 +68,7 @@ dependencies:
68
68
  description: |
69
69
  A comprehensive Ruby implementation of a Knowledge-Based System featuring:
70
70
 
71
- • RETE II Algorithm: Optimized forward-chaining inference engine with unlinking optimization for high-performance pattern matching
71
+ • RETE Algorithm: Optimized forward-chaining inference engine with unlinking optimization for high-performance pattern matching
72
72
  • Declarative DSL: Readable, expressive syntax for rule definition with built-in condition helpers
73
73
  • Blackboard Architecture: Multi-agent coordination with message passing and knowledge source registration
74
74
  • Flexible Persistence: SQLite (durable), Redis (fast), and hybrid storage backends with audit trails
@@ -84,27 +84,90 @@ extensions: []
84
84
  extra_rdoc_files: []
85
85
  files:
86
86
  - ".envrc"
87
+ - ".github/workflows/deploy-github-pages.yml"
87
88
  - CHANGELOG.md
88
89
  - COMMITS.md
89
90
  - LICENSE.txt
90
91
  - README.md
91
92
  - Rakefile
93
+ - docs/advanced/custom-persistence.md
94
+ - docs/advanced/debugging.md
95
+ - docs/advanced/index.md
96
+ - docs/advanced/performance.md
97
+ - docs/advanced/testing.md
98
+ - docs/api/blackboard.md
99
+ - docs/api/engine.md
100
+ - docs/api/facts.md
101
+ - docs/api/index.md
102
+ - docs/api/rules.md
103
+ - docs/architecture/blackboard.md
104
+ - docs/architecture/index.md
105
+ - docs/architecture/network-structure.md
106
+ - docs/architecture/rete-algorithm.md
107
+ - docs/assets/css/custom.css
108
+ - docs/assets/images/blackboard-architecture.svg
109
+ - docs/assets/images/compiled-network.svg
110
+ - docs/assets/images/fact-assertion-flow.svg
111
+ - docs/assets/images/fact-rule-relationship.svg
112
+ - docs/assets/images/fact-structure.svg
113
+ - docs/assets/images/inference-cycle.svg
114
+ - docs/assets/images/kb-components.svg
115
+ - docs/assets/images/kbs.jpg
116
+ - docs/assets/images/pattern-matching-trace.svg
117
+ - docs/assets/images/rete-network-layers.svg
118
+ - docs/assets/images/rule-structure.svg
119
+ - docs/assets/images/system-layers.svg
120
+ - docs/assets/images/trading-signal-network.svg
121
+ - docs/assets/js/mathjax.js
122
+ - docs/examples/index.md
123
+ - docs/guides/blackboard-memory.md
124
+ - docs/guides/dsl.md
125
+ - docs/guides/facts.md
126
+ - docs/guides/getting-started.md
127
+ - docs/guides/index.md
128
+ - docs/guides/negation.md
129
+ - docs/guides/pattern-matching.md
130
+ - docs/guides/persistence.md
131
+ - docs/guides/variable-binding.md
132
+ - docs/guides/writing-rules.md
133
+ - docs/index.md
134
+ - docs/installation.md
135
+ - docs/quick-start.md
136
+ - docs/what-is-a-fact.md
137
+ - docs/what-is-a-knowledge-base.md
138
+ - docs/what-is-a-rule.md
139
+ - examples/.gitignore
92
140
  - examples/README.md
93
141
  - examples/advanced_example.rb
142
+ - examples/advanced_example_dsl.rb
94
143
  - examples/ai_enhanced_kbs.rb
144
+ - examples/ai_enhanced_kbs_dsl.rb
95
145
  - examples/blackboard_demo.rb
146
+ - examples/blackboard_demo_dsl.rb
96
147
  - examples/car_diagnostic.rb
148
+ - examples/car_diagnostic_dsl.rb
97
149
  - examples/concurrent_inference_demo.rb
150
+ - examples/concurrent_inference_demo_dsl.rb
98
151
  - examples/csv_trading_system.rb
152
+ - examples/csv_trading_system_dsl.rb
99
153
  - examples/iot_demo_using_dsl.rb
100
154
  - examples/portfolio_rebalancing_system.rb
155
+ - examples/portfolio_rebalancing_system_dsl.rb
101
156
  - examples/redis_trading_demo.rb
157
+ - examples/redis_trading_demo_dsl.rb
158
+ - examples/rule_source_demo.rb
159
+ - examples/run_all.rb
160
+ - examples/run_all_dsl.rb
102
161
  - examples/sample_stock_data.csv
103
162
  - examples/stock_trading_advanced.rb
104
- - examples/stock_trading_system.rb.bak
163
+ - examples/stock_trading_advanced_dsl.rb
164
+ - examples/temp_dsl.txt
105
165
  - examples/timestamped_trading.rb
166
+ - examples/timestamped_trading_dsl.rb
106
167
  - examples/trading_demo.rb
168
+ - examples/trading_demo_dsl.rb
107
169
  - examples/working_demo.rb
170
+ - examples/working_demo_dsl.rb
108
171
  - lib/kbs.rb
109
172
  - lib/kbs/alpha_memory.rb
110
173
  - lib/kbs/beta_memory.rb
@@ -121,21 +184,23 @@ files:
121
184
  - lib/kbs/blackboard/redis_audit_log.rb
122
185
  - lib/kbs/blackboard/redis_message_queue.rb
123
186
  - lib/kbs/condition.rb
187
+ - lib/kbs/decompiler.rb
124
188
  - lib/kbs/dsl.rb
125
189
  - lib/kbs/dsl/condition_helpers.rb
126
190
  - lib/kbs/dsl/knowledge_base.rb
127
191
  - lib/kbs/dsl/pattern_evaluator.rb
128
192
  - lib/kbs/dsl/rule_builder.rb
129
193
  - lib/kbs/dsl/variable.rb
194
+ - lib/kbs/engine.rb
130
195
  - lib/kbs/fact.rb
131
196
  - lib/kbs/join_node.rb
132
197
  - lib/kbs/negation_node.rb
133
198
  - lib/kbs/production_node.rb
134
- - lib/kbs/rete_engine.rb
135
199
  - lib/kbs/rule.rb
136
200
  - lib/kbs/token.rb
137
201
  - lib/kbs/version.rb
138
202
  - lib/kbs/working_memory.rb
203
+ - mkdocs.yml
139
204
  homepage: https://github.com/madbomber/kbs
140
205
  licenses:
141
206
  - MIT
@@ -157,8 +222,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
222
  - !ruby/object:Gem::Version
158
223
  version: '0'
159
224
  requirements: []
160
- rubygems_version: 3.7.2
225
+ rubygems_version: 4.0.7
161
226
  specification_version: 4
162
- summary: Production-ready Knowledge-Based System with RETE II inference, Blackboard
163
- architecture, and AI integration
227
+ summary: Knowledge-Based System with RETE inference, Blackboard architecture, and
228
+ AI integration
164
229
  test_files: []