feat: wire sandbox into runner for agent-submitted strategies#11
Open
MiaMakesItHappen wants to merge 2 commits into
Open
feat: wire sandbox into runner for agent-submitted strategies#11MiaMakesItHappen wants to merge 2 commits into
MiaMakesItHappen wants to merge 2 commits into
Conversation
- worker/runner.py: add trusted=bool param to run_backtest(); route untrusted strategies through worker.sandbox.run_sandboxed() (process isolation + timeout) instead of bare exec() - api/main.py: add _is_submitted_strategy() helper; pass trusted=False to run_backtest() when strategy path lives inside STRATEGIES_DIR (i.e. came via POST /strategies/submit) - requirements.txt: add pytest==9.0.2 + httpx==0.28.1 (needed for tests) - tests/test_api.py: new end-to-end API test suite (9 tests): health, submit, dedup, validation, run flow, leaderboard, and sandbox-wiring integration test All 21 tests pass (12 sandbox unit + 9 API e2e)
This was referenced Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes the gap between the existing sandbox wrapper and the actual backtest runner — submitted strategies now actually run sandboxed.
Changes
worker/runner.py: Addedtrusted: bool = Trueparam torun_backtest(). WhenFalse, routes strategy execution throughworker.sandbox.run_sandboxed()(process-level isolation, 60s timeout, blocked builtins) instead of bareexec().api/main.py: Added_is_submitted_strategy()helper. When creating a run, passestrusted=Falseif the strategy file lives insideSTRATEGIES_DIR(i.e. was submitted viaPOST /strategies/submit). Local file strategies (strategy_pathrequests) remain trusted.requirements.txt: Addedpytestandhttpxso tests can actually run out-of-the-box.tests/test_api.py: New end-to-end API test suite (9 tests) covering health, submit, dedup, validation, run flow, leaderboard, and the sandbox-wiring integration.Test results
Why
The sandbox wrapper existed but was never called for submitted code — submitted strategies ran with the same bare
exec()as trusted local files. This PR closes that.