{"id":10364,"library":"zen-engine","title":"Zen Engine","description":"Zen Engine is an open-source business rules engine implemented in Rust with Python bindings, designed for high-performance decision-making. It allows users to define complex business logic using a DMN-like JSON/YAML schema for decisions and flows. As of version 0.54.0, it leverages a Rust core for efficiency and provides a Pythonic interface for integration. It is actively maintained with frequent updates.","status":"active","version":"0.54.0","language":"en","source_language":"en","source_url":"https://github.com/gorules/zen","tags":["rules-engine","business-logic","DMN","automation","rust-bindings","decision-management"],"install":[{"cmd":"pip install zen-engine","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Used for loading YAML rule definitions.","package":"PyYAML","optional":false},{"reason":"Used for data validation and serialization of rule schemas.","package":"pydantic","optional":false},{"reason":"Potentially used for fetching external resources or definitions, though not directly in the core evaluation.","package":"requests","optional":false},{"reason":"Core dependency for graph operations within the Rust engine.","package":"rustworkx","optional":false},{"reason":"Used for semantic versioning checks.","package":"semver","optional":false}],"imports":[{"note":"The primary class for creating an engine instance and evaluating rules.","symbol":"ZenEngine","correct":"from zen_engine import ZenEngine"},{"note":"The result object returned by the evaluate method since v0.50.0.","symbol":"ZenResult","correct":"from zen_engine import ZenResult"}],"quickstart":{"code":"from zen_engine import ZenEngine\n\n# Define a simple decision rule in DMN-like JSON format\ndecision_rule = {\n    \"name\": \"Welcome Message Decision\",\n    \"kind\": \"Decision\",\n    \"version\": 1,\n    \"inputs\": {\n        \"name\": \"text\"\n    },\n    \"output\": \"text\",\n    \"expressions\": [\n        {\n            \"kind\": \"Literal\",\n            \"content\": \"'Hello, ' + name + '!'\"\n        }\n    ]\n}\n\n# Initialize the Zen Engine\nengine = ZenEngine()\n\n# Evaluate the decision with context data\ncontext = {\"name\": \"World\"}\nresult = engine.evaluate(decision_rule, context)\n\n# Access the result using the ZenResult object\nif result.success:\n    print(f\"Decision Result: {result.result}\")\nelse:\n    print(f\"Decision Error: {result.error}\")\n\n# Example with a different name\ncontext_2 = {\"name\": \"Alice\"}\nresult_2 = engine.evaluate(decision_rule, context_2)\nprint(f\"Decision Result for Alice: {result_2.result}\")","lang":"python","description":"This quickstart demonstrates how to initialize the `ZenEngine`, define a basic decision rule using its JSON schema, and evaluate it with input context. It also shows how to access the result from the `ZenResult` object."},"warnings":[{"fix":"Review and update your JSON/YAML rule definitions to conform to the new schema introduced in v0.50.0. Refer to the official Zen Engine documentation for the latest schema structure.","message":"The internal schema for Decision and Flow definitions underwent significant changes in version 0.50.0. Older rule definitions might no longer be valid and will fail validation.","severity":"breaking","affected_versions":">=0.50.0"},{"fix":"Update your code to access evaluation results via the `ZenResult` object's properties, such as `result.result` for the successful output, `result.success` to check for success, and `result.error` for error details.","message":"The return type of `engine.evaluate()` changed from a direct dictionary to a `ZenResult` object starting from version 0.50.0. Direct dictionary access (e.g., `result['result']`) will now raise an `AttributeError`.","severity":"breaking","affected_versions":">=0.50.0"},{"fix":"If you were passing a dictionary of resources to `ZenEngine()`, you now need to provide a `loader` object instead. The `loader` is an interface that the engine uses to fetch external DMNs/Flows/etc. Consult the documentation for implementing a custom loader.","message":"When initializing `ZenEngine` for advanced use cases (e.g., loading external resources), the `resources` argument was deprecated and replaced by `loader`.","severity":"gotcha","affected_versions":">=0.50.0"},{"fix":"Always refer to the official Zen Engine documentation for the precise syntax and available functions within its expression language. Do not assume full compatibility with JavaScript or other common expression languages.","message":"Zen Engine expressions use a custom expression language similar to DMN FEEL. Familiarity with JavaScript-like syntax for string manipulation, comparisons, and conditional logic is helpful, but specific functions and operators may differ.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Review the official Zen Engine documentation for the correct schema structure. Pay close attention to required fields, data types, and the structure of expressions. Validate your JSON/YAML carefully.","cause":"Your decision or flow definition JSON/YAML does not conform to the expected schema, often due to changes introduced in v0.50.0 or malformed structure.","error":"zen_engine.ZenSchemaError: Invalid decision schema:"},{"fix":"This error likely means your code was written for Zen Engine versions prior to 0.50.0. Update your result access to use the `ZenResult` object's properties: `result_obj.result`, `result_obj.success`, `result_obj.error`.","cause":"You are trying to access `result.result` (or similar) on what you expect to be a `ZenResult` object, but `engine.evaluate()` returned a plain dictionary, which is no longer the case since v0.50.0.","error":"AttributeError: 'dict' object has no attribute 'result'"},{"fix":"Install the package using pip: `pip install zen-engine`. If already installed, ensure your IDE or script is using the correct Python environment where the package is installed.","cause":"The `zen-engine` package is not installed in your current Python environment, or your Python interpreter path is incorrect.","error":"ModuleNotFoundError: No module named 'zen_engine'"}]}