lock-db 1.0.0

Lock manager and deadlock detection for Rust databases - row/range locks, multiple granularities, and wait-for cycle detection.
Documentation
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

---


## [Unreleased]

## [1.0.0] - 2026-06-06

First stable release. The public API is frozen until 2.0. No code changes from
v0.5.0 — this release captures the final benchmarks, confirms every quality gate
on Linux, macOS, and Windows (stable and MSRV 1.85), and promotes the crate to
1.0.

The complete, stable surface:

- Core (`no_std`): `LockMode`, `KeyRange`, `TxnId`, `ResourceId`, `LockError`.
- `std`: `LockManager`, `Acquisition`, `WaitForGraph`, `VictimPolicy`,
  `Deadlock`, and the `prelude`.

### Changed

- Version promoted to 1.0.0; the public API is stable and will not change before
  a 2.0 major release.

## [0.5.0] - 2026-06-05

Hardening and the formal API freeze. No new public surface — the feature set
frozen at v0.4.0 is now exercised under adversarial load, and the public API is
recorded as frozen until 2.0.

### Added

- Adversarial contention stress test: many threads hammering a shared resource
  pool with random shared/exclusive acquisitions, verifying mutual exclusion
  through an independent per-resource counter.
- Deadlock-storm stress test: many threads acquiring resource pairs in random
  order via `request`, asserting that detect-and-abort keeps every transaction
  making progress (a liveness check that fails loudly rather than hanging).

### Changed

- **Public API frozen.** The surface is stable until 2.0; remaining 0.x releases
  integrate against real consumers and capture final benchmarks. `cargo audit`
  and `cargo deny` are clean.

## [0.4.0] - 2026-06-05

Wait-for deadlock detection, and the feature freeze. This release completes the
1.0 feature set: a wait-for graph with cycle detection and victim selection, and
a deadlock-aware acquisition path on the lock manager. The public API is frozen
as of this release; remaining 0.x work is hardening only.

### Added

- `WaitForGraph` — a wait-for graph with iterative-DFS cycle detection
  (`detect_cycle`, `cycle_from`), edge maintenance (`add_wait`, `add_waits`,
  `clear_waiter`, `remove_txn`), and `pick_victim`.
- `VictimPolicy` (`Youngest` default, `Oldest`) and `Deadlock` (`victim` +
  `cycle`).
- `Acquisition` — the outcome of the new deadlock-aware acquisition
  (`Granted` / `Waiting` / `Deadlock`).
- `LockManager::request` — deadlock-aware acquire: grants, or registers a wait
  and reports `Waiting`, or reports `Deadlock` with a victim when the wait closes
  a cycle. Detection rebuilds the graph from the current lock table, so it never
  aborts a transaction that is not genuinely deadlocked.
- `LockManager::cancel_wait`, `find_deadlock` (on-demand/periodic detection), and
  `waiting_count`.
- Example `deadlock`; a `WaitForGraph` property test against Kahn's algorithm; a
  `loom` model check for the classic two-transaction deadlock; a `request`
  benchmark.

### Changed

- `LockManager::release_all` now also clears a transaction's pending wait.
- **API frozen.** As of v0.4.0 the public API is stable; no further additions are
  planned before 1.0.

## [0.3.0] - 2026-06-05

Multi-granularity and range locking. This release extends the lock-table core
with the full MGL mode set and lattice upgrades, and adds key-range locks for
phantom protection. Acquisition remains `try`-style; wait queues and deadlock
detection follow in later 0.x releases.

### Added

- Three new `LockMode` variants — `IntentionShared` (IS), `IntentionExclusive`
  (IX), and `SharedIntentionExclusive` (SIX) — completing the standard MGL mode
  set, with the full compatibility matrix.
- `LockMode::join` (lattice least upper bound) and `LockMode::is_intention`.
- `KeyRange` — an inclusive `[start, end]` key interval with `new`, `point`,
  `start`, `end`, `contains`, and `overlaps`.
- `LockManager::try_acquire_range`, `release_range`, and `range_count` for
  range locking with overlap-based conflict detection, sharded by key space.
- Examples `hierarchy` (multi-granularity protocol) and `range_locks` (phantom
  protection); property and `loom` coverage for range locks; a range benchmark.

### Changed

- `LockManager::try_acquire` upgrades now resolve to the lattice join of the
  held and requested modes (e.g. `Shared` + `IntentionExclusive``SIX`),
  granted when the joined mode is compatible with every other holder.
- `LockManager::release_all` now releases a transaction's range locks as well as
  its point locks, and counts both.

## [0.2.0] - 2026-06-05

The lock-table core. This release implements the compatibility matrix and a
sharded, non-blocking lock table on top of the v0.1.0 scaffold. Acquisition is
`try`-style: a request that cannot be granted returns an error rather than
blocking. Wait queues, hierarchical and range locks, and deadlock detection
follow in later 0.x releases.

### Added

- `LockMode` — shared and exclusive modes, with `compatible_with`, `covers`, and
  `is_exclusive`. The compatibility matrix is a single `const fn`.
- `TxnId` and `ResourceId` — opaque `u64` newtypes for transactions and
  lockable resources, with `new`/`get` and `From`/`Into` conversions.
- `LockError``Conflict` and `NotHeld`, `#[non_exhaustive]`, with `Display`
  and (under `std`) `std::error::Error`.
- `LockManager` — a sharded lock table with `new`, `with_shards`, `try_acquire`,
  `release`, `release_all`, `holder_count`, `mode_held`, and `shards`. Supports
  re-entrant acquisition, shared-to-exclusive upgrade of a sole holder, and
  bulk release proportional to the locks a transaction holds.
- `prelude` module re-exporting the public surface.
- Property tests cross-checking the manager against a reference model over
  arbitrary acquire/release sequences; `loom` model checks for the concurrent
  acquire/release paths; `criterion` benchmarks for the hot paths.

### Changed

- The core types (`LockMode`, `TxnId`, `ResourceId`, `LockError`) are
  `no_std`-compatible; `LockManager` is gated behind the `std` feature.

## [0.1.0] - 2026-06-05

Initial scaffold and repository bootstrap. No domain logic yet — this release establishes the structure, tooling, and quality gates the implementation will be built on.

### Added

- `Cargo.toml` with crate metadata, Rust 2024 edition, MSRV 1.85, dual `Apache-2.0 OR MIT` license.
- `README.md`, `docs/API.md`, `CONTRIBUTING.md`, and a documentation skeleton.
- `dev/DIRECTIVES.md` and `dev/ROADMAP.md` (committed engineering standards + plan).
- `REPS.md` compliance baseline; `deny.toml`, `clippy.toml`, `rustfmt.toml`.
- `.github/workflows/ci.yml` (Node 24 actions; fmt, clippy, test, doc, audit, deny) and `.github/FUNDING.yml`.

<!-- LINKS -->
[Unreleased]: https://github.com/jamesgober/lock-db/compare/v1.0.0...HEAD
[1.0.0]: https://github.com/jamesgober/lock-db/compare/v0.5.0...v1.0.0
[0.5.0]: https://github.com/jamesgober/lock-db/compare/v0.4.0...v0.5.0
[0.4.0]: https://github.com/jamesgober/lock-db/compare/v0.3.0...v0.4.0
[0.3.0]: https://github.com/jamesgober/lock-db/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/jamesgober/lock-db/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/jamesgober/lock-db/releases/tag/v0.1.0