Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Emmimal/control-layer
/ types & classes
Types & classes
31 in github.com/Emmimal/control-layer
⨍
Functions
145
◇
Types & classes
31
↳
Endpoints
1
↓ 20 callers
Class
ControlLayerConfig
All tunable parameters in one validated place. Pass a config dict or load from YAML/env — never hardcode in prod.
control_layer.py:99
↓ 20 callers
Class
ResponseSchema
Output contract the LLM response must satisfy.
control_layer.py:127
↓ 17 callers
Class
ValidationResult
control_layer.py:156
↓ 10 callers
Class
ControlLayer
The orchestrator. Sits between your application logic and the LLM. Composes all eight components: InputGuard → TokenBudget → PromptBui
control_layer.py:829
↓ 9 callers
Class
TokenBudget
Slot-based token allocator using tiktoken for accurate counts. Production fix over v1: char/4 heuristic replaced with the actual tokeniz
control_layer.py:297
↓ 6 callers
Class
AuditLogger
Records every attempt with its failure mode, latency, and outcome. Production fix over v1: - Thread-safe writes via lock - Persi
control_layer.py:698
↓ 6 callers
Class
AuditRecord
control_layer.py:164
↓ 6 callers
Class
CircuitBreaker
Stops hammering a failing LLM backend. States: CLOSED (normal) → OPEN (failing) → HALF_OPEN (testing) → CLOSED Production fix over v1:
control_layer.py:525
↓ 5 callers
Class
FallbackRouter
When the primary strategy exhausts all retries, routes to a registered fallback handler. Fallbacks are called in registration order. Fir
control_layer.py:659
↓ 4 callers
Class
MockLLM
Simulates an LLM with configurable failure behavior. Swap this for your real LLM in production: layer = ControlLayer(llm_fn=your_open
demo.py:69
↓ 3 callers
Class
LLMCaller
Wraps any callable LLM function with timeout enforcement. Production fix over v1: without a timeout, a hung LLM call blocks the thread f
control_layer.py:788
↓ 3 callers
Class
PromptBuilder
Assembles the final prompt within a hard token budget. Reservation order (priority, highest first): 1. System prompt — fixed overhead
control_layer.py:354
↓ 2 callers
Class
InputGuard
Validates and sanitizes user input before it reaches the prompt builder. Three checks, in order: 1. Empty / whitespace-only input.
control_layer.py:235
↓ 2 callers
Class
ResponseValidator
Validates model output against a schema and rule set. Prompts ask. Validators enforce. That's the whole difference.
control_layer.py:425
↓ 2 callers
Class
RetryEngine
Retries failed LLM calls with prompt mutation targeted at the specific failure mode detected. Production fix over v1: - Uses tenac
control_layer.py:615
↓ 1 callers
Class
ControlPacket
control_layer.py:190
↓ 1 callers
Class
LLMTimeoutError
Raised when the LLM call exceeds the configured timeout.
control_layer.py:784
Class
CircuitState
control_layer.py:519
Class
FailureMode
control_layer.py:77
Class
RetryStrategy
control_layer.py:88
Class
TestAuditLogger
tests/test_control_layer.py:393
Class
TestCircuitBreaker
tests/test_control_layer.py:252
Class
TestControlLayerIntegration
tests/test_control_layer.py:472
Class
TestFallbackRouter
tests/test_control_layer.py:338
Class
TestInputGuard
tests/test_control_layer.py:62
Class
TestLLMCaller
tests/test_control_layer.py:372
Class
TestPromptBuilder
tests/test_control_layer.py:150
Class
TestPydanticConfig
tests/test_control_layer.py:586
Class
TestResponseValidator
tests/test_control_layer.py:188
Class
TestRetryEngine
tests/test_control_layer.py:302
Class
TestTokenBudget
tests/test_control_layer.py:114