# at.happyproto.admin.defs

- Kind: defs
- Authority: admin.happyproto.at
- Lexicon: 1
- Published by [happyproto.at](https://lexicon.garden/identity/did:plc:mo7vq4jbioxwafy5zkcc3eux), the NSID's authority

## Links

- [Documentation](https://lexicon.garden/lexicon/did:plc:mo7vq4jbioxwafy5zkcc3eux/at.happyproto.admin.defs)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:mo7vq4jbioxwafy5zkcc3eux/at.happyproto.admin.defs/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:mo7vq4jbioxwafy5zkcc3eux/at.happyproto.admin.defs/analytics)

## #autoscale (`at.happyproto.admin.defs#autoscale`)

Type: object

The autoscaler's settings and what it is waiting on.

### Properties

- `blockedBy` (string): A failed request that holds off new ones until staff retry or cancel it.
- `cooldownUntil` (string · datetime): No new request before this. Absent once it has passed.
- `costEur` (string): What each host it orders costs a month, in euros, as a decimal string.
- `current` (ref, required)
  - Reference: `#freeCapacity`
- `enabled` (boolean, required): On in the provisioner's config, with the GitHub App set up.
- `hosts` (integer): Hosts that are not retired.
- `inFlight` (integer): Requests under way: 0 or 1.
- `lowSince` (string · datetime): Since when free capacity has been below a threshold. Absent while it is fine.
- `maxHosts` (integer): The most hosts it may bring the fleet to.
- `paused` (boolean, required): Paused by staff: no new requests, though one under way carries on.
- `pausedAt` (string · datetime)
- `pausedBy` (string · did): The staff DID that paused it.
- `thresholds` (ref)
  - Reference: `#thresholds`

## #encryptionKey (`at.happyproto.admin.defs#encryptionKey`)

Type: object

An instance's encryption key and where it is in a rotation.

### Properties

- `blockedBy` (string): Why a rotation cannot start now, when it cannot: the code rotateEncryptionKey would refuse with.
  - Constraints: knownValues: OperationInProgress | RotationInProgress | InstanceStopped | NotLive | RotationUnsupported | AgentUnreachable | NotSettled
- `canRotate` (boolean, required): Whether a rotation can start now.
- `failure` (ref): The instance's latest operation, when it failed and the instance with it. Any kind: a KeyMismatch can fail an update or an upgrade too.
  - Reference: `#keyFailure`
- `operation` (ref): The rotate_key or retire_key operation in progress, if any.
  - Reference: `at.happyproto.admin.listInstances#operation`
- `rotatedAt` (string · datetime): When the current key became current. Absent for the key the instance was created with.
- `sealing` (ref): Only while sealing, and only when the instance's host answered.
  - Reference: `#sealing`
- `stage` (string, required): none: one key. rotating: a new key is made but not live yet. sealing: it is live and HappyView is re-sealing what the old key sealed. retiring: the old key is being removed. failed: the instance is failed and its latest operation is a failed rotate_key or retire_key; retrying the instance sends its keys again.
  - Constraints: knownValues: none | rotating | sealing | retiring | failed

## #event (`at.happyproto.admin.defs#event`)

Type: object

One line of a request's timeline.

### Properties

- `at` (string · datetime, required)
- `kind` (string, required)
  - Constraints: knownValues: requested | dispatched | step_started | step_finished | ordering | configuring | verifying | registered | failed | cancelled | retried | cancel_requested | deploy_cancelled
- `message` (string): What happened, in the provisioner's words.
- `runUrl` (string · uri): The GitHub Actions run the event came from.

## #freeCapacity (`at.happyproto.admin.defs#freeCapacity`)

Type: object

Free capacity across the active hosts. An over-committed host counts as none.

### Properties

- `freeDiskGb` (integer)
- `freeMemoryMb` (integer)

## #hostRequest (`at.happyproto.admin.defs#hostRequest`)

Type: object

A tenant host the autoscaler asked for.

### Properties

- `cancelRunUrl` (string · uri)
- `costEur` (string): The host's monthly cost in euros, as a decimal string.
- `createdAt` (string · datetime, required)
- `currentStep` (string): The workflow step running now.
- `deployRunUrl` (string · uri)
- `dispatchedAt` (string · datetime)
- `error` (string): Why it failed.
- `events` (array): Oldest first. Only on a single request.
  - `items` (ref)
    - Reference: `#event`
- `finishedAt` (string · datetime)
- `id` (string, required): A UUID.
- `name` (string, required): The host's name, like tenant-4.
- `requestedBy` (string): system, or the staff DID.
- `state` (string, required)
  - Constraints: knownValues: requested | ordering | configuring | verifying | registered | failed | cancelling | cancelled
- `trigger` (ref)
  - Reference: `#trigger`
- `updatedAt` (string · datetime)
- `workflowRunUrl` (string · uri)

## #keyFailure (`at.happyproto.admin.defs#keyFailure`)

Type: object

### Properties

- `errorCode` (string): The provisioner's error code. KeyMismatch: the host refused an apply that would drop the key the instance seals with. It needs an operator, not a retry.
  - Constraints: knownValues: KeyMismatch
- `kind` (string, required): The operation's kind, as on #operation.
- `operationId` (string, required)

## #sealing (`at.happyproto.admin.defs#sealing`)

Type: object

### Properties

- `previousKeyLive` (boolean, required): Whether the instance runs with both keys. False when its rotate_key has not reached it, for instance because it failed: then remaining reads 0 without anything being re-sealed, and retrying the instance sends both keys again.
- `remaining` (integer, required): Values only the old key opens. The old key is retired once this reaches 0.
  - Constraints: minimum: 0
- `unreadable` (integer, required): Values neither key opens. They were unreadable before the rotation, too.
  - Constraints: minimum: 0

## #thresholds (`at.happyproto.admin.defs#thresholds`)

Type: object

When the autoscaler orders a host: free capacity across active hosts below either figure for sustainSecs, and no request in the last cooldownSecs.

### Properties

- `cooldownSecs` (integer)
- `freeDiskGb` (integer)
- `freeMemoryMb` (integer)
- `sustainSecs` (integer)

## #trigger (`at.happyproto.admin.defs#trigger`)

Type: object

Free capacity when the request was made, and the thresholds it was below.

### Properties

- `freeDiskGb` (integer)
- `freeMemoryMb` (integer)
- `hosts` (array)
  - `items` (ref)
    - Reference: `#triggerHost`
- `lowSince` (string · datetime)
- `thresholds` (ref)
  - Reference: `#thresholds`

## #triggerHost (`at.happyproto.admin.defs#triggerHost`)

Type: object

### Properties

- `freeDiskGb` (integer)
- `freeMemoryMb` (integer)
- `name` (string)

## Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "autoscale": {
      "description": "The autoscaler's settings and what it is waiting on.",
      "properties": {
        "blockedBy": {
          "description": "A failed request that holds off new ones until staff retry or cancel it.",
          "type": "string"
        },
        "cooldownUntil": {
          "description": "No new request before this. Absent once it has passed.",
          "format": "datetime",
          "type": "string"
        },
        "costEur": {
          "description": "What each host it orders costs a month, in euros, as a decimal string.",
          "type": "string"
        },
        "current": {
          "ref": "#freeCapacity",
          "type": "ref"
        },
        "enabled": {
          "description": "On in the provisioner's config, with the GitHub App set up.",
          "type": "boolean"
        },
        "hosts": {
          "description": "Hosts that are not retired.",
          "type": "integer"
        },
        "inFlight": {
          "description": "Requests under way: 0 or 1.",
          "type": "integer"
        },
        "lowSince": {
          "description": "Since when free capacity has been below a threshold. Absent while it is fine.",
          "format": "datetime",
          "type": "string"
        },
        "maxHosts": {
          "description": "The most hosts it may bring the fleet to.",
          "type": "integer"
        },
        "paused": {
          "description": "Paused by staff: no new requests, though one under way carries on.",
          "type": "boolean"
        },
        "pausedAt": {
          "format": "datetime",
          "type": "string"
        },
        "pausedBy": {
          "description": "The staff DID that paused it.",
          "format": "did",
          "type": "string"
        },
        "thresholds": {
          "ref": "#thresholds",
          "type": "ref"
        }
      },
      "required": [
        "enabled",
        "paused",
        "current"
      ],
      "type": "object"
    },
    "encryptionKey": {
      "description": "An instance's encryption key and where it is in a rotation.",
      "properties": {
        "blockedBy": {
          "description": "Why a rotation cannot start now, when it cannot: the code rotateEncryptionKey would refuse with.",
          "knownValues": [
            "OperationInProgress",
            "RotationInProgress",
            "InstanceStopped",
            "NotLive",
            "RotationUnsupported",
            "AgentUnreachable",
            "NotSettled"
          ],
          "type": "string"
        },
        "canRotate": {
          "description": "Whether a rotation can start now.",
          "type": "boolean"
        },
        "failure": {
          "description": "The instance's latest operation, when it failed and the instance with it. Any kind: a KeyMismatch can fail an update or an upgrade too.",
          "ref": "#keyFailure",
          "type": "ref"
        },
        "operation": {
          "description": "The rotate_key or retire_key operation in progress, if any.",
          "ref": "at.happyproto.admin.listInstances#operation",
          "type": "ref"
        },
        "rotatedAt": {
          "description": "When the current key became current. Absent for the key the instance was created with.",
          "format": "datetime",
          "type": "string"
        },
        "sealing": {
          "description": "Only while sealing, and only when the instance's host answered.",
          "ref": "#sealing",
          "type": "ref"
        },
        "stage": {
          "description": "none: one key. rotating: a new key is made but not live yet. sealing: it is live and HappyView is re-sealing what the old key sealed. retiring: the old key is being removed. failed: the instance is failed and its latest operation is a failed rotate_key or retire_key; retrying the instance sends its keys again.",
          "knownValues": [
            "none",
            "rotating",
            "sealing",
            "retiring",
            "failed"
          ],
          "type": "string"
        }
      },
      "required": [
        "stage",
        "canRotate"
      ],
      "type": "object"
    },
    "event": {
      "description": "One line of a request's timeline.",
      "properties": {
        "at": {
          "format": "datetime",
          "type": "string"
        },
        "kind": {
          "knownValues": [
            "requested",
            "dispatched",
            "step_started",
            "step_finished",
            "ordering",
            "configuring",
            "verifying",
            "registered",
            "failed",
            "cancelled",
            "retried",
            "cancel_requested",
            "deploy_cancelled"
          ],
          "type": "string"
        },
        "message": {
          "description": "What happened, in the provisioner's words.",
          "type": "string"
        },
        "runUrl": {
          "description": "The GitHub Actions run the event came from.",
          "format": "uri",
          "type": "string"
        }
      },
      "required": [
        "at",
        "kind"
      ],
      "type": "object"
    },
    "freeCapacity": {
      "description": "Free capacity across the active hosts. An over-committed host counts as none.",
      "properties": {
        "freeDiskGb": {
          "type": "integer"
        },
        "freeMemoryMb": {
          "type": "integer"
        }
      },
      "type": "object"
    },
    "hostRequest": {
      "description": "A tenant host the autoscaler asked for.",
      "properties": {
        "cancelRunUrl": {
          "format": "uri",
          "type": "string"
        },
        "costEur": {
          "description": "The host's monthly cost in euros, as a decimal string.",
          "type": "string"
        },
        "createdAt": {
          "format": "datetime",
          "type": "string"
        },
        "currentStep": {
          "description": "The workflow step running now.",
          "type": "string"
        },
        "deployRunUrl": {
          "format": "uri",
          "type": "string"
        },
        "dispatchedAt": {
          "format": "datetime",
          "type": "string"
        },
        "error": {
          "description": "Why it failed.",
          "type": "string"
        },
        "events": {
          "description": "Oldest first. Only on a single request.",
          "items": {
            "ref": "#event",
            "type": "ref"
          },
          "type": "array"
        },
        "finishedAt": {
          "format": "datetime",
          "type": "string"
        },
        "id": {
          "description": "A UUID.",
          "type": "string"
        },
        "name": {
          "description": "The host's name, like tenant-4.",
          "type": "string"
        },
        "requestedBy": {
          "description": "system, or the staff DID.",
          "type": "string"
        },
        "state": {
          "knownValues": [
            "requested",
            "ordering",
            "configuring",
            "verifying",
            "registered",
            "failed",
            "cancelling",
            "cancelled"
          ],
          "type": "string"
        },
        "trigger": {
          "ref": "#trigger",
          "type": "ref"
        },
        "updatedAt": {
          "format": "datetime",
          "type": "string"
        },
        "workflowRunUrl": {
          "format": "uri",
          "type": "string"
        }
      },
      "required": [
        "id",
        "name",
        "state",
        "createdAt"
      ],
      "type": "object"
    },
    "keyFailure": {
      "properties": {
        "errorCode": {
          "description": "The provisioner's error code. KeyMismatch: the host refused an apply that would drop the key the instance seals with. It needs an operator, not a retry.",
          "knownValues": [
            "KeyMismatch"
          ],
          "type": "string"
        },
        "kind": {
          "description": "The operation's kind, as on #operation.",
          "type": "string"
        },
        "operationId": {
          "type": "string"
        }
      },
      "required": [
        "operationId",
        "kind"
      ],
      "type": "object"
    },
    "sealing": {
      "properties": {
        "previousKeyLive": {
          "description": "Whether the instance runs with both keys. False when its rotate_key has not reached it, for instance because it failed: then remaining reads 0 without anything being re-sealed, and retrying the instance sends both keys again.",
          "type": "boolean"
        },
        "remaining": {
          "description": "Values only the old key opens. The old key is retired once this reaches 0.",
          "minimum": 0,
          "type": "integer"
        },
        "unreadable": {
          "description": "Values neither key opens. They were unreadable before the rotation, too.",
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "previousKeyLive",
        "remaining",
        "unreadable"
      ],
      "type": "object"
    },
    "thresholds": {
      "description": "When the autoscaler orders a host: free capacity across active hosts below either figure for sustainSecs, and no request in the last cooldownSecs.",
      "properties": {
        "cooldownSecs": {
          "type": "integer"
        },
        "freeDiskGb": {
          "type": "integer"
        },
        "freeMemoryMb": {
          "type": "integer"
        },
        "sustainSecs": {
          "type": "integer"
        }
      },
      "type": "object"
    },
    "trigger": {
      "description": "Free capacity when the request was made, and the thresholds it was below.",
      "properties": {
        "freeDiskGb": {
          "type": "integer"
        },
        "freeMemoryMb": {
          "type": "integer"
        },
        "hosts": {
          "items": {
            "ref": "#triggerHost",
            "type": "ref"
          },
          "type": "array"
        },
        "lowSince": {
          "format": "datetime",
          "type": "string"
        },
        "thresholds": {
          "ref": "#thresholds",
          "type": "ref"
        }
      },
      "type": "object"
    },
    "triggerHost": {
      "properties": {
        "freeDiskGb": {
          "type": "integer"
        },
        "freeMemoryMb": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        }
      },
      "type": "object"
    }
  },
  "id": "at.happyproto.admin.defs",
  "lexicon": 1
}
```
