# xyz.quasigod.lab.letta.lock

> Published by [quasigod.spaces-alpha.bsky.network](https://lexicon.garden/identity/did:plc:7pezv7mb4agwyktraauhl26g)

## Description

Advisory single-writer lock for the space. One instance per space, fixed rkey `self`.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:7pezv7mb4agwyktraauhl26g/xyz.quasigod.lab.letta.lock)
- [Documentation](https://lexicon.garden/lexicon/did:plc:7pezv7mb4agwyktraauhl26g/xyz.quasigod.lab.letta.lock/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:7pezv7mb4agwyktraauhl26g/xyz.quasigod.lab.letta.lock/examples)

## Definitions

### `xyz.quasigod.lab.letta.lock`

**Type**: `record`

Held-writer lock record. Writers coordinate through this record: acquire (put), work, release (delete); an expired lock is stolen by the next writer. This is the in-process fast-path guard; cross-device safety against stray concurrent writes comes from per-record CAS (swapRecord) on data records.

**Key**: `literal:self`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `nonce` | `string` | Yes | Random value proving ownership; read back to confirm the holder is still the writer before releasing. |
| `holder` | `string` | Yes | Identifier of the backend instance holding the lock. |
| `expiresAt` | `string` (datetime) | Yes | TTL deadline. A lock past its deadline is treated as a crashed writer and stolen. |

## Raw Schema

```json
{
  "id": "xyz.quasigod.lab.letta.lock",
  "defs": {
    "main": {
      "key": "literal:self",
      "type": "record",
      "record": {
        "type": "object",
        "required": [
          "holder",
          "nonce",
          "expiresAt"
        ],
        "properties": {
          "nonce": {
            "type": "string",
            "maxLength": 64,
            "description": "Random value proving ownership; read back to confirm the holder is still the writer before releasing."
          },
          "holder": {
            "type": "string",
            "maxLength": 256,
            "description": "Identifier of the backend instance holding the lock."
          },
          "expiresAt": {
            "type": "string",
            "format": "datetime",
            "description": "TTL deadline. A lock past its deadline is treated as a crashed writer and stolen."
          }
        }
      },
      "description": "Held-writer lock record. Writers coordinate through this record: acquire (put), work, release (delete); an expired lock is stolen by the next writer. This is the in-process fast-path guard; cross-device safety against stray concurrent writes comes from per-record CAS (swapRecord) on data records."
    }
  },
  "$type": "com.atproto.lexicon.schema",
  "lexicon": 1,
  "description": "Advisory single-writer lock for the space. One instance per space, fixed rkey `self`."
}
```
