# Transactions / State / Concurrency

> Every principle in this category is listed as a record.

Page: Ontology · Principles
Canonical: https://banes-lab.com/ontology#arch-category-transactions-state-concurrency

Every principle in this category is listed as a record. Each record carries its kind, its severity, the scopes it applies at and the layer it lives in, then the edge relations that join it to other records, the records that point back at it, the contracts that answer to it and the tensions it takes part in. The descriptors say how it is violated, detected, measured, repaired and enforced. Where the record carries one, an exemplar shows the shape before and after the principle is applied.

Relations diagram

The relations inside this category.

```mermaid
flowchart LR
n_idempotency["Idempotency"]
n_atomicity["Atomicity"]
n_acid["ACID"]
n_transaction_boundary["Transaction Boundary"]
n_unit_of_work_pattern["Unit of Work Pattern"]
n_consistency["Consistency"]
n_isolation["Isolation"]
n_concurrency_control["Concurrency Control"]
n_optimistic_locking["Optimistic Locking"]
n_pessimistic_locking["Pessimistic Locking"]
n_state_isolation["State Isolation"]
n_controlled_side_effects["Controlled Side Effects"]
n_petri_nets["Petri Nets"]
n_atomicity --> n_transaction_boundary
n_atomicity --> n_consistency
n_acid --> n_atomicity
n_acid --> n_consistency
n_acid --> n_isolation
n_transaction_boundary --> n_atomicity
n_transaction_boundary --> n_unit_of_work_pattern
n_unit_of_work_pattern --> n_transaction_boundary
n_unit_of_work_pattern --> n_atomicity
n_unit_of_work_pattern --> n_consistency
n_isolation --> n_concurrency_control
n_concurrency_control --> n_isolation
n_optimistic_locking --> n_concurrency_control
n_pessimistic_locking --> n_isolation
```

### Idempotency

- Kind: [principle](https://banes-lab.com/records/kind/principle.md)
- Severity: mandatory
- Scope: API, command, message handler
- Layer: [Atomic Boundary](https://banes-lab.com/records/layer/atomic-boundary.md)

Details

Requires
[Idempotency Key or Deterministic Operation](https://banes-lab.com/records/lex/idempotency-key-or-deterministic-operation.md)

Reinforces
[Retry Safety](https://banes-lab.com/records/lex/retry-safety.md), [Event-Driven Architecture](https://banes-lab.com/records/arch/event-driven-architecture.md)

Enables
[Safe Retries](https://banes-lab.com/records/lex/safe-retries.md)

In tension with
[State Tracking](https://banes-lab.com/records/lex/state-tracking.md)

Conflicts with
[Non-Repeatable Side Effects](https://banes-lab.com/records/lex/non-repeatable-side-effects.md)

Referenced by
[Retry Pattern](https://banes-lab.com/records/arch/retry-pattern.md), [Event-Driven Architecture](https://banes-lab.com/records/arch/event-driven-architecture.md), [Eventual Consistency](https://banes-lab.com/records/arch/eventual-consistency.md), [Saga Pattern](https://banes-lab.com/records/arch/saga-pattern.md), [Canonicalization](https://banes-lab.com/records/arch/canonicalization.md)

Tensions
[Idempotency State Tracking](https://banes-lab.com/records/tension/idempotency-state-tracking.md)

Violated by
duplicate charges/orders/messages on retry

Detected by
side-effectful handlers without deduplication

Measured by
duplicate-effect defect rate

Refactored by
Add Idempotency Key, Add Dedup Store

Enforced by
retry tests, API policy

Before

```typescript
app.post("/foo", async request => fooStore.create(await request.json()));
```

After

```typescript
app.post("/foo", async request => {
const key = requireHeader(request, "Idempotency-Key");
const body = await request.json();
return idempotency.execute(key, () => fooStore.create(body));
});
```

### Atomicity

- Kind: [principle](https://banes-lab.com/records/kind/principle.md)
- Severity: mandatory
- Scope: transaction, operation, workflow
- Layer: [Atomic Boundary](https://banes-lab.com/records/layer/atomic-boundary.md)

Details

Requires
[Transaction Boundary](https://banes-lab.com/records/arch/transaction-boundary.md)

Reinforces
[Consistency](https://banes-lab.com/records/arch/consistency.md), [Correctness](https://banes-lab.com/records/arch/correctness.md)

Enables
[All-or-Nothing State Change](https://banes-lab.com/records/lex/all-or-nothing-state-change.md)

In tension with
[Distributed Scalability](https://banes-lab.com/records/lex/distributed-scalability.md)

Conflicts with
[Partial Commit](https://banes-lab.com/records/lex/partial-commit.md)

Referenced by
[ACID](https://banes-lab.com/records/arch/acid.md), [Transaction Boundary](https://banes-lab.com/records/arch/transaction-boundary.md), [Unit of Work Pattern](https://banes-lab.com/records/arch/unit-of-work-pattern.md)

Tensions
[Atomicity Distributed Scalability](https://banes-lab.com/records/tension/atomicity-distributed-scalability.md)

Violated by
partial updates after failure

Detected by
multi-step writes without transaction/compensation

Measured by
partial failure rate

Refactored by
Add Transaction, Add Saga/Compensation

Enforced by
transaction tests

Before

```typescript
await fooStore.remove(from, foo.id);
await fooStore.add(to, foo.id);
```

After

```typescript
await database.transaction(async tx => {
await tx.foos.remove(from, foo.id);
await tx.foos.add(to, foo.id);
});
```

### ACID

- Kind: [model](https://banes-lab.com/records/kind/model.md)
- Severity: contextual
- Scope: database, transaction
- Layer: [Atomic Boundary](https://banes-lab.com/records/layer/atomic-boundary.md)

Details

Requires
[Atomicity](https://banes-lab.com/records/arch/atomicity.md), [Consistency](https://banes-lab.com/records/arch/consistency.md), [Isolation](https://banes-lab.com/records/arch/isolation.md), [Durability](https://banes-lab.com/records/lex/durability.md)

Reinforces
[Correctness](https://banes-lab.com/records/arch/correctness.md)

Enables
[Strong Transactional Guarantees](https://banes-lab.com/records/lex/strong-transactional-guarantees.md)

In tension with
[Distributed Availability](https://banes-lab.com/records/lex/distributed-availability.md), [BASE/Eventual Consistency](https://banes-lab.com/records/lex/base-eventual-consistency.md)

Conflicts with
none

Tensions
[ACID Distributed Availability](https://banes-lab.com/records/tension/acid-distributed-availability.md), [ACID BASE/Eventual Consistency](https://banes-lab.com/records/tension/acid-base-eventual-consistency.md)

Violated by
inconsistent transactional boundaries

Detected by
non-transactional multi-write invariants

Measured by
transactional invariant defects

Refactored by
Define Transaction Boundary, Add Constraints

Enforced by
DB transactions, isolation tests

Before

```typescript
await fooDb.write(foo);
await barDb.write(bar);
```

After

```typescript
await database.transaction({ isolation: "serializable" }, async tx => {
await tx.foos.save(foo);
await tx.bars.save(bar);
assertInvariant(foo, bar);
});
```

### Transaction Boundary

- Kind: [constraint](https://banes-lab.com/records/kind/constraint.md)
- Severity: mandatory
- Scope: unit of work, aggregate, service
- Layer: [Atomic Boundary](https://banes-lab.com/records/layer/atomic-boundary.md)

Details

Requires
[Consistency Rules](https://banes-lab.com/records/lex/consistency-rules.md)

Reinforces
[Atomicity](https://banes-lab.com/records/arch/atomicity.md), [Unit of Work Pattern](https://banes-lab.com/records/arch/unit-of-work-pattern.md)

Enables
[Safe State Mutation](https://banes-lab.com/records/lex/safe-state-mutation.md)

In tension with
[Large Transaction Scope](https://banes-lab.com/records/lex/large-transaction-scope.md)

Conflicts with
[Hidden Distributed Transaction](https://banes-lab.com/records/lex/hidden-distributed-transaction.md)

Referenced by
[Atomicity](https://banes-lab.com/records/arch/atomicity.md), [Unit of Work Pattern](https://banes-lab.com/records/arch/unit-of-work-pattern.md)

Contracts
[Transaction Boundary](https://banes-lab.com/records/algo/transaction-boundary.md)

Tensions
[Transaction Boundary Large Transaction Scope](https://banes-lab.com/records/tension/large-transaction-scope-transaction-boundary.md)

Violated by
spanning transactions across service boundaries

Detected by
transaction scope leakage

Measured by
transaction size/duration

Refactored by
Shrink Boundary, Add Saga

Enforced by
transaction policy

Before

```typescript
await beginTransaction();
await controller.parse(request);
await service.validate(foo);
await repository.save(foo);
await commitTransaction();
```

After

```typescript
async function createFoo(input: CreateFoo) {
const foo = validateFoo(input);
return database.transaction(tx => new FooRepository(tx).save(foo));
}
```

### Unit of Work Pattern

- Kind: [pattern](https://banes-lab.com/records/kind/pattern.md)
- Severity: recommended
- Scope: application service, persistence
- Aliases: Unit of Work
- Layer: [Atomic Boundary](https://banes-lab.com/records/layer/atomic-boundary.md)

Details

Requires
[Transaction Boundary](https://banes-lab.com/records/arch/transaction-boundary.md)

Reinforces
[Atomicity](https://banes-lab.com/records/arch/atomicity.md), [Consistency](https://banes-lab.com/records/arch/consistency.md)

Enables
[Coordinated Persistence](https://banes-lab.com/records/lex/coordinated-persistence.md)

In tension with
[Repository Complexity](https://banes-lab.com/records/lex/repository-complexity.md)

Conflicts with
[Scattered Save Calls](https://banes-lab.com/records/lex/scattered-save-calls.md)

Referenced by
[Transaction Boundary](https://banes-lab.com/records/arch/transaction-boundary.md)

Tensions
[Unit of Work Pattern Repository Complexity](https://banes-lab.com/records/tension/repository-complexity-unit-of-work-pattern.md)

Violated by
unmanaged partial persistence

Detected by
multiple independent saves in one use case

Measured by
save coordination defects

Refactored by
Introduce Unit of Work

Enforced by
persistence conventions

Before

```typescript
await fooRepository.save(foo);
await barRepository.save(bar);
await eventRepository.save(event);
```

After

```typescript
const uow = unitOfWork.begin();
uow.foos.save(foo);
uow.bars.save(bar);
uow.events.append(event);
await uow.commit();
```

### Consistency

- Kind: [quality-attribute](https://banes-lab.com/records/kind/quality-attribute.md)
- Severity: mandatory
- Scope: data, transaction, distributed system
- Layer: [Atomic Boundary](https://banes-lab.com/records/layer/atomic-boundary.md)

Details

Requires
[Invariants](https://banes-lab.com/records/arch/invariants.md), [Validation](https://banes-lab.com/records/arch/validation.md)

Reinforces
[Correctness](https://banes-lab.com/records/arch/correctness.md)

Enables
[Reliable State](https://banes-lab.com/records/lex/reliable-state.md)

In tension with
[Availability](https://banes-lab.com/records/lex/availability.md), [Latency](https://banes-lab.com/records/arch/latency.md)

Conflicts with
[Inconsistent Replicas/Models](https://banes-lab.com/records/lex/inconsistent-replicas-models.md)

Referenced by
[Code Review](https://banes-lab.com/records/arch/code-review.md), [Reference Architecture](https://banes-lab.com/records/arch/reference-architecture.md), [Standardization](https://banes-lab.com/records/arch/standardization.md), [Total-Order Broadcast](https://banes-lab.com/records/arch/total-order-broadcast.md), [Microservices](https://banes-lab.com/records/arch/microservices.md), [Space-Based Architecture](https://banes-lab.com/records/arch/space-based-architecture.md), [Invariants](https://banes-lab.com/records/arch/invariants.md), [Centralized Configuration](https://banes-lab.com/records/arch/centralized-configuration.md), [Decentralization](https://banes-lab.com/records/arch/decentralization.md), [Consensus](https://banes-lab.com/records/arch/consensus.md), [Do Not Repeat Yourself (DRY)](https://banes-lab.com/records/arch/duplicate-code.md), [Scalability](https://banes-lab.com/records/arch/scalability.md), [Caching](https://banes-lab.com/records/arch/caching.md), [Single Source of Truth](https://banes-lab.com/records/arch/single-source-of-truth.md), [Normalization](https://banes-lab.com/records/arch/normalization.md), [Governance](https://banes-lab.com/records/arch/governance.md), [Failover](https://banes-lab.com/records/arch/failover.md), [Atomicity](https://banes-lab.com/records/arch/atomicity.md), [ACID](https://banes-lab.com/records/arch/acid.md), [Unit of Work Pattern](https://banes-lab.com/records/arch/unit-of-work-pattern.md)

Tensions
[Consistency Availability](https://banes-lab.com/records/tension/availability-consistency.md), [Consistency Latency](https://banes-lab.com/records/tension/consistency-latency.md)

Violated by
invariant-breaking writes

Detected by
data anomalies, failed invariant checks

Measured by
consistency violation count

Refactored by
Add Constraints, Add Transaction, Add Reconciliation

Enforced by
database constraints, invariant tests

Before

```typescript
foo.total = foo.items.reduce((sum, item) => sum + item.value, 0);
foo.itemCount = externalCount;
```

After

```typescript
function rebuildFoo(items: readonly FooItem[]): Foo {
return { items, total: sum(items), itemCount: items.length };
}
const foo = rebuildFoo(items);
```

### Isolation

- Kind: [constraint](https://banes-lab.com/records/kind/constraint.md)
- Severity: contextual
- Scope: database, transaction, concurrency
- Layer: [Atomic Boundary](https://banes-lab.com/records/layer/atomic-boundary.md)

Details

Requires
[Concurrency Control](https://banes-lab.com/records/arch/concurrency-control.md)

Reinforces
[Correctness](https://banes-lab.com/records/arch/correctness.md)

Enables
[Safe Concurrent Operations](https://banes-lab.com/records/lex/safe-concurrent-operations.md)

In tension with
[Throughput](https://banes-lab.com/records/arch/throughput.md)

Conflicts with
[Dirty Reads/Writes](https://banes-lab.com/records/lex/dirty-reads-writes.md)

Referenced by
[Partitioning](https://banes-lab.com/records/arch/partitioning.md), [ACID](https://banes-lab.com/records/arch/acid.md), [Concurrency Control](https://banes-lab.com/records/arch/concurrency-control.md), [Pessimistic Locking](https://banes-lab.com/records/arch/pessimistic-locking.md)

Tensions
[Isolation Throughput](https://banes-lab.com/records/tension/isolation-throughput.md)

Violated by
race-condition state corruption

Detected by
concurrency tests, isolation anomalies

Measured by
anomaly rate, lock contention

Refactored by
Add Locking, Set Isolation Level

Enforced by
DB isolation, concurrency tests

Before

```typescript
const foo = await fooStore.find(id);
foo.count += 1;
await fooStore.save(foo);
```

After

```typescript
await database.transaction({ isolation: "serializable" }, async tx => {
const foo = await tx.foos.lock(id);
await tx.foos.save({ ...foo, count: foo.count + 1 });
});
```

### Concurrency Control

- Kind: [mechanism](https://banes-lab.com/records/kind/mechanism.md)
- Severity: mandatory
- Scope: transaction, memory, distributed system
- Layer: [Atomic Boundary](https://banes-lab.com/records/layer/atomic-boundary.md)

Details

Requires
[Shared State Identification](https://banes-lab.com/records/lex/shared-state-identification.md)

Reinforces
[Isolation](https://banes-lab.com/records/arch/isolation.md), [Correctness](https://banes-lab.com/records/arch/correctness.md)

Enables
[Safe Parallel Mutation](https://banes-lab.com/records/lex/safe-parallel-mutation.md)

In tension with
[Performance](https://banes-lab.com/records/lex/performance.md)

Conflicts with
[Race Conditions](https://banes-lab.com/records/lex/race-conditions.md), [Lost Update](https://banes-lab.com/records/arch/lost-update.md)

Referenced by
[Concurrency](https://banes-lab.com/records/arch/concurrency.md), [Isolation](https://banes-lab.com/records/arch/isolation.md), [Optimistic Locking](https://banes-lab.com/records/arch/optimistic-locking.md)

Tensions
[Concurrency Control Performance](https://banes-lab.com/records/tension/concurrency-control-performance.md)

Violated by
unsynchronized shared mutation

Detected by
race detectors, flaky concurrent tests

Measured by
race count, contention

Refactored by
Add Locking, Use Immutable State, Add CAS

Enforced by
thread-safety analysis, [tests](https://banes-lab.com/records/lex/tests.md)

Before

```typescript
const foo = await fooStore.find(id);
await fooStore.save({ ...foo, count: foo.count + 1 });
```

After

```typescript
await fooStore.update(id, current => ({
...current,
count: current.count + 1,
}), { expectedVersion: foo.version });
```

### Optimistic Locking

- Kind: [pattern](https://banes-lab.com/records/kind/pattern.md)
- Severity: contextual
- Scope: persistence, transaction
- Layer: [Atomic Boundary](https://banes-lab.com/records/layer/atomic-boundary.md)

Details

Requires
[Version Field](https://banes-lab.com/records/lex/version-field.md)

Reinforces
[Concurrency Control](https://banes-lab.com/records/arch/concurrency-control.md)

Enables
[Conflict Detection](https://banes-lab.com/records/lex/conflict-detection.md)

In tension with
[Retry Complexity](https://banes-lab.com/records/lex/retry-complexity.md)

Conflicts with
[Blind Overwrite](https://banes-lab.com/records/lex/blind-overwrite.md)

Tensions
[Optimistic Locking Retry Complexity](https://banes-lab.com/records/tension/optimistic-locking-retry-complexity.md)

Violated by
[lost update](https://banes-lab.com/records/arch/lost-update.md)

Detected by
updates without version check

Measured by
conflict/retry rate

Refactored by
Add Version Column, Add Compare-And-Swap

Enforced by
repository rules, integration tests

Before

```typescript
await fooTable.update({ id: foo.id, name: foo.name });
```

After

```typescript
const updated = await fooTable.update({
id: foo.id,
expectedVersion: foo.version,
next: { ...foo, version: foo.version + 1 },
});
if (!updated) throw new ConflictError(foo.id);
```

### Pessimistic Locking

- Kind: [pattern](https://banes-lab.com/records/kind/pattern.md)
- Severity: contextual
- Scope: persistence, critical section
- Layer: [Atomic Boundary](https://banes-lab.com/records/layer/atomic-boundary.md)

Details

Requires
[Lock Ownership](https://banes-lab.com/records/lex/lock-ownership.md)

Reinforces
[Isolation](https://banes-lab.com/records/arch/isolation.md)

Enables
[Strong Conflict Prevention](https://banes-lab.com/records/lex/strong-conflict-prevention.md)

In tension with
[Deadlocks](https://banes-lab.com/records/lex/deadlocks.md), [Latency](https://banes-lab.com/records/arch/latency.md), [Lock-Free Throughput](https://banes-lab.com/records/lex/lock-free-throughput.md)

Conflicts with
none

Tensions
[Pessimistic Locking Deadlocks](https://banes-lab.com/records/tension/deadlocks-pessimistic-locking.md), [Pessimistic Locking Latency](https://banes-lab.com/records/tension/latency-pessimistic-locking.md), [Pessimistic Locking Lock-Free Throughput](https://banes-lab.com/records/tension/lock-free-throughput-pessimistic-locking.md)

Violated by
missing lock around critical mutation

Detected by
concurrent update conflicts

Measured by
lock wait/deadlock rate

Refactored by
Add Lock, Narrow Lock Scope

Enforced by
transactional tests

Before

```typescript
const foo = await fooTable.find(id);
await fooTable.save(change(foo));
```

After

```typescript
await database.transaction(async tx => {
const foo = await tx.foos.findForUpdate(id);
await tx.foos.save(change(foo));
});
```

### State Isolation

- Kind: [principle](https://banes-lab.com/records/kind/principle.md)
- Severity: mandatory
- Scope: function, component, service
- Layer: [Atomic Boundary](https://banes-lab.com/records/layer/atomic-boundary.md)

Details

Requires
[Encapsulation](https://banes-lab.com/records/arch/encapsulation.md), [Ownership](https://banes-lab.com/records/lex/ownership.md)

Reinforces
[Predictability](https://banes-lab.com/records/arch/predictability.md), [Concurrency Safety](https://banes-lab.com/records/lex/concurrency-safety.md)

Enables
[Testability](https://banes-lab.com/records/arch/testability.md)

In tension with
[Data Sharing](https://banes-lab.com/records/lex/data-sharing.md)

Conflicts with
[Shared Mutable State](https://banes-lab.com/records/arch/shared-mutable-state.md)

Tensions
[State Isolation Data Sharing](https://banes-lab.com/records/tension/data-sharing-state-isolation.md)

Violated by
[global mutable state](https://banes-lab.com/records/lex/global-mutable-state.md)

Detected by
static mutable fields, shared caches without ownership

Measured by
global state count

Refactored by
Encapsulate State, Pass Explicit State, Use Immutable Data

Enforced by
lint rules, architecture tests

Before

```typescript
const globalFooState: Foo[] = [];
function addFoo(foo: Foo) { globalFooState.push(foo); }
```

After

```typescript
class FooSession {
#state: Foo[] = [];
add(foo: Foo) { this.#state = [...this.#state, foo]; }
snapshot() { return [...this.#state]; }
}
```

### Controlled Side Effects

- Kind: [principle](https://banes-lab.com/records/kind/principle.md)
- Severity: recommended
- Scope: function, module, boundary
- Layer: [Atomic Boundary](https://banes-lab.com/records/layer/atomic-boundary.md)

Details

Requires
[Effect Boundaries](https://banes-lab.com/records/lex/effect-boundaries.md)

Reinforces
[Predictability](https://banes-lab.com/records/arch/predictability.md), [Testability](https://banes-lab.com/records/arch/testability.md)

Enables
[Pure Core / Imperative Shell](https://banes-lab.com/records/lex/pure-core-imperative-shell.md)

In tension with
[Performance Optimization](https://banes-lab.com/records/lex/performance-optimization.md)

Conflicts with
[Hidden Side Effects](https://banes-lab.com/records/lex/hidden-side-effects.md), [Action at a Distance](https://banes-lab.com/records/arch/action-at-a-distance.md), [Hidden Side Effect](https://banes-lab.com/records/arch/hidden-side-effect.md)

Tensions
[Controlled Side Effects Performance Optimization](https://banes-lab.com/records/tension/controlled-side-effects-performance-optimization.md)

Violated by
mutation/network/persistence hidden in pure-looking code

Detected by
side effects in domain/pure functions

Measured by
side-effect boundary violations

Refactored by
Move Side Effect to Boundary, Return Command/Event

Enforced by
effect linting, layer rules

Before

```typescript
function calculateFoo(foo: Foo) {
foo.count += 1;
fooLog.record(foo);
fooDb.save(foo);
return foo.count;
}
```

After

```typescript
function nextFoo(foo: Foo): Foo { return { ...foo, count: foo.count + 1 }; }
async function applyFoo(foo: Foo, store: FooStore, log: Log) {
const next = nextFoo(foo);
log.write(next);
await store.save(next);
return next;
}
```

### Petri Nets

- Kind: [model](https://banes-lab.com/records/kind/model.md)
- Severity: contextual
- Scope: concurrency, workflow, verification
- Layer: [Atomic Boundary](https://banes-lab.com/records/layer/atomic-boundary.md)

Details

Requires
[Places and Transitions](https://banes-lab.com/records/lex/places-and-transitions.md)

Reinforces
[Concurrency Correctness](https://banes-lab.com/records/lex/concurrency-correctness.md), [Deadlock Freedom](https://banes-lab.com/records/lex/deadlock-freedom.md)

Enables
[Concurrent-Flow Modeling](https://banes-lab.com/records/lex/concurrent-flow-modeling.md), [Reachability and Deadlock Analysis](https://banes-lab.com/records/lex/reachability-and-deadlock-analysis.md)

In tension with
[Modeling Overhead](https://banes-lab.com/records/lex/modeling-overhead.md)

Conflicts with
[Ad-Hoc Lock Ordering](https://banes-lab.com/records/lex/ad-hoc-lock-ordering.md)

Contracts
[Petri Nets](https://banes-lab.com/records/algo/petri-nets.md)

Tensions
[Petri Nets Modeling Overhead](https://banes-lab.com/records/tension/modeling-overhead-petri-nets.md)

Violated by
concurrent resource flows coordinated by hand-reasoned lock ordering

Detected by
deadlocks or lost tokens found only at runtime

Measured by
unreachable or deadlock-prone markings

Refactored by
Model concurrent flow as a Petri net and analyze reachability

Enforced by
concurrency model review

Before

```typescript
acquire(a); acquire(b); work(); release(b); release(a);
```

After

```typescript
const net = petriNet({
places: { idle: 1, aHeld: 0, bHeld: 0 },
transitions: [
{ name: "takeA", consume: { idle: 1 }, produce: { aHeld: 1 } },
{ name: "takeB", consume: { aHeld: 1 }, produce: { bHeld: 1 } },
],
});
assertNoDeadlock(reachableMarkings(net));
```

## Links to

- [principle](https://banes-lab.com/records/kind/principle.md)
- [Atomic Boundary](https://banes-lab.com/records/layer/atomic-boundary.md)
- [Idempotency Key or Deterministic Operation](https://banes-lab.com/records/lex/idempotency-key-or-deterministic-operation.md)
- [Retry Safety](https://banes-lab.com/records/lex/retry-safety.md)
- [Event-Driven Architecture](https://banes-lab.com/records/arch/event-driven-architecture.md)
- [Safe Retries](https://banes-lab.com/records/lex/safe-retries.md)
- [State Tracking](https://banes-lab.com/records/lex/state-tracking.md)
- [Non-Repeatable Side Effects](https://banes-lab.com/records/lex/non-repeatable-side-effects.md)
- [Retry Pattern](https://banes-lab.com/records/arch/retry-pattern.md)
- [Eventual Consistency](https://banes-lab.com/records/arch/eventual-consistency.md)
- [Saga Pattern](https://banes-lab.com/records/arch/saga-pattern.md)
- [Canonicalization](https://banes-lab.com/records/arch/canonicalization.md)
- [Idempotency / State Tracking](https://banes-lab.com/records/tension/idempotency-state-tracking.md)
- [Transaction Boundary](https://banes-lab.com/records/arch/transaction-boundary.md)
- [Consistency](https://banes-lab.com/records/arch/consistency.md)
- [Correctness](https://banes-lab.com/records/arch/correctness.md)
- [All-or-Nothing State Change](https://banes-lab.com/records/lex/all-or-nothing-state-change.md)
- [Distributed Scalability](https://banes-lab.com/records/lex/distributed-scalability.md)
- [Partial Commit](https://banes-lab.com/records/lex/partial-commit.md)
- [ACID](https://banes-lab.com/records/arch/acid.md)
- [Unit of Work Pattern](https://banes-lab.com/records/arch/unit-of-work-pattern.md)
- [Atomicity / Distributed Scalability](https://banes-lab.com/records/tension/atomicity-distributed-scalability.md)
- [model](https://banes-lab.com/records/kind/model.md)
- [Atomicity](https://banes-lab.com/records/arch/atomicity.md)
- [Isolation](https://banes-lab.com/records/arch/isolation.md)
- [Durability](https://banes-lab.com/records/lex/durability.md)
- [Strong Transactional Guarantees](https://banes-lab.com/records/lex/strong-transactional-guarantees.md)
- [Distributed Availability](https://banes-lab.com/records/lex/distributed-availability.md)
- [BASE/Eventual Consistency](https://banes-lab.com/records/lex/base-eventual-consistency.md)
- [ACID / Distributed Availability](https://banes-lab.com/records/tension/acid-distributed-availability.md)
- [ACID / BASE/Eventual Consistency](https://banes-lab.com/records/tension/acid-base-eventual-consistency.md)
- [constraint](https://banes-lab.com/records/kind/constraint.md)
- [Consistency Rules](https://banes-lab.com/records/lex/consistency-rules.md)
- [Safe State Mutation](https://banes-lab.com/records/lex/safe-state-mutation.md)
- [Large Transaction Scope](https://banes-lab.com/records/lex/large-transaction-scope.md)
- [Hidden Distributed Transaction](https://banes-lab.com/records/lex/hidden-distributed-transaction.md)
- [Transaction Boundary](https://banes-lab.com/records/algo/transaction-boundary.md)
- [Transaction Boundary / Large Transaction Scope](https://banes-lab.com/records/tension/large-transaction-scope-transaction-boundary.md)
- [pattern](https://banes-lab.com/records/kind/pattern.md)
- [Coordinated Persistence](https://banes-lab.com/records/lex/coordinated-persistence.md)
- [Repository Complexity](https://banes-lab.com/records/lex/repository-complexity.md)
- [Scattered Save Calls](https://banes-lab.com/records/lex/scattered-save-calls.md)
- [Unit of Work Pattern / Repository Complexity](https://banes-lab.com/records/tension/repository-complexity-unit-of-work-pattern.md)
- [quality-attribute](https://banes-lab.com/records/kind/quality-attribute.md)
- [Invariants](https://banes-lab.com/records/arch/invariants.md)
- [Validation](https://banes-lab.com/records/arch/validation.md)
- [Reliable State](https://banes-lab.com/records/lex/reliable-state.md)
- [Availability](https://banes-lab.com/records/lex/availability.md)
- [Latency](https://banes-lab.com/records/arch/latency.md)
- [Inconsistent Replicas/Models](https://banes-lab.com/records/lex/inconsistent-replicas-models.md)
- [Code Review](https://banes-lab.com/records/arch/code-review.md)
- [Reference Architecture](https://banes-lab.com/records/arch/reference-architecture.md)
- [Standardization](https://banes-lab.com/records/arch/standardization.md)
- [Total-Order Broadcast](https://banes-lab.com/records/arch/total-order-broadcast.md)
- [Microservices](https://banes-lab.com/records/arch/microservices.md)
- [Space-Based Architecture](https://banes-lab.com/records/arch/space-based-architecture.md)
- [Centralized Configuration](https://banes-lab.com/records/arch/centralized-configuration.md)
- [Decentralization](https://banes-lab.com/records/arch/decentralization.md)
- [Consensus](https://banes-lab.com/records/arch/consensus.md)
- [Do Not Repeat Yourself (DRY)](https://banes-lab.com/records/arch/duplicate-code.md)
- [Scalability](https://banes-lab.com/records/arch/scalability.md)
- [Caching](https://banes-lab.com/records/arch/caching.md)
- [Single Source of Truth](https://banes-lab.com/records/arch/single-source-of-truth.md)
- [Normalization](https://banes-lab.com/records/arch/normalization.md)
- [Governance](https://banes-lab.com/records/arch/governance.md)
- [Failover](https://banes-lab.com/records/arch/failover.md)
- [Consistency / Availability](https://banes-lab.com/records/tension/availability-consistency.md)
- [Consistency / Latency](https://banes-lab.com/records/tension/consistency-latency.md)
- [Concurrency Control](https://banes-lab.com/records/arch/concurrency-control.md)
- [Safe Concurrent Operations](https://banes-lab.com/records/lex/safe-concurrent-operations.md)
- [Throughput](https://banes-lab.com/records/arch/throughput.md)
- [Dirty Reads/Writes](https://banes-lab.com/records/lex/dirty-reads-writes.md)
- [Partitioning](https://banes-lab.com/records/arch/partitioning.md)
- [Pessimistic Locking](https://banes-lab.com/records/arch/pessimistic-locking.md)
- [Isolation / Throughput](https://banes-lab.com/records/tension/isolation-throughput.md)
- [mechanism](https://banes-lab.com/records/kind/mechanism.md)
- [Shared State Identification](https://banes-lab.com/records/lex/shared-state-identification.md)
- [Safe Parallel Mutation](https://banes-lab.com/records/lex/safe-parallel-mutation.md)
- [Performance](https://banes-lab.com/records/lex/performance.md)
- [Race Conditions](https://banes-lab.com/records/lex/race-conditions.md)
- [Lost Update](https://banes-lab.com/records/arch/lost-update.md)
- [Concurrency](https://banes-lab.com/records/arch/concurrency.md)
- [Optimistic Locking](https://banes-lab.com/records/arch/optimistic-locking.md)
- [Concurrency Control / Performance](https://banes-lab.com/records/tension/concurrency-control-performance.md)
- [Tests](https://banes-lab.com/records/lex/tests.md)
- [Version Field](https://banes-lab.com/records/lex/version-field.md)
- [Conflict Detection](https://banes-lab.com/records/lex/conflict-detection.md)
- [Retry Complexity](https://banes-lab.com/records/lex/retry-complexity.md)
- [Blind Overwrite](https://banes-lab.com/records/lex/blind-overwrite.md)
- [Optimistic Locking / Retry Complexity](https://banes-lab.com/records/tension/optimistic-locking-retry-complexity.md)
- [Lock Ownership](https://banes-lab.com/records/lex/lock-ownership.md)
- [Strong Conflict Prevention](https://banes-lab.com/records/lex/strong-conflict-prevention.md)
- [Deadlocks](https://banes-lab.com/records/lex/deadlocks.md)
- [Lock-Free Throughput](https://banes-lab.com/records/lex/lock-free-throughput.md)
- [Pessimistic Locking / Deadlocks](https://banes-lab.com/records/tension/deadlocks-pessimistic-locking.md)
- [Pessimistic Locking / Latency](https://banes-lab.com/records/tension/latency-pessimistic-locking.md)
- [Pessimistic Locking / Lock-Free Throughput](https://banes-lab.com/records/tension/lock-free-throughput-pessimistic-locking.md)
- [Encapsulation](https://banes-lab.com/records/arch/encapsulation.md)
- [Ownership](https://banes-lab.com/records/lex/ownership.md)
- [Predictability](https://banes-lab.com/records/arch/predictability.md)
- [Concurrency Safety](https://banes-lab.com/records/lex/concurrency-safety.md)
- [Testability](https://banes-lab.com/records/arch/testability.md)
- [Data Sharing](https://banes-lab.com/records/lex/data-sharing.md)
- [Shared Mutable State](https://banes-lab.com/records/arch/shared-mutable-state.md)
- [State Isolation / Data Sharing](https://banes-lab.com/records/tension/data-sharing-state-isolation.md)
- [Global Mutable State](https://banes-lab.com/records/lex/global-mutable-state.md)
- [Effect Boundaries](https://banes-lab.com/records/lex/effect-boundaries.md)
- [Pure Core / Imperative Shell](https://banes-lab.com/records/lex/pure-core-imperative-shell.md)
- [Performance Optimization](https://banes-lab.com/records/lex/performance-optimization.md)
- [Hidden Side Effects](https://banes-lab.com/records/lex/hidden-side-effects.md)
- [Action at a Distance](https://banes-lab.com/records/arch/action-at-a-distance.md)
- [Hidden Side Effect](https://banes-lab.com/records/arch/hidden-side-effect.md)
- [Controlled Side Effects / Performance Optimization](https://banes-lab.com/records/tension/controlled-side-effects-performance-optimization.md)
- [Places and Transitions](https://banes-lab.com/records/lex/places-and-transitions.md)
- [Concurrency Correctness](https://banes-lab.com/records/lex/concurrency-correctness.md)
- [Deadlock Freedom](https://banes-lab.com/records/lex/deadlock-freedom.md)
- [Concurrent-Flow Modeling](https://banes-lab.com/records/lex/concurrent-flow-modeling.md)
- [Reachability and Deadlock Analysis](https://banes-lab.com/records/lex/reachability-and-deadlock-analysis.md)
- [Modeling Overhead](https://banes-lab.com/records/lex/modeling-overhead.md)
- [Ad-Hoc Lock Ordering](https://banes-lab.com/records/lex/ad-hoc-lock-ordering.md)
- [Petri Nets](https://banes-lab.com/records/algo/petri-nets.md)
- [Petri Nets / Modeling Overhead](https://banes-lab.com/records/tension/modeling-overhead-petri-nets.md)

## Linked from

- [The layer topology](https://banes-lab.com/ontology/schema/the-layer-topology.md)
- [The membership](https://banes-lab.com/ontology/schema/the-membership.md)
