# Annotations, CRDs, and receipts

When Kix compiles and deploys a cluster, it attaches `kix.run/*` labels and annotations to your manifests and writes lightweight tracking records into the cluster. You rarely need to set these annotations by hand because `scope` builders and the `kix` CLI manage them automatically, but this page is helpful when you are inspecting rendered YAML, debugging rollout order, or reading a deploy receipt from CI.

:::note[Helpful background]
- [05. Basic graph and deploy loop](/docs/tutorials/05-basic-graph-and-deploy-loop/): see how `kix plan` and `kix deploy` use dependency metadata to apply resources in waves.
- [The dependency graph as the model](/docs/explanation/the-dependency-graph/): understand how `kix.run/depends-on` annotations are derived from Nix string context.
- [Server-side apply, field ownership, and drift](/docs/explanation/server-side-apply-and-drift/): learn how Kix tracks field ownership, cedes controller-managed fields, and detects drift.
- [Server-Side Apply (Kubernetes docs)](https://kubernetes.io/docs/reference/using-api/server-side-apply/): review how Kubernetes manages field ownership across multiple controllers and tools.
:::

This page is maintained alongside `kix/lib/core/annotations.nix`, `kix/lib/core/activation.nix`, and `cli/kix-core/src/manifest/keys.rs`.

## Annotation and label catalog

Most `kix.run/*` metadata is stamped automatically by resource builders (`scope.mkResource`, `scope.mkSecret`, `scope.mkCRD`, `scope.mkCRDRef`) or by the `kix` CLI during load and apply. Package authors should use the corresponding builder arguments (`ownership.cede`, `readiness`, `holdsData`, `kix.untrackedRef`) rather than writing `kix.run/*` annotations directly.

### Labels

| Label | Placed on | Meaning |
| --- | --- | --- |
| `app.kubernetes.io/managed-by: kix` | Every Kix-rendered resource and CRD record | Identifies objects managed by Kix (required by [validation check 8](/docs/reference/validation-checks/)). Pruning and garbage collection determine which Kix cluster deploys an object from its `kix.run/identity-hash` and each Kix cluster's [`PackageInstanceRevision`](#packageinstancerevision) objects. |
| `kix.run/cluster` | `Activation` and `PackageInstanceRevision` resources | Names the Kix cluster that owns the record or revision so multiple Kix clusters can share a single Kubernetes cluster. |
| `kix.run/kubernetes-uid` | `Activation` resources of a definition that sets `cluster.kubernetes.uid` | The UID of the Kubernetes cluster's `kube-system` Namespace the build was bound to. While any record carries it, the Kubernetes cluster refuses definitions that do not set the UID. See [Bind a cluster definition to its Kubernetes cluster](/docs/how-to/operate-a-cluster/bind-a-cluster-definition-to-its-kubernetes-cluster/). |
| `kix.run/consumer` | `Namespace` resources in consumer clusters | Names the consumer cluster (built with `kix.interface`) that owns the namespace, allowing platform network policies to select consumer pods. |
| `kix.run/derived` | Derived network policies | `"true"` on network policy resources synthesized by Kix's network policy plugin. (Derived `PodDisruptionBudget` objects do not carry this label.) |
| `kix.run/policy-type` | Derived network policies | Rule category that produced a derived network policy (`"default-deny"`, `"caller-ingress"`, `"scrape"`, `"cr-operand"`, `"apiserver-supplement"`, `"external-ingress-supplement"`, `"gateway"`, `"ingress-controller"`, `"operator-managed-workload"`, or `"platform-intent"`). Basic per-workload egress and ingress policies carry `kix.run/derived: "true"` without `kix.run/policy-type`. |
| `kix.run/db-cluster` | `stackgres-database` and `cnpg-database` resources | Name of the target PostgreSQL cluster resource that the database belongs to. |
| `pod-security.kubernetes.io/enforce` | `Namespace` resources | Pod Security Admission level (`privileged`, `baseline`, or `restricted`) set from `namespaces.<name>.podSecurity`, package `meta.podSecurity`, or a platform interface. |

### Build identity and live ownership annotations

| Annotation | Written by | Meaning |
| --- | --- | --- |
| `kix.run/identity-hash` | CLI on load | 32-character store hash of the sealed manifest. Changes whenever the manifest content or any dependency in its store context changes. |
| `kix.run/package` | CLI on load | Name of the owning package instance. |
| `kix.run/package-namespace` | CLI on load | Namespace of the owning package instance. |
| `kix.run/lifecycle` | CLI on load | Lifecycle classification from `meta.lifecycle` (`"stateful"`, `"stateless"`, or `"ephemeral"`). Only `"stateful"` changes Kix behavior (requiring `holdsData` on custom resources in the instance and marking resources as stateful during migration checks); other values are informational. |
| `kix.run/holds-data` | `scope.mkResource` / `scope.mkCR` | `"true"` or `"false"`. Indicates whether deleting the resource loses persistent data. Derived automatically for `PersistentVolumeClaim`, `PersistentVolume`, and `StatefulSet` resources with `volumeClaimTemplates`, and required via CRD `holdsData` for custom resources in stateful packages. |
| `kix.run/built-via` | CLI on `Activation` | Store path of the cluster activation index (`kix-activation-<cluster>.json`), a JSON file that names the store paths of `kix-packages.json`, `kix-image-sources.json`, and related build metadata. Records written by Kix 0.6 and earlier name the activation output directory (`k8s-activation-<cluster>`) instead, and Kix still reads them. |
| `kix.run/withdrawn-kix` | CLI on `Activation` | Withdrawn Kix version that deployed or rolled back to this record when `KIX_ALLOW_WITHDRAWN` was set to that version. See [Withdrawn releases](/docs/reference/cli/deploy/#withdrawn-releases). |
| `kix.run/downgraded-from` | CLI on `Activation` | Newer Kix version that last deployed the cluster, recorded when an older minor version deploys or rolls back to this `Activation` with `KIX_ALLOW_DOWNGRADE` set. See [Deploys by an older Kix](/docs/reference/cli/deploy/#deploys-by-an-older-kix). |

### Deployment graph and apply behavior annotations

| Annotation | Set via | Meaning |
| --- | --- | --- |
| `kix.run/depends-on` | Nix string context, `requires`, `controller`, `extraDeps` | Comma-separated dependency entries (`<hash>`, `requires:<hash>`, `controller:<hash>`, `extra:<hash>`) that define the deployment dependency graph. All prefixes affect deploy and delete order the same way. A `controller:<hash>` entry comes from `controller` on `scope.mkCRD` or `scope.mkCRDRef`, and Kix uses it to report the controller's status when deleting a custom resource times out (`[K2794]`). |
| `kix.run/readiness` | `readiness` on `scope.mkCRD` / `scope.mkCRDRef`, or on `scope.mkCR` for one resource | JSON readiness rule evaluated by `kix deploy` for custom resources. See [`kix.run/readiness`](#kixrunreadiness). |
| `kix.run/rerun` | `scope.mkJob`, on every `Job` it builds | `"on-change"` on a `Job` resource. Instructs `kix deploy`, `kix rollback`, and the operator to delete and recreate the Job when its `kix.run/rerun-hash` changes. `kix deploy` and `kix rollback` also recreate it when its previous run failed. A change that leaves the Job's own manifest alone, such as a new label on its namespace, updates the Job in place without running it again. |
| `kix.run/rerun-hash` | `scope.mkResource`, on every resource that carries `kix.run/rerun` | Hash of the content that triggers a rerun. Combines the resource's `out.contentHash` with the `out.contentHash` of each Kix-built Secret and ConfigMap that its pod reads through a volume, `env`, or `envFrom` (or equals `out.contentHash` when the pod reads none). Excludes `kix.run/*` metadata and other dependencies. Pod template `checksum/*` annotations are part of the Job's own manifest, so changing one (such as an annotation set to another resource's `out.contentHash`) also reruns the Job. Jobs deployed before Kix added this annotation run once more on the first deploy after upgrading. |
| `kix.run/cede-fields` | `ownership.cede` on `scope.mkResource` / `scope.mkCRD` | Comma-separated field paths another controller may take over after creation. See [`kix.run/cede-fields`](#kixruncede-fields). |
| `kix.run/expects` | `kix.untrackedRef { kind; name; by?; }` | Comma-separated `apiVersion\|Kind\|name` entries that `kix deploy` waits to exist before applying the resource. See [`kix.run/expects`](#kixrunexpects). |

### Retired annotations

Earlier versions of Kix wrote two additional annotations onto every object
after applying it. Kix no longer writes them, and the first deploy after
upgrading removes them (see
[The first deploy after upgrading](/docs/explanation/server-side-apply-and-drift/#the-first-deploy-after-upgrading)).

| Annotation | What it held | Where Kix keeps it now |
| --- | --- | --- |
| `kix.run/activations` | Comma-separated identity hashes of the `Activation` records that included the object. | [`status.revisions`](#activation-spec-and-status-fields) on the `Activation` record, which links to `PackageInstanceRevision` objects listing the objects. |
| `kix.run/applied-hash` | Hash of the fields Kix owned after its last apply. | [`status.applied`](#packageinstancerevision) on the revision that lists the object. |

If another Kix cluster on an earlier version also deploys a shared object, Kix
keeps both annotations on that object until the other cluster upgrades, because
the earlier version checks `kix.run/activations` before deleting orphans.
Meanwhile, Kix appends its own deployment record hash to `kix.run/activations`.

### Field manager

Kix applies every object with Server-Side Apply under the field manager
`kix/<cluster>`, where `<cluster>` is the Kix cluster's name (such as
`kix/production`). Kubernetes records each field manager in
`metadata.managedFields`, showing which Kix clusters manage the object. When
two Kix clusters set conflicting values for a field on a shared object,
Kubernetes rejects the second apply and Kix stops with `[K5636]`.

Earlier versions of Kix applied under the shared field manager `kix` for every
Kix cluster. On the first deploy after upgrading, Kix renames `kix` to
`kix/<cluster>` on each object listed in this cluster's deployment records, and
removes the `Update` entry under `kix` left by the retired annotations. On
objects also deployed by another Kix cluster, Kix leaves the `kix` entry in
place until every sharing cluster has its own `kix/<cluster>` entry and has
upgraded to revisions. On an object never listed in this cluster's deployment
records, Kix applies without force and adds `kix/<cluster>` alongside any
existing `kix` entry rather than claiming `kix` as its own.

#### `kix.run/readiness`

Stamped on custom resources built via `scope.mkCR` when the CRD or CRD reference declares `readiness`, or when `scope.mkCR` receives its own `readiness`, which replaces the kind's:

| CRD `readiness` declaration | Stamped JSON value | When `kix deploy` considers the resource ready |
| --- | --- | --- |
| `{ path = "/status/phase"; equals = "Ready"; }` | `{"equals":"Ready","path":"/status/phase"}` | The JSON pointer `path` equals `"Ready"` (booleans and numbers are compared as their JSON text, such as `"true"`). |
| `{ path = "/status/updateStatus"; notEquals = "failed"; }` | `{"notEquals":"failed","path":"/status/updateStatus"}` | The JSON pointer `path` is absent or holds any value other than `"failed"`. |
| `{ condition = { type = "Programmed"; status = "True"; }; }` | `{"condition":{"status":"True","type":"Programmed"}}` | `status.conditions` contains an entry with matching `type` and `status`. |
| `{ condition = { type = "Valid"; status = "True"; }; failed = [ { condition = { type = "Valid"; status = "False"; }; } ]; }` | `{"condition":{"status":"True","type":"Valid"},"failed":[{"condition":{"status":"False","type":"Valid"}}]}` | Ready as in the row above. When a `failed` entry matches instead, `kix deploy` stops waiting and fails the resource with the controller's message. |

A `failed` entry is `{ condition = { type; status; reason ? ...; }; }` (the reason is matched only when declared) or `{ path; equals; rejected ? false; hint ? ...; message ? ...; }`, where `rejected = true` makes the message say to change the object (the default for conditions), `hint` is the next step for a runtime outcome, and `message` is a JSON pointer, or a list of them, whose values the message quotes (stamped as a list). A match counts once the condition's `observedGeneration`, or `status.observedGeneration`, has reached `metadata.generation`; without a generation, once the condition's `lastTransitionTime` is later than this deploy's apply of the object (an earlier one is not reported); and with neither field, once the match has held for ten seconds of polling. A version of Kix that predates `failed` ignores the key and waits as before.

Two more keys can sit beside the ready rule:

- `observedGeneration` names the status field where the controller reports the generation it has acted on, as a JSON pointer such as `"/status/desiredGeneration"`, or is `false` when the kind reports none. Without it, Kix reads `status.observedGeneration`. The ready rule, the `failed` entries, and `pendingRestart` wait until that field has reached `metadata.generation`. A declared field that is absent counts as not reached yet, while an absent `status.observedGeneration` imposes no wait. A condition's own `observedGeneration` still comes first. A value that is neither a JSON pointer nor `false` makes Kix ignore the whole annotation.
- `pendingRestart` is `{ condition = { type; status; reason ? ...; }; hint ? ...; }` or `{ path; equals; hint ? ...; message ? ...; }`. It names the state in which the controller has accepted the spec and the running workload keeps the previous one until it restarts. When it matches on a ready resource whose status is current, `kix deploy` reports the resource as ready with a restart pending, quoting the controller's message and the hint. Without a generation, a condition that last changed before this deploy applied the resource is not reported. The JSON deploy log reports it as an `awaiting_restart` detail with the message.

A version of Kix that predates these keys ignores them, waits on `status.observedGeneration`, and reports plain ready.

:::tip[Use it in a task]
See [Declare readiness for custom resources](/docs/how-to/author-packages-and-clusters/declare-readiness-for-custom-resources/) for examples of custom resource readiness rules.
:::

#### `kix.run/cede-fields`

Generated from `ownership.cede = [ "spec.versions" "webhooks[*].rules" ];` on `scope.mkResource` or `scope.mkCRD`. Paths use server-side apply field notation without a leading dot. In lists, `[*]` matches any item, `[2]` matches zero-based index `2`, and key selectors such as `[name="web"]` or `spec.ports[port=53,protocol="UDP"].name` match an item by its key fields (in the order shown in the API server's conflict message). Write string values in double quotes and numbers without quotes: `[port=53]` matches the number `53`, and `[name="1"]` matches the string `"1"`. When an apply receives `409 Conflict` from the API server and every conflicting path falls under a declared `kix.run/cede-fields` prefix, `kix deploy` retries the apply once with the ceded fields omitted so the external controller retains ownership of those fields. Forced applies (whether reverting drift or running with `--force-conflicts`) also omit any ceded field owned by another manager on the live object, so that manager keeps it.

:::tip[Use it in a task]
See [Cede fields to a controller](/docs/how-to/adopt-existing-resources/cede-fields-to-a-controller/) and [Server-side apply, field ownership, and drift](/docs/explanation/server-side-apply-and-drift/).
:::

#### `kix.run/expects`

Generated from the experimental attribute-set form of [`kix.untrackedRef`](/docs/reference/composition-helpers/#facts-and-untrackedref) when `kind` is specified (`kix.untrackedRef { apiVersion = "v1"; kind = "Secret"; name = "webhook-cert"; by = self.certJob; }`). Before applying the resource, `kix deploy` waits up to 180 seconds for each `apiVersion|Kind|name` target to exist.

### Secret annotations

| Annotation | Set via | Meaning |
| --- | --- | --- |
| `kix.run/secret-keys` | `scope.mkSecret` | Comma-separated list of keys declared on the Secret. |
| `kix.run/secret-sources` | `scope.mkSecret` | Comma-separated `<key>=<source>` pairs (`inline`, `plain`, `sops`, `controller`, or `*=controller`) read by the `security.secretSource` scorecard rule. |
| `kix.run/sops-source` | `scope.mkSecret` (`source`) | Store path of the encrypted SOPS file decrypted at deploy time. |
| `kix.run/sops-digest` | `scope.mkSecret` (`source`) | SHA-256 of the encrypted SOPS file, in hex. `kix deploy` checks the file against it before decrypting. |
| `kix.run/secret-type` | `scope.mkSecret` (`type`) | Kubernetes Secret type (defaults to `"Opaque"`). |
| `kix.run/classification` | `scope.mkSecret` (`meta.classification`) | Data classification (such as `"configuration"`). |
| `kix.run/rotation-policy` | `scope.mkSecret` (`meta.rotationPolicy`) | Rotation policy metadata. |

### Package marker annotations

| Annotation | Meaning |
| --- | --- |
| `kix.run/operand-of` | `"<group>/<Kind>/<name>"` of the operator custom resource whose runtime pods a `Service`, `NetworkPolicy`, or `PodDisruptionBudget` selects. |
| `kix.run/network-policy-widened` | Comma-separated reason codes (such as `world-egress-services` or `pod-start-egress-open`) added to a generated `NetworkPolicy` when it allows broader traffic than intended, such as CIDR rules matching in-cluster IPs or brief outbound traffic during pod startup. Written by the standard `NetworkPolicy` enforcer and checked by the [`security.networkPolicyWidened`](/docs/reference/scorecard-and-rules/#built-in-security-rules) scorecard rule, which warns when a `cluster.network` setting can narrow the rule and reports platform limits at `info`. |
| `kix.run/monitors-external-service` | `"true"` on a `ServiceMonitor` or `VMServiceScrape` that intentionally targets a Service outside the Kix build. |
| `kix.run/role` | Reserved key (`kix.keys.role`); not currently stamped by built-in builders or packages. |

## Activation

`Activation` (`activations.kix.run`, API version `kix.run/v1alpha1`) is the cluster-scoped custom resource that serves as the root of a Kix cluster's deployment graph and records deployment state on the Kubernetes cluster. When the CLI loads a build, it names the `Activation` `<cluster>-<12-char identity-hash prefix>` so each distinct build gets its own historical record on the cluster.

```yaml
apiVersion: kix.run/v1alpha1
kind: Activation
metadata:
  name: production-jak8b4glx8fn
  labels:
    app.kubernetes.io/managed-by: kix
    kix.run/cluster: production
  annotations:
    kix.run/identity-hash: jak8b4glx8fnbq2c3hkb0khyyvigb96i
    kix.run/built-via: /nix/store/...-kix-activation-production.json
    kix.run/depends-on: ...
spec:
  instances:
    apps:
      web: web
    data:
      postgres: postgres
```

### `Activation` spec and status fields

| Path | Type | Meaning |
| --- | --- | --- |
| `spec.instances` | `object` (`{ <namespace>: { <instance>: string } }`) | Nested map from namespace and instance name to the `PackageInstance` resource name for every active instance in the build. |
| `spec.consumers` | `object` (optional) | Hosted consumer clusters (`{ <consumer>: { interface, sha256 } }`) declared by a platform cluster. |
| `spec.interfaces` | `object` (optional) | Platform interfaces (`{ <platform>: { consumer, path, sha256 } }`) that a consumer cluster was built against. |
| `spec.source` | `object` (optional) | Build location for the Kix operator (`{ type: "storePath", path }`). Written only by `kix deploy --operator` and `kix rollback --operator`. |
| `spec.request` | `string` (optional) | Random token written on each run of `kix deploy --operator` or `kix rollback --operator` to ask the Kix operator to deploy this record. Compared by equality with `status.startedRequest` and `status.finishedRequest`, so clock differences between machines do not matter. Commands without `--operator` never set it. |
| `status.phase` | `string` | Lifecycle state: `Queued`, `Deploying`, `Active`, `Degraded`, `Failed`, `Partial`, or `Superseded`. |
| `status.startedRequest` | `string` (optional) | Most recent `spec.request` token the Kix operator has started processing. When `spec.request` has a different value, that request is still waiting to start. |
| `status.finishedRequest` | `string` (optional) | Most recent `spec.request` token the Kix operator has finished applying. `kix deploy --operator` and `kix rollback --operator` wait until this field or `status.failedRequest.request` matches `spec.request`, or the record enters `Failed` or `Superseded`. |
| `status.failedRequest` | `object` (optional) | Most recent `spec.request` that failed on an `Active` or `Degraded` record, written when redeploying the current build fails. Contains `request` (the `spec.request` token), `reason` (why the redeploy failed), and `at` (RFC 3339 UTC timestamp). Because the operator leaves `status.finishedRequest` unchanged, older versions of Kix keep waiting rather than reporting success. |
| `status.partial` | `object` (optional) | Present only when `status.phase` is `Partial`, written by [`kix deploy --only`](/docs/reference/cli/deploy/#deploy-one-instance-at-a-time). Contains `only` (sorted `namespace/instance` names of every selected and required instance applied so far across `--only` runs of this build) and `at` (RFC 3339 UTC timestamp). Cleared when a new deploy of this record starts or when the record is marked `Superseded`. |
| `status.receipt` | `object` | Provenance record written by `kix deploy` (see [Deploy receipt schema](#deploy-receipt-schema)). |
| `status.revisions` | `object` (optional) | Map of [`PackageInstanceRevision`](#packageinstancerevision) objects for this deploy, written when the deploy starts and updated when it finishes. See [Revision map](#revision-map). |
| `status.packageIndex` | `object` (optional) | Legacy map of package instances and cluster-level resources to manifest identity hashes, written only by earlier versions of Kix. Kix still reads it on older records. See [The package index](#the-package-index). |
| `status.orphansKeptFrom` | `array of string` (optional) | Legacy list of previous activation build paths whose orphaned resources were kept when `--prune` was omitted. Kix still reads it on older records and clears it when a deploy finishes (replaced by the kept-orphans revision). |

### Revision map

`status.revisions` links one revision per package instance in the build, one
revision for cluster-level objects outside any package instance, and (when
unpruned orphans remain) one kept-orphans revision.

| Path | Type | Meaning |
| --- | --- | --- |
| `format` | `integer` | Schema version of the revision map. Kix reads and writes `1`, and refuses to prune or garbage-collect when a deployment record has a `format` it cannot read. |
| `instances` | `object` | Map from `namespace/instance` to the `PackageInstanceRevision` name for that package instance. |
| `clusterLevel` | `string` | Name of the `PackageInstanceRevision` for cluster-level objects outside any package instance, such as Namespaces. |
| `keptOrphans` | `string` (optional) | Name of the `PackageInstanceRevision` listing orphans kept by this deploy or earlier deploys that ran without `--prune`. `kix deploy --prune` and `kix gc` delete the objects it lists. |

```yaml
status:
  revisions:
    format: 1
    instances:
      apps/web: production-3f1c0a9e5b7d2c4e8a6f0b1d3c5e7a9b
      data/postgres: production-8e2d4c6a0b1f3e5d7c9a2b4d6f8e0a1c
    clusterLevel: production-1a3c5e7b9d0f2a4c6e8b0d1f3a5c7e9b
    keptOrphans: production-5b7d9f1a3c5e7b9d0f2a4c6e8b0d1f3a
```

When a package instance is unchanged from the previous deploy,
`status.revisions` reuses the existing revision name.

### The package index

Earlier versions of Kix wrote `status.packageIndex` to list a deploy's objects
grouped by package. Kix still reads `status.packageIndex` on older records and
writes [revisions](#packageinstancerevision) instead on new deploys.
Commands that read the cluster without building it, such as
[`kix status`](/docs/reference/cli/status/) and `kix diff`, use it to group
objects by package and to find objects that are gone from the cluster.

| Path | Type | Meaning |
| --- | --- | --- |
| `format` | `integer` | Version of the index's shape. Readers check it before the rest. |
| `packages` | `object` | Map from `namespace/instance` to `{ instance, resources }`: the identity hash of the package's `PackageInstance`, and the identity hashes of its resources. |
| `clusterLevel` | `array of string` | Identity hashes of the resources no package lists, such as Namespaces. |
| `names` | `object` (optional) | Map from each object's identity hash to `[kind, namespace, name]`. `namespace` is `""` for a cluster-scoped object. |
| `groups` | `object` (optional) | Map from each object's identity hash to its API group (such as `apps` or `kix.run`) for objects in `names` outside the core `v1` API group. Kix treats any object in `names` without a `groups` entry as part of the core `v1` API group, including in indexes written by earlier versions. |

```yaml
status:
  packageIndex:
    format: 1
    packages:
      default/web:
        instance: 1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
        resources: [3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]
    clusterLevel: [4aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]
    names:
      1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: [PackageInstance, default, web]
      3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: [ConfigMap, default, web-config]
      4aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: [Namespace, "", default]
    groups:
      1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: kix.run
```

The index had a size limit of 150 KiB, so a record of a large deploy may
have an index without `names`, or none.

### Activation lifecycle and operator finalizer

- **`Queued` -> `Deploying` -> `Active` | `Degraded` | `Failed` | `Partial` -> `Superseded`**: `kix deploy` creates or updates the `Activation` record before applying the first wave. `Active` means every resource applied and became ready. `Degraded` means the deploy completed but one or more resources failed readiness; it remains the cluster's current activation. `Failed` means the deploy aborted before completion. `Partial` means `kix deploy --only` applied every selected resource and left the rest of the build for a later deploy (recorded in `status.partial`). After a `Failed` or `Partial` record, the next deploy uses the previous `Active` or `Degraded` activation as its primary diff baseline while also sweeping changes from that run.
- **Operator requests (`--operator`)**: Each run of `kix deploy --operator` or `kix rollback --operator` writes a new token to `spec.request`, and the Kix operator copies it to `status.startedRequest` when work begins. If the record is `Superseded`, `Failed`, or `Partial` (for example, during `kix rollback --operator`, a retry of a failed deploy, or a full deploy after `kix deploy --only`), the operator sets `status.phase` back to `Queued` and deploys the build. During any new deploy or rollback, the cluster's existing `Active` or `Degraded` record remains current until the deploy finishes, when the operator marks it `Superseded`. If the deploy reaches `Failed` instead, that record remains current and the operator restores the cluster to match it. If the record is already `Active` or `Degraded` (when `kix deploy --operator` redeploys the current build), it keeps that phase while the operator applies the build again. Once per request, when the deploy starts, the operator reruns any Job marked `kix.run/rerun` whose last run failed. When the deploy finishes, the operator writes the token to `status.finishedRequest`. If redeploying the current build fails, the operator writes the token and failure reason to `status.failedRequest` instead of `status.finishedRequest`, and the record keeps its phase.
- **Operator features (`kix.run/operator-features`)**: On startup, the Kix operator sets `kix.run/operator-features` on the `activations.kix.run` CustomResourceDefinition to `requests,head-lock,revisions`: `requests` (processes `spec.request`), `head-lock` (takes each Kix cluster's [deploy lock](#activationhead) before modifying the cluster), and `revisions` (records deployed objects in [revisions](#packageinstancerevision) instead of writing post-apply annotations on workload objects). `kix deploy --operator` and `kix rollback --operator` check this annotation before making changes and stop with `[K9557]` if any feature is missing, because an older operator ignores `spec.request`, deploys without the deploy lock, or writes back the [retired annotations](#retired-annotations). Other cluster-modifying commands also stop with `[K9557]` before planning if an active, queued, or deploying record for that Kix cluster has `spec.source` (meaning the operator manages it) and the annotation lacks `revisions` (including operators from Kix 0.9 or earlier, which write no annotation). Other Kix clusters on the same Kubernetes cluster are unaffected. If you uninstalled the operator, run `kix deploy <cluster> --operator-removed` once to reclaim the cluster (see [`--operator-removed`](/docs/reference/cli/deploy/#take-a-cluster-back-from-a-removed-operator)).
- **In-cluster operator (`--operator`)**: When managed by `kix-operator`, the record carries the finalizer `kix.run/operator-gc`. Deleting an `Active`, `Deploying`, or `Degraded` `Activation` causes the operator to delete all resources owned by that activation except `Namespace` and `CustomResourceDefinition` objects. Deleting a `Superseded` record (for example, during `kix gc --operator`) simply removes the finalizer.

## ActivationHead

`ActivationHead` (`activationheads.kix.run`, API version `kix.run/v1alpha1`)
is a cluster-scoped custom resource. Each Kix cluster has one, named after
the Kix cluster and labelled `kix.run/cluster`. It holds the cluster's
[deploy lock](/docs/reference/cli/deploy/#the-deploy-lock), names the active
deployment record, and records the Kix version that last changed the cluster.
An `Activation` record without a `kix.run/cluster` label uses an
`ActivationHead` named after the record itself.

Kix installs its four CustomResourceDefinitions automatically
(`activations.kix.run`, `packageinstances.kix.run`, `activationheads.kix.run`,
and `packageinstancerevisions.kix.run`), and cluster builds do not include them.
Before taking the lock, `kix deploy`, `kix rollback`, `kix gc`, and
`kix migrate domain` create any missing CRD, as does the Kix operator on
startup. Each CRD carries a `kix.run/definition` annotation recording its
schema revision: newer versions of Kix update older CRD definitions, while
older versions of Kix leave newer definitions untouched and stop with an error
only if the cluster's CRD no longer serves the API version they require.

The `activationheads.kix.run` CRD has no status subresource. On every write, Kix replaces the whole object with the
`resourceVersion` it read, so the Kubernetes API server rejects concurrent
writes. Do not edit `ActivationHead` objects directly; inspect them with
`kubectl get activationhead` or `kix status`.

| Field | Meaning |
| --- | --- |
| `status.current` | Name of the active `Activation` record for the cluster. A deploy or rollback updates this field in a single write after applying all resources and before updating `Activation` record phases. |
| `status.generation` | Counter that increments whenever a run that modified the cluster commits or releases the lock (including finished or stopped deploys, `--only` deploys, and `kix gc`), when a run takes over an expired lock, or when Kix repairs out-of-sync state. Plans record this number, and commands stop if it changed before they take the lock. Operator drift repair does not increment it. |
| `status.lock` | Present while a run holds the lock: `holder` (run ID; the operator's ID stays constant across pod restarts), `hint` (human-readable caller, such as `kix deploy by ana@laptop, process 4242`), `activation` (record being deployed, if any), `purpose` (`deploy`, `rollback`, `gc`, `migrate`, `repair`, or `teardown`), `renewed` (RFC 3339 timestamp from the holder's clock), `durationSeconds` (lease duration: `30`), and `waiting` (ID of a run waiting for operator drift repair to yield). |
| `status.writer` | Kix version that last modified the cluster: `version` and `program` (`cli` or `operator`). Used by the [required stops](/docs/reference/cli/deploy/#required-stops) and [older Kix](/docs/reference/cli/deploy/#deploys-by-an-older-kix) checks. Omitted before a lock-aware Kix writes to the cluster, or after Kix rebuilds `ActivationHead` following a deploy by an older Kix; in both cases, those checks fall back to the active record's deploy receipt. |

An active holder renews its lock every 10 seconds. When another run finds the
lock held, it watches for up to 30 seconds: if the holder renews, the waiting
run stops; if nothing renews for 30 seconds, the waiting run takes over the
lock and marks any other record the stopped run was deploying as `Failed`.

If `ActivationHead` and the `Activation` record phases disagree, the next run
that takes the lock reconciles them. When the `Activation` record named in
`status.current` no longer exists or is in phase `Superseded` while another
record is `Active` or `Degraded` (for example, after an older Kix deployed),
when another record without `status.revisions` is `Active` or `Degraded` while
the record in `status.current` still is too (because an earlier version of Kix
deployed after this version), or when `ActivationHead` has no `status` (such as on first creation or after
restoring a backup without `status`), Kix rebuilds `ActivationHead` from the
record phases. When the record named in
`status.current` exists without an `Active` or `Degraded` phase (because a
deploy stopped after updating `ActivationHead` and before updating record
phases), Kix updates the record phases to match `ActivationHead`. Rebuilding
an existing `status` or repairing phases increments `status.generation`.

## PackageInstanceRevision

`PackageInstanceRevision` (`packageinstancerevisions.kix.run`, API version
`kix.run/v1alpha1`) is a cluster-scoped custom resource that lists the objects
one build produces for one slot of a Kix cluster and records the applied hash
of each object. Deployment records link to their revisions in
[`status.revisions`](#revision-map). Each revision carries the label
`kix.run/cluster`, so you can list all revisions for a cluster with:

<Command commands={["kubectl get packageinstancerevisions -l kix.run/cluster=production"]} />

| Field | Meaning |
| --- | --- |
| `spec.cluster` | Name of the Kix cluster. |
| `spec.slot` | Scope covered by the revision: `{ kind: instance, namespace, name }` for a package instance, `{ kind: clusterLevel }` for cluster-level objects outside any package instance, or `{ kind: keptOrphans }` for orphaned objects kept by deploys that ran without `--prune`. |
| `spec.objects` | Sorted list of objects: `hash` (`kix.run/identity-hash`), `group` (`""` for core `v1`), `kind`, `namespace` (omitted when cluster-scoped), and `name`. |
| `status.applied` | Map from each object's `hash` to the hash of the Kix-owned live fields after its last apply (excluding fields listed in [`kix.run/cede-fields`](#kixruncede-fields)). Used to detect drift. If an object has no entry, the next deploy reapplies it and records its hash. |

Each revision is named `<cluster>-<32-char spec hash>`, so any machine holding
the same build computes the same revision name. The CRD makes `spec` immutable,
and Kix verifies that the name matches `spec` whenever it reads a revision.
Because `status` is a separate subresource, RBAC rules can allow an account to
edit workloads while denying write access to `packageinstancerevisions/status`.

Kix retains only revisions referenced by deployment records it still consults:
the active record, any queued or deploying record, and any `Failed` or
`Partial` record until a later deploy finishes and folds in its changes.
`Superseded` records carry no revision links. Finishing a deploy or running
`kix gc` deletes unreferenced revisions for that Kix cluster, and `kix rollback`
recreates the target record's revisions from its build. Each revision holds up
to roughly 1.5 MB (around 6,500 objects), and Kix stops before applying if a
package instance exceeds that limit. Because deployment records from Kix 0.5
and earlier have no package index, upgrading places all of a record's objects
into a single revision. If they exceed the size limit, Kix stops and tells you
to deploy an updated build of the cluster once with Kix 0.9 (which writes a
package index), then upgrade Kix again and redeploy.

If a deployment record references a revision that is missing from the cluster,
`kix deploy`, `kix gc`, and the Kix operator refuse to prune or delete
resources, while `kix status` warns and continues. Redeploying that record's
build recreates the missing revision under the same name. If the missing
revision is `keptOrphans`, run `kix gc --full-scan` to rebuild it from live
objects owned by this Kix cluster that no other revision lists.

Do not edit `PackageInstanceRevision` objects by hand.

## PackageInstance

`PackageInstance` (`packageinstances.kix.run`, API version `kix.run/v1alpha1`) is a namespaced custom resource emitted for each active package instance, external import (`kix.mkImport`), Secret reference (`scope.mkSecretRef`), Service reference (`scope.mkServiceRef`), and CRD reference (`scope.mkCRDRef`).

A package instance's record sits in the instance's namespace. The record of an instance under a `_`-prefixed key, such as `instances._cluster`, sits in [`cluster.recordNamespace`](/docs/reference/cluster-configuration/#clusterrecordnamespace) (`kube-system` by default), and its `spec.namespaceName` keeps the key.

```yaml
apiVersion: kix.run/v1alpha1
kind: PackageInstance
metadata:
  name: web
  namespace: apps
  labels:
    app.kubernetes.io/managed-by: kix
  annotations:
    kix.run/root: web-server
    kix.run/depends-on: ...
spec:
  instanceName: web
  namespaceName: apps
  version: "1.2.0"
  package: echo-server
  lifecycle: stateless
```

### `PackageInstance` spec and annotations

| Field or annotation | Present on | Meaning |
| --- | --- | --- |
| `spec.instanceName` | Managed and import instances | Name of the instance within its namespace. |
| `spec.namespaceName` | Managed and import instances | Namespace of the instance, or its `_`-prefixed key such as `_cluster`. Kix groups a package's resources by this value, not by the record's own namespace. |
| `spec.version` | Managed and import instances | The instance's `version` option, else the `out.version` the package builds, else the package's `meta.version`. Left out when none is set, or when `out.version` is `null` because the image tag names no version. |
| `spec.package` | Instances of built-in packages | Package ID: `<name>` for stable packages (such as `harbor`) and `experimental/<name>` for experimental packages (such as `experimental/coredns`). Kix release notes use the same IDs, so tools can match release notes to running instances. Omitted for imports, custom packages, and wrapper functions around built-in packages. |
| `spec.lifecycle` | When `meta.lifecycle` is set | Workload lifecycle (`"stateful"`, `"stateless"`, or `"ephemeral"`). Only `"stateful"` changes build validation and deploy behavior; other values are informational. |
| `kix.run/root` | Managed instances | Name of the package's `root` resource. |
| `kix.run/package-requires` | When non-empty | Comma-separated `<Kind>/<name>` entries that the package's `root` resource transitively depends on. |
| `kix.run/post-hooks` | When non-empty | Comma-separated `<Kind>/<name>` entries declared in `root.postHooks`. |
| `kix.run/inverse-deps` | When non-empty | Comma-separated `<Kind>/<name>` entries outside the instance that depend on it. |
| `kix.run/auto-instantiated` | Auto-instantiated instances | `"true"` when created on demand from `availablePackages`. |
| `kix.run/optional-activated` | Activated optional instances | `"true"` when an `optional = true` instance was activated by dependency demand. |
| `kix.run/mode` | Import and ref markers | `"import"` on markers created by `kix.mkImport`, `scope.mkSecretRef`, `scope.mkServiceRef`, and `scope.mkCRDRef`. |
| `kix.run/import-kind`, `kix.run/import-apiversion`, `kix.run/import-name` | Import, SecretRef, ServiceRef markers | Target Kubernetes object identity verified by `kix deploy` before dependent waves run. |
| `kix.run/import-namespace` | `kix.mkImport` markers when `namespace` differs from the instance's namespace | Namespace of the target Kubernetes object. When omitted, build validation and `kix deploy` look for a namespaced target in the marker's own namespace. |
| `kix.run/import-secret-keys` | `scope.mkSecretRef` markers | Comma-separated keys that must exist in the external `Secret`'s `data`. |
| `kix.run/import-fqdn`, `kix.run/service-selector`, `kix.run/service-ports`, `kix.run/service-labels` | `scope.mkServiceRef` and Service imports | Service address, JSON-encoded selector, ports, and metadata labels used by network policy derivation and scorecard rules. |
| `kix.run/crd-kind`, `kix.run/crd-version`, `kix.run/crd-served-versions`, `kix.run/crd-scope` | `scope.mkCRDRef` and `kix.mkImport { crds }` markers | CRD kind, default version, comma-separated served versions, and scope (`Namespaced` or `Cluster`) verified against the live CRD during `kix deploy`. |

`spec.package` holds the package ID from the Kix version that built the `PackageInstance`. When an experimental package becomes stable, new builds write `<name>` instead of `experimental/<name>`. Live `PackageInstance` resources on the cluster keep `experimental/<name>` until the next deploy.

## Deploy receipt schema

Every `kix deploy` writes a provenance receipt to `status.receipt` on the `Activation` resource (`schema: "kix.run/receipt/v1"`). Storing the receipt in `status` rather than `spec` ensures that re-applying or rolling back an `Activation` spec never overwrites the historical record of what was deployed.

Inspect the live receipt with `kubectl` or generate a SLSA provenance attestation from it with [`kix compliance attest`](/docs/reference/cli/compliance-commands/):

```json
{
  "schema": "kix.run/receipt/v1",
  "cluster": "production",
  "activationHash": "jak8b4glx8fnbq2c3hkb0khyyvigb96i",
  "deployedAt": "2026-09-09T10:47:55Z",
  "source": {
    "flakeRef": "./clusters",
    "gitCommit": "700ab956bbe98187a21f4cc99acb938e1401245e",
    "dirty": false,
    "revision": "700ab956bbe98187a21f4cc99acb938e1401245e",
    "flakeLock": "blake3:1d2417994d31f798..."
  },
  "builder": {
    "kixVersion": "0.1.0",
    "nixVersion": "nix (Nix) 2.28.5",
    "arch": "x86_64",
    "os": "linux"
  },
  "inputs": [
    {
      "name": "nixpkgs",
      "rev": "8d8c1fa...",
      "narHash": "sha256-J0dZU4a..."
    }
  ],
  "images": [
    "docker.io/nginxinc/nginx-unprivileged:1.28-alpine@sha256:7377697a..."
  ]
}
```

### Receipt fields

| Field | Type | Meaning |
| --- | --- | --- |
| `schema` | `string` | Receipt format identifier (`"kix.run/receipt/v1"`). |
| `cluster` | `string` | Name of the Kix cluster. |
| `activationHash` | `string` | 32-character store hash of the deployed `Activation`. |
| `deployedAt` | `string` | RFC 3339 UTC timestamp when the deployment finalized. |
| `source.flakeRef` | `string` | Flake reference passed to `kix deploy` (or `kix bundle` when deployed from a bundle). |
| `source.gitCommit` | `string` (optional) | Git commit SHA of the source repository. Omitted when the source directory is not a Git repository. |
| `source.dirty` | `boolean` (optional) | `true` when tracked files in the Git working tree had uncommitted changes at build time (untracked files are ignored by Nix flake evaluation). Omitted when `source.gitCommit` is absent. |
| `source.revision` | `string` (optional) | Commit SHA, suffixed with `-dirty` when `source.dirty` is `true`. Omitted when `source.gitCommit` is absent. |
| `source.flakeLock` | `string` (optional) | `blake3:<hex>` digest of `flake.lock`. Omitted when no `flake.lock` is present. |
| `source.bundle` | `{ sha256, kixRev? }` (optional) | Present only when deploying from a `.kixbundle` archive. Records the `sha256` hex digest of the bundle archive verified by `kix deploy` and the optional `kixRev` recorded in the bundle. |
| `builder` | `{ kixVersion, nixVersion?, kixInput?, arch, os }` | Versions and platform of the machine that built the activation (for bundle deploys, the machine that ran `kix bundle`). `nixVersion` is omitted when Nix is unavailable. `kixInput` names the flake input that provided the cluster's Kix library (such as `"kix"` or `"kix-stable"`), and is included only when `kix.toml` defines [`[versions]`](/docs/reference/kix-toml/#the-versions-table). |
| `deployer` | `{ kixVersion, arch, os }` (optional) | Present only when deploying from a `.kixbundle` archive. Records the `kix` version and platform of the machine that ran `kix deploy`. |
| `inputs` | `array of object` | Flake inputs from `flake.lock`. Locked inputs record `{ name, rev, narHash }`; unlocked local `path:` inputs record `{ name, type, path?, url?, locked: false }`. |
| `images` | `array of string` | Container image references collected across all workloads in the activation. |

Rendered manifests are intentionally excluded from `status.receipt` so inline Secret values never appear in cluster-wide status objects.