utils/code_runner
Krzysztof kuhy Rudnicki 70c8aa8fbb code_runner: contain hostile result.json, v0.1.1
Deep or oversized values from the sandbox now fail that example only; compare refuses nesting past 64 levels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWYGW5NZL5uVpnqmNKo
2026-11-02 15:59:01 +01:00
..
code_runner code_runner: contain hostile result.json, v0.1.1 2026-11-02 15:59:01 +01:00
.pre-commit-config.yaml Add code_runner sandboxed example runner 2026-11-02 14:59:30 +01:00
install.sh Add code_runner sandboxed example runner 2026-11-02 14:59:30 +01:00
pyproject.toml code_runner: contain hostile result.json, v0.1.1 2026-11-02 15:59:01 +01:00
README.md Add code_runner sandboxed example runner 2026-11-02 14:59:30 +01:00
requirements.txt Add code_runner sandboxed example runner 2026-11-02 14:59:30 +01:00

code_runner

Runs a learner's solution (Python 3, JavaScript, TypeScript) against a problem statement's examples inside bubblewrap: no network, read-only /usr, scratch dir, CPU/memory/process/file/time limits.

import code_runner as cr

statement = ...  # markdown from ~/.claude/skills/leetcode/fetch_problem.py
results = cr.run("python3", code, cr.extract_starter(statement), cr.parse_examples(statement))

run(lang, code, starter, examples) -> list[CaseResult] with n, input, expected, actual, ok, stdout, error, ms. One sandbox process per example. TypeScript runs through node's type stripping (no type check, no enums). Needs bwrap, prlimit, /usr/bin/python3, node >= 22.18. Install: ./install.sh.