mehmetsekercioglu

mehmetsekercioglu

Hello,

I’ve been building Zygo, a Linux sandbox runtime for running code other people wrote: customer plugins, workflow steps, an LLM’s tool calls. zygo_sdk is its Elixir client.

Why a BEAM app might want it

If your app has to run a user’s Python or JavaScript, the BEAM can’t sandbox it for you. A Port or System.cmd runs it as your app’s own user, with your files and your network. Zygo gives every call its own process, cgroup, deadline and secrets, inside a sandbox (namespaces, seccomp, Landlock, a read-only root from an OCI image, network off unless you allow names), and throws it away afterwards. For Python it forks a warm, pre-imported interpreter, so a call costs about 1.4 ms through the API on a 2 vCPU Linux VM. Node can’t be forked safely, so each JS call gets a pre-loaded worker instead, at about 25 ms of CPU.

What it looks like

client = Zygo.connect()

Zygo.serve_runtime!(client, "py312", %{"image" => "python:3.12-slim", "agent" => "python"})

script = Zygo.put_script!(client, """
def handler(event):
    words = event["text"].split()
    return {"words": len(words), "longest": max(words, key=len)}
""")

Zygo.run_script!(client, "py312", script.sha256, %{"text" => "the quick brown fox"}).result
#=> %{"words" => 4, "longest" => "quick"}

A script that misbehaves stays in its sandbox:

{:error, %Zygo.Error{kind: :handler, stderr: stderr}} =
  Zygo.run_script(client, "py312", "def handler(e):\n    open('/etc/shadow').read()\n")

The client

  • Every API call returns {:ok, value} or {:error, %Zygo.Error{}} and has a ! twin. One error struct with a kind (:busy, :handler, :timeout, …) instead of a module per error.
  • Pooled keep-alive connections over TCP or a unix socket, with a named pool you start under your own supervisor.
  • :busy and :unavailable mean the request never ran, so they can be retried for you, honouring Retry-After.
  • A call’s output can be streamed as a lazy Stream.
  • Two dependencies, Mint and NimblePool. Elixir 1.18+, for the standard library’s JSON.

Before you try it

The package is only a client. zygo itself is a static binary for Linux; on macOS it runs in a VM it manages. The README’s “Before you start” section has the four commands to get the API running.

Limits

The wall is the host kernel, so it’s meant for semi-trusted code, your customers’ rather than anonymous attackers’. The escape suite attempts 21 vectors with 0 escapes, but there has been no external audit. It’s Linux only and one machine. v0.1.5, Apache-2.0, one maintainer, no production users yet.

Feedback I’d especially like

  • Is one error struct with a kind the right shape for Elixir, or would you rather match on exception modules? ADR 0007 explains why I chose it.
  • How would you supervise this in a real app: one named pool per API, or one per tenant?
  • Anything that feels unidiomatic.

Links:

I built it with heavy use of Claude Code.

Where Next? Top

Trending in Announcing Top

restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 12366 136
New
type1fool
WebAuthnLiveComponent WebAuthnComponents See this post about renaming the package. Passwordless authentication for Phoenix LiveView app...
New
GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
kip
I’ll shortly be launching Text, a nascent text analysis library. Current functionality In this early version (not ready for prime time) ...
New
kip
Following on from my CLDR lbraries I started work on Unicode transforms. But like everything related to CLDR there is a lot of yak-shavin...
New

Other Trending Topics Top

CodeSync
We have 4 in-person tickets to Code BEAM Europe 2026 (21-22 October, PHIL Haarlem) to give away: 1 diversity ticket (sponsored by AppSi...
New
gus
Happy Friday, all! :slight_smile: Our October meetup is coming up next week - Wednesday, October 14th at 19h CET via Zoom! This month we...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews