Skip to main content

crackedai-connect

Local runtime for crackedaicode.com — runs and grades your code on your own machine, using your own GPU and toolchains.

Four modes: PyTorch and JAX (tensor problems, benchmarked against a reference time), Python (production-grade typed Python, graded by mypy) and Rust (compiled with rustc, graded by clippy).

The website (Elixir/Phoenix, separate repo) ships your code and test cases to this runtime over localhost. Code never round-trips through a server.


Table of contents


Install & run

pip install crackedai-connect
crackedai-connect

That's it for the tensor modes. On first run the CLI inspects your hardware and installs the right PyTorch + JAX:

  • NVIDIA GPU — PyTorch + JAX with CUDA support. The runtime parses nvidia-smi, picks the highest PyTorch wheel tag that doesn't exceed your driver's CUDA version (cu118, cu121, cu124, or cu126), and installs the matching jax[cudaN] extra.
  • Apple Silicon — PyTorch with MPS + the default JAX wheel.
  • Everything else — CPU-only PyTorch (smaller download) + the default JAX wheel.

Plus Flax and Optax on every platform (0.7.0). They're the neural-network and optimiser libraries on top of JAX, they're pure Python, and 37% of the published JAX problems import one of them. Before 0.7.0 they weren't installed and weren't reported, so a third of JAX mode failed with ModuleNotFoundError on a runtime whose banner said jax ✓.

Setup state is recorded in ~/.crackedai/setup_done. Subsequent runs skip the install step, unless:

  • one of the required packages can't be imported (you uninstalled it), or
  • the marker predates the current setup generation — bumped whenever the required set grows, so a runtime that now needs more than it used to actually installs it. Without this, the old check (marker exists and torch and jax import) meant adding a package could never reach anyone who had already run setup once. That is exactly how Flax stayed missing.
$ crackedai-connect

  CrackedAI Runtime v0.7.0

  Setting up ML frameworks for your hardware...
  Found NVIDIA GPU (CUDA 12.4)
  Installing PyTorch (CUDA 12.4, cu124)... done
  Installing JAX (CUDA 12)... done
  Installing Flax + Optax (jax neural-network stack)... done
  Setup complete!

  Detected: NVIDIA RTX 4090 | Linux
    python 3.12.4 ✓
    numpy 1.26.4 ✓
    pytorch 2.3.0 ✓ (CUDA accelerated)
    jax 0.4.30 ✓ (cuda)
    flax 0.12.8 ✓
    optax 0.2.8 ✓
    mypy 1.11.2 ✓ (strict type checking)
    rustc 1.95.0 ✓ (edition 2024)
    clippy 0.1.95 ✓ (lint gate)

  Listening on http://127.0.0.1:52341
  Open crackedaicode.com to start solving problems.
  Press Ctrl+C to stop.

Then open https://crackedaicode.com and start solving problems. The site auto-detects the runtime via a 2-second health check on the problem-solving page.

If you only use some of the modes, skip the parts you do not need:

crackedai-connect --python-only   # no PyTorch/JAX install, and no nag about rustc
crackedai-connect --rust-only     # no PyTorch/JAX install, and no nag about mypy
crackedai-connect --skip-setup    # never auto-install or verify anything

Modes and what each needs

The startup banner reports every gate and tells you how to fix a missing one, so you do not have to work it out from a failed submission.

Mode Needs Installed for you? Graded on
PyTorch torch ✅ on first run tests + benchmark vs a reference time
JAX jax, flax, optax ✅ on first run tests + benchmark vs a reference time
Python mypy ✅ (a dependency of this package) tests and mypy --strict
Rust rustc + clippy ❌ — install it yourself compile + tests + clippy-driver -D warnings

Rust is the one that needs you to do something. The runtime will not install a Rust toolchain, so:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh   # if you have no rustc
rustup component add clippy                                      # the grading gate

Without clippy, Rust submissions are reported as ungradeable rather than passing — the website refuses to record a solve it could not fully check. The same is true of mypy for Python mode. That is deliberate: in a mode whose entire point is the gate, failing open would mark unchecked code as solved.

Rust problems compile as a single file with rustc -O --edition 2024. There is no cargo, no Cargo.toml and no external crates — the curriculum is built on the standard library on purpose, so by the time you reach async you write the executor yourself.


What it does

When you click Run or Submit on crackedaicode.com, your code executes locally on your machine:

  • Your own GPU — CUDA, Apple Silicon MPS, or CPU
  • Your own packages — whatever pip (or your venv / conda / pixi) gave you
  • Your own toolchains — your rustc, your mypy, your Python
  • Zero server round-trip — localhost only
  • Code never leaves your machine — only pass/fail, gate verdicts and benchmark numbers go back to the website

Grading happens here too, not just execution. A compiled mode runs rustc and clippy; a gated mode runs mypy. The website reads the verdicts and decides whether to record a solve — it never sees the code that produced them.

The runtime is small (Flask + numpy + mypy + flask-cors) and runs only while you keep the terminal open. Stop it with Ctrl+C.


How it works

Browser (crackedaicode.com)                  localhost:52341 (this runtime)
        │                                                 │
        │   GET /health                                   │
        │ ────────────────────────────────────────────►   │
        │                                                 │
        │   { hardware, frameworks, python, version }     │
        │ ◄────────────────────────────────────────────   │
        │                                                 │
        │   POST /execute                                 │
        │   { code, framework, function_name,             │
        │     test_cases, timeout_ms,                     │
        │     reference_code? }                           │
        │ ────────────────────────────────────────────►   │
        │                                                 │
        │                                       ┌─────────▼──────────┐
        │                                       │ Python subprocess  │
        │                                       │ (your code,        │
        │                                       │  isolated tempdir) │
        │                                       └─────────┬──────────┘
        │                                                 │
        │   { status, test_results[], benchmark? }        │
        │ ◄────────────────────────────────────────────   │

Each /execute request runs your code in a fresh Python subprocess in a temporary directory. The harness script, your solution, and (when benchmarking) the reference solution are written into that tempdir, then python run_tests.py framework function_name '[test_cases_json]' is invoked with subprocess.run(..., timeout=timeout_sec).

If the subprocess crashes, segfaults, hangs, or pollutes its environment, only that subprocess dies. The Flask server keeps serving.

For the deeper internals, see docs/ARCHITECTURE.md.


Already have PyTorch / JAX?

If everything the runtime needs — torch, jax, flax, optax — is already importable when you start crackedai-connect, the setup step is skipped (the marker file ~/.crackedai/setup_done is created so we don't re-check on every launch).

If any one of them is missing, setup runs. Upgrading the runtime to a version that requires more than yours did also re-runs it.

To force a reinstall:

rm ~/.crackedai/setup_done
crackedai-connect

The runtime executes whatever it can import — so if you want to test against a specific PyTorch build, install it in your environment before running and it will be picked up.


HTTP API

Running code for your other devices

crackedai-connect --link CODE (code from Settings on the website) attaches this machine to your account, and it then polls for work from your other devices — so you can write on a phone and have it run here. The daemon dials out: nothing listens for inbound connections and no port is opened, because a phone and a laptop usually share no route at all, and exposing /execute to a network would put an arbitrary-code endpoint on whatever wifi you are on.

--unlink stops it. The token is stored 0600 in ~/.crackedai/runner.json and can also be revoked from the website, which takes effect on the next request.

Jobs are executed by POSTing them to this daemon's own /execute, so validation, the tensor cache, static checks and the worker pool apply exactly as they do to a request from the browser — it is the same code path.

CORS is locked to https://crackedaicode.com and http://localhost:4000 (the website's dev server). Other origins will be rejected by the browser even though the requests would work over plain HTTP.

The daemon also answers Chrome's Private Network Access preflight. A request from a public page to a loopback address is preflighted even when it is an otherwise-simple GET, and the response must carry Access-Control-Allow-Private-Network: true or the browser drops it — so that header is what lets the deployed site talk to this daemon at all. It is set explicitly (allow_private_network=True) rather than left to the library: flask-cors 4.x sent true unconditionally, 5.0 made it an option defaulting to False, and 6.x sends an explicit false. With the dependency unpinned that flipped under unchanged code and broke every fresh install (fixed in 0.8.3; flask-cors>=5 is now a floor). Note that it never affected localhost:4000, because a private→local request is not preflighted this way — only the deployed public origin is.

GET /health

Returns the cached environment info that was detected at startup.

{
  "status": "ok",
  "version": "0.2.2",
  "hardware": {
    "platform": "Darwin",
    "processor": "arm",
    "device": "mps",
    "device_name": "Apple arm64"
  },
  "frameworks": {
    "numpy":   { "version": "1.26.4", "available": true },
    "pytorch": { "version": "2.3.0",  "available": true, "device": "mps" },
    "jax":     { "version": "0.4.30", "available": true, "backend": "METAL" },
    "flax":    { "version": "0.12.8",  "available": true },
    "optax":   { "version": "0.2.8",   "available": true }
  },
  "python": "3.12.4"
}

POST /execute

Required fields:

Field Type Notes
code string The user's solution. Must define function_name.
framework "pytorch" | "jax" Selects the tensor library used for input/output deserialization.
function_name string Function in code to call.
test_cases array See below.

Optional:

Field Type Default Notes
timeout_ms int 30000 Per-execution timeout for the subprocess.
reference_code string none If provided and all tests pass, runs a benchmark against this reference solution.

A test_case looks like:

{
  "id": "case_1",
  "inputs": { "x": { "shape": [3], "values": [1.0, 2.0, 3.0] } },
  "expected": { "shape": [3], "values": [0.09, 0.24, 0.66] },
  "tolerance": 0.0001
}

tolerance defaults to 1e-5 if omitted. Inputs are passed as keyword arguments to function_name(**inputs).

Response

{
  "status": "passed" | "failed" | "error",
  "test_results": [
    {
      "id": "case_1",
      "passed": true,
      "actual": { "shape": [3], "values": [...] },
      "error": "",
      "runtime_us": 1234.5,
      "stdout": "x is 3.0\n",
      "stderr": ""
    }
  ],
  "setup_stdout": "",
  "setup_stderr": "",
  "stdout": "x is 3.0\n",
  "stderr": "",
  "runtime_us": 4567.8,
  "benchmark": {
    "user_median_ms": 12.34,
    "reference_median_ms": 10.0,
    "ratio": 1.234
  }
}

benchmark is present only on a passing run when reference_code was supplied. The runtime does 1 warmup + 3 timed runs for both the user and reference solutions and takes the median; ratio = user_median / reference_median. Lower is better — the website turns this into a percentile against other solvers.

Each test result's stdout / stderr is what that case printed, and setup_stdout / setup_stderr (interpreted frameworks) what printed while the module loaded; the top-level stdout is all of it joined. See docs/CONTRACT.md, "Printed output (0.11.0)", for caps and edge cases.

status is "error" when the subprocess crashed, timed out, or returned non-JSON.

Errors are returned with HTTP 200 and status: "error" in the body. The only HTTP error you'll see is 400 for missing required fields.


Tensor wire format

The runtime and website agree on a tiny convention for serializing tensors over JSON:

  • A scalar (int, float, bool) passes through as-is.
  • A tensor / numpy array becomes { "shape": [...], "values": [...] }. values is the row-major flattened list at dtype=float32.

The harness deserializes inputs into framework-native tensors:

  • pytorch → torch.tensor(np.array(values, dtype=float32).reshape(shape))
  • jax → jnp.array(...) of the same.

It serializes the function's return value the same way. Comparison is np.allclose(actual, expected, atol=tolerance) for tensors, abs(a - b) < tolerance for scalars, == for everything else.

This means: your function can return a Python int/float/bool or a tensor; non-tensor non-primitive returns will round-trip through ==. If you need dict/list support, extend serialize_value / deserialize_value in harness.py.


Configuration

There isn't much.

Where Purpose
~/.crackedai/setup_done Marker file. Delete to force framework reinstall.
Port 52341 Hardcoded in cli.py and local_runtime.js on the website. Don't change one without changing the other.
CORS origins Hardcoded in server.py: https://crackedaicode.com, http://localhost:4000.
KMP_DUPLICATE_LIB_OK=TRUE Set in pixi.toml activation env to dodge the OpenMP duplicate-library crash on macOS when both PyTorch and JAX get imported.

For contributors

Two supported environments.

pixi (preferred, fully-pinned)

git clone https://github.com/anupa/cracked-ai-connect.git
cd cracked-ai-connect
pixi install                # solves env, installs python+flask+pytorch+jax
pixi run test               # pytest tests/ -v
pixi run connect            # python -m crackedai_connect.cli

pixi.toml defines two environments:

  • default — CPU PyTorch + plain JAX (works on every platform)
  • cuda — CUDA-enabled JAX (Linux/Windows only). Activate with pixi shell -e cuda.

pip (lighter, what end users get)

pip install -e .            # install in editable mode
just test                   # python -m pytest tests/ -v
just run                    # crackedai-connect

This mirrors what end users do, except for the editable install. Note that pip install -e . installs only the runtime deps (numpy, flask, flask-cors) — for the test suite to actually exercise PyTorch/JAX paths you need torch + jax in the env too (run crackedai-connect once to auto-install them, or pip install torch jax).

Layout

cracked-ai-connect/
├── src/crackedai_connect/
│   ├── __init__.py        # __version__ — kept in sync with pyproject.toml
│   ├── __main__.py        # `python -m crackedai_connect`
│   ├── cli.py             # Entry point: setup → detect → start Flask
│   ├── setup.py           # First-run installer (CUDA detection, PyTorch/JAX install)
│   ├── detect.py          # Hardware + framework detection (cached)
│   ├── server.py          # Flask app: /health, /execute (with CORS)
│   ├── executor.py        # Subprocess orchestration + benchmark loop
│   └── harness.py         # Run inside the subprocess. Imports user code, runs tests.
├── tests/                 # pytest
├── docs/
│   ├── superpowers/       # Historical design specs + plans
│   └── ARCHITECTURE.md    # Deep-dive on the internals
├── justfile               # task runner (`just test`, `just bump`, `just release`)
├── pixi.toml / pixi.lock  # pixi environment
├── pyproject.toml         # PyPI metadata + setuptools config
└── README.md              # this file

Tests

pixi run test
# or
python -m pytest tests/ -v

Tests live in tests/:

  • test_detect.py — environment introspection
  • test_setup.py — first-run install logic
  • test_server.py — Flask routes (uses app.test_client())
  • test_executor.py — subprocess orchestration (timeout, crash, success)
  • test_harness.py — the in-subprocess harness directly

Releasing

The release GitHub Action publishes to PyPI on any push to main whose pyproject.toml version field changed.

The justfile automates the bump:

just bump 0.2.3      # rewrites version in both pyproject.toml and __init__.py, commits
git push             # CI publishes to PyPI + creates a GitHub Release

Or do it all in one shot from local (skips CI, requires ~/.pypirc or TWINE_PASSWORD):

just release 0.2.3   # bump + build + twine upload

Always update both pyproject.toml and src/crackedai_connect/__init__.py. The bump recipe does this in lockstep.


License

MIT — see LICENSE.

Metadata

Release files for crackedai-connect 0.11.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for crackedai-connect 0.11.0
File Size Uploaded Provenance Actions
crackedai_connect-0.11.0.tar.gz 142.4 kB Without provenance Details for crackedai_connect-0.11.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for crackedai-connect 0.11.0
File Interpreter ABI Platform Actions
crackedai_connect-0.11.0-py3-none-any.whl Python 3 none any Details for crackedai_connect-0.11.0-py3-none-any.whl

Total release size: 242.2 kB

Release files / crackedai_connect-0.11.0.tar.gz

Download URL crackedai_connect-0.11.0.tar.gz
Size 142.4 kB
Tags Source
SHA-256 checksum
How to use checksums
04c8ad91d2988892ab76b8d582077790aa6054316972e33cbd5c5e2f11d629a4
BLAKE2b-256 checksum
How to use checksums
1302b180e2e1882572531c606382dbbbf02ff966897defdca6a0d563eec220ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / crackedai_connect-0.11.0-py3-none-any.whl

Download URL crackedai_connect-0.11.0-py3-none-any.whl
Size 99.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2b8fdc7b078dd6e7aa870fa484c18b0953cdf3fff0c6885a826ffb6ea68e966
BLAKE2b-256 checksum
How to use checksums
38ec7790f07b1561a26f6091ed0cc3887a39c319dae5b9e018a86308e0cdc4eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Security for crackedai-connect 0.11.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page