Architecture
~9 min readUpdated: December 2026

EnterpriseSim: PostgreSQL Multi-Hazard Gym for Transactional Agents

EnterpriseSim PostgreSQL Multi-Hazard Gym and Pre-SQL Commit Gate Architecture

EnterpriseSim (arXiv:2612.01881) is an open-source PostgreSQL gym of 83 tasks (53 multi-hazard) across six enterprise departments. Across 3,619 episodes, unguided 55-tool consoles and live background contention drop frontier models by 10–30 percentage points, while a pre-PostgreSQL commit gate blocks all single-agent unsafe writes at 0% false blocking and <10 ms p99 latency.

Technical Review: Smoke Monkey Core Architecture Team
Tested on Node.js 18+ & BunTypeScript 5.x
Quick Answer & Executive Definition

EnterpriseSim: PostgreSQL Multi-Hazard Gym for Transactional Agents: EnterpriseSim (arXiv:2612.01881) is an open-source PostgreSQL gym of 83 tasks (53 multi-hazard) across six enterprise departments. Across 3,619 episodes, unguided 55-tool consoles and live background contention drop frontier models by 10–30 percentage points, while a pre-PostgreSQL commit gate blocks all single-agent unsafe writes at 0% false blocking and <10 ms p99 latency. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.

Key Architectural Takeaways
Quick Implementation Exampleenterprisesim-commit-gate-agent.ts
enterprisesim-commit-gate-agent.tstypescript
import { createAgent } from '@smoke-monkey/harness';
// Transactional enterprise agent wrapped with deterministic pre-SQL commit gate checks
const agent = createAgent({
agentId: 'enterprisesim-oltp-guard',
provider: 'anthropic',
model: 'claude-sonnet-4-5',
workspacePath: process.cwd(),
permissions: {
read_file: 'allow',
write_file: 'allow',
run_command: 'ask',
},
});
interface RefundInvariantInput {
paymentSettledCents: number;
priorRefundsCents: number;
requestedRefundCents: number;
rowVersionExpected: number;
rowVersionActual: number;
}
function preCommitInvariantGate(tx: RefundInvariantInput): { allowed: boolean; reason: string } {
if (tx.rowVersionExpected !== tx.rowVersionActual) {
return { allowed: false, reason: '409_VERSION_CONFLICT: concurrent worker updated row' };
}
if (tx.priorRefundsCents + tx.requestedRefundCents > tx.paymentSettledCents) {
return { allowed: false, reason: 'INV-FIN-001_VIOLATION: refund exceeds settled payment' };
}
return { allowed: true, reason: 'OK' };
}
async function main() {
const verdict = preCommitInvariantGate({
paymentSettledCents: 12000,
priorRefundsCents: 12000,
requestedRefundCents: 12000,
rowVersionExpected: 3,
rowVersionActual: 3,
});
const res = await agent.run(
`HTTP 504 occurred during refund tool call. Commit gate returned ${JSON.stringify(verdict)}. Reconcile idempotency key safely.`
);
console.log(res.summary);
}
main().catch(console.error);
Video Guides

Watch: Related Video Guides

AI Agent Evaluation Explained: Metrics, Trajectories & Reliability

AI Agent Evaluation Metrics: What It Says vs What It Does?

Why Single-Actor Benchmarks Miss Production Enterprise Agent Failures

EnterpriseSim (arXiv:2612.01881) is an open-source PostgreSQL-based evaluation gym containing 83 tasks—30 single-incident and 53 multi-hazard tasks spanning six departments—designed to test write-capable AI agents under real database contention. Unlike function-calling suites that grade final chat messages with an LLM judge, EnterpriseSim grades exact SQL table invariants after deterministic replay.

Across 3,619 evaluation episodes, the authors show that passing a ticket in a single-actor sandbox hides severe database corruption risks: agents duplicate refunds after ambiguous HTTP 504 timeouts, overwrite concurrent security patches (0/7 models passed task CF03 unguarded), and lose 10 to 30 percentage points when moved to vague inbox alerts and 55-tool consoles.

Model (53 Multi-Hazard Tasks, B1-Concise)Strict Safe PassCore-18Held-Out + Res. (25)Avg CallsAvg TokensLatency
Gemini 4 Argon98.1% (52/53)94.4%96.0%21.7129.1k70.8 s
Gemini 4 Carbon92.5% (49/53)94.4%88.0%26.4163.1k99.9 s
Gemini 3.8 Flash88.7% (47/53)88.9%92.0%18.4156.4k49.4 s
Claude Sonnet 5.583.0% (44/53)88.9%76.0%19.7239.6k70.6 s
Qwen 3.8 27B (Local Ollama)79.2% (42/53)83.3%76.0%21.1102.1k190.6 s
GPT-6.2 Sol66.0% (35/53)61.1%64.0%24.2152.7k106.2 s
GPT-6 Luna47.2% (25/53)38.9%36.0%23.9148.4k60.7 s

Declarative PostgreSQL Invariants and Sub-10ms Pre-SQL Commit Gates

Every EnterpriseSim episode checks domain-specific declarative SQL invariants that cannot be bypassed by polite natural-language summaries:

  1. Financial & Double-Entry Rules (`INV-FIN-001..003`): Total settled refunds cannot exceed settled payment amounts or role caps, voided invoices require zero balance, and general-ledger debits must equal credits.
  2. Inventory Conservation (`INV-INV-001..002`): On-hand, reserved, allocated, and available stock remain non-negative and conserved within warehouse capacity across concurrent worker updates.
  3. Why Prompt Safety Fails vs Commit Gates: Long safety prompts push agents into repetitive read loops, whereas a deterministic commit gate placed immediately in front of PostgreSQL catches 100% of observed single-agent unsafe writes at <10 ms p99 with 0% false blocking (while multi-writer budget caps still require row-level SELECT ... FOR UPDATE database locks).

Do Not Rely on Prompt Instructions Alone for Concurrency Safety

Even Gemini 4 Argon (98.1% overall) failed concurrent security-patch race CF03 unguarded. Pair agent harnesses with optimistic row versions and pre-SQL invariant gates.

Verifying Agent Writes With PostgreSQL Check Constraints & Advisory Locks

You can mirror EnterpriseSim's invariant pattern in any production PostgreSQL database backing an AI agent tool layer by combining optimistic version checks with double-entry ledger assertions.

bash
# Run deterministic PostgreSQL invariant verification against an agent staging schema
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -c "
  SELECT 'INV-FIN-003_GL_IMBALANCE' AS violation, COUNT(*)
  FROM gl_entries
  HAVING COALESCE(SUM(debit_cents), 0) <> COALESCE(SUM(credit_cents), 0);
"
Google Search Questions & Answers

Frequently Asked Questions

Q:How does EnterpriseSim grade agents without using LLM judges?

EnterpriseSim executes deterministic PostgreSQL invariant queries against the database state after every episode, checking exact conservation rules for inventory, refunds, double-entry general ledger balances, and access controls.

Q:Why do agent scores drop 10–30 percentage points in unguided EnterpriseSim runs?

Unguided runs replace explicit instructions with vague inbox alerts, expand the tool surface to 55 tools, add distraction tickets, and activate four background worker bots mutating shared rows.

Q:Does a pre-SQL commit gate replace PostgreSQL row locks for parallel agents?

No. EnterpriseSim shows that a <10 ms p99 commit gate stops all observed single-agent unsafe writes with 0% false blocking, but parallel multi-writer budget caps still require database-level locks.

Q:How did local Qwen 3.8 27B perform compared to cloud models on EnterpriseSim?

Running locally via Ollama, Qwen 3.8 27B achieved 79.2% strict safe pass (42/53 tasks), outperforming GPT-6.2 Sol (66.0%) and GPT-6 Luna (47.2%) while using fewer tokens (102.1k average).

Related Alternatives & Comparisons

Related Architecture Guides

View all guides

Build with Smoke Monkey Harness

Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.

npm install smoke-monkey-harness