Argon 2.11 builds a database's secondary indexes in every sandbox, and 2.10 can give each sandbox its own MongoDB user, revoked on discard. A transcript on the published release, what it costs, and the limits.
Current capability notes: checkout materializes a physical database; native actor attribution is per branch/run; undo needs complete images and retained history. CLI sandboxes require watch and scheduled sweep. Read the capability matrix.
A sandbox is only a good place for an AI agent to work if it behaves like the database the change is meant for. Two things decide most of that. Does it refuse the writes production would refuse? And can the agent reach anything outside its sandbox?
Until recently Argon got both wrong. A sandbox had the source's documents but only the _id index, so an insert that production would reject with a duplicate key error went through. The connection string carried the engine's own MongoDB credentials, so code holding it could read every database the engine could. Two releases changed that:
- Argon 2.10.0 can give each sandbox its own MongoDB user, revoked when the sandbox goes.
- Argon 2.11.0 builds each collection's secondary indexes in every sandbox.
This post runs both on the published release and shows what is refused. It also covers what happens when the data breaks an index, what the indexes cost, and what is still not covered.
What we ran #
- Argon 2.11.1 , installed from npm as
argonctl. - MongoDB 7.0.45 as a one-member replica set with access control (
--auth --keyFile), in a container. Argon connects as a root user. - A source database
shopwith 1,000 orders and three secondary indexes: unique onsku, compound onstatus, total, and a 30-day TTL oncreatedAt. A second database,billing, stands for everything else on the deployment.
Every command and its output is in the transcript, with passwords masked. The report has the script that produced it. Below, $SANDBOX is the connection string Argon returned; IDs and long output are shortened with …
The source's indexes, in the sandbox #
$ mongosh "$ENGINE" --eval 'db.getSiblingDB("shop").orders.getIndexes().map(i => i.name)'
[ '_id_', 'sku_1', 'status_1_total_-1', 'createdAt_1' ]
$ argon import database --uri "$ENGINE" --database shop --project shop --source-quiesced --yes
$ argon sandbox create -p shop --name agent-run --ttl 1h --credential --output json
{
"connection_string": "mongodb://sandbox_6b015c85…:•••@localhost:27017/argon_br_6b015c85…?authSource=argon_br_6b015c85…&replicaSet=rs0",
"index_notes": [
"index createdAt_1 on orders was built without its TTL expiry"
],
"indexes": 3,
…
}
The import recorded the three definitions, and the checkout built them after copying the documents. Inside the sandbox:
$ mongosh "$SANDBOX" --eval 'db.orders.getIndexes().map(…)'
[ '_id_', 'sku_1 unique', 'status_1_total_-1', 'createdAt_1' ]
$ mongosh "$SANDBOX" --eval 'db.orders.updateOne({_id: 7}, {$set: {status: "refunded"}})'
{ acknowledged: true, insertedId: null, matchedCount: 1, modifiedCount: 1, upsertedCount: 0 }
$ mongosh "$SANDBOX" --eval 'db.orders.insertOne({_id: 5000, sku: "sku-42"})'
E11000 duplicate key error collection: argon_br_6b015c85….orders index: sku_1 dup key: { sku: "sku-42" }
The duplicate sku fails where the agent writes it, as it would in production. Before 2.11 the insert succeeded. The conflict surfaced only at argon merge check, after the agent's run, or when the write reached the real database. Queries in the sandbox now use the same indexes as on the source too.
createdAt_1 is there, but without its expiry. A copy of a database is often older than its newest documents' TTL. With the expiry kept, MongoDB would start deleting the sandbox's documents on its own, and capture would record those deletions as the agent's changes.
The definitions come from three places:
- the import, which reads the source's indexes;
- following, which records index builds and drops on the source as they happen;
- capture, which records index builds and drops made through a branch's own checkout. These apply to that branch and its descendants, not to its parent.
Indexes are not versioned: a branch uses the latest definitions recorded for it. Details are in the operations guide and the pull request.
A MongoDB user for each sandbox #
--credential made the connection string above carry a user named after the sandbox's branch ID. It can read and write that one database, and that database is its authSource. Argon returns the password once and stores only the user name. Outside the sandbox:
$ mongosh "$SANDBOX" --eval 'db.getSiblingDB("billing").invoices.findOne()'
not authorized on billing to execute command { find: "invoices", … }
$ mongosh "$SANDBOX" --eval 'db.getSiblingDB("argon_br_6b015c85…").orders.findOne()' # main's database
not authorized on argon_br_6b015c85… to execute command { find: "orders", … }
$ mongosh "$SANDBOX" --eval 'db.getSiblingDB("argon_wal").wal_log.findOne()'
not authorized on argon_wal to execute command { find: "wal_log", … }
Discarding the sandbox drops the user before the database. We kept a connection open across the discard, writing once before and once after:
$ argon sandbox discard -p shop -b agent-run
Discarded; storage reclaimed.
first write: ok
second write: Command update requires authentication
$ mongosh "$SANDBOX" --eval 'db.orders.findOne()' # a new connection
MongoServerError: Authentication failed.
Three conditions apply:
- The deployment must enforce authentication. On one that does not, a per-sandbox user would not be enforced, so Argon refuses the flag. The REST API answers 422 since 2.11.1.
- The engine needs
userAdminon the sandbox databases, oruserAdminAnyDatabase. - Expiry alone revokes nothing. An expired sandbox's credential keeps working until a sweep runs. The REST and MCP servers sweep every minute; with the CLI alone, schedule
argon sandbox sweep.
Without the flag the connection string still uses the engine's credentials. The Python SDK takes the same option as create_sandbox(..., credential=True) from 0.3.0. See Exposure and credentials and the pull request.
When the data breaks an index #
An index can only be built over data that satisfies it. To see what happens otherwise, we made a branch, checked it out with capture running, dropped its unique index and inserted a duplicate. That is the kind of change an agent cleaning up data might make.
$ mongosh "$CLEANUP" --eval 'db.orders.dropIndex("sku_1"); db.orders.insertOne({_id: 6000, sku: "sku-42"})'
{ acknowledged: true, insertedId: 6000 }
$ argon merge preview -p shop -b cleanup
Merging cleanup → main
put orders/~argon:bson:DAAAABBpAHAXAAAA
1 change(s), 0 conflict(s)
$ argon merge apply 6b015ca0d335a77244e5d98c # main is checked out and has sku_1
Error: apply failed: write exception: write errors: [E11000 duplicate key error collection: argon_br_6b015c85….orders index: sku_1 dup key: { sku: "sku-42" }]
main was checked out, so its database still had the unique index, and MongoDB refused the merge. Nothing changed: main stayed at LSN 1002.
With main released, nothing enforced the index at merge time. A fresh preview applied, and the next sandbox reported what it could not build:
$ argon release -p shop -b main
$ argon merge apply 6b015ca0d335a77244e5d98c
Error: apply failed: stale plan: branch state changed since preview; run preview again
$ argon merge preview -p shop -b cleanup # saves plan 6b015ca01cdbacf2ac128b6b
$ argon merge apply 6b015ca01cdbacf2ac128b6b
Merged: 1 change(s) applied.
$ argon sandbox create -p shop --name next-run --ttl 1h
Sandbox "next-run" forked from main at LSN 1008.
Note: index sku_1 on orders was not built: (DuplicateKey) Index build failed: … E11000 duplicate key error … dup key: { sku: "sku-42" }
Note: index createdAt_1 on orders was built without its TTL expiry
The checkout built the other indexes and named the one it skipped, in the CLI output and in index_notes. It did not fail the whole sandbox.
The broader point: indexes are not versioned, and a merge does not carry index changes. Keep the branch you merge into checked out if you want MongoDB to enforce its unique indexes at merge time. Run argon merge check before writing a plan back to the source.
What it costs #
Building indexes takes time, and a checkout now does it before the sandbox is handed over. We ran Argon 2.10.0 and 2.11.1 alternately, three rounds each with three sandboxes per round, at 100,000 documents of about 1 KB:
| Fixture | 2.10.0, ready | 2.11.1, ready |
|---|---|---|
1 collection, only the _id index |
1.98 s (1.67–2.32) | 2.04 s (1.73–2.35) |
| 10 collections, 20 secondary indexes | 1.70 s (1.61–2.55) | 4.21 s (4.05–4.27) |
Medians of nine sandboxes, with the range in brackets. The first write afterwards took a few milliseconds in both releases.
Without secondary indexes nothing changed. With 20, a sandbox of this size takes about 2.5 seconds longer. The host is shared and its load average was 11 to 13 throughout, so the absolute times are inflated; alternating the releases keeps the comparison fair. The figures are in the report. For how readiness grows with size, see the earlier measurement: 0.2, 2.4 and 16 seconds at 10,000, 100,000 and 1,000,000 documents, nearly all of it the physical copy.
Which deployments this is tested on #
Since 2.10.0, importing, following and write-back are tested against sources with access control and TLS, using the least-privilege role for each command. They are also tested through primary elections on a three-member replica set, and with MongoDB 6.0 and 8.0 sources and an 8.0 engine (pull request). The source permissions table lists the roles. Grant listIndexes so that sandboxes get the source's indexes; without it the import still works and says which collections get only _id.
Limits #
- Indexes are not versioned. A branch uses its own or its nearest ancestor's latest definitions, and a merge does not carry index changes.
- Validators, collation defaults and other collection options are not copied.
- Atlas itself and sharded sources are not tested. Atlas Search indexes are not secondary indexes and are not built.
- A sandbox credential needs a deployment that enforces authentication. It stays valid after expiry until a sweep runs.
- Checkout copies the data, so readiness grows with the database. Index builds add to it.
The full list for this release is in the changelog.
Try it #
npm install -g argonctl@2.11.1 --allow-scripts=argonctl
export MONGODB_URI="mongodb://…" # a replica set; with access control for --credential
argon import database --uri "$MONGODB_URI" --database shop --project shop --source-quiesced --yes
argon sandbox create -p shop --ttl 1h --credential --watch
The sandbox's JSON output, or its notes on stdout, lists the indexes it built. Discard it with argon sandbox discard -p shop -b <name>.
Frequently asked questions #
- Does an Argon sandbox have the same indexes as the source database?
- From Argon 2.11.0, yes for secondary indexes. The import records each collection's index definitions, following and resync keep them current, and every checkout builds them after copying the documents. A unique index therefore refuses a duplicate key inside the sandbox, as it would in production. A TTL index is built without its expiry, and an index the sandbox's data violates is skipped and reported. Validators and collection options are still not copied.
- Can each sandbox get its own MongoDB user?
- Yes, from Argon 2.10.0: argon sandbox create --credential returns a connection string for a user that can read and write only that sandbox's database. In our run that user was refused on another database, on the main branch's database and on Argon's metadata. The deployment must enforce authentication, and the engine needs userAdmin on the sandbox databases; otherwise Argon refuses to issue the credential.
- What happens to the credential when the sandbox is discarded?
- Argon drops the user before it drops the database. In our run a connection that was already open failed its next write with "requires authentication", and a new connection failed to authenticate. An expired sandbox's credential stays valid until a sweep runs; the REST and MCP servers sweep every minute.
- How much slower is a sandbox with indexes?
- At 100,000 documents spread over ten collections with 20 secondary indexes, a sandbox was ready in about 4.2 s on Argon 2.11.1 against 1.7 s on 2.10.0, which did not build them. With no secondary indexes the time did not change. Both releases were run alternately on the same shared host.
- Is this tested on Atlas?
- No. Since 2.10.0 the import, follow and write-back tests cover access control with least-privilege roles, TLS, primary elections on a three-member replica set, and MongoDB 6.0 and 8.0. Atlas itself and sharded sources are not tested.
Continue reading #
- Branch a Live MongoDB Database and Write Reviewed Changes Back
- Connect a Code Sandbox to a MongoDB Sandbox: A Runnable Example with boxd
- Code Sandboxes Isolate What Agents Run. What Isolates What They Write?
Argon is open source and MIT-licensed.