Evaluator Architecture
SimuCode uses a robust, fault-isolated architecture to execute and validate robotics code.
Execution Flow
- API Request: The frontend sends the user's code to the
backendcontainer via/api/problems/submit. - Job Queue: The backend pushes a new job into a BullMQ queue (backed by Redis).
- Worker: The
workercontainer picks up the job. It handles code orchestration, including:- Creating a temporary workspace.
- Scaffolding ROS2 packages (if necessary).
- Writing
solution.py/solution.cpp.
- Docker-in-Docker (DinD): The worker spawns a short-lived child container (
simucode-ros2:humble) to run the code.- Isolation: The child container has 1GB RAM limit and no network access.
- Resource Control: CPU and memory limits are strictly enforced.
- Validation: A
test_runner.py(supplied by the problem definition) runs inside the child container to check the robot's behavior. - Cleanup: The child container is destroyed, and the results are reported back to the user.
Key Components
- Redis: Acts as the message broker for the job queue.
- Worker (
worker.js): The heart of the execution engine. It manages the lifecycle of the simulation jobs. - Docker Socket: The worker shares the host's
/var/run/docker.sockto manage containers.