polix.optimized.templates
Pre-computed residual structures for optimized evaluation.
Extracts templates from constraint sets that can be used to construct residuals efficiently at runtime. Open residuals are fully pre-computed; conflict residuals use pre-computed templates with per-constraint makers.
build-open-residual
(build-open-residual path constraints)Builds a pre-computed open residual map for a path.
Returns a map like {[:role] [[:= "admin"]]} that can be returned directly when the document is missing the required path.
constraint->open
(constraint->open {:keys [op value]})Converts a constraint to its open residual form.
Returns a vector like [:= "admin"] that represents the constraint waiting to be evaluated.
extract-path-templates
(extract-path-templates path constraints)Extracts templates for a single path in the constraint set.
Returns a map with: - :path - the document path as keyword vector - :open - pre-computed open residual map - :constraint-evaluators - vector of per-constraint evaluators
Each constraint evaluator has its own pre-computed make-conflict function, eliminating the need for filter/find operations during conflict detection.
extract-templates
(extract-templates constraint-set)Extracts all templates from a constraint set.
Takes a constraint set (map of path -> constraints) and returns a map with: - :satisfied - empty map for satisfied result - :path-templates - vector of path templates for iteration
The satisfied result is always the empty map which can be returned with zero allocation. Path templates are stored as a vector for efficient iteration during evaluation.
satisfied
(satisfied)Returns the satisfied result (empty map).
template-info
(template-info templates)Returns information about templates for debugging/diagnostics.
Returns a map with: - :path-count - number of paths with templates - :paths - list of paths - :total-constraints - total constraint count across all paths