> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orka.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Domain Logic

> Define business rules, metrics, and terms that shape how your agents interpret and answer queries.

## What is domain logic

Domain logic is a set of definitions — business rules, metric formulas, and term explanations — that your agents apply automatically at query time. Instead of repeating context in every question, you define it once and every relevant agent uses it.

## Definition types

Each definition has a type that tells the agent how to use it:

* **Metric** — a calculation or KPI. Use this for formulas, financial ratios, or any numeric measure the agent should know how to compute.
* **Term** — what a concept means. Use this to define acronyms, internal jargon, or domain-specific vocabulary.
* **Rule** — how to behave or process data. Use this for business logic, classification criteria, or instructions the agent should follow.

## Create a definition

Go to **Logic** in the sidebar and click **Create Definition**. Fill in:

* **Title** — a short name for the definition.
* **Description** (optional) — when or why this definition applies.
* **Type** — metric, term, or rule.
* **Scope** — workspace-level or a specific datastore.
* **Definition** — the full text the agent uses at query time.

## Scoping

A definition's scope controls which agents see it:

* **Workspace-level** — applied to all agents in the workspace.
* **Datastore-level** — applied only to agents that are linked to that specific datastore.

Choose datastore-level scoping when a definition is relevant only to a particular set of documents.

## Version history

Every edit to a definition creates a new version. The full history is preserved — nothing is deleted.

From the definition detail page, you can:

* View a timeline of all versions with timestamps and authors.
* Select any two versions to compare them side by side with a line-by-line diff.
* Revert to a previous version. Reverting creates a new version with the old content, so the history stays intact.

## Definitions in chat

When an agent uses definitions to answer a question, they appear in the response as an **Applied definitions** section. Each definition shows its type, name, and a preview of the text. Click a definition to view or edit it directly.
