2.5 KiB
2.5 KiB
id, name, status, depends_on, scope, risk, impact, level, tags
| id | name | status | depends_on | scope | risk | impact | level | tags | ||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| mem-engine-locks | Mem engine — named locks (in-memory TTL registry) | pending |
|
narrow | low | component | implementation |
|
Description
The named-locks mechanism over an in-memory TTL registry (engine-mem.md §Mapping the contract, locks row):
store.try_lock(name, owner, ttl)— acquire or fail (Option<Lock>; no-work is a value); validation at entry (empty →InvalidName, reserved →ReservedName); duration guard at entry —ttl <= 0rejects with opaqueErr(ADR-023 §2, durations kind), never a silent immediately-expired lease.Lockhandle (ADR-019):renew(ttl)(absolute reset; renews past expiry refused) andrelease. Registry entries carry owner + deadline; expiry is a clock check at try/renew boundaries (tokio time; no ambient revoker) — after TTL expiry exclusion lapses silently (the ADR-008 §7 row), re-acquirable; the holder may still release.- Single-instance contention semantics: two
try_locks on the same name within the registry are serialized by the guarded-state discipline — first wins, second getsNonecleanly (the SQLite busy-path question has no mem analog; loser is a value, never an error). Not part of the tx seam (nolock_tx— contract-verbatim: a lock held across a business tx is held by explicit acquisition; the overlay neither sees nor stages locks).
Acceptance Criteria
try_lock/renew/releaseover the TTL registry; entry validation (names + duration guard) — pinned- TTL expiry: silent lapse, re-acquisition, renew-past-expiry refused — pinned (clock-controlled tests via the state core's clock accessor)
- Concurrent-contention shape: loser is
None, winner's lease intact — pinned cargo check --target wasm32-unknown-unknown -p alkstore-memclean; workspace gates green
References
- docs/architecture/core-contract.md §named locks
- docs/architecture/decisions/008-contract-v1-pinning.md §7; 019-mechanism-handle-surfaces.md; 023 §2
- docs/architecture/engine-mem.md §Mapping the contract (locks row)
- tasks/pg-engine-locks.md (the structural twin's task of record — the duration guards land identically)
Notes
To be filled by implementation agent
Summary
To be filled on completion