Skip to content

Instantly share code, notes, and snippets.

@Ahmad-Al-Dibo
Last active May 7, 2026 18:40
Show Gist options
  • Select an option

  • Save Ahmad-Al-Dibo/14b68eba5cbee996d00a2ecb700d9650 to your computer and use it in GitHub Desktop.

Select an option

Save Ahmad-Al-Dibo/14b68eba5cbee996d00a2ecb700d9650 to your computer and use it in GitHub Desktop.
Execution Routing Engine

Execution Routing Engine

A modular prompt-driven execution runtime for routing user intent to commands, tools, and permission-aware execution pipelines.

Designed as a deterministic runtime layer that analyzes user intent, routes execution requests to the most relevant commands and tools, enforces permission boundaries before execution, and returns fully traceable runtime sessions.


Core Architecture

User Prompt
    ↓
PortRouter
    ↓
ExecutionEngine
    ↓
QueryEnginePort
    ↓
RuntimeSession

Component Responsibilities

Component Responsibility
PortRouter Tokenizes prompts, scores modules, and routes execution requests
ExecutionRegistry Stores and resolves available commands and tools
ExecutionEngine Executes matched components and enforces permission policies
QueryEnginePort Aggregates execution results into structured runtime output
RuntimeSession Stores prompt, routing decisions, execution logs, and final results

Example Flow

from query_runtime import CleanRuntime

runtime = CleanRuntime()

session = runtime.run(
    "Search how data processing using python?"
)

print(session.routed_matches)
print(session.command_execution_messages)
print(session.tool_execution_messages)

Output

[
    RoutedMatch(
        kind='command',
        name='search',
        score=1
    ),

    RoutedMatch(
        kind='tool',
        name='python',
        score=1
    )
]

Key Design Principles

Deterministic Routing

Prompt-to-module routing based on token scoring.

Permission-Aware Execution

Execution permissions are validated before tool invocation.

Full Traceability

Every execution produces a structured RuntimeSession.

Modular Extensibility

New commands, tools, scoring strategies, and policies can be added without changing the core runtime.


Current Features

  • Prompt tokenization
  • Command routing
  • Tool routing
  • Execution registry
  • Permission enforcement
  • Runtime session tracking
  • Structured execution logging

Planned Evolution

  • Semantic routing (Embeddings / BM25 / Hybrid retrieval)
  • Role-based access control (RBAC)
  • Async execution pipelines
  • DAG-based dependency execution
  • Adaptive confidence thresholds
  • Multi-agent orchestration

Repository

Full source code:

https://github.com/Ahmad-Al-Dibo/execution-routing-engine


Technical Article

Architecture article:

https://www.linkedin.com/pulse/van-lost-data-naar-controle-het-herontwerpen-een-runtime-al-dibo-jjnse/


Author

Ahmad Al Dibo Student

This tool was inspired by the leaked Cloudcode code; I transformed it into a usable tool and used artificial intelligence to organize the code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment