Expand description
Re-exports§
pub use api::evaluate_data_value_from_json_value;pub use api::parse_evaluate_data_object;pub use api::resolve_evaluate_rules;pub use api::show_document;pub use api::evaluate_data_value_from_json_value as run_data_value_from_json_value;pub use api::parse_evaluate_data_object as parse_run_data_object;pub use api::resolve_evaluate_rules as resolve_run_rules;pub use result_value::CalendarResult;pub use result_value::RangeResult;pub use result_value::RowReference;pub use result_value::RowResult;pub use result_value::RuleResultValue;pub use result_value::RuleResultValueFailure;pub use result_value::SpecResult;pub use result_value::SpecRuleResult;pub use quality::Recommendation;
Modules§
- api
- JSON API types for Engine boundary documents.
- deps
- Dependency layout under
<workdir>/lemma_deps/, shared by CLI install and LSP. - documentation
- Embedded language guides and example specs.
- mcp
- Pure Lemma MCP tools:
Engine+ arguments in, catalog or text out. - quality
- Structural quality analysis over loaded specs.
- result_
value - API value for a rule result,
ShowData.value, orShowData.suggestion.
Structs§
- Arithmetic
Term - One operand of a
NormalFormKind::SumorNormalFormKind::Product.inversemarks a subtracted (Sum) or divided (Product) operand. The first term of a Sum/Product is never inverse. - Bound
Value Kind - Canonical suggestion/fill value plus the written measure unit when one was declared.
- Cause
- Context
- Ordered store of specs keyed by
(repository, name)and grouped intoLemmaSpecSets. - Data
Path - Resolved path to a data (created during planning from AST DataReference)
- Date
Time Value - Engine
- Engine for evaluating Lemma rules.
- Engine
Error - Flat wire view of
ErrormatchingEngineErrorinengine/schemas/api.v1.jsonandengine/packages/npm/lemma.d.ts. Missing optionals serialize as JSONnull. - Engine
Error Source - Source location attached to an
EngineError. Line and column are 1-based;lengthis the UTF-8 byte length of the offending span. - Error
Details - Detailed error information with optional source location.
- Errors
- Load failure: errors plus the source texts we attempted to load.
- Evaluate
Data - User-provided data values resolved against a plan’s type declarations.
- Executable
Rule - A named rule’s root in the normal-form table, plus declaration metadata.
- Execution
Plan - A complete execution plan ready for the evaluator
- Explained
Rule - One narrated rule body stored in an explanation’s
rulestable. - Explained
Rule Id - Compact id of a rule in an
crate::evaluation::explanations::Explanation’srulestable. Assigned in first-reach order from the root. - Explanation
- Fetch
- Header
- Http
Response - Index
Map - A hash table where the iteration order of the key-value pairs is independent of the hash values of the keys.
- Install
- KeyField
- One field in a list’s row key: display name and resolved template data path.
- Lemma
Base - LemmaBase registry: bound to
https://lemmabase.com. Not configurable. - Lemma
Data - Lemma
Repository - A Lemma repository header. Identity carrier; never owns specs.
- Lemma
Spec - A Lemma spec containing data and rules.
- Lemma
Spec Set - All spec versions sharing a (repository, name) identity, keyed by effective_from.
- Lemma
Type - Resolved type after planning
- Lexer
- Literal
Value - Runtime literal payload. Type lives on
NormalForm.result_type/DataDefinition/ explicit computation parameters — not on the value. - Measure
Unit - A single unit within a Measure type.
- Measure
Units - Normal
Form - One node in THE DAG: algebraic Kind, stamped result type, optional conversion span, optional fold origin, optional rule use-site identity.
- Normal
Form Id - Index into a [
NormalFormInterner] / shippedcrate::planning::execution_plan::ExecutionPlan::normal_forms. - Parse
Result - Path
Segment - A single segment in a resolved path traversal
- Ratio
Unit - Ratio
Units - Rational
Integer - Registries
- The registries the host composes.
Defaultis LemmaBase alone. - Registry
Bundle - Registry
Error - Repository
- Repository group from
Engine::specs. - Repository
Install Result - Result of
Install: LemmaBase repository source text and normalized id. - Repository
Qualifier - Textual repository qualifier as written in source (for example
@iso/countries).namestores the qualifier verbatim, including a leading@when present. The planner resolves aRepositoryQualifierto anArc<LemmaRepository>against the active context. - Resolve
- Resolved
Spec Types - Fully resolved types for a single spec. After resolution, all imports are inlined — specs are independent.
- Resource
Limits - Limits to prevent abuse and enable predictable resource usage
- Response
- Response from evaluating a Lemma spec
- RowInstance
- A row instance: its spec, where it came from, and its bound fields.
- RowRead
- A member chain read on a row, through the row spec’s template plans: every end
but the last reads a
usesslot, as that instance; the last is the member read. - Rule
Path - Resolved path to a rule (created during planning from a rule reference).
- Rule
Result - Result of evaluating a single rule. Struct fields match the API JSON shape.
- Serialized
Conversion Trace Step - Show
- Consumer [
Engine::show] result: local offered types, inputs rules need, this spec’s own rules (empty path), and resolved temporal window. Source: [Engine::source]. Branch Rule leaves may name reachable imports that are not keys ofSelf::rules; follow those viashowon the imported spec. - Show
Branch - One arm of a rule’s flat last-match table on Show.
- Show
Data - One data entry in a
Show. - Show
Rule - Local rule on Show: result type, authored branches, stored topo deps.
- Signature
Factor - One resolved unit in a signature: declared name, owning family, exponent.
- Source
- Positional source location: source id and span.
- Span
- Span representing a location in source code
- Spec
Dependency - One
usestarget from a spec version’s source. - Spec
Identity - Resolved spec a value or rule result refers to: one temporal slice of one version.
- Spec
Instance - The hops that name a spec instance, relative to the plan holding it:
useshops (rack.low), or a list hop with its row number (staff.2). - SpecRef
- A spec reference written in source.
- Spec
Version - One temporal spec version from
Engine::specs. - Timezone
Value - UTC offset in signed whole minutes;
|offset_minutes|is at most 23:59. - Transport
Failure - Type
Family - Root of a custom type’s extension chain: the spec version that declares the root type,
and its name. Types share a unit family only when they share this root declaration;
a local
moneyand an importedpricing.moneyare different families. Two versions ofpricingdeclare differentpricing <date>.moneyfamilies; values from different versions do not mix. Interface drift across unpinned versions compares structure withLemmaType::same_interface, which ignores the family’s effective date. - Typed
Literal - Planning-time literal: value plus resolved type.
- Unit
Index - Expression-scope units after bind: every declarer per bare unit name.
- Veto
Expression - A veto expression that prohibits any valid verdict from the rule
Enums§
- Arithmetic
Computation - Arithmetic computations
- Branch
Outcome - Outcome of inspecting a branch condition or a boolean operand.
- Calendar
Period Unit - Granularity of a calendar-period check.
- Command
Arg - A parsed constraint command argument, preserving the literal kind from the
grammar rule
command_arg: { number_literal | boolean_literal | text_literal | label }. - Comparison
Computation - Comparison computations
- Conversion
Trace Role - Conversion
Type Kind - Primitive kind that can appear as an
asconversion target. ExcludesText(display formatting is not a conversion) and the range kinds (a range is not a cast target — use a range literal or...operator instead). The parser rejectsas textat theastarget position;data x: textdeclarations still use [PrimitiveKind::Text] via [crate::parsing::lexer::token_kind_to_primitive]. - Data
Definition - Resolved data value for the execution plan: aligned with [
DataValue] but with source per variant. - Data
Origin - Who wrote a data slot’s definition.
- Data
Value - Parse-time data value (before type resolution)
- Date
Calendar Kind - Calendar-period membership checks.
- Date
Granularity - Date
Relative Kind - Whether a date is relative to
nowin the past or future direction. - Dispatch
Key - One breakpoint in an ordered dispatch table.
- Dispatch
Region - One region body of a
NormalFormKind::OrderedDispatchtable. - Effective
Date - Error
- Error types for the Lemma system with source location tracking
- Error
Kind - Classification of an
Error. Serialized as thekindfield on the flat object returned to JavaScript from WASM (engine/src/wasm.rs,JsError). - Evaluate
Data Value - Neutral overlay tree.
EvaluateData::resolvereads each value by declared type. - Explained
List Op - List command identity on a narrated
ExplanationNode::ListCommand. - Explanation
Node - Install
Step - Leaf
Kind - Leaves in the shipped equation DAG: literals and data only.
- ListKey
- How a list addresses its rows.
- List
Pred Kind - List
Predicate Form - Logical
Connective - Mathematical
Computation - Mathematical computations
- Normal
Form Kind - Algebraic structure only. Children are
NormalFormId. Hash/Eq drive cons — no source spans or rule-ref identity here (those live onNormalForm). - Normal
Form List Op - Number
Arithmetic Failure - Numeric
Failure - Operation
Result - Result of evaluating a rule, expression, or data leaf.
- Parent
Type - Parent type in a type definition: built-in primitive or custom type name.
- Piecewise
Decision - Where the Piecewise arm scan stopped. Arm 0 is the default; unless arms
1..arm_countare scanned from the highest index down, like the evaluator. - Range
Bound - Which endpoint of a range
lower/upperreads. - Reference
Target - What a
DataDefinition::Referencecopies its value from: either another data path or a rule whose result becomes this data’s value. - Registry
Error Kind - The kind of failure that occurred during a Registry operation.
- Request
Error Kind - Distinguishes HTTP 404 (not found) from 400 (bad request) for request errors.
- Resolve
Step - Rounding
Mode - Direction of a
-> round|floor|ceil <step>command. - RowBinding
- A field of a
RowInstance. - RowEnd
- Field of a row read through the row spec’s template plan.
- RowOrigin
- Where a row instance came from. Names missing fields and explanations.
- Show
Conversion Target - Conversion target on a Show
asexpression (no owning type — inspection only). - Show
Expression - Resolved expression tree for Show branches (
tag = "type"on the API mirror). - Source
Type - Token
Kind - Type
Constraint Command - Constraint command for type definitions. Derived from lexer tokens; no string matching.
- Type
Specification - Unit
Scale - Conversion factor of a measure unit: a plan-time rational, or a product of data/rule references whose values are known only during evaluation.
- Value
Kind - Value payload (shape of a literal).
- Veto
Type - Why an operation yielded no value (domain veto).
Constants§
- API_
V1_ SCHEMA_ JSON - Checked-in JSON Schema for Show, Response, and related wire types
(
engine/schemas/api.v1.json). Regenerated bycargo run -p xtask -- schema. - COMPLETION_
KEYWORD_ LABELS - Spellings shared by [
keyword_from_identifier] and LSP completion. - EMBEDDED_
STDLIB_ REPOSITORY - Repository name reserved for the embedded standard library (
repo lemma,spec units). UserEngine::loadmust not target this name viaSourceType::Dependency. - MAX_
DATA_ NAME_ LENGTH - MAX_
RULE_ NAME_ LENGTH - MAX_
SPEC_ NAME_ LENGTH - UNITS_
LEMMA
Traits§
- Http
Transport - Synchronous driver for Rust hosts. wasm drives the steps itself with async fetch.
- Registry
- A registry is a request builder and response interpreter. It never performs I/O.
Functions§
- arithmetic_
operation - Perform type-aware arithmetic operation, returning OperationResult (Veto for runtime errors).
- attribute_
evaluate_ data_ error - Attribute a walker error to its top-level data key unless already attributed.
- attribute_
run_ data_ error - Attribute a walker error to its top-level data key unless already attributed.
- can_
be_ label - Returns true if the token kind can be used as a label or reference segment
(identifier, or one of the keywords
past/future/permille/isin label position). - checked_
div - checked_
mul - comparison_
operation - Perform type-aware comparison, returning OperationResult (Veto on error).
- condition_
outcome - How a piecewise unless-arm condition or a logical operand decides.
- convert_
unit_ operand - Apply a type cast when the operand is already held as
BoundValueKind. - decimal_
to_ rational - evaluate_
data_ from_ entries - Top-level run-data entries from a host walker. Keys differing only in case: request Error.
- evaluate_
data_ map_ from_ entries - Nested object entries from a host walker. Keys differing only in case: request Error.
- evaluate_
data_ null_ list_ item - Host list item that is null (JSON
null, JSnull/undefined, Javanull, Elixirnil). A list has no unsupplied row, so this is a request Error, never an omitted item.positionis 1-based within its list. - format_
explanation - format_
parse_ result - Format a
ParseResult(repository groups + specs) into canonical Lemma source. - format_
repositories - Text view of
Engine::specs, aslemma specsprints it. - format_
source - Parse a source string and format it to canonical Lemma source.
- format_
specs - Format a sequence of parsed specs into canonical Lemma source.
- negated_
comparison - Logical computation operators (defined in semantics, not used by the parser). Returns the logical negation of a comparison (used by De Morgan / NOT-normal-form rewriting).
- number_
arithmetic - numbered_
row_ origin - 1-based numbered origin of a list row (
items.2). - parse
- parse_
data_ value - parse_
spec_ set_ id - Validate and normalize a spec set identifier (a spec name in the default repository).
- piecewise_
decision - Scan unless-arm conditions high to low.
outcome(arm)reports the condition’s decision, orNonewhen there is none to read. - primitive_
number_ arc - rational_
new - region_
count - Number of regions for
boundary_countbreakpoints. - region_
of_ scrutinee - Region index for an evaluated, non-veto scrutinee value. The one decision
procedure shared by value evaluation, explain’s winner check and
missing_dataliveness. A calendar or rational failure is the veto the dispatch evaluates to. A value kind the fold excludes is a planning bug. - resolve_
effective - Resolve an optional effective datetime string for planning or evaluation.
- row_
field_ input_ key - Input key of a field of a numbered list row (
items.2.weight). - run_
data_ from_ entries - Top-level run-data entries from a host walker. Keys differing only in case: request Error.
- run_
data_ map_ from_ entries - Nested object entries from a host walker. Keys differing only in case: request Error.
- run_
data_ null_ list_ item - Host list item that is null (JSON
null, JSnull/undefined, Javanull, Elixirnil). A list has no unsupplied row, so this is a request Error, never an omitted item.positionis 1-based within its list. - try_
parse_ type_ constraint_ command - Parses a constraint command name. Returns None for unknown (parser returns error).
- type_
detail_ lines - Produce a human-readable summary of type constraints, or
Nonewhen there are no constraints worth showing (e.g. bareboolean). Returns one formatted string per constraint or property of the type specification. Usesdisplay_strfor all rational bounds so they render as decimals, not as raw fractions.
Type Aliases§
- RunData
Value Deprecated - Signature
Index - Reverse index mapping a resolved unit signature to the unit (by name) and its owning measure type.