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 Rollikey

Hosted Pilot npm: @rollikey/sdk npm: @rollikey/mcp CI CodeQL Glama MCP Score

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

PackageWhat
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 unless ROLLIKEY_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), revert stops that step before writing anything, marks it revert_failed, lists the IDs/keys/numbers under drifted, and keeps the newer edit. Call revert(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 in rollikey_runs: new mutations, emails and Slack posts in that run fail with run_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 with run_busy. A side effect that lands after the revert started keeps its provider receipt (Slack ts, S3 ETag, Stripe ID) and is marked revert_failed; it is never shown as applied, and re-running revert(runId) undoes it. An operator can skip an acknowledged revert_failed step with revert(runId, { skipStepIds: [...] }); the step stays revert_failed and is listed under skipped. Use a new runId for new work.
  • Stripe refunds are compensated, not undone. Revert cancels a refund that is still cancellable. A refund that already succeeded is 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 in rollikey_compensation_attempts and checked against Stripe (metadata.rollikey_reverses) first, so retries never charge twice. A refund that is neither cancellable nor succeeded, or an earlier attempt with no receipt at Stripe, halts with revert_failed for 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 stays releasing. revert reports it under inFlight (also included in alreadySent); a Slack post stuck there for over 5 minutes is reported as delivery_unknown. Only Slack error codes that prove non-delivery (e.g. channel_not_found, invalid_auth, ratelimited) count as a rejection; internal_error / fatal_error are treated as unknown. Sent email cannot be recalled, and neither can a Slack post already sent through an incoming webhook: revert records it as webhook_already_sent, lists it under unrecallable, and keeps reverting the earlier steps.
  • Postgres accepts structured where/set calls, not raw SQL. Target tables must be standalone ordinary tables in the public schema (public."<table>"; partitioned tables, partitions and INHERITS parents or children are refused with unsupported_table_kind) with id as their single-column, non-generated primary key of a scalar type (smallint / integer / bigint, text / varchar / char, or uuid; identity columns are fine; other key types are refused with unsupported_primary_key). Tables with an enabled user AFTER or INSTEAD OF trigger 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 JSON null in a json / jsonb column, or a json object 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 with ON DELETE CASCADE / SET NULL / SET DEFAULT, and updates are blocked when they change a column referenced with ON UPDATE CASCADE / SET NULL / SET DEFAULT. Generated columns are never written (they are recomputed), and GENERATED ALWAYS AS IDENTITY keys are restored with their original values. Rows with values JavaScript cannot represent exactly (BIGINT above 2^53, high-precision NUMERIC) are refused with unsafe_numeric. Tables starting with rollikey_ 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 revert checks 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), but CopyObject resets 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; revert recreates the branch at its saved SHA but does not reopen them. S3 vaulting and restores use server-side CopyObject, 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 pending S3 or GitHub step with no receipt that is younger than ROLLIKEY_INFLIGHT_WINDOW_MS (default 60000, i.e. 60s) may still be on the wire, so revert halts there with in_flight (the step stays pending, 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 step failed instead (or, after some items succeeded, lets revert restore those at once). Stripe steps are reconciled at Stripe through idempotency keys and metadata instead; a refund or hold not yet visible there halts with in_flight for a fixed 15 minutes (not this setting).
  • One tool call at a time per run. Steps of a runId are ordered by seq and reverted in reverse; issue an agent's tool calls for one run sequentially (each turn waits for the previous call to return), and use separate runIds 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-running revert(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 point DATABASE_URL at 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:

  1. Create a Railway project from this repo and add the Postgres and Redis plugins.
  2. Set DATABASE_URL, REDIS_URL, DASHBOARD_ALLOWED_HOSTS=<your-app>.up.railway.app, and (optional) ROLLIKEY_PILOT_URL. The container binds 0.0.0.0 and reads Railway's PORT.
  3. Run npm run db:migrate -w @rollikey/mcp once 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)

PathLicense
packages/sdkMIT
packages/serverFSL-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:

ConnectorSandboxSnapshotGate
PostgreSQLdocker postgresrows as JSON>10 rows / >$1,000
Stripetest modecharge + PI>$1,000
AWS S3docker minio (rollikey-minio)bytes + metadata copied to a recovery-vault bucket>10 object deletes, public ACLs
GitHubbuilt-in offline REST sandbox (:4010); real API when GITHUB_TOKEN is setissue/PR fields, branch head SHAs>10 items, protected branches
Slack / Emaillocal Slack sink + docker mailpit (:8025); live SMTP & SLACK_BOT_TOKEN/SLACK_WEBHOOK_URL when setmessage + airlock rowoutbound 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):

UnprotectedProtected by Rollikey
Step 1: wipe 200 balancesall 200 overwrittenblocked by the gate, retry of 10 is snapshotted
Step 2: $249 charge + duplicate $500 refundscaptured, $1,000 outauth-hold only, refunds snapshotted
Step 3: delete 25 invoices, email a strangerdeleted, email deliveredblocked, retry vaulted, email held in the airlock
Step 4: crashpermanent damagerevert(runId) in well under a second, 100% restored

Non-custodial Stripe auth-hold and optional fee

  • rollikey_stripe_authorize_hold creates a PaymentIntent with capture_method: 'manual': funds are authorized, not moved. Call rollikey_stripe_capture_holds once the multi-step run verifies cleanly. revert(runId) cancels uncaptured holds with paymentIntents.cancel (a captured hold is refunded instead). Rollikey never holds customer money.
  • ROLLIKEY_CONNECT_FEE_BPS (default 0) sets a Stripe Connect application_fee_amount on captured holds only. Allowed values: 0, or 25 to 50 (0.25%-0.50%); it requires ROLLIKEY_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.