OneLinersCommand workbench
AI
Back to skills
SKILL.md

Environment drift investigator

An evidence-first workflow to compare declared and observed deployment state without mutating either.

Revision
2
Verified
2026-10-20
Save or explore
Save to collectionCreate a collection in the sidebar first.

Compatibility and paths

Codexskills/environment-drift/SKILL.md
Claude Code.claude/skills/environment-drift/SKILL.md
VS Code.github/skills/environment-drift/SKILL.md

Trust and provenance

Curated record reviewed 2026-10-20. Results still depend on the supplied context and target environment.

Generated assetReady to copy or download
---
name: environment-drift
description: Compares desired and observed deployment evidence while distinguishing artifact/configuration drift, controller-owned variance and incomparable identifiers. Use for release discrepancies or environment differences; produce a field-level ledger without reconciling infrastructure or state.
license: CC-BY-4.0
compatibility: Offline evidence review needs no credentials or network. External queries, repository execution and writes require separately scoped authorization.
metadata:
  author: oneliners
  version: "2.0.0"
---

# Environment drift investigator

## Establish identity and authority
Start with exact account/project or cluster context, namespace, resource and container identity. Obtain the versioned desired artifact, inventory collection time and relevant policy/exception owners. Compare the same target, not a staging manifest with production observations. A Git declaration, Terraform state snapshot and live inventory are different evidence sources; state is not proof that nothing changed afterward. Ask which source is approved when they disagree, rather than choosing the most convenient one.

## Normalize semantics without erasing evidence
Compare immutable artifact identity at the same digest level and platform, required configuration NAMES, known non-secret values and controller ownership. Image tags are labels, not proof of equal bytes. An OCI index digest, platform manifest digest and image configuration ID are not interchangeable; mark UNKNOWN when the supplied evidence cannot bridge those identifiers. Keep original snapshots immutable and record normalizations separately. Exclude generated IDs/timestamps from the semantic diff, but retain their collection context. Do not normalize away a permission, digest, endpoint or required variable just to reduce finding count.

## Respect declared dynamic ownership
Ask whether autoscaling or another controller owns replicas, resources or injected configuration. Evaluate values against that explicit policy and snapshot timing rather than against an unrelated fixed count. An allowed range is not proof of actual HPA health, sufficient capacity or an error-free deployment. An unapproved override remains unresolved even if the application looks healthy. If the evidence lacks ownership, report UNKNOWN/needs review; do not invent an autoscaler to explain a difference.

## Worked inventory
This deliberately contains three differences plus expected replica variance. The two digests below are synthetic shape-valid labels, not downloadable artifacts. No secret values or live infrastructure identifiers are included.

```json
{
  "provenance": "synthetic desired/observed inventory, not kubectl output",
  "target": {
    "context": "training-eu",
    "namespace": "staging",
    "deployment": "orders-api"
  },
  "desired": {
    "imageTag": "orders-api:release-42",
    "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "digestKind": "platform-manifest",
    "platform": "linux/amd64",
    "requiredEnvNames": [
      "DATABASE_URL",
      "QUEUE_NAME"
    ],
    "publicConfig": {
      "LOG_LEVEL": "info"
    }
  },
  "observed": {
    "context": "training-eu",
    "namespace": "staging",
    "deployment": "orders-api",
    "imageTag": "orders-api:release-42",
    "digest": "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
    "digestKind": "platform-manifest",
    "platform": "linux/amd64",
    "presentEnvNames": [
      "DATABASE_URL"
    ],
    "publicConfig": {
      "LOG_LEVEL": "debug"
    },
    "replicas": 5,
    "metadata": {
      "uid": "fixture-object-1",
      "resourceVersion": "9102",
      "observedAt": "2026-10-20T10:00:00Z"
    }
  },
  "policy": {
    "hpaOwnsReplicas": true,
    "minReplicas": 3,
    "maxReplicas": 6,
    "acceptedOwners": [
      "service-owner",
      "platform-owner"
    ]
  }
}
```

## Normalized review
Target: training-eu / staging / orders-api. Inventory is synthetic and supplied, not a live cluster observation. Comparison scope: one container's linux/amd64 platform-manifest digest, environment-name presence, one non-secret setting and owner-approved HPA range.

| Field | Classification | Evidence | Next bounded check / role |
| --- | --- | --- | --- |
| Image | DRIFT; promotion blocker under this fixture's approved artifact contract | Same release-42 tag, different sha256 digests; both explicitly platform-manifest/linux/amd64 | Release engineer: match signed/tested artifact to the target container's resolved image identity and registry manifest of the same platform. No rollout yet. |
| QUEUE_NAME | MISSING REQUIRED NAME | Required names DATABASE_URL,QUEUE_NAME; observed only DATABASE_URL | Service owner: verify the exact revision's configuration references and workload injection without reading values into this report. Presence of DATABASE_URL proves neither a value nor database access. |
| LOG_LEVEL | CONFIGURATION DRIFT, operational impact unverified | info declared; debug supplied | Service owner: check whether an approved incident exception exists; review exposure/cost risk before a change. No sensitive log collection. |
| Replicas=5 | EXPECTED VARIANCE, not a finding | Explicit HPA ownership and inclusive allowed range3–6 | Platform owner: confirm controller target/ownership and timing from authoritative evidence. Do not scale back to3 just to match an old rendered manifest. |
| UID/resourceVersion/time | EXCLUDED from semantic comparison | Generated metadata, not an artifact/configuration requirement | Retain timestamps as provenance; never delete them from the original evidence. |

Do not deploy, restart, scale, apply, refresh state or edit Terraform state to make the report green. Reconciliation requires an approved source of truth and change plan. This packet cannot identify who changed the image, whether the tag moved in the registry, whether pods are healthy or whether a customer was affected. Request a second snapshot with collection times and controller generation before asserting persistence or cause.

## Independent checks and useful counterexamples
1. Hold target identity and digest domain constant, replace the observed b... digest with desired a...: image comparison becomes MATCH, while QUEUE_NAME and LOG_LEVEL remain unresolved. One corrected field does not close the entire review.
2. Keep both different digests, change observed digestKind to image-config or platform to linux/arm64: classification becomes UNKNOWN_COMPARABILITY, not confirmed artifact drift. Obtain an authoritative index-to-manifest/config relationship for the selected platform before concluding mismatch.
3. Keep replica count5 but remove confirmed HPA ownership: expected variance is no longer established. Ask for ownership/scale evidence; do not call it a proven outage. Under the supplied HPA policy, count7 is outside the approved range and needs review even if the image matches.
4. Add QUEUE_NAME to presentEnvNames: name presence is resolved only. Do not label the queue connection or secret validity verified. Change only uid/resourceVersion: the semantic findings must not change.
5. Change namespace to production in only the observed packet: stop. This is an identity error, not a fleet-wide drift conclusion.

## Verification plan for a real case
Agree a read-only collection scope with the owner. Request the selected container's declared image plus resolved runtime identity and platform, matched registry provenance, names of configuration references, controller target and relevant generations, timestamps and approved exceptions. Avoid bulk get-secrets/export-env requests. Compare snapshots collected within an agreed interval and identify admission mutations or rolling-update overlap before calling a temporary difference persistent. Never infer a malicious actor from a different digest alone.

## Output and reconciliation boundary
Use a ledger with target, desired source/revision, observed source/time, field, comparison rule, DRIFT/MATCH/EXPECTED_VARIANCE/UNKNOWN, evidence, owner, next check and release impact under a named policy. Keep a separate list of excluded generated fields and why. Include unresolved comparability, approved exceptions and a retest condition. Any proposed remediation is a separate reviewed change; do not execute apply, scale, import, state rm, refresh-only apply or manual state edits during diagnosis. Terraform state may contain secrets; do not paste its whole JSON into a public report. The [state documentation](https://developer.hashicorp.com/terraform/language/state), [image identity guidance](https://kubernetes.io/docs/concepts/containers/images/) and [autoscaler guidance](https://kubernetes.io/docs/concepts/workloads/autoscaling/horizontal-pod-autoscale/) provide platform context, not a substitute for this target's inventory.

Real example

Input

Compare this synthetic target without changing it. Separate drift from expected variance and incomparable IDs.

{
  "provenance": "synthetic desired/observed inventory, not kubectl output",
  "target": {
    "context": "training-eu",
    "namespace": "staging",
    "deployment": "orders-api"
  },
  "desired": {
    "imageTag": "orders-api:release-42",
    "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "digestKind": "platform-manifest",
    "platform": "linux/amd64",
    "requiredEnvNames": [
      "DATABASE_URL",
      "QUEUE_NAME"
    ],
    "publicConfig": {
      "LOG_LEVEL": "info"
    }
  },
  "observed": {
    "context": "training-eu",
    "namespace": "staging",
    "deployment": "orders-api",
    "imageTag": "orders-api:release-42",
    "digest": "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
    "digestKind": "platform-manifest",
    "platform": "linux/amd64",
    "presentEnvNames": [
      "DATABASE_URL"
    ],
    "publicConfig": {
      "LOG_LEVEL": "debug"
    },
    "replicas": 5,
    "metadata": {
      "uid": "fixture-object-1",
      "resourceVersion": "9102",
      "observedAt": "2026-10-20T10:00:00Z"
    }
  },
  "policy": {
    "hpaOwnsReplicas": true,
    "minReplicas": 3,
    "maxReplicas": 6,
    "acceptedOwners": [
      "service-owner",
      "platform-owner"
    ]
  }
}

Expected result

Target: training-eu / staging / orders-api. Inventory is synthetic and supplied, not a live cluster observation. Comparison scope: one container's linux/amd64 platform-manifest digest, environment-name presence, one non-secret setting and owner-approved HPA range.

| Field | Classification | Evidence | Next bounded check / role |
| --- | --- | --- | --- |
| Image | DRIFT; promotion blocker under this fixture's approved artifact contract | Same release-42 tag, different sha256 digests; both explicitly platform-manifest/linux/amd64 | Release engineer: match signed/tested artifact to the target container's resolved image identity and registry manifest of the same platform. No rollout yet. |
| QUEUE_NAME | MISSING REQUIRED NAME | Required names DATABASE_URL,QUEUE_NAME; observed only DATABASE_URL | Service owner: verify the exact revision's configuration references and workload injection without reading values into this report. Presence of DATABASE_URL proves neither a value nor database access. |
| LOG_LEVEL | CONFIGURATION DRIFT, operational impact unverified | info declared; debug supplied | Service owner: check whether an approved incident exception exists; review exposure/cost risk before a change. No sensitive log collection. |
| Replicas=5 | EXPECTED VARIANCE, not a finding | Explicit HPA ownership and inclusive allowed range3–6 | Platform owner: confirm controller target/ownership and timing from authoritative evidence. Do not scale back to3 just to match an old rendered manifest. |
| UID/resourceVersion/time | EXCLUDED from semantic comparison | Generated metadata, not an artifact/configuration requirement | Retain timestamps as provenance; never delete them from the original evidence. |

Do not deploy, restart, scale, apply, refresh state or edit Terraform state to make the report green. Reconciliation requires an approved source of truth and change plan. This packet cannot identify who changed the image, whether the tag moved in the registry, whether pods are healthy or whether a customer was affected. Request a second snapshot with collection times and controller generation before asserting persistence or cause.

Source evidence

Agent Skills specificationofficialTerraform state documentationofficialKubernetes image identitiesofficialKubernetes horizontal autoscalingofficial