← Back to blog

Dev notes / 01

Your app shouldn't be the sandbox

If your product runs code it didn't write, keep that code out of your web process. Here's how to think about the split.

Diagram for Your app shouldn't be the sandbox
Diagram · Your app shouldn't be the sandbox

Say you’re building a coding exercise site, a plugin system, or an agent that writes and runs scripts. Sooner or later someone suggests the quick version: take the snippet, spawn a subprocess on the API server, return stdout. It works in the demo, and that’s what makes it dangerous.

Once untrusted code runs next to your request handlers, it can read your env vars, your database credentials, and whatever else sits on that box. One bad snippet becomes an incident in your production app.

🧱 Split “accept the job” from “run the job”

Your API has one job here: take the request, check it, give it an ID, and answer quickly. Running the code happens somewhere else, behind a line you drew on purpose.

In practice your client code ends up looking like this:

Terminal window
# submit: returns an ID right away, not the program's output
curl -X POST https://your-api/v1/executions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"language":"python","code":"print(1 + 1)"}'
# then ask how it went
curl https://your-api/v1/executions/$ID \
-H "Authorization: Bearer $API_KEY"

Yes, that’s one more request than a blocking call. In exchange you get a record you can poll, cancel, and look at after something breaks.

🔍 Make every job something you can look up

When a user writes “my run never finished”, you want to answer with facts instead of grepping logs. Give every execution a status you can query: queued, running, cancelled, timed out, finished. Users can see where their job is, and you can see where it got stuck.

⚠️ Be honest about what runs today

If you try mPaka locally right now, the executor is mock_no_code_execution. It accepts and tracks executions, and it doesn’t run your code. We’re building the API contract first and we’ll only turn on real isolation once we can prove it holds up. Please don’t put it in front of untrusted users in the meantime.

🚀 What you can do now

Build your integration against the async flow: submit, poll, cancel. When a real executor shows up, your client code shouldn’t need to change.