# app.cosmosis.supercluster

> A derived grouping of accounts defined as a set expression (union / intersection / difference) over Clusters and/or other Superclusters. No members are stored directly; membership is evaluated at query time by resolving the expression tree. Superclusters are always permissioned: each lives inside its own dedicated Space of type `app.cosmosis.superclusterSpace`, with the Space `skey` and record `rkey` sharing the same tid. (Every leaf of an expression is ultimately a Cluster, and Clusters are always permissioned, so a public Supercluster could not be resolved by third parties.) To resolve a Supercluster, the reader must have access to the Space of every Cluster and Supercluster it references, directly or transitively.

- Kind: record
- Record key: tid
- Authority: cosmosis.app
- Lexicon: 1
- Published by [cosmosis.app](https://lexicon.garden/identity/did:plc:ahyfb4aosesmcpkc34kmc6mo), the NSID's authority

## Links

- [Documentation](https://lexicon.garden/lexicon/did:plc:ahyfb4aosesmcpkc34kmc6mo/app.cosmosis.supercluster)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:ahyfb4aosesmcpkc34kmc6mo/app.cosmosis.supercluster/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:ahyfb4aosesmcpkc34kmc6mo/app.cosmosis.supercluster/analytics)

## Record (`app.cosmosis.supercluster`)

Type: record · key tid

### Properties

- `createdAt` (string · datetime, required)
- `description` (string)
  - Constraints: maxLength: 300
- `expression` (union, required): Root node of the expression tree: a set operation over child nodes, or a single leaf reference to a Cluster or Supercluster. The union is open so new node kinds can be added later without a breaking change.
  - One of: `#setOperation`, `#clusterRef`, `#superclusterRef`
- `name` (string, required)
  - Constraints: maxLength: 100

## #clusterRef (`app.cosmosis.supercluster#clusterRef`)

Type: object

A leaf node referencing a Cluster record. Resolves to the set of `subject`s of that Cluster's clusterMember records. The resolver must have access to the referenced Cluster's Space.

### Properties

- `uri` (string · uri, required): The space record URI of the referenced `app.cosmosis.cluster` record.

## #setOperation (`app.cosmosis.supercluster#setOperation`)

Type: object

Combines two or more expression nodes using a set operation. 'difference' expects exactly 2 operands (A minus B); deeper subtractions should be expressed with nested setOperations.

### Properties

- `op` (string, required)
  - Constraints: knownValues: union | intersection | difference
- `operands` (array, required)
  - Constraints: minLength: 2
  - `items` (union): A child node: a nested set operation, or a leaf reference to a Cluster or Supercluster.
    - One of: `#setOperation`, `#clusterRef`, `#superclusterRef`

## #superclusterRef (`app.cosmosis.supercluster#superclusterRef`)

Type: object

A leaf node referencing another Supercluster record, enabling composition. Cycle detection must be enforced at write time, and resolvers must also guard against cycles (a referenced Supercluster can be edited after this one is written).

### Properties

- `uri` (string · uri, required): The space record URI of the referenced `app.cosmosis.supercluster` record.

## Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "clusterRef": {
      "description": "A leaf node referencing a Cluster record. Resolves to the set of `subject`s of that Cluster's clusterMember records. The resolver must have access to the referenced Cluster's Space.",
      "properties": {
        "uri": {
          "description": "The space record URI of the referenced `app.cosmosis.cluster` record.",
          "format": "uri",
          "type": "string"
        }
      },
      "required": [
        "uri"
      ],
      "type": "object"
    },
    "main": {
      "description": "A derived grouping of accounts defined as a set expression (union / intersection / difference) over Clusters and/or other Superclusters. No members are stored directly; membership is evaluated at query time by resolving the expression tree. Superclusters are always permissioned: each lives inside its own dedicated Space of type `app.cosmosis.superclusterSpace`, with the Space `skey` and record `rkey` sharing the same tid. (Every leaf of an expression is ultimately a Cluster, and Clusters are always permissioned, so a public Supercluster could not be resolved by third parties.) To resolve a Supercluster, the reader must have access to the Space of every Cluster and Supercluster it references, directly or transitively.",
      "key": "tid",
      "record": {
        "properties": {
          "createdAt": {
            "format": "datetime",
            "type": "string"
          },
          "description": {
            "maxLength": 300,
            "type": "string"
          },
          "expression": {
            "description": "Root node of the expression tree: a set operation over child nodes, or a single leaf reference to a Cluster or Supercluster. The union is open so new node kinds can be added later without a breaking change.",
            "refs": [
              "#setOperation",
              "#clusterRef",
              "#superclusterRef"
            ],
            "type": "union"
          },
          "name": {
            "maxLength": 100,
            "type": "string"
          }
        },
        "required": [
          "name",
          "expression",
          "createdAt"
        ],
        "type": "object"
      },
      "type": "record"
    },
    "setOperation": {
      "description": "Combines two or more expression nodes using a set operation. 'difference' expects exactly 2 operands (A minus B); deeper subtractions should be expressed with nested setOperations.",
      "properties": {
        "op": {
          "knownValues": [
            "union",
            "intersection",
            "difference"
          ],
          "type": "string"
        },
        "operands": {
          "items": {
            "description": "A child node: a nested set operation, or a leaf reference to a Cluster or Supercluster.",
            "refs": [
              "#setOperation",
              "#clusterRef",
              "#superclusterRef"
            ],
            "type": "union"
          },
          "minLength": 2,
          "type": "array"
        }
      },
      "required": [
        "op",
        "operands"
      ],
      "type": "object"
    },
    "superclusterRef": {
      "description": "A leaf node referencing another Supercluster record, enabling composition. Cycle detection must be enforced at write time, and resolvers must also guard against cycles (a referenced Supercluster can be edited after this one is written).",
      "properties": {
        "uri": {
          "description": "The space record URI of the referenced `app.cosmosis.supercluster` record.",
          "format": "uri",
          "type": "string"
        }
      },
      "required": [
        "uri"
      ],
      "type": "object"
    }
  },
  "id": "app.cosmosis.supercluster",
  "lexicon": 1
}
```
