Tutorial 6 — Managed TS, JS, and Python Checks
Goal: write custom Check logic in TypeScript, JavaScript, and Python
without building a custom:exec wrapper.
You will learn: how madbench chooses Bun, Python, goja, or raw subprocesses; how dependency roots work; and how to make CI strict with lockfiles.
Runtime dispatch
The Check type chooses the runtime:
| YAML surface | Runtime |
|---|---|
type: ts / type: js | managed Bun |
type: python | managed Python via uv |
transform | embedded goja |
metrics: expressions | embedded goja — managed Bun instead when a module/ directory sits beside the bench |
custom:exec | user-managed subprocess |
Version fields only pin runtimes. They do not choose the evaluator:
defaults:
bun: "1.3.4"
python: "3.12"
type: ts still means Bun. transform: still means goja.
Inline Checks
description: "Managed runtime Checks"
harness: mock
scenarios:
- name: inline-checks
prompt: "hello from managed runtimes"
vars:
requiredWord: managed
checks:
- type: ts
value: output.includes(vars.requiredWord)
- type: python
value: "config['required_word'] in output"
config:
required_word: runtimes
Madbench passes output, vars, config, session, assertion, and
context to managed runtime code. Boolean returns become pass/fail results.
Any other key you write beside type: reaches the code too: YAML writes a Check's own keys flat, beside type:; the envelope carries them under assertion.args.
File Checks
checks:
- type: js
value: file://evals/check-output.js
config:
requiredWord: evaluator
- type: python
value: file://evals/check_output.py
config:
min_length: 20
JavaScript / TypeScript files export a function:
export default function evaluate(output, context) {
const pass = output.includes(context.config.requiredWord);
return { pass, score: pass ? 1 : 0, reason: pass ? "ok" : "missing word" };
}
Python files define evaluate:
def evaluate(output, context):
passed = len(output) >= context["config"]["min_length"]
return {"pass": passed, "score": 1 if passed else 0, "reason": "checked"}
Return values may be booleans, numbers, or result objects containing
pass, score, reason, and optional evidence.
Dependencies
For a file Check, madbench walks upward from the Check file and uses the nearest dependency root.
Shared JS dependencies:
madbench.yaml
package.json
bun.lock
evals/
check-output.ts
Per-evaluator Python dependencies:
evals/similarity/
pyproject.toml
uv.lock
check.py
Users add dependencies with the normal tools:
cd evals
bun add zod
cd evals/similarity
uv add pydantic
Madbench installs/syncs dependencies in its cache during a run; it
does not write node_modules, .venv, bun.lock, or uv.lock into your Bench
directory.
If Bun, uv, or the requested Python version is missing, madbench bootstraps the
managed runtime into its cache too. The cache defaults to
$XDG_CACHE_HOME/madbench or ~/.cache/madbench.
Default local behavior is friendly:
| Files present | Behavior |
|---|---|
| no package file | run standalone |
package.json + no bun.lock | install in cache using the current dependency resolver |
pyproject.toml + no uv.lock | sync in cache using the current dependency resolver |
| lockfile present | install/sync from lockfile |
CI can force reproducibility:
MADBENCH_LOCKFILE_REQUIRED=1 madbench
or in YAML:
defaults:
lockfile_required: true
scenarios:
- name: allow-local-prototype
lockfile_required: false
With strict mode enabled, package.json requires bun.lock, and
pyproject.toml requires uv.lock.
Run the example
From the repo root:
go build ./cmd/madbench
./madbench examples/managed-runtimes/madbench.yaml
The first run may prepare managed runtimes or dependency caches. Later runs reuse the cache.
Verify cold installs
There is an opt-in Docker test that starts from an image with no Bun, uv,
python, or python3 on PATH. It verifies that madbench installs Bun, uv,
Python, and both JS/Python evaluator dependencies into cache without mutating
the eval source directory:
MADBENCH_DOCKER_RUNTIME_TESTS=1 go test ./pkg/check/script -run TestDockerManagedRuntimeInstallAndDependencies -count=1
Previous: Tutorial 5 — SWE-bench-style multi-Scenario Benches.