This is the complete specification for the **Universal Orchestration DSL (v1.0)**. This language is designed to be compiled into an execution plan that can be routed between a **Fast-Path Engine** (Eventual Consistency/Combat) and a **Safe-Path Engine** (Strong Consistency/Trade). ### 1. Core Flow & Orchestration These operators define the movement of the workflow through the state machine. | Operator | Keyword / Syntax | Description | Example | Consistency | | :--- | :--- | :--- | :--- | :--- | | **Sequence** | `->` | Linear transition from one node to the next. | `NodeA -> NodeB` | Variable | | **Fork** | `F-> [A, B, C]` | Splits the flow into parallel paths; all paths start simultaneously. | `Start F-> [Task1, Task2]` | Eventual | | **Join** | `[A, B, C] J->` | Synchronization barrier; waits for all listed paths to complete before proceeding. | `[T1, T2] J-> Complete` | Eventual | | **Branch** | `? [ condition -> X ]` | Conditional logic based on the output of the previous node. | `? [ available -> Create ]` | Variable | | **Loop** | `Loop { condition }` | Repeats a block of logic until a specific condition is met. | `Loop AI.Refine { valid }` | Variable | | **Timeout** | `T [duration]` | Sets a maximum wait time before triggering a failure path. | `T [5m] -> TimeoutHandler` | Variable | | **Module** | `Module Name { ... }` | A logical grouping of nodes that can be called as a single unit. | `Module ProfileSetup { ... }` | Variable | --- ### 2. AI & Agentic Logic Operators specifically designed for non-deterministic LLM interactions and verification. | Operator | Keyword / Syntax | Description | Example | Consistency | | :--- | :--- | :--- | :--- | :--- | | **Generation** | `AI.Generate [model]` | Calls an LLM to produce a result based on a prompt and context. | `AI.Generate {prompt: "..."}` | Eventual | | **Evaluation** | `AI.Evaluate` | Uses an AI to judge if a previous output meets specific criteria. | `AI.Evaluate {criteria: "..."}` | Eventual | | **Analysis** | `AI.Analyze` | Performs pattern recognition or anomaly detection across a dataset. | `AI.Analyze {metric: "SD"}` | Eventual | | **Human-In-Loop**| `Approval.Wait` | Pauses the workflow until a human provides a digital signature/approval. | `Approval.Wait /require /sig` | Strong | | **Refinement** | `AI.Refine` | An iterative loop to improve AI output based on feedback. | `Loop AI.Refine { valid }` | Eventual | --- ### 3. Infrastructure & Reliability The "Safe Path" operators used to ensure data integrity and system stability. | Operator | Keyword / Syntax | Description | Example | Consistency | | :--- | :--- | :--- | :--- | :--- | | **Distributed Lock**| `Lock (resource) { ... }` | Ensures exclusive access to a resource; prevents race conditions. | `Lock ($user_id) { ... }` | **Strong** | | **Atomic Saga** | `Saga.Atomic { ... }` | A transaction that must either complete entirely or not at all. | `Saga.Atomic { Add, Sub }` | **Strong** | | **Compensation** | `Saga.Compensate { ... }` | An "Undo" path triggered when a distributed transaction fails. | `Saga.Compensate { Refund }` | **Strong** | | **Circuit Breaker**| `circuit_break [args]` | Stops calling a failing external service to prevent system collapse. | `EXT:API /circuit_break` | Variable | | **Bulk Sink** | `Bulk.Save /insert` | Groups thousands of updates into a single database transaction. | `Bulk.Save { data: list }` | **Strong** | --- ### 4. Real-Time & Game Logic Operators designed for high-frequency updates and reactive event-driven environments. | Operator | Keyword / Syntax | Description | Example | Consistency | | :--- | :--- | :--- | :--- | :--- | | **Event Listener**| `ON (Event) -> X` | Triggers a workflow when a specific system event occurs. | `ON (Player.Death) -> X` | Eventual | | **Heartbeat** | `Tick [interval]` | Executes a block of logic at a fixed time frequency. | `Tick [100ms] { ... }` | Eventual | | **State Snapshot**| `State.Snapshot` | Serializes current global state for save/load or recovery. | `State.Snapshot /save` | Strong | | **Delta Update** | `Value -= Delta` | Updates a value by a relative amount rather than an absolute. | `Boss.HP -= {damage}` | Eventual | | **Resource Lock** | `SortedIds(A, B)` | A helper to lock multiple resources in order to prevent deadlocks. | `Lock (SortedIds(A, B))` | **Strong** | --- ### 5. Web & External Integration Operators for connecting the workflow to the outside world and third-party services. | Operator | Keyword / Syntax | Description | Example | Consistency | | :--- | :--- | :--- | :--- | :--- | | **External Call** | `EXT:Service.Method` | Executes a call to an external API or microservice. | `EXT:AuthService.Create` | Variable | | **Webhook** | `Webhook.Emit /post` | Sends data to an external URL and optionally waits for a response. | `Webhook.Emit /post {url}` | Eventual | | **Middleware** | `Module.Middleware` | Logic that intercepts every call into a module (Auth, Logging). | `Module.Middleware { Auth }` | Variable | | **Wait Condition** | `WAIT (Event)` | Pauses execution until a specific external signal is received. | `WAIT (Payment_Success)` | Variable | --- ### 6. Global State & Variables Definition of how data is stored and modified across the workflow. | Element | Syntax | Description | Example | Scope | | :--- | :--- | :--- | :--- | :--- | | **Global Variable**| `$var_name = value` | A state variable shared across all nodes in the workflow. | `$user_id = null` | Global | | **Local Variable**| `{var_name}` | A temporary variable passed between nodes as a payload. | `{email}` | Node-local | | **Resource Map** | `Resource > Level` | Mapping of a game object to its required consistency level. | `Wallet > Strong` | System | | **Identity** | `Crypto.Sign(key)` | Attaches a cryptographic signature to a request for validation. | `sig: Crypto.Sign($key)` | Security |