distributed-consensus-and-concurrency-gate
Skill4 starsChanged 31 days agoMITView on GitHub
Review concurrent writes, optimistic concurrency, idempotent delivery, distributed leases, leader election, clock assumptions, and database transaction boundaries. Use when a stale reader, duplicate request, partition, or paused worker could violate a data invariant.
In this repository47 other files it gives its agents.
- AGENTS.mdAGENTS.md
- anti-slop-engineeringSkill
- anti-slop-engineeringSkill
- api-ergonomics-and-contract-governorSkill
- apple-craft-and-frame-budgetSkill
- apple-craft-and-interaction-physicsSkill
- asset-provenance-guardSkill
- backprop-guardSkill
- chaos-and-degradation-choreographerSkill
- chromatic-drift-guardSkill
- cognitive-load-and-attention-governorSkill
- comment-budget-guardSkill
- context-window-and-token-economics-architectSkill
- cryptographic-agility-and-secret-lifecycle-gateSkill
- decision-guardSkill
- demock-guardSkill
- design-system-drift-guardSkill
- deterministic-simulation-and-property-testingSkill
- finops-and-unit-economics-governorSkill
- future-scale-gateSkill
- grumpy-senior-staff-engineerSkill
- honeypot-trap-guardSkill
- house-tell-guardSkill
- install-anti-slopSkill
- llm-eval-and-prompt-injection-fortressSkill
- mandela-guardSkill
- mechanical-sympathy-and-perf-gateSkill
- mechanical-sympathy-profilerSkill
- motion-runtime-guardSkill
- observability-and-slo-architectSkill
- observability-and-slo-gateSkill
- paranoid-principal-architectSkill
- pr-boundary-guardSkill
- privacy-and-data-lineage-gateSkill
- re0-handoff-guardSkill
- reduction-guardSkill
- repo-memory-and-invariant-stewardSkill
- root-fix-gateSkill
- safe-evolution-and-rollout-choreographerSkill
- scientific-fault-isolationSkill
- styleseed-guardSkill
- supply-chain-and-sbom-sentinelSkill
- tagore-guardSkill
- type-level-and-ast-slop-gateSkill
- ui-and-copy-disciplineSkill
- verification-oracle-architectSkill
- zero-downtime-migration-gateSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
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 15
Follow every writer through its check, mutation, commit, and acknowledgment.
≈ “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.
Files
Distributed Consensus and Concurrency Gate
Review
- State the invariant, who may change it, the authoritative store, and when callers see success. Example: one inventory unit admits one committed reservation even if two callers read the same initial stock.
- Follow every writer through its check, mutation, commit, and acknowledgment. Record the isolation level and unique constraints, or the compare-and-write condition and affected-row handling. Include jobs and retries that enter through a different route.
- Replay one interleaving where both writers observe the same state. Add error schedules for a crash after commit before acknowledgment, a stale holder resuming after handover, and a partition during election when each applies.
- Record the file or query, schedule, asserted result, and exact test command for each claim. Mark checks against a model as such. Use real sessions on the deployed database engine and the affected isolation level to verify storage behavior.
Select controls by invariant
| Case | Evidence to require |
| Check-then-act or lost update | Protect the check and write in the authoritative store. Use atomic conditional updates or version compare-and-swap for a row invariant. For predicate or multi-row invariants, demonstrate a database constraint, appropriate locking, or serializable isolation with a bounded retry of the complete transaction. A lock on existing rows may leave a concurrent insert unprotected. |
| Optimistic concurrency | The update predicates on the previously observed revision and increments it atomically. Distinguish a zero-row conflict from success. Retry only safe operations after rereading, within a request deadline and attempt budget. |
| Duplicate delivery or lost acknowledgment | Bind the deduplication key to tenant, operation, and payload. A repeated key with identical input returns the original result, and conflicting input is rejected. Commit the dedupe record with the local effect, or use an outbox and verify downstream idempotency for external effects. Retain keys through the supported retry window. |
| Lease protects an external writer | Identify who grants ownership and which sink rejects stale epochs atomically with writes. Verify fencing at the sink with a durable high-water mark or authoritative epoch. A lease timeout makes failover possible. It cannot revoke a paused worker's already issued request. |
| Consensus or leader change | Identify the actual protocol, membership, quorum, allowed failures, and conditions for a committed acknowledgment. Pause the prior leader, isolate a minority, elect through a quorum, then heal. Assert preservation of acknowledged commits and rejection of unauthorized stale writes. Check liveness after quorum recovers separately. |
| Clock-dependent ordering | Specify which clocks supply elapsed durations and event order. Use a monotonic clock for local deadlines. Test measured offset assumptions or rely on a protocol-provided revision, log position, or causal relation with the scope the invariant needs. |
Evidence fixtures
Run the two-session reservation schedule directly with Python 3.9+. Both workers observe the same snapshot before either commits. The guarded writer rejects the second reservation. The unguarded control admits two reservations and leaves a plausible stock reading of zero. SQLite demonstrates the conditional write with a deterministic sequence. Verify transaction-level claims again on the target database.
| Schedule | Assertion |
| Worker A receives epoch 41 and stalls. Worker B receives 42, commits a write, and A resumes. | The sink rejects epoch 41 and retains B's value. |
| Caller sends one create request twice, with the first reply lost after commit. | One effect is visible. The retry returns the original result. Reusing that key with a different payload returns a conflict. |
| Two transactions see one free slot and each tries to insert a distinct reservation. | The invariant admits one reservation. If a transaction is retried, it repeats the original read and decision on fresh state. |
| A three-replica cluster loses connectivity between its leader and the other two replicas. | The isolated leader cannot acknowledge a new quorum-committed write. A new leader preserves previously acknowledged entries. |
Catalog: CON-01, CON-12, DAT-12. For larger schedules use deterministic simulation with the optional deterministic-simulation-and-property-testing skill.
Sources: PostgreSQL transaction isolation, PostgreSQL serialization failure handling, etcd concurrency reference, Raft paper.
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.

