tessl install tessl/pypi-crosshair-tool@0.0.0Analyze Python code for correctness using symbolic execution and SMT solving to automatically find counterexamples for functions with type annotations and contracts.
Agent Success
Agent success rate when using this tile
86%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.25x
Baseline
Agent success rate without this tile
69%
Build a system that uses symbolic execution to find valid configuration parameters that satisfy system constraints.
You need to implement configuration validation functions for a server deployment system. The system must find valid configuration values that satisfy multiple interdependent constraints.
Implement a function validate_server_config that verifies a server configuration is valid. The configuration has the following parameters:
worker_threads: Number of worker threads (must be positive integer)connection_pool_size: Size of connection pool (must be positive integer)max_memory_mb: Maximum memory in MB (must be positive integer)timeout_seconds: Request timeout in seconds (must be positive integer)The configuration must satisfy these constraints:
worker_threads must be between 1 and 32connection_pool_size must be at least worker_threads * 2max_memory_mb must be at least connection_pool_size * 10timeout_seconds must be between 1 and 300(worker_threads * 100 + connection_pool_size * 10) must not exceed 5000The function should raise a ValueError with a descriptive message if any constraint is violated.
Implement a second function find_optimal_config that uses symbolic execution to find a configuration that maximizes worker_threads while satisfying all constraints, given a fixed max_memory_mb budget.
worker_threads=4, connection_pool_size=8, max_memory_mb=80, timeout_seconds=30 is valid @testworker_threads=4, connection_pool_size=6, max_memory_mb=80, timeout_seconds=30 raises ValueError because pool size is too small @testmax_memory_mb=500 returns a valid configuration that maximizes worker threads @test@generates
from typing import NamedTuple
class ServerConfig(NamedTuple):
"""Server configuration parameters."""
worker_threads: int
connection_pool_size: int
max_memory_mb: int
timeout_seconds: int
def validate_server_config(config: ServerConfig) -> None:
"""
Validate a server configuration against system constraints.
Raises:
ValueError: If any constraint is violated, with a message describing the issue.
"""
pass
def find_optimal_config(max_memory_mb: int) -> ServerConfig:
"""
Find a valid configuration that maximizes worker_threads given a memory budget.
Uses symbolic execution to search the constraint space.
Args:
max_memory_mb: The memory budget constraint
Returns:
An optimal ServerConfig that maximizes worker_threads
Raises:
ValueError: If no valid configuration exists for the given budget
"""
passProvides symbolic execution and constraint solving capabilities for searching valid parameter combinations.
@satisfied-by