Pi Dash self-evolution experiment with Muse Code and Meta Muse Spark 1.3
Pi Dash coordinated 26 Muse Code agents to rewrite its own Django backend in Rust. The main port took about ten days and cost about $350 in model usage.
Introduction#
Pi Dash is an open source agent coordination platform developed by AI Republic, that automatically assigns tasks to a team of AI agents. We used the platform to refactor its own backend. This article is a short report on how that worked.
On a Pi Dash board, agents do the issues: your own Muse Code, Claude Code, Codex or Cursor through the Pi Dash daemon, or the built-in Pi Dash Agent. The rulebook, the coordinator and the review-test-merge loop in this post are ordinary Pi Dash features. You can run the same setup on your own backlog.
Pi Dash rewrote its own backend in Rust#
In late September and early October 2026, Pi Dash coordinated 26 Muse Code agents on 5 developer machines to rewrite its own backend from Python and Django to Rust. The main port took about ten days. The agents picked up issues from a Pi Dash board, wrote the code, reviewed it, tested it against the running Django server, and merged their own pull requests.
The backend started as a fork of Plane’s Django API. By September it was about 101,000 lines of application code, plus about 20,000 lines of cloud-only code. We wanted it in Rust. We also wanted to find out whether our own product could run a project this large with no person approving each step.
It could, with caveats. This post covers the rules we gave the agents, how we checked that they were right, and what still needs improving.
Why Muse Code and Muse Spark. Every agent was Muse Code running as a Pi Dash runner, with muse-spark-1.3-contribute as the model. We chose them for two reasons:
- Price and performance. A project this size means an agent run for every step of every issue, so the cost of each run matters as much as its quality.
- Stability on long runs. The work went on for days with few people involved, so the model had to stay on task across long sessions without someone stepping in.
Across the whole project, the agents sent about 166,000 requests to the model and used about 48.6 billion tokens, for a total model cost of about $350.
The short version:
- Time: about ten days for the main port, September 26 to October 5. By then about three quarters of the final Rust code and nine in ten domain-port pull requests had merged.
- Volume: about 1,740 Pi Dash issues and about 1,320 merged pull requests.
- Correctness: 5,029 contract tests run against both backends. Every HTTP contract test passes on Rust.
- Safety: no
unsafecode. Every crate forbids it. - Process: no human approval gate on any merge.
Why leave Django#
We had three reasons.
- Python cost too much to run. The Django backend was heavy and slow: on our production host it used about 1.5 GB of memory against 81 MB for Rust, and with 32 requests at once it answered a third as many per second (The numbers has the details).
- One language from the cloud to the developer’s machine. The agent daemon and the desktop app were already Rust. With the backend in Rust too, the cloud and the daemon can share the same code.
- A backend built for running agents. The backend now hands out and tracks agent work all day, which needs a language that answers fast on few resources. Django serves more requests by adding Python processes; Rust serves them from one process.
Same behavior, new code#
Planning came first. Muse Code scanned the Django codebase and wrote a plan: it measured every area of the backend, marked dead code to skip, and split the rest into 10 foundation issues and 37 domain epics. Claude Code reviewed the plan. Muse Code then created the epics and the rulebook in Pi Dash through MCP, one issue per row of the plan. From there, each epic’s first run splits it into its own sub-issues, as the loop section shows.
Every agent run starts by reading one rulebook, a Pi Dash issue called PIDASHCONV-1. Its main rules:
- Keep the behavior. Same URLs, JSON, database schema and SQL behavior. Changing behavior needs its own issue.
- Quarantine. Code goes only under
rust-api/. No Python file is touched. - Done means green. The named tests pass. No stubs, skipped tests or placeholders.
- Review assumes the code is wrong. Two independent passes against the Python before any decision.
- Report problems, don’t work around them. A rule that can’t be followed becomes a
process:comment on the rulebook.
The first rule fixed behavior, not code. Django does much of its work implicitly, through base classes, serializers, permission classes and lazy querysets, so most of it has no direct Rust equivalent. For each issue, an agent worked out what the Python actually does (the rows it reads, the checks it applies, the JSON it returns, the side effects) and wrote new Rust to match. That is closer to clean-room development: the Python was the specification, not the template. Contract tests, Python suites that send real HTTP requests, then ran against both backends to check the result.
Figure 1
The agent works out what the Python does, then writes Rust that does the same
Django does much of its work out of sight: the base view checks the login, and the body is parsed on first use. None of that maps line for line to Rust, so each agent first writes down the behavior, then implements it. This is the per-job toggle of the D-03 epic.
Pythonapps/api/pi_dash/loop/views.py
What it does
Rustrust-api/crates/api/src/loop/user.rs
| Contract test | What it sends | Django | Rust |
|---|
AutoPMJobEndpoint.patch. The Rust is shortened from patch_job and job_by_slug_select: error handling condensed and the status comments added. Test names are the real contract tests in rust-api/contract-tests/loop/.The Rust is organized by layer, not by Django app: types → db → auth → services → api, plus jobs. The lower layers were written first and then locked.
One rule changed midway. On October 26, “same JSON” stopped meaning every byte: business behavior and the API contract must still match, but library quirks no client can trigger are no longer copied.
The loop: implement, review, test, merge#
Every issue moves through the same loop on a Pi Dash board, and each step is a separate agent run with its own fresh context. The run that writes the code never reviews it.
A review or test that finds a problem sends the issue back to Implement. A pass goes straight to the merge, in the same run.
The coordinator is a scheduled Pi Dash agent that acts as project manager. It frees issues whose stage is open and whose blockers are done. It re-dispatches stuck runs, turns process: comments into issues and reports progress. It never touches code.
Epics split themselves. Each Django domain started as one epic. Its first run read the Python and filed sub-issues bottom-up: serializers, then models, queries, permissions, tasks, handlers, with at most five units each. A review run checked that split against the source before any sub-issue could start.
Figure 2
One epic splits itself into issues, and agents carry each one to a merge
The coordinator opens each stage when the previous one is done. A domain epic's first run reads the Python and files its own sub-issues. Then every sub-issue goes through implement, review and test, each a separate agent run.
Merging is the test run’s job. The merge procedure has five steps:
- Merge the issues this one depends on first.
- Rebase on the Rust branch.
- Re-run the affected checks.
- Wait for the one required check.
- Squash-merge and post the commit SHA.
If other pull requests keep landing first, the run may rebase up to six times before it stops and reports.
Red CI after a merge is never reverted. GitHub runs the full Rust suite after each merge. If it goes red, the coordinator files one urgent fix issue naming the failing tests and the merges since the last green run. The fix run bisects that range using only the failing tests.
The numbers#
Most of the code was written in about ten days. From September 26 to October 5, agents merged about 720,000 net lines of Rust, about three quarters of what was there when the branch merged into main. By October 12 it was about 88%. The domain ports themselves ran from September 27 to October 10, and 353 of their 395 pull requests had merged by October 5. The weeks after went to fixes, parity work and cleanup, and to time spent waiting for us to check results and decide what came next. The branch merged into main on November 3.
.rs lines per day under rust-api/crates, from git log origin/rust-dev, September 26 to October 5, 2026. Tests and comments included. Leaves out a 201,769-line character-set table added October 5 and deleted October 27.After October 12 the pace dropped to a few thousand lines a day across all merges, as the work moved to fixes, parity and cleanup.
Figure 3
Ten days of merged pull requests, replayed
Every dot is one pull request an agent merged into the Rust branch, placed at its merge time and sized by the Rust lines it added. Hover a dot for its title.
git log origin/rust-dev -- rust-api, 494 squash-merged pull requests authored September 26 to October 5, 2026; lines are net .rs lines under rust-api/crates. One 201,769-line character-set table (pull request #1102, deleted October 27) is drawn at zero size. Rows are grouped by the rulebook's stages.| Measure | Value |
|---|---|
| Django application code ported | ~101,000 lines (excluding tests, migrations, comments, blank lines) |
| Rust application code | ~505,000 lines (excluding tests, comments, blank lines) |
| Rust comments | ~144,000 lines, mostly “ported from” notes |
| Rust unit tests | 9,175 test functions |
| Contract tests (run on both backends) | 5,029 tests in ~50 domains |
| Recorded fixtures | 715 files |
unsafe blocks | 0 |
| Pi Dash issues filed | ~1,740 |
| Merged pull requests | ~1,320 |
| Commits after the merge into main (to Nov 17) | 333 |
The Rust is about five times longer than the Python it replaced. Django does much of its work implicitly: the ORM writes the SQL, and DRF serializers and permission classes do the rest. Rust spells out each query, each JSON field and each check.
Rust and Django side by side#
Both backends run on the same production host and database, so we compared them directly.
Memory. The Rust backend uses about 18 times less memory (measured November 18; the Rust containers had been up three hours, the Django ones five days).
| Process | Rust | Django |
|---|---|---|
| API server | 63 MiB | 802 MiB |
| Background worker | 18 MiB | 472 MiB |
| Scheduler | inside the worker | 233 MiB |
| Total | 81 MiB | 1,507 MiB |
Image size. 88.5 MB compressed for Rust, against 141.1 MB for Django.
Under load. At 32 requests at once, Rust served three times as many requests per second as Django. We sent an unauthenticated GET /api/users/me/ with 1, 8 and 32 requests in flight on November 20.
| Requests at once | Rust req/s | Django req/s | Rust p50 | Django p50 | Rust p99 | Django p99 |
|---|---|---|---|---|---|---|
| 1 | 32 | 29 | 24 ms | 29 ms | 135 ms | 122 ms |
| 8 | 191 | 148 | 31 ms | 41 ms | 210 ms | 143 ms |
| 32 | 607 | 204 | 37 ms | 134 ms | 190 ms | 764 ms |
Cost. Django takes about 1.5 GB of the host’s 3.8 GB. Without it, the Rust stack fits on a smaller instance.
Switching over, one domain at a time#
Nothing was deleted. The Python backend is still in the repository, and the Rust backend took over by routing: a proxy moved traffic to Rust one domain at a time while the rest still reached Django. Today Rust serves all of pidash.airepublic.com.
That is why the agents could be trusted to merge their own work. Merging a pull request changed what was built, not what was served.
What still needs improving#
We were surprised by how much a team of AI agents could do when they worked together under Pi Dash’s coordination. The project also showed three major areas where the platform still needs to improve.
Managing agent sandboxes. During the port, agent sandboxes ran out of disk space. We freed the space by hand, then wrote a script to clean them up automatically. Pi Dash should look after connected sandboxes itself, and become a platform that manages a fleet of agent sandboxes end to end.
Using fewer tokens. Token use is still high, because an agent often runs several loops to finish one task. Better memory of task runs for agents can make them use tokens more efficiently.
Letting AI manage more of the work. Pi Dash is evolving into a platform where AI manages AI to resolve tasks for human engineers. The next step is letting agents take on more of the task management themselves.
Try Pi Dash yourself#
Last month we also set up a debugging scheduler in Pi Dash. It runs on a schedule and keeps debugging the new Rust backend, to get it working end to end. With Pi Dash, we can see how AI agents can work as digital employees, managed the way a modern enterprise manages its teams.
We have open-sourced the code at github.com/The-AI-Republic/pi-dash, and a ready-to-use cloud service runs at pidash.airepublic.com. Download the source code and try it yourself.