Skip to content

Add sandboxed Python runner sidecar and /api/run endpoints - #27

Merged
tytremblay merged 2 commits into
mainfrom
feat/python-runner
Nov 24, 2026
Merged

tytremblay merged 2 commits into
mainfrom
feat/python-runner

Conversation

@tytremblay

Copy link
Copy Markdown
Contributor

Adds a sandboxed Python execution sidecar (runner/), /api/run and /api/run/maze endpoints in server.mjs, and frontend Python playground support while keeping existing Java lessons running on CheerpJ during the transition.

Changes

  • runner/: zero-dependency Python 3.12 runner (server.py, maze_solver.py, maze_driver.py, Dockerfile, test_runner.py). Runs each request in a fresh /tmp/run-<id> dir with python3 -I -B, process-group kill on timeout/overflow, 2s RLIMIT_CPU, 3s wall timeout, 128 MB RLIMIT_AS (Linux), RLIMIT_FSIZE=0, and a 32 KB output cap.
  • server.mjs, .hawk/app.json, scripts/deploy-check.mjs: adds POST /api/run and POST /api/run/maze proxying to RUNNER_URL, with X-Hawk-Slack-User/X-Hawk-Slack-Team auth checks when HAWK_SUITE_TRUST_PROXY=true, per-user token-bucket rate limiting (30/min, burst 5), and a concurrency semaphore (4 active, 16 queued).
  • site/: adds pythonRuntime.ts, @codemirror/lang-python, and dual Python/Java support in lessons.ts, CodeBlock.tsx, JavaRunner.tsx, LessonView.tsx, and MazePlayground.tsx.
  • .github/workflows/ci.yml, .github/workflows/docker.yml, scripts/smoke-runner.sh, docker-compose.dev.yml: tests and publishes ghcr.io/frc2713/hawk-learn-runner on the same sha-<commit> tag as hawk-learn.

Verification

  • python3 -m unittest discover -t . -s runner -p "test_*.py" -v (15 tests)
  • npm run lint && npm run build in site/
  • IMAGE=hawk-learn-runner:test bash scripts/smoke-runner.sh under --network none --read-only --cap-drop ALL --pids-limit 64 --memory 256m
  • End-to-end test of server.mjs + runner/server.py (401 auth checks, /api/run, /api/run/maze, 429 rate limit)

@tytremblay
tytremblay merged commit 3fbb54c into main Nov 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant