feat: add inspect-facts function and memorize root facts#17
Merged
Conversation
a6bd56e to
9576eaf
Compare
191ab0d to
f832a6a
Compare
7b9f405 to
4ff981d
Compare
hiredman
reviewed
Jan 12, 2026
hiredman
approved these changes
Jan 12, 2026
hiredman
approved these changes
Jan 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR enhances Clara Rules' introspection capabilities by adding memory tracking of root facts and a new
inspect-factsfunction that provides comprehensive fact inspection.Changes
Core Memory Enhancements
->RootElementhelper functionNew Inspection Capabilities
inspect-factsfunction (clara.tools.inspect/inspect-facts) - Returns a structured map containing::rules- map of rule IDs to their production nodes:facts- sequence of all facts with metadata::fact- the actual fact value:rule-id(optional) - ID of the rule that inserted the fact (absent for root facts):bindings(optional) - bindings used to insert the fact (absent for root facts):fact-types- sequence of fact types including ancestorsinspectfunction to include:root-factsin the inspection mapget-alphas-fnfor broader reuseAPI Improvements
:insertion→:insert,:retraction→:retractInspectionSchema→RulesInspectionSchema, added newFactsInspectionSchemaTest Coverage
Added comprehensive test coverage in
clara.tools.test-inspectfor the newinspect-factsfunction, validating both root and derived facts with their metadata.