agentleFS
terrene-foundationterrene-foundation/pact/.claude/skills/15-enterprise-infrastructure/SKILL.md

enterprise-infrastructure

Skill0 starsChanged 8 months agoApache-2.0View on GitHub

Enterprise infrastructure patterns including progressive infrastructure model, dialect-portable SQL, store factory, task queues, worker management, and idempotency. Use when asking about 'database portability', 'store factory', 'task queue', 'KAILASH_DATABASE_URL', 'idempotency', 'worker registry', 'SKIP LOCKED', 'Level 0/1/2', 'ConnectionManager', or 'QueryDialect'.

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use ? canonical placeholders in all SQL -- ConnectionManager translates automatically

    line 77
  2. Very specific:

    Use dialect.upsert() instead of check-then-act (TOCTOU race)

    line 79
  3. Very specific:

    Use async with conn.transaction() as tx: for multi-statement operations

    line 80
  4. Distinctive:

    Use this skill when you need to:

    line 88
  5. Distinctive:

    Write dialect-portable SQL that works across PostgreSQL, MySQL, and SQLite

    line 91
  6. Distinctive:

    Add idempotency guarantees to workflow execution

    line 94

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Enterprise Infrastructure - Skills

Comprehensive guide to Kailash's progressive infrastructure model for scaling from single-process SQLite to multi-worker PostgreSQL/MySQL deployments.

Features

The enterprise infrastructure layer provides:

  • Progressive Infrastructure Model: Level 0 (SQLite, in-process) to Level 2 (multi-worker, shared database + queue)
  • QueryDialect Strategy Pattern: Dialect-portable SQL across PostgreSQL, MySQL 8.0+, and SQLite
  • ConnectionManager: Async connection pooling with dialect-aware placeholder translation
  • StoreFactory: Singleton factory for creating store backends from KAILASH_DATABASE_URL
  • SQL Task Queue: Database-backed task queue using FOR UPDATE SKIP LOCKED
  • Worker Registry: Heartbeat monitoring and dead worker reaping
  • IdempotentExecutor: Exactly-once workflow execution via claim-execute-store pattern
  • Schema Versioning: kailash_meta table with downgrade protection

Quick Start

# Level 0: Zero config (default)
from kailash.runtime import LocalRuntime
runtime = LocalRuntime()  # SQLite stores, in-process

# Level 1: Set KAILASH_DATABASE_URL=postgresql://user:pass@localhost/kailash
# Auto-detects PG, all stores use shared ConnectionManager

# Level 2: Set KAILASH_QUEUE_URL=redis://localhost:6379/0
# OR KAILASH_QUEUE_URL=postgresql://user:pass@localhost/kailash

The user's workflow code is identical at all levels.

Reference Documentation

Core Patterns

  • progressive-infrastructure - Level 0/1/2 model, StoreFactory, env vars, schema versioning
  • dialect-portable-sql - QueryDialect strategy, ? placeholders, _validate_identifier()
  • connection-manager-patterns - ConnectionManager lifecycle, transactions, driver behavior

Operations

  • task-queue-patterns - SQL task queue, SKIP LOCKED, Redis vs SQL, worker registry
  • idempotency-patterns - IdempotentExecutor, claim-execute-store, TTL expiry

Key Concepts

Progressive Levels

LevelConfigRuntimePersistence
0NoneIn-process, LocalRuntimeSQLite + in-memory
1KAILASH_DATABASE_URLIn-process, shared DBPostgreSQL/MySQL/SQLite
2KAILASH_QUEUE_URLMulti-worker + task queueShared DB + Redis or SQL queue

Environment Variables

VariablePurposeDefault
KAILASH_DATABASE_URLInfrastructure storesNone (Level 0)
DATABASE_URLFallback for KAILASH_DATABASE_URLNone
KAILASH_QUEUE_URLTask queue brokerNone (no queue)

Source Code Layout

PackagePurpose

Critical Rules

  • Use ? canonical placeholders in all SQL -- ConnectionManager translates automatically
  • Validate all SQL identifiers with _validate_identifier() before interpolation
  • Use dialect.upsert() instead of check-then-act (TOCTOU race)
  • Use async with conn.transaction() as tx: for multi-statement operations
  • Bound in-memory stores: OrderedDict with LRU eviction, max 10,000 entries
  • Lazy imports for database drivers (aiosqlite, asyncpg, aiomysql)
  • No AUTOINCREMENT in shared DDL (SQLite-specific)
  • Share a single ConnectionManager via StoreFactory (never create separate instances per store)

When to Use This Skill

Use this skill when you need to:

  • Scale from Level 0 (SQLite) to Level 1 (PostgreSQL) or Level 2 (multi-worker)
  • Write dialect-portable SQL that works across PostgreSQL, MySQL, and SQLite
  • Set up the StoreFactory for infrastructure store backends
  • Implement task queue processing with SQL or Redis
  • Add idempotency guarantees to workflow execution
  • Manage worker registration and heartbeat monitoring
  • Understand schema versioning and migration patterns

Related Skills

  • 01-core-sdk - Core SDK workflow patterns (infrastructure backs execution)
  • 02-dataflow - DataFlow for user data (infrastructure for runtime stores)
  • 03-nexus - Multi-channel platform deployment
  • 07-development-guides - Testing and development patterns

Support

For complex infrastructure questions, invoke:

  • infrastructure-specialist - Progressive infrastructure, dialect portability, store factory
  • testing-specialist - Infrastructure testing with real databases
  • security-reviewer - SQL injection prevention, transaction safety

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.