Rollikey
Rollback LIFO deterministik, gerbang radius dampak, penahanan otorisasi Stripe, dan proxy airlock Slack/Email 60 detik untuk agen AI di Postgres, Stripe, S3, dan GitHub.
Dokumentasi
https://github.com/user-attachments/assets/1003f497-8a23-4f76-a6ea-5471f8c4b649
Rollikey
Deterministic rollback and blast-radius proxy for AI agents across PostgreSQL, Stripe, AWS S3, GitHub, and Slack/Email:
- Pre-flight snapshots & blast-radius gates. Intercepts DB, Stripe, S3, and GitHub writes—saving Before-State snapshots and blocking >10-item mutations, >$1,000 charges/refunds, public S3 ACLs, or protected branches.
- 60-second staging airlock. Holds outbound emails and high-blast-radius Slack posts in Redis before releasing to SMTP or Slack.
- Deterministic LIFO
revert(runId). Cancels held messages and reverses applied actions in reverse order across all five connectors.
3-line quickstart
npm install @rollikey/sdk # typed client
npx -y @rollikey/mcp # the MCP proxy (needs DATABASE_URL / REDIS_URL, see .env.example)
docker compose up -d && npm install && npm run db:seed # postgres, redis, mailpit, minio (all local, $0)
npm run dashboard # http://localhost:3000 · side-by-side demo: http://localhost:3000/demo
import { RollikeyClient } from '@rollikey/sdk';
const sp = await RollikeyClient.connectStdio({ command: 'npx', args: ['-y', '@rollikey/mcp'] });
const run = sp.run(); // 1. one run = one undo unit
try { await myAgent(run); } catch { await run.revert(); } // 2-3. unchanged agent; crash → LIFO undo
Works with MCP clients, Anthropic / OpenAI / Gemini tool calls (anthropicTools, openAITools, geminiTools + run.call(name, args))
and LangGraph. Copy-paste snippets for each are in packages/sdk/README.md.
Docker is only needed for the backing services; the dashboard and MCP server run on a current Node (uses process.loadEnvFile).
Stop the stack with docker compose down (add -v to wipe data).
Packages
| Package | What |
|---|---|
packages/server (@rollikey/mcp) | Engine, migrations and seed, MCP server (stdio), airlock worker |
packages/sdk (@rollikey/sdk) | Typed client (RollikeyClient / RollikeyRun) that talks to the MCP server |
Local CLI & test drills
git clone https://github.com/rollikey/rollikey.git && cd rollikey
docker compose up -d
npm install
npm run db:seed # runs migrations, then seeds 5,000 customers (deterministic)
ROLLIKEY_AIRLOCK_SECONDS=3 npm run demo # end-to-end assertions
npx tsx packages/sdk/examples/quickstart.ts # SDK -> MCP stdio -> engine
- MCP server over stdio:
npm run dev. It runs the airlock worker in-process unlessROLLIKEY_RUN_AIRLOCK_WORKER=false. - Standalone airlock worker:
npm run worker.
MCP tools
rollikey_db_update, rollikey_db_delete, rollikey_stripe_refund, rollikey_stripe_authorize_hold, rollikey_stripe_capture_holds, rollikey_send_email, S3/GitHub/Slack tools, rollikey_revert, rollikey_get_run. When the gate blocks a call, the tool returns isError: true with status: "blocked" and the reason.
Current v0.1.3 limits
- Drift halts by default (Postgres, S3, GitHub). If a target changed after the agent touched it (a row's updated columns, a deleted row that reappeared, an S3 object rewritten or re-created, a patched issue/PR field),
revertstops that step before writing anything, marks itrevert_failed, lists the IDs/keys/numbers underdrifted, and keeps the newer edit. Callrevert(runId, { onDrift: 'overwrite' })(SDK:run.revert({ onDrift: 'overwrite' }), MCP:onDrift: "overwrite") to restore the snapshot anyway. Only the columns/fields the agent set are compared and restored. A deleted branch that reappears at a different SHA always halts (branch_drift). - Runs are fenced on revert. Once
revert(runId)starts, the run is recorded inrollikey_runs: new mutations, emails and Slack posts in that run fail withrun_fenced, and the airlock never releases its held messages. A fenced run fails fast instead of waiting on the run lock; a run whose lock is busy for more than 5s fails withrun_busy. A side effect that lands after the revert started keeps its provider receipt (Slackts, S3 ETag, Stripe ID) and is markedrevert_failed; it is never shown asapplied, and re-runningrevert(runId)undoes it. An operator can skip an acknowledgedrevert_failedstep withrevert(runId, { skipStepIds: [...] }); the step staysrevert_failedand is listed underskipped. Use a newrunIdfor new work. - Stripe refunds are compensated, not undone. Revert cancels a refund that is still cancellable. A refund that already
succeededis offset by an off-session re-charge of the same customer + payment method, and only if the original PaymentIntent has both. Each re-charge is claimed once inrollikey_compensation_attemptsand checked against Stripe (metadata.rollikey_reverses) first, so retries never charge twice. A refund that is neither cancellable norsucceeded, or an earlier attempt with no receipt at Stripe, halts withrevert_failedfor manual review. Live keys (sk_live_) are refused. - Airlock submission is at-most-once (email and Slack). Once a message is handed to SMTP/Slack it never goes back to
held, except after a definitive rejection. If the outcome is unknown, or the database update after a successful send fails, the message staysreleasing.revertreports it underinFlight(also included inalreadySent); a Slack post stuck there for over 5 minutes is reported asdelivery_unknown. Only Slack error codes that prove non-delivery (e.g.channel_not_found,invalid_auth,ratelimited) count as a rejection;internal_error/fatal_errorare treated as unknown. Sent email cannot be recalled, and neither can a Slack post already sent through an incoming webhook:revertrecords it aswebhook_already_sent, lists it underunrecallable, and keeps reverting the earlier steps. - Postgres accepts structured
where/setcalls, not raw SQL. Target tables must be standalone ordinary tables in thepublicschema (public."<table>"; partitioned tables, partitions andINHERITSparents or children are refused withunsupported_table_kind) withidas their single-column, non-generated primary key of a scalar type (smallint/integer/bigint,text/varchar/char, oruuid; identity columns are fine; other key types are refused withunsupported_primary_key). Tables with an enabled userAFTERorINSTEAD OFtrigger are refused (unsupported_trigger), since such a trigger can change rows a snapshot never records. Rows holding an array whose lower bound is not 1, a top-level JSONnullin ajson/jsonbcolumn, or ajsonobject with a duplicate key are refused (lossy_snapshot). A restore fails closed when a restored column changed type since the snapshot (schema_drift), when it would cascade into other rows (cascade_blocked), or when a trigger, coercion or deferred constraint stops the rows reading back as their Before State (restore_verification_failed; deferred constraints are checked before the read-back). Deletes are blocked when other tables reference the target withON DELETE CASCADE / SET NULL / SET DEFAULT, and updates are blocked when they change a column referenced withON UPDATE CASCADE / SET NULL / SET DEFAULT. Generated columns are never written (they are recomputed), andGENERATED ALWAYS AS IDENTITYkeys are restored with their original values. Rows with values JavaScript cannot represent exactly (BIGINT above 2^53, high-precision NUMERIC) are refused withunsafe_numeric. Tables starting withrollikey_are protected. - GitHub and S3 restores are not compare-and-set. GitHub's issue/PR PATCH and S3's unversioned PUT/COPY have no conditional write, so
revertchecks for drift right before it writes (the agent's own PATCH response and the S3 ETag + user metadata are the receipts), but an edit landing in the moment between that check and the write can still be overwritten. Enable S3 bucket versioning if you need a full history. S3 restores bring back the bytes, user metadata and standard headers (Content-Type,Cache-Control,Content-Disposition,Content-Encoding,Content-Language,Expires), butCopyObjectresets any per-object ACL to the bucket default. Bucket ACL restores fail closed when the prior ACL could not be read. - S3 is optional. Buckets are created on the first S3 action (or S3 restore), so a Postgres-only deployment without S3 still serves the dashboard and
revert. - Known gaps in v0.1.3. Deleting a GitHub branch makes GitHub auto-close its open pull requests;
revertrecreates the branch at its saved SHA but does not reopen them. S3 vaulting and restores use server-sideCopyObject, so objects over 5 GB are refused, objects in archive storage classes (Glacier / Deep Archive) cannot be copied, and restored objects use the bucket's default storage class. The optional MCP run caps (ROLLIKEY_MAX_RUN_DOLLARS/ROLLIKEY_MAX_RUN_ITEMS) count pre-flight estimates from each call's arguments; the strict per-call gates still decide every individual call. - Stripe compensation scope. A refund is undone by a standalone off-session re-charge, which Stripe only accepts at or above its currency minimum (e.g. $0.50 for USD), so a smaller refund halts for manual review; compensation is scoped to a single
runId(a hold's revert only refunds re-charges made for that run's own refunds). - In-flight S3 / GitHub writes hold the revert. A
pendingS3 or GitHub step with no receipt that is younger thanROLLIKEY_INFLIGHT_WINDOW_MS(default 60000, i.e. 60s) may still be on the wire, soreverthalts there within_flight(the step stayspending, earlier steps are untouched) instead of reverting underneath it; retry once it lands or the window passes. A partially completed GitHub batch whose failing request may still land (timeout, network error, 408/429/5xx) is held the same way; past the window only the items or branches that were actually sent are restored. A definitive 4xx rejection (not 408/429) marks the stepfailedinstead (or, after some items succeeded, letsrevertrestore those at once). Stripe steps are reconciled at Stripe through idempotency keys and metadata instead; a refund or hold not yet visible there halts within_flightfor a fixed 15 minutes (not this setting). - One tool call at a time per run. Steps of a
runIdare ordered byseqand reverted in reverse; issue an agent's tool calls for one run sequentially (each turn waits for the previous call to return), and use separaterunIds for work that runs in parallel. If a late write lands on a step after revert started, that step and every earlier reverted Postgres / S3 / GitHub step of the run are reopened (revert_failed), so re-runningrevert(runId)walks back to the very first Before State. - Postgres needs a direct connection. Revert holds a session-level advisory lock for the whole run. A transaction-mode pooler (e.g. PgBouncer
pool_mode=transaction) does not keep that lock, so pointDATABASE_URLat Postgres directly or use session pooling.
Visual Trace & Airlock Dashboard
npm run dashboard # http://localhost:3000 (needs `docker compose up -d`)
Live run/tool-call trace with Before-State snapshots, the 60-second staging airlock
(Release Early / Kill Switch), Shadow-State Replay, and a one-click Chaos Drill
(Gemini agent or a deterministic scripted agent). Binds to 127.0.0.1 by default. It refuses to start on
a non-loopback DASHBOARD_HOST unless DASHBOARD_ALLOWED_HOSTS or DASHBOARD_TOKEN is set. With
DASHBOARD_TOKEN, every /api/* call needs the token: open /?token=… once (it moves into an HttpOnly cookie)
or send Authorization: Bearer ….
Hosted Cloud & Design-Partner Pilot
Skip self-hosting Postgres, Redis, and the airlock worker. We deploy, secure, and manage a dedicated Rollikey instance wired to your stack—complete with private auth, custom blast-radius limits, connector allow-lists, and airlock hold windows.
Design-Partner Pilots ($1,000/mo): Turnkey hosted airlock and custom guardrails for startup teams shipping agents in production. Apply for a Hosted Pilot →
Self-Hosting on Railway (Internal Use)
To self-host @rollikey/mcp internally using the included Dockerfile and railway.json:
- Create a Railway project from this repo and add the Postgres and Redis plugins.
- Set
DATABASE_URL,REDIS_URL,DASHBOARD_ALLOWED_HOSTS=<your-app>.up.railway.app, and (optional)ROLLIKEY_PILOT_URL. The container binds0.0.0.0and reads Railway'sPORT. - Run
npm run db:migrate -w @rollikey/mcponce in the Railway shell (we recommend starting with Stripe Test Mode keys while validating rules).
Security note: The open-core dashboard has no user accounts. Set DASHBOARD_TOKEN (a shared secret for the API) and keep self-hosted deployments behind Railway private networking or an auth proxy before exposing them publicly.
Optional MCP guards (all off by default): ROLLIKEY_PINNED_RUN_ID forces every call into one run, ROLLIKEY_HIDE_OPERATOR_TOOLS=true hides rollikey_revert / rollikey_stripe_capture_holds from the agent, and ROLLIKEY_MAX_RUN_DOLLARS / ROLLIKEY_MAX_RUN_ITEMS cap cumulative money / items per run.
Licensing (open core)
| Path | License |
|---|---|
packages/sdk | MIT |
packages/server | FSL-1.1-MIT (converts to MIT after two years) |
ee/ | Proprietary, all rights reserved (private, never published to npm) |
Connectors
All five connectors are gated, snapshotted and revertable (strict LIFO) with $0 local sandboxes:
| Connector | Sandbox | Snapshot | Gate |
|---|---|---|---|
| PostgreSQL | docker postgres | rows as JSON | >10 rows / >$1,000 |
| Stripe | test mode | charge + PI | >$1,000 |
| AWS S3 | docker minio (rollikey-minio) | bytes + metadata copied to a recovery-vault bucket | >10 object deletes, public ACLs |
| GitHub | built-in offline REST sandbox (:4010); real API when GITHUB_TOKEN is set | issue/PR fields, branch head SHAs | >10 items, protected branches |
| Slack / Email | local Slack sink + docker mailpit (:8025); live SMTP & SLACK_BOT_TOKEN/SLACK_WEBHOOK_URL when set | message + airlock row | outbound email & @channel/external/webhook airlocked 60s; >10 msgs, archiving blocked |
npm test # connector integration tests (requires docker compose up -d)
npm run drill:5tool # headless 5-tool chaos drill (or use the dashboard button)
Side-by-side disaster demo
Run npm run dashboard locally, then open http://localhost:3000/demo in your browser and press Run Side-by-Side Comparison (about 45 s).
The same rogue agent runs twice against disposable sandboxes (demo_* tables, demo/ S3 prefixes, an in-memory Stripe; nothing real is touched):
| Unprotected | Protected by Rollikey | |
|---|---|---|
| Step 1: wipe 200 balances | all 200 overwritten | blocked by the gate, retry of 10 is snapshotted |
| Step 2: $249 charge + duplicate $500 refunds | captured, $1,000 out | auth-hold only, refunds snapshotted |
| Step 3: delete 25 invoices, email a stranger | deleted, email delivered | blocked, retry vaulted, email held in the airlock |
| Step 4: crash | permanent damage | revert(runId) in well under a second, 100% restored |
Non-custodial Stripe auth-hold and optional fee
rollikey_stripe_authorize_holdcreates a PaymentIntent withcapture_method: 'manual': funds are authorized, not moved. Callrollikey_stripe_capture_holdsonce the multi-step run verifies cleanly.revert(runId)cancels uncaptured holds withpaymentIntents.cancel(a captured hold is refunded instead). Rollikey never holds customer money.ROLLIKEY_CONNECT_FEE_BPS(default0) sets a Stripe Connectapplication_fee_amounton captured holds only. Allowed values:0, or25to50(0.25%-0.50%); it requiresROLLIKEY_CONNECT_ACCOUNT(hosted Connect mode). Self-hosted installs leave it at 0. Database, S3, GitHub and Slack/Email rollbacks are always free.- Live Stripe test-mode check:
npm run check:stripe-hold -w @rollikey/mcp.