MELRA
Modular Execution Layer for Reliable Autonomy
Your AI agent decides what to do. MELRA governs how tool calls are authorized, verified, and recovered.
An open-source local execution runtime for agent tool calls you route through MELRA. It checks each call against policy, requests approval when needed, verifies declared evidence, and keeps a redacted receipt of what runs to an outcome. For each task, MELRA dispatches mutations at most once; uncertain outcomes are parked for reconciliation instead of replay. Exactly-once external effects still depend on the provider. Calls made through other tools remain outside MELRA's control.
Works with Β
26-second demo Β Β·Β Quick start Β Β·Β How it works Β Β·Β See what it is doing Β Β·Β Docs Β Β·Β Contribute Β Β·Β Discussions Β Β·Β Product Hunt launch
26-second demo
https://github.com/user-attachments/assets/e5cf895d-7ea6-4797-a1ef-e69cc5860d3f
[!WARNING] MELRA is alpha software. The local runtime is tested end to end, but APIs may change before
1.0. Use an isolated workspace, keep domain and command allowlists narrow, and read every approval before you give it.
Quick start
You need Node.js 22.13 or newer, or 23.4 or newer. From the project the agent should work in, one command sets everything up:
cd ~/project
npx @melra/cli@alpha setup
That directory becomes the agent's workspace, the boundary for its file and command
operations. setup shows it, and asks before making your home directory, a directory
holding it, or / the workspace; set MELRA_WORKSPACE to choose another.
In a terminal, setup is a short wizard. It writes a safe local policy, finds the
agent apps on your machine, asks which one should use MELRA, and writes MELRA into
that app's own config file, keeping everything else in it (and saving a .bak first):
Which MCP client should use MELRA?
1) Claude Code detected: 'claude' on PATH
2) Cursor detected: config file found
3) Gemini CLI detected: config folder found
...
Choose 1-26 [1]: 1
Write it into ~/project/.mcp.json? [Y/n]
β Workspace ~/project
β Policy ~/.melra/policy.json
β Claude Code ~/project/.mcp.json
Next: Start claude in this workspace and approve the 'melra' server when it asks; 'claude mcp list' then shows it connected.
Then restart your agent app (Claude Code asks you to approve a project's server once) and ask it to do something, for example "use melra to show me the system info". That's it.
Every command prints readable output in a terminal and plain JSON when piped or with
--json, so scripts keep working. MELRA creates <MELRA_HOME>/payload.key with
private permissions on first start; back it up with the SQLite files, because losing
it makes persisted payloads unreadable. See installation for
every install path, environment variable, and the hardened Docker invocation.
[!CAUTION] This project publishes only under the
@melra/npm scope (@melra/cliis the CLI) and on its releases, where the Python SDK's wheel is. An unscoped npm packagemelraor a PyPI packagemelrais not this project's. Install from that scope, from this repository, or from the releases.
If MELRA helps, star the repository so other
agent builders can find it. Trying it in Cursor or another client? Share the client
and its version, your OS, and your MELRA version (npx @melra/cli@alpha version) in
issue #184; partial test results are
useful too.
What is MELRA?
AI agents no longer just talk. They edit files, run commands, click through websites and call APIs on your behalf. Four questions come with that, and most agents answer them differently, or not at all:
π‘οΈ Is it allowed?
Every action MELRA receives is checked against your policy, and checked again at the moment it runs. Risky changes wait for your exact approval.
β Did it really work?
"No error" is not success. An action counts only when the evidence you declared holds: the file exists, the exit code is 0, the page says what it should.
π What if it crashes?
Every mutation MELRA dispatches is recorded before it runs and runs at most
once. After a crash, MELRA settles it from its evidence or the provider; what it
cannot settle waits in recovery_required and is never replayed.
π§Ύ What happened?
Every action MELRA runs to an outcome leaves a redacted, hash-linked receipt, so you can audit what ran, who asked, and why it was allowed.
MELRA answers those questions in one place for tool calls routed through it, across supported agents. It sits underneath your agent for those calls, the way an operating system sits underneath your apps:
The LLM reasons. The harness manages the loop. MELRA governs the effect lifecycle for calls routed through it. Swap the model or the agent; MELRA's policies, approvals, credentials, history and receipts can stay in place.
Works with your agent
MELRA speaks the Model Context Protocol, so any MCP
client can use it. For these, melra setup --client <name> writes the config in the
client's own format and location, and melra doctor tells you whether each one is
pointed at MELRA:
Building your own agent? Use the TypeScript SDK or the Python SDK. Both can spawn MELRA or connect to one that is already running over loopback HTTP or a private Unix socket. For agent frameworks, see the framework examples: LangChain / LangGraph, the OpenAI Agents SDK, the Vercel AI SDK, and the official MCP SDKs.
[!NOTE] A named client is marked verified only after the released package, not a source checkout, passes discovery, planning, approval, execution, cancellation and receipt retrieval in that client. Per-client status lives in COMPATIBILITY.md.
How it works
An effect is one bounded operation an agent routes through MELRA: file.write,
terminal.run, browser.click, http.request, and so on. MELRA handles each routed
effect in nine stages, split between a plan step and an execute step (for a single
task, melra_plan then melra_execute) so that nothing runs at planning time:
Here is one change from start to finish, in developer mode. In
enforced mode the challenge carries no
phrase: you approve with melra approve <task-id> outside the conversation,
and the agent's melra_execute sends no approval at all.
sequenceDiagram
autonumber
participant A as Your agent
participant M as MELRA
participant You
participant W as Your system
A->>M: melra_plan: write notes.md, evidence "file contains 'done'"
M->>M: type, classify, check policy, record
M-->>A: awaiting_approval + challenge "APPROVE 3f9cβ¦"
A->>You: May I write notes.md?
You-->>A: yes
A->>M: melra_execute with the exact phrase
M->>M: policy again, not already done?
M->>W: write the file (under a budget)
M->>W: read it back, independently
M-->>A: verified_success + receipt
What the final status means, and what an agent should do next:
The agent resolves "run the checks" into one bounded operation, plus the evidence that would prove it worked:
{
"goal": "Run the repository checks",
"operation": { "kind": "terminal", "action": "run", "command": "pnpm", "args": ["check"] },
"requiredEvidence": [{ "type": "exit_code", "value": 0 }]
}
The task reaches verified_success only if the process exits 0. A process that runs
and exits 1 completed the action but failed the evidence, so it is reported as
partial. MELRA never receives a goal like "fix the production server": that needs
judgement, which belongs to the model. A kernel that interpreted sentences would be a
kernel whose guarantees depended on a model.
When an agent connects, MELRA also sends it a short guide to this loop (the MCP
server's instructions), so a model knows to declare evidence, read the status, and
never blindly retry an unknown outcome, without anyone prompt-engineering it.
See what it is doing
You can see each action MELRA handled and its policy decision, and, for each that ran to an outcome, its evidence and receipt, from the terminal or the browser. Nothing here can approve or start work, and approval phrases are never displayed.
From the terminal
$ melra status
MELRA 0.3.0-alpha.15 developer mode
Tasks 3 total: 1 awaiting_approval,
1 policy_blocked, 1 verified_success
Waiting 1 waiting for approval
HTTP 127.0.0.1:7457 not running
$ melra tasks
ID STATUS OPERATION UPDATED
64199678 awaiting_approval file.write 0s ago
ca4aec7a policy_blocked terminal.run 1s ago
a1285e0f verified_success system.info 1s ago
$ melra watch # live, until Ctrl-C
6:07:21 PM task 882cf55c verified_success
6:07:22 PM task f813364c awaiting_approval
melra doctor checks Node, SQLite, the browser and policy, and reports which of your
agent apps point at MELRA, with the one command that fixes anything wrong.
In the browser: melra serve --http --open
An overview, a searchable task list, and durable workflows with a live event stream. It works at phone width and in light and dark, and it is served with a strict Content-Security-Policy.
Safe by default
Every row above can be switched off at once with melra serve --unsafe-local (or
MELRA_UNHINGED=1): no policy, no approvals, no evidence requirement, no workspace
confinement, no destination checks. The agent gets exactly the reach your OS user has.
The mode announces itself on stderr, in melra doctor and in melra_capabilities,
and receipts still record what ran. See
unsafe-local mode.
The honest gap in a default install is that MELRA governs the effects it is asked
for. An agent holding both a MELRA terminal and a native one makes the kernel
optional. MELRA_MODE is where you say which situation you are in:
MELRA cannot verify that assertion from inside its own process, and it does not
pretend to; the isolation is the operating system's job. What enforced mode does is
close every door MELRA owns: --unsafe-local is refused outright, nothing binds
outside loopback (a 0600 Unix socket is allowed), no client can register itself, and
mode is stamped on every receipt. For the operating-system side,
examples/deploy has a hardened Docker run and systemd
unit, each checked in CI, and melra doctor reports which restrictions are actually in
effect. See
deployment modes,
the threat model and the security policy.
Why MELRA
An LLM decides what to do. A harness runs the loop that gets it there. Something still has to decide whether the resulting effect is allowed, avoid replaying uncertain mutations, prove what happened, and survive a crash in the middle. Today that machinery is rebuilt inside every agent harness, and it dies with the harness. MELRA is that machinery, factored out and made agent-independent.
- Tool call executes immediately
- Success = no exception thrown
- Policy, if any, checked once
- Changes look the same as reads
- Output is trusted
- No durable record
- Rules live inside one agent
- Plan and execute are separate calls
- Success = declared evidence passed
- Policy checked again at execution time
- Changes need evidence and an exact approval
- Page content is explicitly untrusted
- Redacted receipt + SHA-256 execution certificate
- Rules outlive the agent that used them
Next to the two layers it is most often mistaken for:
Plenty of MCP servers can do these things; this is not a claim that none of them do.
The difference is that in MELRA they are the execution contract rather than a per-tool
option. The boundary is partly shipped: MELRA_MODE=enforced closes every door
MELRA owns, but the OS isolation that stops a harness reaching the filesystem around
the kernel is the operator's to build; runnable hardened deployment recipes are still
to come (#52).
The feature test. Anything that would still make sense if the request came from ordinary deterministic software belongs in MELRA: authorisation, idempotency, credential isolation, recovery, verification, effect history. Prompt optimisation, LLM memory, model selection, a planner and agent personality belong to the harness above. That is why nothing in MELRA's execution path ever calls a model.
What it can do
Effect adapters
The kernel is the contract; these are its shipped implementations. Every one passes through the same policy, approval, budget, verification, receipt and certificate pipeline; an adapter that skipped it would not be an adapter.
Database, cloud and SaaS adapters are designed and on the roadmap, not shipped today. Semantic memory about the user (preferences, conversation history) belongs to the harness, not here.
A deliberately small tool surface
Eleven tools in front of the adapters and one durable workflow controller. The CLI, both SDKs, loopback HTTP and the Unix socket reach the same eleven operations; this list is the kernel contract, not an MCP-specific API.
Prefer tool names your model already knows? Set MELRA_HARNESS_TOOLS=1 and thirteen
more appear alongside these (read_file, write_file, run_command, browser_click,
approve, β¦). They are not a second path: each one builds an ordinary task and runs
the same pipeline. See ordinary tool names.
Durable, restart-safe workflows
Workflows compose operation, approval, condition, parallel, bounded_loop,
checkpoint, compensation, human_input and delegation nodes, and every effect
still travels through the task pipeline. Each CLI call below is a new process, so this
exercises restart persistence with no daemon:
melra workflow plan --definition examples/workflows/restart-safe.json # save the id
melra workflow advance <workflow-id>
melra workflow advance <workflow-id> # exits 3 with the write's approval challenge
# developer mode echoes the phrase; enforced mode runs `melra approve <task-id>` instead
melra workflow advance <workflow-id> --approval '<approval-id>:<exact phrase>'
melra workflow advance <workflow-id>
planned stateVersion=2
running stateVersion=4 inspect=verified_complete
awaiting_approval stateVersion=7 phrase="APPROVE <digest prefix>" (developer mode)
running stateVersion=10 write=verified_complete
verified_complete stateVersion=14 checkpoint=verified_complete
Stop the process after any line and the next command resumes from the same
MELRA_HOME. Interrupted reads may retry; interrupted changes are never silently
repeated. They are settled by re-observation, or they park in recovery_required.
See the full CHANGELOG.
Evidence and benchmarks
Numbers come from committed scripts and JSON artifacts, with dataset hashes and claim boundaries. They are component measurements, not a claim that MELRA is "the best" or that unlike benchmarks are comparable.
Raw artifacts: core microbenchmarks, LoCoMo and GovBench.
The repository also contains a pre-registered browser-agent harness (MiniWoB-125 and the WebArena-Verified Hard-30 registered subset) whose task IDs, upstream revisions and dataset hashes are frozen. Its score is not yet claimed: it will be published only after a full fixed-denominator run passes the publication gate. MELRA has not run an official OSWorld, WebArena or LongMemEval submission.
# the full validation gate
pnpm check && pnpm evals && pnpm e2e && pnpm pack:check && pnpm security:audit
pnpm --filter @melra/evals evaluate:durable-core -- --publishable
# memory, browser, terminal and computer microbenchmarks
pnpm benchmark:core
# governance benchmark: 362 model-free cases, loopback fixtures only
pnpm benchmark:govbench
# LoCoMo (dataset not vendored: CC BY-NC 4.0)
git clone https://github.com/snap-research/locomo.git /tmp/locomo
pnpm benchmark:locomo -- --dataset /tmp/locomo/data/locomo10.json \
--output docs/research/results/locomo-retrieval.json
# browser-agent harness contract checks (no model, no network)
pnpm benchmark:browser:check
pnpm benchmark:browser:verify-upstream
# hardened container and a real MCP smoke test
docker build -t melra:local . && docker run --rm melra:local doctor && pnpm docker:smoke
The MiniWoB suite also needs the pinned MiniWoB++ assets and an agent configuration; see the research index and the methodology. Run outputs (HAR, screenshots, video, transcripts) are git-ignored and must never be committed.
For developers
SDKs
Both SDKs spawn a local server or connect to a running one over HTTP or a Unix socket. The token is always passed explicitly, and plain HTTP to a remote host is refused unless you opt in.
CLI at a glance
apps/cli/ CLI and stdio entrypoint
kernel services
packages/protocol/ strict task, workflow, event and operation schemas
packages/runtime-core/ task/workflow lifecycle, events, recovery
packages/policy-core/ local policy and scoped approvals
packages/storage-sqlite/ transactional tasks, workflows, events, evidence
packages/verifier-core/ deterministic evidence predicates
packages/receipt-schema/ receipts and execution certificates
packages/memory/ operational memory: scoped retrieval and lifecycle
packages/server/ runtime composition, MCP, loopback HTTP and Unix socket
reference effect adapters
packages/file-runtime/ confined filesystem operations
packages/terminal-runtime/ shell-free process supervision
packages/browser-runtime/ isolated browser automation and stable-DOM wait
packages/computer-runtime/ governed local computer-use adapters
packages/http-runtime/ governed HTTP and API calls
clients and evidence
packages/sdk-ts/ TypeScript client SDK
sdk-py/ Python client SDK
benchmarks/browser-agent/ pre-registered browser-agent evaluation harness
evals/ safety and durable crash-recovery evaluations
scripts/ benchmark and release checks
docs/research/ methods, findings and raw results
examples/ runnable task examples
MELRA is capability-driven, not language-restricted: Rust, Go, Swift, C# or another language can be added when measurement shows a real benefit and the same conformance suite passes.
Runnable examples cover a read-only system task, a verified file write, a terminal check, browser inspection, scoped memory, computer capability discovery, a governed API call, independent verification, and a restart-safe workflow.
Documentation
Contributing
Code, adapters, client integrations, benchmark harnesses, verifier predicates, documentation and threat analysis are all welcome.
- Read CONTRIBUTING.md and the Code of Conduct.
- Sign your commits under the DCO (
git commit -s). - Run
pnpm checkbefore opening a pull request; it also checks links, the environment-variable table and the CHANGELOG shape. - Report vulnerabilities through private vulnerability reporting, never in a public issue.
License
Software and documentation are licensed under the Apache License 2.0. The official logo and hero artwork are licensed under CC BY-ND 4.0. Third-party benchmark datasets keep their own licenses and are not included in this repository.
Built in the open by XAGI Labs.
MELRA brand assets Β© XAGI Labs Private Limited, licensed CC BY-ND 4.0.