---
library: "bootstrap"
slug: "StateLock"
name: "StateLock"
ref: "StateLock#c9c2"
hash: "sema:StateLock#mh:SHA-256:c9c2809bdf97bb6ac17a8ffe428d4aa9a28294b99d64cc8a336a239d26a8afb8"
type: "Protocols"
layer: "Society"
version: "0.11.0"
root: "a6a3d1ff0f982ee30430c5b42f3784c8ec901fd68482cfc1bc30899c1e5e48c5"
license: null
url: "https://semahash.org/vocabularies/bootstrap/patterns/StateLock"
---

# StateLock

Atomic coordination via temporary state fusion

Society · Protocols

## Mechanism

A coordination pattern where two [Actor](https://semahash.org/vocabularies/bootstrap/patterns/Actor.md)s temporarily 'fuse' a subset of their writable [State](https://semahash.org/vocabularies/bootstrap/patterns/State.md). During the [Lock](https://semahash.org/vocabularies/bootstrap/patterns/Lock.md), changes require a cryptographic signature from both. Contention triggers [Backoff](https://semahash.org/vocabularies/bootstrap/patterns/Backoff.md) and [Cooldown](https://semahash.org/vocabularies/bootstrap/patterns/Cooldown.md).

## Invariants

- Both [Actor](https://semahash.org/vocabularies/bootstrap/patterns/Actor.md)s sign every write to the fused [State](https://semahash.org/vocabularies/bootstrap/patterns/State.md) subset.
- Exclusive over that subset: no third party writes it while the [Lock](https://semahash.org/vocabularies/bootstrap/patterns/Lock.md) holds.
- Temporary: the fusion ends on completion or timeout, never implicitly.

## Signature

- Lock(State)

## Failure modes

- Deadlock: both parties wait for each other indefinitely.
- Livelock: lock acquired and released rapidly, denying access to others.
- Premature dissolution: state auto-dissolves while legitimate work is in progress.

## Caution

Exclusive state access — misuse enables denial of service via lock starvation.

## Where this came from

—

## Builds on

- [Backoff](https://semahash.org/vocabularies/bootstrap/patterns/Backoff.md) (composes_with)
- [Cooldown](https://semahash.org/vocabularies/bootstrap/patterns/Cooldown.md) (composes_with)
- [Actor](https://semahash.org/vocabularies/bootstrap/patterns/Actor.md) (references)
- [State](https://semahash.org/vocabularies/bootstrap/patterns/State.md) (references)
- [Lock](https://semahash.org/vocabularies/bootstrap/patterns/Lock.md) (references)

## Used by

- [CausalBarrier](https://semahash.org/vocabularies/bootstrap/patterns/CausalBarrier.md) (references)
- [ContinuousResourceAuction](https://semahash.org/vocabularies/bootstrap/patterns/ContinuousResourceAuction.md) (composes_with)
- [IdempotentWrite](https://semahash.org/vocabularies/bootstrap/patterns/IdempotentWrite.md) (references)
- [MonotonicCounter](https://semahash.org/vocabularies/bootstrap/patterns/MonotonicCounter.md) (references)

## Identity

- Library: bootstrap 0.11.0 (root a6a3d1ff0f98)
- Ref: StateLock#c9c2
- Hash: sema:StateLock#mh:SHA-256:c9c2809bdf97bb6ac17a8ffe428d4aa9a28294b99d64cc8a336a239d26a8afb8

## Links

- Page: https://semahash.org/vocabularies/bootstrap/patterns/StateLock
- JSON: https://semahash.org/vocabularies/bootstrap/patterns/StateLock.json
- Library: https://semahash.org/vocabularies/bootstrap
- Library index: https://semahash.org/vocabularies/bootstrap/index.json
