contract-concurrency
Contract Concurrency
Discipline for adapter contract parity and concurrent stress testing.
The codebase-design and tdd skills recommend isolating external systems behind clean seams (such as OrderStoreAdapter) and writing business logic tests against fast in-memory adapters (InMemoryOrderStore).
However, in-memory adapters run synchronously in single-threaded JavaScript, masking production realities: transaction isolation levels, connection pooling limits, foreign key constraints, deadlocks, and race conditions. A test suite that passes 100% on an in-memory adapter can fail catastrophically when deployed against PostgreSQL or Redis.
contract-concurrency extends tdd with two mandatory testing practices.
1. Contract Parity Test Suite
Whenever a seam has two or more implementations (for example, InMemoryStore for local development and unit tests, and PostgresStore for production), both adapters must pass the exact same contract test suite.
The Shared Contract Runner Pattern
Define the test suite inside a shared factory function that accepts an adapter factory: