Skip to main content

Crate lemma

Crate lemma 

Source
Expand description

§Lemma Engine

Rules for man and machine

Consumer API: load → specs → show / source → evaluate.

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, or ShowData.suggestion.

Structs§

Cause
Context
Ordered store of specs keyed by (repository, name) and grouped into LemmaSpecSets.
DataPath
Resolved path to a data (created during planning from AST DataReference)
DateTimeValue
Engine
Engine for evaluating Lemma rules.
EngineError
Flat wire view of Error matching EngineError in engine/schemas/api.v1.json and engine/packages/npm/lemma.d.ts. Missing optionals serialize as JSON null.
EngineErrorSource
Source location attached to an EngineError. Line and column are 1-based; length is the UTF-8 byte length of the offending span.
ErrorDetails
Detailed error information with optional source location.
Errors
Load failure: errors plus the source texts we attempted to load.
ExplainedRule
One narrated rule body stored in an explanation’s rules table.
ExplainedRuleId
Compact id of a rule in an crate::evaluation::explanations::Explanation’s rules table. Assigned in first-reach order from the root.
Explanation
Fetch
Header
HttpResponse
IndexMap
A hash table where the iteration order of the key-value pairs is independent of the hash values of the keys.
Install
LemmaBase
LemmaBase registry: bound to https://lemmabase.com. Not configurable.
LemmaData
LemmaRepository
A Lemma repository header. Identity carrier; never owns specs.
LemmaSpec
A Lemma spec containing data and rules.
LemmaSpecSet
All spec versions sharing a (repository, name) identity, keyed by effective_from.
LemmaType
Resolved type after planning
Lexer
LiteralValue
Runtime literal payload. Type lives on NormalForm.result_type / DataDefinition / explicit computation parameters — not on the value.
MeasureUnit
A single unit within a Measure type.
MeasureUnits
ParseResult
PathSegment
A single segment in a resolved path traversal
RatioUnit
RatioUnits
Registries
The registries the host composes. Default is LemmaBase alone.
RegistryBundle
RegistryError
Repository
Repository group from Engine::specs.
RepositoryInstallResult
Result of Install: LemmaBase repository source text and normalized id.
RepositoryQualifier
Textual repository qualifier as written in source (for example @iso/countries). name stores the qualifier verbatim, including a leading @ when present. The planner resolves a RepositoryQualifier to an Arc<LemmaRepository> against the active context.
Resolve
ResourceLimits
Limits to prevent abuse and enable predictable resource usage
Response
Response from evaluating a Lemma spec
RuleResult
Result of evaluating a single rule. Struct fields match the API JSON shape.
SerializedConversionTraceStep
Show
Consumer [Engine::show] result: local offered types, inputs rules need, this spec’s rule graph (local rules plus reachable imports), and resolved temporal window. Source: [Engine::source].
ShowBranch
One arm of a rule’s flat last-match table on Show.
ShowData
One data entry in a Show.
ShowRule
Local rule on Show: result type, authored branches, stored topo deps.
Source
Positional source location: source id and span.
Span
Span representing a location in source code
SpecDependency
One uses target from a spec version’s source.
SpecIdentity
Resolved spec a value or rule result refers to.
SpecRef
A spec reference written in source.
SpecVersion
One temporal spec version from Engine::specs.
TimezoneValue
UTC offset in signed whole minutes; |offset_minutes| is at most 23:59.
TransportFailure

Enums§

CommandArg
A parsed constraint command argument, preserving the literal kind from the grammar rule command_arg: { number_literal | boolean_literal | text_literal | label }.
ConversionTraceRole
DataValue
Parse-time data value (before type resolution)
DateGranularity
EffectiveDate
Error
Error types for the Lemma system with source location tracking
ErrorKind
Classification of an Error. Serialized as the kind field on the flat object returned to JavaScript from WASM (engine/src/wasm.rs, JsError).
EvaluateDataValue
Neutral overlay tree. [EvaluateData::resolve] reads each value by declared type.
ExplanationNode
InstallStep
ListKey
How a list addresses its rows.
OperationResult
Result of evaluating a rule, expression, or data leaf.
ParentType
Parent type in a type definition: built-in primitive or custom type name.
RegistryErrorKind
The kind of failure that occurred during a Registry operation.
RequestErrorKind
Distinguishes HTTP 404 (not found) from 400 (bad request) for request errors.
ResolveStep
ShowConversionTarget
Conversion target on a Show as expression (no owning type — inspection only).
ShowExpression
Resolved expression tree for Show branches (tag = "type" on the API mirror).
SourceType
TokenKind
TypeConstraintCommand
Constraint command for type definitions. Derived from lexer tokens; no string matching.
TypeSpecification
ValueKind
Value payload (shape of a literal).
VetoType
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 by cargo 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). User Engine::load must not target this name via SourceType::Dependency.
MAX_DATA_NAME_LENGTH
MAX_RULE_NAME_LENGTH
MAX_SPEC_NAME_LENGTH
UNITS_LEMMA

Traits§

HttpTransport
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§

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 / is in label position).
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, JS null / undefined, Java null, Elixir nil). A list has no unsupplied row, so this is a request Error, never an omitted item. position is 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, as lemma specs prints 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.
numbered_row_origin
1-based numbered origin of a list row (items.2).
parse
parse_spec_set_id
Validate and normalize a spec set identifier (a spec name in the default repository).
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, JS null / undefined, Java null, Elixir nil). A list has no unsupplied row, so this is a request Error, never an omitted item. position is 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 None when there are no constraints worth showing (e.g. bare boolean). Returns one formatted string per constraint or property of the type specification. Uses display_str for all rational bounds so they render as decimals, not as raw fractions.

Type Aliases§

RunDataValueDeprecated