MantisDocs

Write guardrails

Hold unfiltered or bulk updates and deletes on main until a person approves them.

Schema guardrails stop an agent from dropping a table or column on main. Write guardrails stop an agent (or a buggy server script) from wiping or rewriting rows in place on main — like an accidental delete({ where: {} }) or a bulk update that hits thousands of rows.

Default protection

Guardrails are on by default for every update and delete on main sent with a secret, agent, or branch_only key:

SettingDefaultWhat it holds on main
blockUnfilteredDeletetrueAny delete with an empty where: {}
blockUnfilteredUpdatetrueAny update with an empty where: {}
maxRowsPerWrite100Any update or delete that would affect more than this many rows

On non-main branches, write guardrails never hold — your agent can wipe, seed, and rewrite branch data freely. Browser requests with a publishable key are already constrained by access rules, and actions started directly by a human in the dashboard are not held.

Configure in your schema

Tune the thresholds per project in mantis/schema.ts:

mantis/schema.ts
import { defineSchema, t, table } from "@shipmantis/sdk";

export default defineSchema(
  {
    orders: table({
      status: t.text(),
      totalCents: t.integer(),
    }),
  },
  {
    guardrails: {
      maxRowsPerWrite: 50,
      blockUnfilteredDelete: true,
      blockUnfilteredUpdate: true,
    },
  },
);

Push the change with npx shipmantis push so the updated limits take effect on main.

What happens when a write is held

Before executing a guarded update or delete on main, Mantis counts the matching rows inside the transaction. If a guardrail trips:

  1. Zero rows are modified. The write is rolled back before touching your data.
  2. A held change (kind: "write") is created with the table name, operation, exact affected row count, and reason.
  3. The runtime responds with HTTP 202 and the held change payload instead of returning rows.

In @shipmantis/sdk, a held write throws MantisHeldError (a subclass of MantisError):

import { MantisHeldError } from "@shipmantis/sdk";

try {
  await mantis.from("orders").delete({ where: { status: "expired" } });
} catch (error) {
  if (error instanceof MantisHeldError) {
    console.log("Waiting for approval:", error.change.id);
    console.log("Affected rows:", error.change.writeOp?.affectedRows);
  } else {
    throw error;
  }
}

Approving or rejecting

Open the project's History page in the dashboard to inspect the held write: it shows the operation (update or delete), the target table, whether the filter was empty, and how many rows will be touched.

  • Approve executes the stored query once on main (and still records the writes so they remain rewindable).
  • Reject discards the request without touching any rows.

Your agent can check whether a held write was approved or rejected using the check_change MCP tool.

On this page