EventSourcingDB

EventSourcingDB is a cursor rule for Cursor from StratoKit/strato-db. It costs 1,070 tokens per session, scanned A, original, MIT.

Database modules that use event sourcing, a design where changes are stored as events and used to build the current data state. They process events in order and apply the resulting changes in database transactions.

In plain words
What is it for?
It is for processing events, updating JSON-style models, and deriving follow-up work in a database-backed application.
Why use it?
It provides a structured way to keep an ordered history of changes while updating stored data consistently.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/stratokit/strato-db/eventsourcingdb
Clone the repo
git clone --depth 1 https://github.com/StratoKit/strato-db

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for EventSourcingDB

README.md
[![agentmods](https://agentmods.dev/badge/rules/stratokit/strato-db/eventsourcingdb.svg)](https://agentmods.dev/rules/stratokit/strato-db/eventsourcingdb)
Your own site
<a href="https://agentmods.dev/rules/stratokit/strato-db/eventsourcingdb"><img src="https://agentmods.dev/badge/rules/stratokit/strato-db/eventsourcingdb.svg" alt="Measured on agentmods" height="20"></a>
Per session 1,070 This file is loaded in full into every session.
When invoked 1,070 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.01070 $0.01070
Opus 5 $0.00535 $0.00535
Sonnet 5 $0.00214 $0.00214
Haiku 4.5 $0.00107 $0.00107

Measured yesterday against content hash e1a4ec03e4ca, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

EventSourcingDB scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/EventSourcingDB.mdc · 63 lines

How it starts

The opening of the file, as written. The whole thing — 63 lines — stays where its author put it; the contents beside it link to each section on GitHub.

EventSourcingDB & ESModel Modules (src/EventSourcingDB)

These modules implement the core event sourcing pattern for the database.

Core Components

EventSourcingDB.js (EventSourcingDB class)

  • Purpose: Orchestrates the event sourcing process. It manages the flow of events from the EventQueue to the ESModel instances, ensuring atomic and ordered processing.
  • Key Features:
    • Event Loop: Polls or waits for new events from the EventQueue.
    • Event Processing Pipeline: For each event:
      1. Preprocessing: Calls preprocessor static methods on all registered ESModels. ESModel.preprocessor assigns IDs to new objects.
      2. Reduction: Calls reducer static methods on all ESModels. ESModel.reducer calculates the necessary change (ins, upd, rm, esFail) based on the event type and current state.
      3. Application: Within a database transaction:
        • Calls applyResult (via model.applyResult(result) which calls the imported applyResult) on each model with its calculated result, making the actual database changes using the underlying JsonModel methods (in writable mode).
        • Calls deriver methods on models for post-processing (also in writable mode).
      4. Commit: Commits the transaction and updates the database user_version.
    • Sub-events: Handles events dispatched during the processing of another event, processing them recursively within the same transaction.
    • Error Handling: Logs errors and halts processing if a reducer or applicator fails. Stores error information in the event's result field in the EventQueue.
    • State Management: Manages database connections (potentially separate R/W and RO), tracks the current processed version, and uses AsyncLocalStorage for context.
    • Lifecycle Events: Emits events ('begin', 'result', 'error', 'processed') for monitoring.
  • Dependencies: DB, EventQueue, ESModel, debug, lodash, AsyncLocalStorage.

Read the full file on GitHub · 63 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 63 lines · 1,070 tokens per session scan A e1a4ec03e4ca

Subscribe to this mod's changes

EventSourcingDB is a cursor rule published in the GitHub repository StratoKit/strato-db (14 stars, last pushed 6mo ago), licensed MIT. It adds 1,070 tokens to every session, about $0.0053 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-04.