AGENT SKILL

pilot-patch-and-drift

Use when Pilot is CLASSIFYING DRIFT and DECIDING WHAT TO DO ABOUT IT after a divergence between intended state and live state is detected. Natural phrasings: "Pilot, classify this drift", "is this manual edit or controller drift?", "should Pilot revert this patch?", "quarantine or accept-as-canonical?", "what does cub-scout say about who touched this field?", "render a drift verdict for the audit". Pilot consumes cub-scout's attribution evidence (`cause: manual-edit` / `controller-drift` / `unknown` + `managerHint` + `gitSource` + `bindingSource`) and decides revert / quarantine / accept-as-canonical / ASK-human. The decision shape matches the attribution layer's evidence shape — cub-scout produces deterministic classification; Pilot picks the policy action. Do NOT load for: a single-resource pre-deploy gate (use pilot-cd-gate), a real-time event response (use pilot-watch-alert-response), a fleet roll-up (use pilot-fleet-conformance), or any mutating action. Pilot mutates via `cub` / Argo / kubectl — never via cub-scout.

License 许可
MIT
最近更新
2026-11-14
Stars
★ 14
Forks
1

01 前言 Front Matter

name
pilot-patch-and-drift
phase
cross-cutting
description
Use when Pilot is CLASSIFYING DRIFT and DECIDING WHAT TO DO ABOUT IT after a divergence between intended state and live state is detected. Natural phrasings: "Pilot, classify this drift", "is this manual edit or controller drift?", "should Pilot revert this patch?", "quarantine or accept-as-canonical?", "what does cub-scout say about who touched this field?", "render a drift verdict for the audit". Pilot consumes cub-scout's attribution evidence (`cause: manual-edit` / `controller-drift` / `unknown` + `managerHint` + `gitSource` + `bindingSource`) and decides revert / quarantine / accept-as-canonical / ASK-human. The decision shape matches the attribution layer's evidence shape — cub-scout produces deterministic classification; Pilot picks the policy action. Do NOT load for: a single-resource pre-deploy gate (use pilot-cd-gate), a real-time event response (use pilot-watch-alert-response), a fleet roll-up (use pilot-fleet-conformance), or any mutating action. Pilot mutates via `cub` / Argo / kubectl — never via cub-scout.
allowed-tools
Bash(./cub-scout compare three-way *) Bash(cub-scout compare three-way *) Bash(cub scout compare three-way *) Bash(./cub-scout compare drift *) Bash(cub-scout compare drift *) Bash(cub scout compare drift *) Bash(./cub-scout compare source-truth *) Bash(cub-scout compare source-truth *) Bash(cub scout compare source-truth *) Bash(./cub-scout explain *) Bash(cub-scout explain *) Bash(cub scout explain *) Bash(./cub-scout trace *) Bash(cub-scout trace *) Bash(cub scout trace *) Bash(./cub-scout history *) Bash(cub-scout history *) Bash(cub scout history *) Bash(./cub-scout receipt verify *) Bash(cub-scout receipt verify *) Bash(cub scout receipt verify *) Bash(./cub-scout receipt show *) Bash(cub-scout receipt show *) Bash(cub scout receipt show *) Bash(./cub-scout receipt validate *) Bash(cub-scout receipt validate *) Bash(cub scout receipt validate *) Bash(./cub-scout receipt list *) Bash(cub-scout receipt list *) Bash(cub scout receipt list *) Bash(kubectl get *) Bash(kubectl describe *) Bash(kubectl get --show-managed-fields *) Bash(cub space list *) Bash(cub unit get *) Bash(cub unit list *) Bash(cub link get *) Bash(cub link list *) Bash(cub view get *) Bash(cub view list *) Bash(cub unit-event list *) Bash(cub resource list *) Bash(cub release list *) Bash(cub changeset list *) Bash(argocd app get *) Bash(flux get *)

03 SKILL.md 正文

pilot-patch-and-drift

The drift-classification scenario from Pilot's side. A field has diverged from its intended value; Pilot needs to decide what to do — revert, quarantine, accept-as-canonical, or ASK a human. The decision depends on who changed the field and what kind of change it was, which is exactly what cub-scout's attribution layer (#435) produces.

cub-scout's attribution surface is deterministic: every compareFieldMismatch carries cause (controller-drift / manual-edit / unknown) + managerHint (the verified manager-string from managedFields) + gitSource (where the intended value came from) + bindingSource (which ConfigHub Link supplied it, when connected). Pilot reads that triple and picks an action.

When to use

Explicit phrasings:

  • "Pilot, classify this drift"
  • "Is this manual edit or controller drift?"
  • "Should Pilot revert this patch?"
  • "Quarantine or accept-as-canonical?"
  • "What does cub-scout say about who touched this field?"
  • "Render a drift verdict for the audit"
  • "Decision: is this an emergency manual fix we accept, or noise we revert?"
  • "Argo and kubectl both wrote this field — who actually owns it?"

Implicit intents:

  • A divergence is already known (an audit found it, a watch event surfaced it, a gate failed) — this isn't the discovery skill
  • The user wants a classification + action, not just a description
  • The action is the operator's call but informed by deterministic attribution evidence
  • The result may persist as a fingerprinted receipt if the action needs an audit trail

Do not load for

The Pilot ↔ cub-scout drift loop

   alert: drift detected on deploy/payments-api spec.replicas
        │
        ▼
   Pilot (acceptance judge)
        │  "classify this drift, decide an action"
        │
        ├──► cub-scout compare three-way deploy/payments-api -n prod
        │     --format json
        │     │
        │     │   per-field fieldMismatches[] with:
        │     │     cause          (controller-drift / manual-edit / unknown)
        │     │     managerHint    (verified manager string)
        │     │     gitSource      (repoUrl / revision / path / file / line)
        │     │     bindingSource  (upstream unit + binding path + link, connected)
        │     │     compareThreeWay (DRY/WET/LIVE values per field)
        │     ▼
        │
        ├──► (optional) cub-scout history deploy/payments-api -n prod
        │     # ConfigHub ChangeSet timeline for the past 24h
        │
        ├──► (optional) cub-scout explain deploy/payments-api -n prod --presentation ai
        │     # narrative ownership + lineage (AI-shaped output)
        │
        └──► (optional, for audit) cub-scout receipt verify deploy/payments-api -n prod
              --predicate no-manual-edits-since --since <timestamp> --save
        │
        ▼
   Pilot's drift verdict, by field:
        │
        │  cause: controller-drift   → ACCEPT (controller is reconciling; transient)
        │  cause: manual-edit + Argo-owned → INVESTIGATE → likely REVERT or QUARANTINE
        │  cause: manual-edit + Flux-owned → same
        │  cause: manual-edit + unmanaged   → ACCEPT-AS-CANONICAL or QUARANTINE
        │  cause: unknown                   → ASK (managedFields incomplete)
        │
        ▼
   downstream consumer reads the action
        │  ACCEPT             → no-op
        │  REVERT             → route to Pilot's REVERT path (controller sync or
        │                       intent re-apply; mutation lives outside cub-scout)
        │  QUARANTINE         → tag the resource, alert the owner
        │  ACCEPT-AS-CANONICAL → route to Pilot's intent-update path (Git PR / ConfigHub
        │                       unit update; mutation lives outside cub-scout)
        │  ASK                → page a human
        └────────────────────────────────────────────────────

Five Pilot policy cases over three cause values + owner context

cub-scout's attribution layer produces one of three cause values per field (per pkg/agent/field_ownership.go:10-30): controller-drift, manual-edit, unknown. Pilot's policy decision is shaped by the (cause, owner, managerHint) triple — so the same cause can map to different actions depending on whether the resource has a controller owner and whether the writer's manager string is in the verified enumeration:

cause Owner / manager context Typical Pilot action
controller-drift Detected owner's controller wrote the field; managerHint is in the verified enumeration. The drift is the controller doing its job (HPA scaled replicas, etc.). ACCEPT — no action; the controller is reconciling.
manual-edit Argo / Flux / ConfigHub / Sveltos / Modelplane / kro / Crossplane owner; kubectl-* writer touched the field. The controller will fight the manual edit on next sync. INVESTIGATE — read the gitSource / bindingSource; usually REVERT (let the controller win) or QUARANTINE if the manual edit was an emergency fix.
manual-edit No controller owner (unmanaged resource); kubectl-* writer. There's no controller to fight back. ACCEPT-AS-CANONICAL (update intent to match) or QUARANTINE if the resource shouldn't be unmanaged.
controller-drift A controller wrote it, but the managerHint is not in the verified enumeration, OR it's from a different controller than the detected owner (e.g., Argo wrote on a Flux-owned resource). ASK — possible controller-on-controller conflict; cub-scout doesn't guess which is canonical.
unknown managedFields is missing (older K8s, stripped) or the field-path resolution failed. ASK — Pilot doesn't have enough evidence.

The five rows above are Pilot policy cases, not five distinct cause values from cub-scout. cub-scout's cause is the three-valued enum; the owner / manager / verified-or-not context disambiguates within the manual-edit and controller-drift cases. See verified-manager-strings for the canonical enumeration.

The verified manager-string enumeration (verified-manager-strings) covers Argo CD, Flux (kustomize/helm/source controllers), Helm direct, Crossplane (composite/composed/claim/MRD/refs), kro (applyset/parent/labeller), Sveltos (application/apply-patch), Modelplane via Crossplane composition managers, and kubectl-*. Strings not in the enumeration return unknown rather than misclassifying — same parse, don't guess rule used by ownership detection.

Step-by-step

Step 1 — get the structured evidence

$ cub-scout compare three-way deploy/payments-api -n prod --format json

The output's fieldMismatches[] is per-field. Each entry has:

{
  "path": "spec.template.spec.containers[0].image",
  "compareThreeWay": {
    "dry": "ghcr.io/org/payments-api:v1.4.2",
    "wet": "ghcr.io/org/payments-api:v1.4.2",
    "live": "ghcr.io/org/payments-api:v1.4.3-hotfix"
  },
  "cause": "manual-edit",
  "managerHint": "kubectl-edit",
  "gitSource": {
    "repoUrl": "https://github.com/org/payments",
    "revision": "abc123",
    "path": "apps/prod/payments-api/deployment.yaml",
    "file": "apps/prod/payments-api/deployment.yaml",
    "line": 42
  },
  "bindingSource": null
}

This is the canonical evidence shape Pilot reads. The triple (cause, managerHint, gitSource) carries the deterministic classification; the four values (dry, wet, live, plus the resolved gitSource) carry the divergence shape.

Step 2 — (connected) check the binding source

When connected, the same output includes a bindingSource per field that the field came from an upstream ConfigHub Link:

{
  "bindingSource": {
    "unit": "payments-base",
    "path": ".spec.image",
    "link": "lnk-2024-prod-image-bump"
  }
}

Reading: the live image field was supposed to come from upstream unit payments-base via Link lnk-2024-prod-image-bump. Pilot can:

  • cub unit get payments-base to see the canonical value
  • cub link list payments-api to see all incoming bindings
  • Decide whether the divergence is in the downstream resource or the upstream unit

When standalone or the resource isn't ConfigHub-linked, bindingSource: null and Pilot drops back to the cause + managerHint evidence.

Step 3 — (optional) get the change timeline

$ cub-scout history deploy/payments-api -n prod --since 24h --format json

The history surface produces the ConfigHub ChangeSet timeline (connected only). Useful when:

  • The drift might be a recent intentional change Pilot should reconcile to
  • The audit needs a "who changed what when" entry

Step 4 — render the verdict

Pilot's verdict per field is the action from the table above. For the worked-example field (manual-edit on an Argo-owned image field):

{
  "resource": "Deployment/payments-api in prod",
  "field": "spec.template.spec.containers[0].image",
  "cause": "manual-edit",
  "managerHint": "kubectl-edit",
  "owner": "argo",
  "action": "INVESTIGATE",
  "recommendation": "Likely emergency hotfix — verify with on-call before reverting. If intentional, update intent (Git PR to apps/prod/payments-api/deployment.yaml line 42); if not, let Argo sync revert it.",
  "evidence_path": null
}

Step 5 — (optional) persist a receipt

If the verdict needs an audit trail (e.g., for compliance review later):

# Predicate "no-manual-edits-since": BLOCK if any kubectl-* writer touched the resource
# after the cutoff. The cutoff is typically the last known intentional change.
$ cub-scout receipt verify deploy/payments-api -n prod \
    --predicate no-manual-edits-since \
    --since 2026-05-22T00:00:00Z \
    --save \
    --out drift.receipt.json

The receipt records what cub-scout observed at this moment + the verdict (BLOCK if a kubectl-* writer touched it after the cutoff). Pilot attaches drift.receipt.json to the drift ticket.

Step 6 — invoke the action (Pilot's surface, not cub-scout's)

Pilot's mutation choices, by action (mutation implementation lives outside cub-scout — concrete CLI surfaces are intentionally abstracted here):

Action Pilot's mutation path
ACCEPT none (no-op)
REVERT Pilot's REVERT path — controller sync or intent re-apply, depending on which controller owns the resource. Implementation lives in Pilot / cub / Argo / Flux; this skill does not name a specific CLI.
QUARANTINE Label/annotate the resource (out-of-scope for cub-scout); page the owner.
ACCEPT-AS-CANONICAL Pilot's intent-update path — typically a Git PR amending intent, or a ConfigHub unit update. Implementation lives outside cub-scout.
ASK Escalate to the on-call human.

cub-scout participates only in evidence. The mutation paths above are all out-of-scope for this skill, and their concrete CLI surfaces (controller sync verbs, ConfigHub unit update verbs) are deliberately not enumerated here to keep cub-scout's read-only boundary loud.

Worked example

A drift alert fires on deploy/payments-api in prod — spec.template.spec.containers[0].image has diverged.

$ cub-scout compare three-way deploy/payments-api -n prod --format json \
    | jq '.fieldMismatches[] | select(.path | contains("image"))'
{
  "path": "spec.template.spec.containers[0].image",
  "compareThreeWay": {
    "dry": "ghcr.io/org/payments-api:v1.4.2",
    "wet": "ghcr.io/org/payments-api:v1.4.2",
    "live": "ghcr.io/org/payments-api:v1.4.3-hotfix"
  },
  "cause": "manual-edit",
  "managerHint": "kubectl-edit",
  "gitSource": {
    "repoUrl": "https://github.com/org/payments",
    "revision": "abc123",
    "path": "apps/prod/payments-api/deployment.yaml",
    "file": "apps/prod/payments-api/deployment.yaml",
    "line": 42
  },
  "bindingSource": null
}

Pilot's reading:

  • DRY=WET (v1.4.2) but LIVE=v1.4.3-hotfix — manual-edit
  • cause: manual-edit + managerHint: kubectl-edit confirms a human ran kubectl edit or kubectl set image
  • Owner (from cub-scout explain): Argo CD application payments-api
  • gitSource.file:line points at the canonical declaration

Pilot's verdict:

  • Action: INVESTIGATE
  • Recommendation: Likely an emergency hotfix (suffix -hotfix is a strong hint). Verify with on-call:
    • If intentional → open Git PR amending apps/prod/payments-api/deployment.yaml:42 to v1.4.3-hotfix and merge; Argo will sync.
    • If accidental → route to Pilot's REVERT path (a controller-sync verb in Pilot's stack); cub-scout doesn't perform the sync itself.

Pilot's downstream system records the verdict + the cub-scout evidence ID + a link to the on-call ticket.

Edge cases the attribution layer handles

  • Argo CD CSA migration default and kubectl apply --client-side write the same manager string — the classifier reads pkg/agent/ownership.go first; Argo-owned resources resolve as controller-drift, non-Argo as manual-edit. (See verified-manager-strings for the full enumeration.)
  • Crossplane composed children use prefix match — apiextensions.crossplane.io/composed-<hash> varies per XR. The classifier matches by prefix, not exact string.
  • Per-field rollup degrades cleanly to resource-level — when FieldsV1 is missing (older K8s, stripped), classification is resource-level. When present, per-field. List-key fields (e.g., spec.template.spec.containers[name="api"].image) currently fall back to resource-level pending list-key selector support — pilot-patch-and-drift should treat resource-level cause as authoritative for those fields.
  • gitSource.file:line is opt-in via --source-path <local-checkout> — the resource-level gitSource (repoUrl/revision/path) is automatic; raw-YAML back-resolution to file:line requires the CI pipeline (or Pilot's runtime) to have a local checkout available. Helm/Kustomize templating explicitly deferred.

Tool boundary

  • Allowed (cub-scout): Compare verbs (read-only attribution); explain, trace, history; receipt verify / show / validate / list. All read-only.
  • Allowed (cluster): kubectl get/describe, kubectl get --show-managed-fields (Pilot may want to inspect the raw managedFields to verify cub-scout's classification). NOT kubectl apply / edit / patch / delete.
  • Allowed (ConfigHub): cub <entity> get / list for the entities named in allowed-tools. NOT cub * create / update / delete.
  • Allowed (controllers): argocd app get, flux get. NOT argocd app sync, flux reconcile (those are Pilot's REVERT path, not cub-scout's).
  • Pilot's mutation paths (REVERT, QUARANTINE, ACCEPT-AS-CANONICAL) are out-of-scope for this skill. cub-scout produces the classification; Pilot decides; the mutation lives in cub / Argo / Flux.

References

Constraints

  • Per-field cause classification requires managedFields present on the resource (K8s ≥ 1.18 default; some controllers strip it). When missing, classification degrades to resource-level.
  • The verified manager-string enumeration is a whitelist, not a heuristic. New controllers' manager strings need to be added to pkg/agent/manager_strings.go (a cub-scout core change, not a Pilot-side patch).
  • bindingSource requires connected mode AND the resource being ConfigHub-linked via cub link create. Without that, bindingSource: null and Pilot drops to cause + managerHint alone.
  • gitSource.file:line requires --source-path <local-checkout> to be passed AND the source to be raw YAML (not Helm/Kustomize templated). Templated sources only get the resource-level repoUrl/revision/path anchor.
  • Pilot's action policy (revert vs quarantine vs accept-as-canonical) is Pilot's call. cub-scout produces the classification; the action mapping above is illustrative, not normative.

04 同仓库更多 Skills

confighub
confighub/cub-scout

异常工作负载故障分诊

triage-unhealthy-workload

当用户需要在时间压力下应对出现故障的 Kubernetes 工作负载时使用——例如寻呼告警响起、CI 飘红、“生产环境挂了”的场景。自然表述包括:“deploy/api 出现 CrashLoopBackOff,该怎么办?”“发布卡住了,帮帮我”“这个 pod 起不来”“支付服务触发了寻呼告警”“argocd 里全红了”“我应该先检查什么?”“给我一份针对这个工作负载的分诊方案”。它将 doctor → explain → trace 组合成一个紧凑的约 30 秒循环,运维人员可在已确认寻呼告警的上下文中执行。不要用于:没有紧迫性的计划性排查(直接使用 scout-diagnose)、漂移相关问题(使用 investigate-drift),或任何变更操作(cub-scout 从不做变更——应由用户主导,转由 kubectl 处理)。

SRE 工程师生产事故响应与应急处置
★ 14
confighub
confighub/cub-scout

资源证据收据生成与校验

scout-verify

当用户需要针对某个 Kubernetes 资源生成带类型、带指纹、不可篡改(TYPED、FINGERPRINTED、IMMUTABLE)的证据工件时使用——即 cub-scout 的 Verify 动词组(在 #446 中发布的收据能力)。自然表述包括:“出具一份证明此资源合规的收据”“给我一份证明集群与 Git 一致的证明”“我需要一份可用于审计跟踪的可验证记录”“生成一份收据,证明自部署以来没有人工改动”“对照事实源(source-truth)校验 deploy/api 并保存工件”“验证此收据未被篡改”“展示我们有哪些收据”“此收据是否被篡改过?”“把证据附加到我的 CI 关卡”。当意图涉及 receipt / attestation / evidence-artifact / tamper-evident-record / verified-record / audit-trail / postmortem-evidence / acceptance-judge-input 时均应加载。不要用于:不落盘工件的实时比对(使用 scout-compare)、解读单个字段的来源出处(使用 scout-attribute),或真正实施修复(cub-scout 从不做变更——应由用户主导,转由 cub / argocd / kubectl 处理)。

SRE 工程师审计准备与证据管理
★ 14
confighub
confighub/cub-scout

scout-observe

Use when the user wants to SEE what is running in a Kubernetes cluster, who owns it, and how it is structured — the read-only Observe verb group of cub-scout. Natural phrasing: "what is running in my cluster?", "give me a map of resources", "who owns this Deployment?", "trace this back to its source", "show me the ownership tree", "scan this cluster for risk", "dump the cluster as JSON", "stream cluster events", "run cub-scout as a bot", "what is the connection status?", "is this cluster healthy?". Load when intent is observe / inventory / map / show / list / trace / scan / dump / stream / bot / health-check over a Kubernetes cluster. Do NOT load for: explaining WHY something is broken (use scout-diagnose), comparing cluster state to intended state (use scout-compare), provenance of individual field values (use scout-attribute), or any action that mutates the cluster (cub-scout never mutates — route to cub or kubectl with the user driving).

★ 14
confighub
confighub/cub-scout

scout-mcp

Use when the user wants to expose cub-scout to an AI agent over MCP, wants a deterministic AI-ready snapshot of cluster context, or wants cub-scout running as a read-only event bot — the Integrate verb group. Natural phrasing: "start the MCP server", "expose cub-scout to Claude / Codex / my agent", "give me an AI-ready context pack of this cluster", "set up the MCP gateway", "what MCP tools does cub-scout expose?", "run cub-scout as a bot", "produce JSON context for an LLM to reason about this cluster". Load whenever intent is mcp / mcp-gateway / mcp-serve / context-pack / bot / agent-context / ai-snapshot / llm-context / model-context-protocol. Do NOT load for: actually running a non-integrate verb (those are scout-observe / scout-diagnose / scout-compare / scout-attribute / scout-ingest / scout-govern / scout-verify), or `cub` MCP integration (that's a separate tool surface).

★ 14
confighub
confighub/cub-scout

scout-ingest

Use when the user wants to ADOPT existing Kubernetes / GitOps workload structure into ConfigHub after observing the live cluster — the adoption/import verb group of cub-scout. Natural phrasing: "discover workloads in this cluster and propose ConfigHub units", "show me the import proposal before I apply", "import this Argo Application set", "bring my Flux Kustomizations into ConfigHub", "preview what would land in ConfigHub if I imported this repo", "parse my git repo as a ConfigHub import bundle", "import a cluster aggregator", "what would --git-path produce for this repo?". Load whenever intent is adopt / import / ingest / preview / propose / parse-repo / discovery / aggregator / bring-into-confighub / what-would-confighub-see. Do NOT load for: questions about who changed a resource, whether it was edited by hand or drifted (use scout-attribute or investigate-drift); reading an exported `kubectl get -o yaml` dump to answer a question about the cluster (that is not an import); basic live-cluster inventory (use scout-observe), troubleshooting (use scout-diagnose), comparing live state to ConfigHub (use scout-compare), or the actual write to ConfigHub via `cub variant upload` (that is `cub`, not cub-scout — route to cub skills). Important: `cub-scout import apply` IS the mutating write into ConfigHub — this skill teaches the read-only preview path and explicitly refuses to invoke `import apply` itself.

★ 14
confighub
confighub/cub-scout

ConfigHub 治理信号查询

scout-govern

当用户希望从 cub-scout 获取已连接的(CONNECTED)ConfigHub 治理信号时使用该技能 —— Govern(治理)动词组。自然表述:"给我看这个单元的 ChangeSet 历史"、"如果我修改这个单元,影响范围(blast radius)有多大?"、"我的机群中哪些集群是异常值?"、"给我看昨天的连接摘要"、"在整个机群中呈现这个视图"、"审计谁修改了这个"、"上一次应用来自哪里?"、"列出我拥有的 ConfigHub bundle"、"给我看过往快照的目录"。当意图为历史 / 影响 / 影响范围 / 机群异常 / 摘要 / 视图 / 审计 / bundle / 目录 / 连接上下文时加载。不要用于:实时集群比较(使用 scout-compare)、回执(使用 scout-verify)、正在运行的 Pod 清单(使用 scout-observe),或通过 cub 进行的任何修改。该技能的大部分功能需要 `cub auth login` —— 请提前说明。

SRE 工程师工程变更管理
★ 14