feat: read-only session durability enhancements#18
Merged
Conversation
hiredman
approved these changes
Jan 28, 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
Adds support for query-only sessions as a durability optimization. Query-only sessions are a more restrictive subset of read-only sessions that support only query execution, resulting in significantly smaller memory footprint and serialization size.
Motivation
When deserializing sessions for query-only use cases, there's no need to restore the full rule network infrastructure (production nodes, alpha/beta roots, activation groups, etc.). By stripping out everything except query nodes and their beta memory, we can achieve additional memory and serialization size reductions for scenarios where only queries are needed.
Changes
Core Features
:query-only?option to session deserialization (similar to existing:read-only?)rulebase->query-only-rulebaseto create minimal rulebases containing only query nodesmemory->query-only-beta-memoryto extract only query-related beta memoryassemble-query-onlyandas-query-onlyfunctions for creating query-only sessionsDurability Support
*read-only*dynamic var to coordinate expression compilation behavior during deserializationreconstruct-node-expr-fn-lookupto centralize expression reconstruction logicDocumentation
Relationship to Read-Only Sessions
:read-only? true): Support queries and inspection operations:query-only? true): Support queries only (subset of read-only)Query-only is the more aggressive optimization with smaller memory footprint.
Testing
test_durability.cljverifying query-only sessions:test_rules.cljto verify query-only conversion withas-query-onlyBreaking Changes
None. This is a backward-compatible addition. All existing code continues to work unchanged.
Usage Example