Files
alkstore/tasks/mem-engine-locks.md
T
glm-5.3-flash 5abd351c86 Wave-6 decomposition (mem engine): eleven tasks per the pg-wave rhythm — foundations (crate scaffold, MemStore::new isolation, guarded state core, wake routing, wasm32 gate from birth), seam-tx (the load-bearing tx overlay: eleven staged _tx methods, commit-merge + wake-at-commit — pg-fix-tx-wake's discipline structural from the start, drop = discard trivial, with_tx panic posture), mechanisms mutually parallel (notify-listen close-at-engine-drop/no-replay/never-coalesced; queues = ADR-010 machine driver-free with the equal-jitter curve and opts resolution as ADR-012 §2's third owner; streams log+offsets+trim; locks TTL registry, no busy-path analog), scheduler-outbox (tick/catch-up-64/leadership through the __alkstore_scheduler lock, engine-uniform per ADR-009 §4; outbox over queues with the 60/5/5 seam stamp), integration (suite third StoreFactory column green on host under a current-thread flavor, wasm32 acceptance items, engine-mem.md to implementation-complete), and the review-wave-6 gate (born-pinned audit: conformance read, discharge-map wiring, wasm items, three-way equivalence green, class-1 window discipline). Window riders: suite-harness-current-thread — the wave's one suite-side pre-task, past_stamp_sleep's blocking sleep goes async per review 003's properties.rs:1683 posture note, enabling the current-thread flavor; pg-fix-scheduler-tick-seam — review 003 Finding 1, the cfg(test) transient-fault seam driving the real tick_with_retries through retry-then-success and exhaustion arms (the last uncovered wave-4 hardening arm, sqlite-commit-error-arm pattern). Task hygiene: pg-fix-open-path frontmatter fixed (unquoted 'max_size: 0' colon-space inside the name scalar broke YAML parsing — taskgraph validate had been red one-error since the wave-4 fix-batch decomposition; also restores review-wave-4-fixes' dependency resolution). implementation.md: wave-6 table row → decomposed, task-set listing with the parallelism note (rider + pre-task independent of the mem chain; rider closes before the gate), wave-6 decomposition bullet in the review-rounds record. Docs-only change; verified taskgraph validate (60 tasks, no cycles), cargo fmt --check, cross-reference read
2026-10-10 09:57:01 +00:00

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
mem-engine-seam-tx
narrow low component implementation
wave-6
mem-engine
locks

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 <= 0 rejects with opaque Err (ADR-023 §2, durations kind), never a silent immediately-expired lease.
  • Lock handle (ADR-019): renew(ttl) (absolute reset; renews past expiry refused) and release. 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 gets None cleanly (the SQLite busy-path question has no mem analog; loser is a value, never an error). Not part of the tx seam (no lock_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/release over 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-mem clean; 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