data-consistency-modeling
Skill0 starsChanged 6 months agoMITView on GitHub
Models consistency, isolation, and integrity guarantees across transactions, replicas, and services. Use when choosing isolation levels, designing cross-service data flows, debugging anomalies like lost updates or dirty reads, or deciding between strong and eventual consistency.
In this repository29 other files it gives its agents.
- adversarial-code-reviewSkill
- api-contract-designSkill
- attack-surface-mappingSkill
- authn-authz-design-reviewSkill
- benchmark-designSkill
- capacity-scalability-planningSkill
- concurrency-race-analysisSkill
- data-exfiltration-analysisSkill
- distributed-consensus-designSkill
- error-handling-architectureSkill
- event-driven-architectureSkill
- experiment-designSkill
- hypothesis-falsificationSkill
- incident-rca-postmortemSkill
- legacy-refactoring-strategySkill
- literature-synthesisSkill
- metrics-designSkill
- multi-layer-caching-strategySkill
- mvp-scope-cuttingSkill
- performance-profilingSkill
- rate-limiting-designSkill
- requirements-disambiguationSkill
- secrets-management-auditSkill
- statistical-validity-analysisSkill
- supply-chain-risk-analysisSkill
- system-decomposition-synthesisSkill
- threat-modelingSkill
- tradeoff-decision-frameworkSkill
- user-failure-mode-mappingSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 3 are distinctive, and 0 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.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Dirty read: read uncommitted data. Forbidden at Read Committed+.
- Distinctive: line 25
Use the outbox pattern to make "update DB + publish event" atomic via the local transaction, then relay.
- Distinctive: line 26
Use sagas for multi-service workflows: each step has a compensating action.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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.
Files
Data Consistency Modeling
Consistency is a spectrum of anomalies you choose to permit, not a binary. Name the specific anomalies your system can tolerate; "we use transactions" is not a guarantee.
Reason in anomalies, not labels
Isolation levels are defined by which anomalies they forbid:
- Dirty read: read uncommitted data. Forbidden at Read Committed+.
- Non-repeatable read: same row, two values within one transaction. Forbidden at Repeatable Read+.
- Phantom: a range query returns different rows on re-read. Forbidden at Serializable.
- Lost update: two read-modify-writes, one overwrites the other. Not prevented by Read Committed — a common production bug. Needs RR, SELECT FOR UPDATE, or compare-and-swap.
- Write skew: two transactions each read a shared invariant, both write, jointly violating it. Only Serializable (or explicit locking) prevents it — Snapshot Isolation does not.
Most databases default to Read Committed or Snapshot Isolation, neither of which is serializable. Know your default; it permits lost updates and write skew silently.
Cross-service consistency (no shared transaction)
- There is no distributed transaction across HTTP/queue boundaries that is both available and atomic — 2PC blocks.
- Use the outbox pattern to make "update DB + publish event" atomic via the local transaction, then relay.
- Use sagas for multi-service workflows: each step has a compensating action; the system is eventually consistent, never atomic. Design compensations for every step, including the non-idempotent ones.
- Idempotency keys are mandatory because retries are guaranteed.
Adversarial validation
- Construct the interleaving for lost update and write skew on your actual schema. Does your isolation level forbid it, or are you relying on luck/low concurrency?
- Replica lag: a user writes then immediately reads from a replica. Do they see their own write? (Read-your-writes often needs sticky routing or read-from-primary.)
- A saga step fails after earlier steps committed. Does compensation fully reverse the effect, including events others already consumed?
- Duplicate message delivery: does processing it twice change state twice?
Non-obvious risks
- "Eventually consistent" without a bound is "possibly never consistent" under sustained load or stuck replication.
- Foreign-key-style invariants across services have no enforcer — they degrade to "hopefully consistent".
- Aggregates computed from eventually-consistent reads drift; reconciliation jobs are not optional.
Output structure
Deliver: the invariants that must hold, the specific anomalies tolerated vs forbidden, the isolation level / coordination mechanism that enforces them (with the lost-update and write-skew check done explicitly), the cross-service consistency mechanism (outbox/saga + compensations), and the reconciliation strategy for residual drift.
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
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.

