Kubernetes 状态对比与漂移检测
scout-compare
当用户想要比较 Kubernetes 的预期(INTENDED)状态与实际(ACTUAL)状态时使用该技能 —— cub-scout 的 Compare(比较)动词组。自然表述:"这次发布上线了吗?"、"集群与 Git 一致吗?"、"是否存在漂移?"、"对比该单元的 DRY / WET / LIVE 状态"、"ConfigHub 认为这里应该运行什么?"、"给我这个资源的真实来源(source-truth)判定"、"Argo 是否应用了提交中的内容?"、"将此清单与实时状态对比"。当意图为比较 / 漂移 / 同步状态 / 验证匹配 / DRY-WET-LIVE / 真实来源 / 是否已上线时加载。不要用于:正在运行内容的列表(使用 scout-observe)、解读出错原因(使用 scout-diagnose)、逐字段溯源(使用 scout-attribute),或实际应用 / 同步(cub-scout 从不修改状态 —— 应转由用户驱动 cub、argocd、flux 或 kubectl 执行)。
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 14
- Forks
- 1
01 前言 Front Matter
- name
- scout-compare
- phase
- verify
- description
- Use when the user wants to compare INTENDED vs ACTUAL Kubernetes state — the Compare verb group of cub-scout. Natural phrasing: "did this release land?", "does the cluster match Git?", "is there drift?", "compare DRY / WET / LIVE for this unit", "what does ConfigHub say should be running here?", "give me a source-truth verdict for this resource", "did Argo apply what was in the commit?", "compare this manifest to live state". Load whenever intent is compare / drift / sync-status / verify-matching / DRY-WET-LIVE / source-truth / has-this-landed. Do NOT load for: a list of what is running (use scout-observe), interpreting why something is wrong (use scout-diagnose), per-field provenance (use scout-attribute), or actually applying / syncing (cub-scout never mutates — route to cub, argocd, flux, or kubectl with the user driving).
- 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(kubectl get *) Bash(kubectl describe *) 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 *)
02 资源文件 2
- 参考文档SOURCE.md175 B
- 参考文档TRUST.auto.yaml2.2 KB
03 SKILL.md 正文
scout-compare
The Compare verb group of cub-scout. Four ways to ask "does what's running match what was intended?", with deterministic verdicts and structured evidence.
When to use
Explicit phrasings:
- "Did this release land in prod?"
- "Does the cluster match what Git says?" / "is the manifest in the file actually deployed?"
- "Is there drift between ConfigHub and the cluster?"
- "Compare DRY / WET / LIVE for unit X" / "show me the three-way state"
- "Give me a source-truth verdict for deploy/api"
- "Did Argo apply what was in commit abc123?"
- "Compare this YAML file to what's running in prod"
- "Is namespace prod conformant to ConfigHub?"
Implicit intents:
- The user has desired state somewhere (Git, ConfigHub, a local manifest, a debug bundle) and wants to verify it's reflected in the cluster
- The user wants a verdict (PASS / WATCH / BLOCK / INCONCLUSIVE), not just a diff
- The user is gating a CI step on conformance
Do not load for
- Pure inventory ("show me what's running") —
scout-observe - Interpreting why something is wrong (CrashLoop / events / patterns) —
scout-diagnose - Per-field provenance (which controller / which git file produced this value) —
scout-attribute - Forcing a sync / apply / reconcile — cub-scout cannot. Route to
cub,argocd app sync(with the user driving),flux reconcile, orkubectl apply
Standalone vs connected
- Standalone (cluster + file/bundle):
compare drift --file <yaml>andcompare --git-path <repo>work without ConfigHub. Compares the file or repo against the live cluster. - Connected (cluster +
cub auth login):compare three-wayadds the DRY (ConfigHub intent) layer;compare source-truthruns a strategy-relative verdict over DRY / WET / LIVE. - Offline (file or bundle vs file):
comparebetween a manifest file and a debug-bundle snapshot, no cluster needed.
Tool boundary
- Allowed (read-only): all four Compare verbs;
kubectl get/describe;cub <entity> get / listfor the entities named in allowed-tools (connected);argocd app get,flux get(controller-side reads). - Not allowed:
argocd app syncas a mutation,flux reconcile,kubectl apply/edit/patch/delete,cub * create/update/delete. The compare commands never apply a fix. --fail-on: the existingcompare three-way --fail-on info|warningflag makes the command a CI gate (exit code 2 on violations). It still doesn't mutate — the gate just fails the pipeline.
The verb menu
| Question | Verb | Notes |
|---|---|---|
| "Compare a manifest file to the cluster" | cub-scout compare drift --file <yaml> |
File-vs-live drift. Works standalone, no ConfigHub. |
| "Compare this resource end-to-end" | cub-scout compare <kind>/<name> -n <ns> |
Single-resource compare. Connected: full DRY/WET/LIVE. Standalone: LIVE only with notes. |
| "Compare a scope" | cub-scout compare three-way --scope namespace/<ns> |
Multi-resource DRY/WET/LIVE with agreement summary. Requires connected mode for DRY/WET. Supports --scope, --view <uuid-or-url>, --source-path <local-checkout> (stage B back-resolution), --fail-on. |
| "Strategy-relative verdict" | cub-scout compare source-truth <kind>/<name> -n <ns> --strategy <s> |
One of 9 strategies (confighub-oci-argo, confighub-oci-flux, git-argo, git-flux, helm-flux, helm-argo, kustomize-flux, oci-flux, oci-argo). Returns a structured pair status ∈ {PASS, WATCH, BLOCK, ASK} + source_truth ∈ {AGREED, MISMATCH, INCOMPLETE, BLOCKED, UNKNOWN}. Pilot's acceptance kernel consumes both axes. |
All four verbs emit --format json for agents and the MCP gateway.
The loop
- Identify the desired state. Where is "intent" living? A YAML file? A ConfigHub unit? A git repo? A local checkout? This determines the verb:
- File →
compare drift --file - ConfigHub unit (connected) →
compare three-way - Strategy-typed (connected) →
compare source-truth --strategy <s> - Local git checkout →
compare three-way --source-path <dir>(stage B back-resolution, #440)
- File →
- Pick the scope. Single resource (
<kind>/<name> -n <ns>), namespace (--scope namespace/<ns>), view (--view <uuid-or-url>), or cluster (--scope cluster). - Invoke. Use
--format jsonif the output is going to an agent or CI; ASCII otherwise. - Read the verdict + evidence. For
compare source-truth: the structured pairstatus∈ {PASS, WATCH, BLOCK, ASK} +source_truth∈ {AGREED, MISMATCH, INCOMPLETE, BLOCKED, UNKNOWN}. Forcompare three-way/compare drift: per-field diffs with attribution evidence (cause,managerHint,gitSource,bindingSource) — seescout-attributefor how to read those.INCONCLUSIVEis the receipt-level verdict — it shows up only when these results are wrapped into acub-scout receipt verifyartifact, not in rawcompare source-truthoutput. - Hand off. If the verdict is
WATCHorBLOCKand the user wants to fix it, refuse to mutate and route them: drift produced bykubectl edit(percause: manual-edit) typically goes to the original-author path (commit the change back); drift produced by a controller (cause: controller-drift) typically resolves on its own — wait or re-run.
Worked examples
A: file vs live drift, standalone
The primary v1 path. No ConfigHub auth required.
$ cub-scout compare drift --file desired.yaml -n prod
Drift Report
════════════
Cluster: prod-cluster
Source: desired.yaml
[Config] Configuration Drift
└─ [WARNING] Deployment:prod/api
path: spec.template.spec.containers[name=app].env[name=LOG_LEVEL]
desired: info
observed: debug
Summary: 1 finding
Pair with scout-attribute when you want to know who changed LOG_LEVEL (controller? human? agent?). cub-scout reads metadata.managedFields on the live object to produce that classification — works without ConfigHub.
B: did Argo land commit abc123? (connected enrichment)
$ cub-scout compare three-way --scope namespace/prod --fail-on warning
Three-Way Compare:
Scope: namespace/prod
Resources: 12 Connected: 12 DRY/WET/LIVE: 12 Mismatched: 0
Agreement: ✓ AGREED — All 12 resources agree
Conformance: PASS (threshold: warning, max: info, 0 issues)
exit 0
CI pipeline can gate on exit 0. Mismatch produces exit 2 + a structured compareFieldMismatch[] array with per-field cause and managerHint from the attribution layer (#435). Requires cub auth login — adds the DRY (ConfigHub-intended) layer that the standalone case doesn't have.
C: strategy-relative verdict for Pilot (connected, strategy-declared)
$ cub-scout compare source-truth Deployment/api -n prod --strategy git-argo --format json
{
"subject": {"kind": "Deployment", "name": "api", "namespace": "prod"},
"strategy": "git-argo",
"status": "PASS",
"verdict": "AGREED",
"evidence": {
"git": {"repoUrl": "https://github.com/org/repo", "revision": "abc123"},
"controller": {"argocd": {"lastSync": "abc123", "sync": "Synced"}},
"cluster": {"resourceVersion": "1234567"}
}
}
Pilot's acceptance kernel consumes this JSON directly. The strategy must be declared explicitly — compare source-truth does not auto-detect the strategy (Pilot needs the operator's stated assumption, not cub-scout's guess).
Output evidence
compare three-wayagreement:summary.agreement.state∈ {agreed,converging,diverged,partial}; the canonical "did the cluster end up matching ConfigHub intent?" rollup.compare source-truth(two separate enums):status∈ {PASS,WATCH,BLOCK,ASK} — cub-scout's evidence-quality verdictsource_truth∈ {AGREED,MISMATCH,INCOMPLETE,BLOCKED,UNKNOWN} — cross-surface agreement under the declared strategy- Status and verdict are separate axes — a verdict can be
MISMATCHwhile status isBLOCK(strategy violation) ORWATCH(soft mismatch with proof gaps). Seereferences/source-truth-strategies.mdfor the full status×verdict matrix.
- Receipt-level verdict (only when wrapped via
cub-scout receipt verify --strategy <s>):PASS/WATCH/BLOCK/INCONCLUSIVE.INCONCLUSIVEis the receipt-only fourth state; it does NOT appear in rawcompare source-truthoutput. - Per-field mismatches (
compareFieldMismatch[]) with attribution:cause,managerHint,gitSource,bindingSource. - Agreement summary (three-way):
summary.agreement.state∈ {agreed,converging,diverged,partial}. - CI exit code:
--fail-on info|warningproduces exit 2 on violations. nextSteps[]structured hints — everyactionType∈ {read-only,waiting,human-decision}; mutating is rejected at emit.
References
- Capability map:
README.md§ Compare - Source-truth contract: #393 (v0.1, 4 strategies); #418 (Phase 2 expansion to 9 strategies)
- Three-way agreement summary: #371
--viewscope (connected): #391 / #414- Stage B back-resolution (
--source-path): #440 - Attribution layer (the evidence inside each mismatch): #435 — and
scout-attribute
Constraints
compare source-truthdoes not auto-detect the strategy. The strategy is the operator's declared assumption (which authority produced this artifact?) and Pilot needs it stated, not guessed.- Standalone mode cannot produce a DRY verdict (no ConfigHub). For pure standalone, prefer
compare drift --fileorcompare --git-path. Missing connected-mode evidence is recorded explicitly, not silenced. - For a durable, fingerprinted receipt of the comparison result, use the planned
cub-scout receipt verifyonce #446 batch 1 lands. Until then,--format jsonoutput is the contract — it's stable, but ephemeral. - Never advise the user to bypass a
BLOCKverdict by mutating directly. If the user wants to accept the live state as the new intent, route them to acubskill for governed write-back.
04 同仓库更多 Skills
异常工作负载故障分诊
triage-unhealthy-workload
当用户需要在时间压力下应对出现故障的 Kubernetes 工作负载时使用——例如寻呼告警响起、CI 飘红、“生产环境挂了”的场景。自然表述包括:“deploy/api 出现 CrashLoopBackOff,该怎么办?”“发布卡住了,帮帮我”“这个 pod 起不来”“支付服务触发了寻呼告警”“argocd 里全红了”“我应该先检查什么?”“给我一份针对这个工作负载的分诊方案”。它将 doctor → explain → trace 组合成一个紧凑的约 30 秒循环,运维人员可在已确认寻呼告警的上下文中执行。不要用于:没有紧迫性的计划性排查(直接使用 scout-diagnose)、漂移相关问题(使用 investigate-drift),或任何变更操作(cub-scout 从不做变更——应由用户主导,转由 kubectl 处理)。
资源证据收据生成与校验
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 处理)。
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).
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).
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.
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` —— 请提前说明。