DevOps(AI 驱动的交付与基础设施)
1. 介绍
1.1. 背景:交付链路正在被 AI 重写
过去十年,DevOps 的核心命题是缩短从提交到上线的距离:通过持续集成、持续交付、基础设施即代码(IaC)与自动化发布,把"周级发布"压缩到"天级""小时级"。
AI 的介入改变了这条链路的性质。在 2023—2024 年,AI 在 DevOps 中的角色主要是辅助:生成流水线片段、解释报错、写 Dockerfile 或 Kubernetes 清单。到了 2025 年,角色开始转向代理:智能体被授予读取仓库、修改 IaC、创建合并请求、甚至触发环境发布的能力。
这一转变带来一个根本性的新命题:流水线不再是"执行人写好的脚本",而开始"执行模型生成的意图"。而流水线恰恰是组织里权限最集中、影响面最大、最容易造成不可逆后果的系统之一——它持有制品仓库写权限、云资源凭证、生产环境访问权。
因此,DevOps 方向的 AI Harness 建设,本质上是一个权限工程问题:如何在把写权限交给一个非确定性系统的同时,保持交付链路的可预期性。
1.2. 定义
DevOps 方向(AI 驱动的交付与基础设施):研究与实践以 AI 智能体参与 CI/CD 流水线、基础设施即代码、环境编排与发布过程,并在门禁内保证变更安全、可追溯、可回滚的工程领域。
本方向覆盖四类任务:
| 任务类型 | 说明 | 风险等级 |
|---|---|---|
| 流水线变更 | 新增/修改 CI 阶段、缓存策略、并行度、门禁规则 | L3 高风险 |
| IaC 变更 | 修改 Terraform / Kubernetes / Helm 等基础设施定义 | L3—L4 |
| 发布编排 | 灰度策略、环境提升(promotion)、特性开关切换 | L3—L4 |
| 交付分析 | 构建失败归因、耗时瓶颈定位、依赖与供应链风险扫描 | L0—L1 |
1.3. 在 AI Harness 体系中的定位
图 1-1|DevOps 在 AI Harness 六层体系中的定位与瓶颈
数据来源:基于本文分析绘制的示意图。
本方向主层为 L3 编排与控制层,次层为 L6 治理与安全层与 L2 工具与执行层。它也是六层中 L6 权重最高的方向。
| Harness 层 | 权重 | 本方向的职责 | 具体形态 |
|---|---|---|---|
| L1 上下文工程 | 参与 | 决定模型"看到什么" | 流水线现状清单、IaC 状态(state)、环境差异、既有门禁规则 |
| L2 工具与执行 | 次 | 决定模型"能做什么" | 构建执行器、IaC CLI(plan/apply)、制品仓库、云 API |
| L3 编排与控制 | 主 | 决定"按什么顺序做" | 流水线 DAG、阶段门禁、环境提升顺序、可中断可恢复的发布流程 |
| L4 记忆与状态 | 参与 | 决定"记住什么" | IaC 状态文件、发布记录、环境快照、回滚点 |
| L5 评估与观测 | 参与 | 决定"做得好不好" | 部署频率、变更前置时间、变更失败率、构建耗时、成本 |
| L6 治理与安全 | 主(本方向最重) | 决定"不能做什么" | 权限分离、供应链完整性、审批链、审计留痕、成本护栏 |
1.4. 瓶颈所在层
本方向的瓶颈在 L6 治理与安全层,具体是三个互相纠缠的难题:
- 权限分离失效。DevOps 中最危险的反模式是"能生成变更的系统也能审批变更"。当智能体同时拥有"生成 IaC 变更"与"放宽门禁"的能力时,一切门禁都形同虚设。这是本方向第一位的架构约束。
- 不可逆性。与代码不同,基础设施与发布动作高度不可逆:一次
terraform apply可能销毁资源,一次切流可能把流量导向未验证版本。代码可以git revert,资源销毁不能。 - 配置漂移与状态不一致。IaC 的声明式理想与现实的手动改动之间存在漂移;AI 基于过时状态生成的变更,可能在
plan阶段看起来无害,apply阶段却引发大规模替换。
次要瓶颈在 L3 编排与控制层:发布流程必须可中断、可暂停在任意阶段、可从中断点恢复或回滚——这不是所有 CI 系统都具备的能力。
1.5. 价值
- 把交付链路的认知负担降下来:现代流水线的复杂度已经超出单人可全面掌握的范围,AI 在"理解现状—提出最小变更"上具有实际价值。
- 把安全基线变成默认:AI 生成流水线时可默认注入签名校验、SBOM 生成、依赖扫描等控制项——这在人工编写时最常被省略。
- 把发布从"手艺"变成"流程":灰度策略、回滚触发条件、变更窗口由代码定义,AI 在门禁内执行,减少人为差异。
- 把交付性能可度量:DORA 四指标(部署频率、变更前置时间、变更失败率、服务恢复时间)天然适合作为本方向的度量口径,且已有行业基线可对比。
2. 名词解释
| 术语 | 英文 / 缩写 | 释义 |
|---|---|---|
| 持续集成 | Continuous Integration / CI | 频繁将变更集成到主干并自动构建与测试的实践 |
| 持续交付/部署 | Continuous Delivery / Deployment / CD | 保证主干随时可发布(交付)或自动发布(部署)的实践 |
| 基础设施即代码 | Infrastructure as Code / IaC | 用声明式代码定义基础设施并版本化管理 |
| 计划与应用 | plan / apply | IaC 的两阶段:plan 预演变更、apply 实际执行;apply 视为不可逆 |
| 状态文件 | State File | IaC 记录当前资源实际状态的权威数据;漂移检测的基准 |
| 配置漂移 | Configuration Drift | 实际基础设施与声明式定义之间出现偏差的现象 |
| 制品 | Artifact | 构建产出的可部署单元(镜像、包、二进制) |
| 制品来源证明 | Provenance | 记录制品"由谁、用什么输入、在何时构建"的元数据,是供应链安全的核心 |
| 软件物料清单 | Software Bill of Materials / SBOM | 制品所含全部组件与依赖的清单 |
| 供应链级别 | Supply-chain Levels for Software Artifacts / SLSA | 以等级衡量软件供应链完整性的框架 |
| 门禁 | Gate | 流水线中必须满足的条件;不满足则阻断流转 |
| 环境提升 | Promotion | 制品从一个环境(如预发)晋级到下一环境(如生产)的过程 |
| 蓝绿部署 | Blue-Green Deployment | 准备两套环境,切换时整体切换,回滚快但资源翻倍 |
| 金丝雀发布 | Canary Release | 先向小比例流量发布新版本,观测无误后逐步放大 |
| 特性开关 | Feature Flag / Toggle | 用配置控制功能是否生效,使发布与解耦 |
| 幂等性 | Idempotency | 重复执行同一变更结果一致;是重试安全的前提 |
| 不可变基础设施 | Immutable Infrastructure | 资源不就地修改,而是整体替换,以保证环境一致性 |
| 审批链 | Approval Chain | 变更在发布前必须获得的授权序列 |
| 变更失败率 | Change Failure Rate | 导致服务降级的变更占比,DORA 四指标之一 |
| 变更前置时间 | Lead Time for Changes | 从提交到成功运行于生产的时长,DORA 四指标之一 |
| 成本护栏 | Budget Guardrail | 对云资源与 AI 调用设定的支出上限与告警 |
| 漂移检测 | Drift Detection | 周期性比对实际状态与声明状态并报告差异 |
3. 案例
说明:以下案例依据公开可核实的一手来源整理。效果数字均标注来源方口径与时间;自评口径与实测口径分别标注。
3.1. 案例一:一体化 DevOps 平台的 AI 化演进
来源:GitLab 版本发布记录(18.0 于 2025-05-15、19.0 于 2025-11-19、20.0 于 2026-05-15),https://about.gitlab.com/releases/;GitLab Duo with Amazon Q
3.1.1. 背景
一体化 DevOps 平台(把源码管理、CI/CD、制品、安全扫描、发布编排收拢到一个系统)在 AI 时代具备一个结构性优势:AI 可以在同一个权限域与同一套上下文里,看到从代码到生产的完整链路。分散工具链则相反——AI 每跨一个系统都要重新认证、重新装配上下文,且跨系统的行为难以统一审计。
3.1.2. 方案
以 GitLab 为代表的一体化平台在 2025 至 2026 年的版本线中持续推进 AI 能力(GitLab Duo,并进一步与 Amazon Q 集成):
- 版本节奏:18.0(2025-05-15)→ 19.0(2025-11-19)→ 20.0(2026-05-15),约半年一个大版本,AI 能力随版本线持续演进。
- 一体化上下文:AI 可访问议题、合并请求、流水线日志、安全扫描结果,无需跨系统联邦查询。
- 门禁内置:AI 产生的变更同样必须过流水线门禁,平台不因"AI 生成"而豁免任何控制项。
- 权限继承:AI 的操作权限继承自触发它的用户或令牌,不额外提权——这是防止"AI 成为权限放大器"的关键设计。
3.1.3. 效果
公开信息中,GitLab 的 AI 化路径体现为平台能力集成而非单点指标;具体的量化收益数字在本文可核实范围内标注为 。
可提炼的工程要点(不依赖具体数字):
- 权限继承原则:AI 不得拥有超过触发者的权限。这一条能消除绝大多数"AI 成为特权通道"的风险。
- 门禁不可豁免原则:AI 生成的变更与人工变更走同一条流水线、同一组门禁。
- 一体化上下文优势:在单一系统内,L1 上下文装配成本显著低于跨系统联邦,这是平台化路线的真实价值。
3.2. 案例二:AI 采用率与交付性能的行业基线
来源:DORA 2025 State of AI-assisted Software Development,Google Cloud / DORA,2025-11-12,https://dora.dev/research/2025/dora-report/;Google DORA《AI-assisted software development》报告,2025-10-08
3.2.1. 背景
AI 编码工具的采用率已不再是问题,真正的问题是:采用之后,交付性能是否改善? 在缺乏行业基线的情况下,每个组织都只能与自己的过去比较,而自我比较极易被季节与需求波动污染。
3.2.2. 方案
DORA 采用大样本调查,把 AI 采用情况与交付性能(DORA 四指标)以及开发者主观感受放在一起测量,形成可对照的行业基线。其方法学价值在于:同时测量客观指标与主观感受,从而让两者的背离变得可见。
3.2.3. 效果
表 3-1 DORA 2025 关键发现(2025-11-12)
| 发现 | 数值 | 口径 |
|---|---|---|
| 开发者使用 AI 的比例 | 90%+ | 调查自评 |
| 自评生产力提升 | +80% | 自评,非实测 |
| 代码评审时间变化 | -90% | 自评 |
| 单次任务耗时超 4 小时的比例 | 30% | 调查自评 |
表 3-2 采用率的其他交叉印证
| 来源 | 数值 | 时间 |
|---|---|---|
| Stack Overflow 2025 开发者调查:使用或计划使用 | 84% | 2025-07-30 |
| Stack Overflow 2025 开发者调查:近普及采用 | 90% | 2025-07-30 |
| Stack Overflow 2025 开发者调查:不信任 AI 输出准确性 | 46% | 2025-07-30 |
解读:
- 采用率已越线,信任度未越线。84%—90% 的人在用,但 46% 的人不信任输出准确性。这个组合说明当前处于"高频使用 + 高频核验"的阶段——验证成本被系统性低估。
- 30% 的任务单次超 4 小时,与 AI"提速"的叙事形成张力:长任务占比高说明大量任务并未被 AI 简单化,反而可能因为 AI 介入而变得更长(生成—验证—返工的循环)。
- 自评 -90% 的评审时间需要格外谨慎。评审时间下降可能来自"评审变浅"而非"代码变好",必须与缺陷逃逸率联合观测。
3.3. 案例三:为 AI 生成的变更建立供应链门禁
来源:NIST SP 800-218A(SSDF 1.1),2024-10,https://csrc.nist.gov/pubs/sp/800/218/a/final;NIST Cybersecurity Framework (CSF) 2.0,2024-02-26,https://www.nist.gov/cyberframework
3.3.1. 背景
AI 生成代码带来一个特有的供应链风险:模型可能建议使用不存在、已废弃或被投毒的依赖包(依赖幻觉 / slopsquatting)。传统依赖扫描只能发现已知漏洞,无法识别"这个包从来就不该存在"。同时,AI 生成变更的速度使得人工审查依赖变更成为瓶颈。
3.3.2. 方案
把供应链控制做成流水线上的自动门禁,而不是人工检查项:
- 来源可信性门禁:新增依赖必须有可解析的上游仓库、可识别的维护者、发布时间与下载量基线;不满足即阻断。
- SBOM 门禁:每次构建生成 SBOM,与上一次对比,任何新增组件都需显式确认。
- 来源证明门禁:制品必须携带 provenance(构建者、输入 commit、构建环境),缺少即拒绝晋级。
- 完整性门禁:制品签名校验;未签名或签名不匹配即拒绝部署。
- 权限分离:生成变更的智能体不得拥有修改上述门禁规则的权限。
- 对齐框架:控制项映射 NIST SP 800-218A(SSDF 1.1)的保护软件(PW)、构建安全(PS)与响应漏洞(RV)系列实践;风险管理类目对齐 NIST CSF 2.0(2024-02-26)。
3.3.3. 效果
本案例的效果不以速度衡量,而以风险拦截衡量:
- 依赖幻觉在门禁层被拦截,不进入代码评审环节,从而不消耗评审资源。
- 制品来源证明使"这个镜像是怎么来的"成为可回答的问题,这在 AI 大量参与构建的时代是审计的基础。
- 权限分离使"AI 放宽自己的门禁"在架构上不可能,而非"被禁止"。
落地提示:这些门禁的价值在于默认开启且不可被单一角色关闭。若门禁可以被一线开发者(或智能体)自行豁免,其存在即无意义。
4. 实践标准
4.1. AGENTS.md 规范
以下为本方向的完整 AGENTS.md 原文,置于代码块中以便直接复制。使用时须叠加组级 AGENTS.md 的共同条款,冲突时以就近优先原则消解。
# AGENTS.md —— 软件工程 · DevOps 方向(交付与基础设施)
## 角色与边界
- 本文件约束**参与交付链路的 AI 智能体**:流水线变更、IaC 变更、发布编排、交付分析。
- 允许自行完成:读取仓库与流水线配置、只读调用云 API 查询现状、生成 IaC 变更与 `plan` 预演、生成流水线片段、分析构建失败原因、生成 SBOM 与依赖差异报告、在预发环境执行验证性部署。
- 禁止自行完成:执行 `apply` / `kubectl apply` 等下达类命令、修改或放宽门禁规则、创建或轮换凭证、发布到生产、删除制品或镜像、变更审批链、修改审计配置。
- 边界判定:**`apply` 与 `plan` 的分界线就是本方向的权限红线**——`plan` 可自行,`apply` 必须人工确认。
- 核心原则:智能体的权限**继承自触发者**,不得额外提权;智能体不得成为权限放大器。
## 环境假设
- 提供仓库读写(分支隔离)、流水线系统访问、IaC CLI、制品仓库、云 API(只读为默认)。
- 提供容器或微虚机沙箱;`plan` 与构建在沙箱内执行。
- 提供 IaC 状态文件的只读访问,且状态有版本与时间戳(用于漂移检测)。
- 提供制品仓库与签名/来源证明(provenance)机制。
- 提供审计日志(谁、何时、对什么环境做了什么),且智能体不可删改。
- 提供成本计量(云支出 + AI 调用)与上限设置。
- 缺失任一项时降级执行并显式声明;**审计日志缺失时禁止执行任何写操作**。
## 上下文加载顺序(Context Budget)
1. 任务契约:目标、产出物、验收标准(固定,不压缩)
2. 就近指令文件:当前目录及其祖先链
3. 流水线现状:阶段定义、门禁规则、触发条件、最近 N 次执行结果
4. IaC 现状:声明定义 + 状态文件摘要 + 漂移报告
5. 环境拓扑:环境清单、晋级路径、审批要求
6. 供应链现状:依赖清单、SBOM、最近变更
7. 历史事故:发布相关事故的摘要与教训
8. 工具结果:按需追加
记录 Token 预算表;超限压缩而非截断,压缩须保留门禁规则与环境约束。
## 工具契约
- 副作用分级:R(只读)/ W(工作区写)/ X(沙箱内执行)/ S(共享状态写,需确认)/ D(不可逆,默认拒绝)。
- **`apply` 类命令一律列为 D 级**:`terraform apply`、`kubectl apply`、`helm upgrade`、制品晋级、生产切流。
- 云 API 调用默认只读;写操作须显式列出且逐项确认。
- `plan` 输出必须完整保留作为证据,且 `apply` 前须比对"本次 plan 与待执行变更集一致"。
- 所有执行类工具必须设置超时;非幂等工具重试前先确认上次是否生效。
- 输出超限时截断并给出定位信息。
## 任务执行流程(SOP)
1. 解析契约:明确目标环境与验收标准;缺失则停止并澄清。
2. 现状盘点:流水线阶段、IaC 状态与漂移、环境拓扑、依赖清单。
3. 影响面分析:本次变更影响哪些资源、服务、环境、成本。
4. 变更草案 + `plan` 预演:**必须产出 plan 输出作为证据**。
5. 计划确认(L3 高风险):提交 影响面 + plan 输出 + 风险点 + 回滚方案,获审批。
6. 执行:仅执行已审批的变更;每步完成后验证。
7. 门禁验证:全部流水线门禁通过,含供应链门禁。
8. 交付:五段式变更说明 + plan/apply 记录 + 门禁报告。
9. 留痕与观测:归档审计日志;发布后进入观测窗口,异常即触发回滚。
## 验证与证据要求
| 验证项 | 判定 | 证据 |
|---|---|---|
| `plan` 与变更集一致 | 逐项比对通过 | plan 输出 + 比对结论 |
| 门禁全通过 | 无被豁免项 | 门禁报告(含豁免项清单 = 0) |
| 供应链门禁 | SBOM 生成、来源证明齐备、签名有效 | SBOM + provenance + 签名校验结果 |
| 依赖合法性 | 新增依赖来源可解析、许可证明确 | 依赖差异表 |
| 回滚可用 | 回滚方案存在且已演练或可证明 | 回滚方案 + 演练记录 |
| 成本在预算内 | 预估增量 ≤ 上限 | 成本预估 |
| 审批链完整 | 所需审批已获且留痕 | 审批记录 |
| 审计留痕 | 操作可追溯到人 | 审计日志条目 |
**禁止**:以"流水线显示绿色"作为唯一证据——必须确认门禁是真实开启的(用一条故意失败的变更反向验证)。
**禁止**:自行豁免任何门禁;如需豁免,须人工审批并在变更说明中显式列出。
## 失败与升级策略
- 门禁失败:定位失败原因 → 修正变更(**禁止修正门禁**)→ 重试;重试 3 次仍失败则回滚并上报。
- `plan` 出现意外的大规模替换(如资源将被销毁重建):**立即停止**,判定为高风险,升级人工。
- 漂移检测发现显著偏差:停止自动变更,先对齐状态或人工介入。
- 发布后观测异常:按预设触发条件自动回滚;回滚后保留现场证据。
- 权限被拦截:不得绕过;记录并升级。
升级三要素:已尝试动作与结果 / 卡点现象与证据 / 建议选项及风险。
## 安全与合规红线
1. 禁止智能体拥有修改门禁规则的权限(**权限分离**)。
2. 禁止执行 `apply` 类命令而未获人工审批。
3. 禁止创建、轮换、导出凭证;禁止在配置、日志、制品中写入密钥。
4. 禁止删除制品、镜像、状态文件、审计日志。
5. 禁止在变更中关闭 TLS 校验、禁用安全扫描、降低签名要求。
6. 禁止跨环境直接晋级(如从开发直接到生产),必须按既定晋级路径。
7. 遵循 NIST SP 800-218A(SSDF 1.1,2024-10)的 PW / PS / RV 系列实践。
8. 风险管理对齐 NIST CSF 2.0(2024-02-26)的治理(GV)、识别(ID)、保护(PR)、检测(DE)、响应(RS)、恢复(RC)六个功能。
9. 组织级落地对齐 ISO/IEC 42001:2023 的角色职责与成文信息要求。
## 禁止事项
1. 禁止把 `plan` 输出当作"已经验证"的证据——`plan` 只说明意图,不说明结果。
2. 禁止在无回滚方案的情况下执行任何 `apply`。
3. 禁止使用 `[待填写]`、`XX`、`___` 之外的非标准占位符;不确定处统一使用 `[待填写]`。
4. 禁止以"模型认为"作为技术判断依据。
5. 禁止在生产环境做实验性变更。
6. 禁止变更集超出审批范围(审批了 A 却顺带改了 B)。
7. 禁止删除或改写他人的指令文件、门禁配置与安全策略。
## 输出格式
每次交付必须包含五段:
- 变更说明:文件/资源清单 + 每项一句话说明
- 为什么改:动因与依据(关联任务/缺陷/需求编号)
- 如何验证:plan 输出摘要、门禁报告、SBOM/签名结果、未验证项与原因
- 风险与影响:受影响资源与服务、成本增量、回滚触发条件
- 回滚方案:具体命令或操作路径、回滚代价与注意事项(**回滚必须可执行**)
附加输出:影响面清单、环境晋级路径、审批记录引用、发布后观测窗口与指标。
## 评估与自检
| 自检项 | 判定 |
|---|---|
| plan 与变更集一致 | 是 / 否 |
| 门禁全通过且无自我豁免 | 是 / 否 |
| 供应链门禁(SBOM/来源证明/签名)齐备 | 是 / 否 |
| 依赖来源可解析 | 是 / 否 |
| 回滚方案可执行且已演练或可证明 | 是 / 否 |
| 成本在预算内 | 是 / 否 |
| 审批链完整留痕 | 是 / 否 |
| 审计日志可追溯到人 | 是 / 否 |
任一"否"须显式列出;自检不通过即任务未完成。
度量口径:部署频率、变更前置时间、变更失败率、服务恢复时间(DORA 四指标);辅以构建耗时、门禁拦截率、回滚率、成本趋势。 4.2. SKILL.md 规范
---
name: safe-iac-and-pipeline-change
description: 在门禁内完成一项基础设施或流水线变更——盘点现状、分析影响面、产出 plan 预演、跑通供应链与门禁检查、获取审批、执行并留痕。适用于 IaC 变更、CI/CD 流水线修改、发布编排与环境晋级。当需要让 AI 参与交付链路且必须保证可回滚、可审计时使用。
version: 1.0
created: 2026-09-12
---
# 安全的基础设施与流水线变更
## 适用场景
- 修改 IaC 定义(Terraform / Kubernetes / Helm 等)。
- 新增或修改 CI/CD 阶段、缓存策略、并行度、门禁规则。
- 制品环境晋级、灰度策略调整、特性开关切换。
- 构建失败归因、依赖与供应链风险扫描。
不适用于:生产环境的紧急热修复(走应急流程)、无变更工单的临时操作、探索性云资源试用。
## 前置条件
| 类别 | 要求 | 缺失时处置 |
|---|---|---|
| 变更契约 | 目标环境、影响范围、验收标准 | 停止,先补全 |
| 状态可见 | IaC 状态文件可读且有时间戳 | 先做漂移检测 |
| 审计 | 操作可留痕 | **禁止任何写操作** |
| 沙箱 | `plan` 与构建在隔离环境执行 | 升级 |
| 权限 | 智能体权限继承自触发者,无额外提权 | 按最低权限执行 |
| 回滚点 | 存在可回退的状态或版本 | 先创建回滚点 |
## 输入
- 变更需求与验收标准
- 仓库 + 分支 + commit SHA
- 目标环境(开发 / 预发 / 生产)
- 关联变更单或审批编号
- 预算上限(成本增量 / 时长)
## 输出
- IaC 变更集 + `plan` 输出
- 影响面清单(资源、服务、成本)
- 门禁报告(含供应链门禁)
- 五段式变更说明 + 审批记录引用
- 发布后观测窗口与指标定义
## 执行步骤
1. **解析契约**:明确目标环境与验收标准;生产环境一律 L3/L4。
2. **现状盘点**:流水线阶段、IaC 定义与状态、漂移报告、环境拓扑、依赖清单。
3. **影响面分析**:列出受影响资源、服务、环境、成本增量;识别是否有资源将被销毁重建。
4. **变更草案**:最小化改动;不夹带无关调整。
5. **`plan` 预演**:执行 `plan`,完整保留输出;**若出现意外的大规模替换或销毁,立即停止并升级**。
6. **门禁验证**:供应链门禁(SBOM、来源证明、签名)+ 常规门禁;任一未过则修正变更(**不修正门禁**)。
7. **提交审批**:影响面 + plan 输出 + 风险点 + 回滚方案;等待审批,**超时不得自行继续**。
8. **执行**:仅执行已审批内容;每步完成后验证。
9. **观测**:发布后进入观测窗口,按预设触发条件判断是否回滚。
10. **留痕**:归档审计日志、plan/apply 记录、门禁报告。
## 质量标准(DoD)
1. `plan` 输出与最终变更集逐项一致。
2. 全部门禁通过且**无任何自我豁免项**。
3. SBOM 已生成、来源证明齐备、签名有效。
4. 新增依赖来源可解析、许可证明确、维护状态可查。
5. 回滚方案明确、可执行,且不依赖智能体继续参与。
6. 成本增量在预算内。
7. 审批链完整且留痕。
8. 审计日志可追溯到具体的人。
9. 发布后观测窗口与回滚触发条件已定义。
10. 未触及权限与安全红线;智能体未拥有修改门禁的能力。
## 常见失败与处理
| 失败 | 表现 | 处理 |
|---|---|---|
| plan 出现意外销毁 | "will be destroyed" 超出预期 | 立即停止并升级;禁止 apply |
| 门禁失败 | 依赖扫描/签名/测试未过 | 修正变更;**禁止放宽门禁** |
| 状态漂移 | 实际状态与声明偏差大 | 停止自动变更,先对齐状态 |
| 依赖幻觉 | 建议的包不存在或被废弃 | 门禁拦截;不得人工放行 |
| 审批超时 | 无人响应 | 挂起并升级,不得自行继续 |
| 发布后异常 | 观测指标越界 | 按触发条件自动回滚,保留现场 |
| 回滚失败 | 回滚依赖智能体继续参与 | D5 未通过,必须重做 |
| 范围蔓延 | 审批了 A 却改了 B | 回退越界部分,重新审批 |
## 示例
**场景**:为服务新增一个只读副本数据库,并调整连接池上限。
- 契约:仅预发环境;不影响主库;可一键回滚。
- 现状:主库 1 实例,连接池上限 100;IaC 状态无漂移。
- 影响面:新增 1 个只读实例(成本 +约 X/月)、安全组规则 1 条、应用配置 1 处。
- `plan`:输出显示 "1 to add, 0 to change, 0 to destroy" —— 与预期一致,无销毁项。
- 门禁:SBOM 生成;依赖无新增;镜像签名有效;集成测试通过。
- 审批:L3 高风险,需人工审批(变更单号已关联)。
- 执行:apply 后验证只读实例可连通、主从延迟在阈值内。
- 观测:30 分钟窗口,监控主从延迟与错误率;延迟超阈值即回滚。
- 回滚:删除只读实例 + 恢复连接池配置(IaC 回退至上一版本)。
- 自检:八项全"是"。 4.3. 落地检查清单
权限与分离(L6,最高优先级)
- [ ] 智能体权限继承自触发者,无额外提权
- [ ] 生成变更的智能体不具备修改门禁规则的权限
- [ ] 审批权与生成权在架构上分离(非仅流程约定)
- [ ]
apply/kubectl apply/ 制品晋级被列为 D 级并硬拦截 - [ ] 凭证创建与轮换对智能体完全关闭
- [ ] 审计日志智能体不可删改
流水线与门禁(L3)
- [ ] 门禁对 AI 生成变更与人工变更一视同仁,无豁免通道
- [ ] 已用一条故意失败的变更反向验证门禁确实会拦截
- [ ] 流水线支持在任意阶段暂停与从中断点恢复
- [ ] 环境晋级路径固定(开发 → 预发 → 生产),无跨域直跳
- [ ] 回滚是流水线的一等公民(一键可触发,非手工拼命令)
基础设施(L2 + L4)
- [ ] IaC 状态文件有版本与时间戳,漂移检测周期运行
- [ ]
plan输出完整保留为证据,且与最终变更集逐项比对 - [ ]
plan中出现销毁项时自动升级人工 - [ ] 采用不可变基础设施策略,减少就地修改
- [ ] 变更幂等,重复执行结果一致
供应链(L6)
- [ ] 每次构建生成 SBOM,并做与上一次的差异比对
- [ ] 制品携带来源证明(provenance)
- [ ] 制品签名校验在部署前执行
- [ ] 新增依赖有来源可解析性、许可证、维护状态检查
- [ ] 已对齐 NIST SP 800-218A(SSDF 1.1)与 NIST CSF 2.0 控制项
度量(L5)
- [ ] 部署频率、变更前置时间、变更失败率、服务恢复时间四指标在测
- [ ] 门禁拦截率与回滚率在测(拦截率高说明上游质量有改进空间)
- [ ] 云成本与 AI 调用成本有护栏与趋势观测
- [ ] 自评数据与实测数据分别标注,未混用
5. 总结
DevOps 方向是 AI Harness 六层能力中 L6 治理与安全权重最高的方向,原因很简单:流水线是组织里权限最集中、后果最不可逆的系统,而 AI 是一个非确定性的参与者。
本方向有三个不可妥协的架构约束:
- 权限分离:能生成变更的系统不能审批变更,能生成变更的系统不能修改门禁。这不是流程约定,必须是架构事实——否则一切门禁都只是"建议"。
plan与apply的分界线即权限红线:plan是意图,可自行;apply是事实,必须人工。把plan输出当作验证证据,是本方向最常见的认知错误。- 权限继承而非权限放大:AI 的权限不得超过触发它的主体。这一条能消除绝大多数"AI 成为特权通道"的风险。
关于效果,需要保持清醒:DORA 2025(2025-11-12)显示 90%+ 的开发者在用 AI、自评生产力 +80%、评审时间 -90%,但同一份数据也显示 30% 的任务单次耗时超过 4 小时;而 Stack Overflow 2025(2025-07-30)显示 46% 的开发者不信任 AI 输出的准确性。这组数字共同指向一个结论:采用率已经越线,信任度与可预期性尚未越线。
DevOps 方向在 AI 时代的真实任务,不是让 AI 更快地发布,而是让 AI 参与的发布依然可以被信任——可回滚、可审计、可归因。
信息缺口声明
- GitLab 各版本(18.0 / 19.0 / 20.0)中 AI 能力的具体清单与量化收益数字标注为 ,本文仅在可核实范围内引用版本与发布时间。
- 案例 3.1 中 GitLab Duo with Amazon Q 的具体集成能力与效果数字缺乏可访问的一手来源,标注为 ,本文未采用具体数字。
- SLSA(供应链等级)在本方向被引用为通用框架,具体等级要求与组织当前达成等级标注为
[待填写]。 - 各组织自身的 DORA 四指标基线值标注为
[待填写],需以内部度量填补。 - 本方向的部分企业案例细节与来源 URL 待检索报告补充后回填。
6. 参考资料
- GitLab 版本发布记录(18.0 / 19.0 / 20.0) — GitLab Inc.https://about.gitlab.com/releases/
- DORA 2025 State of AI-assisted Software Development — Google Cloud / DORA,2025-11-12。https://dora.dev/research/2025/dora-report/
- AI-assisted software development — Google DORA,2025-10-08。https://dora.dev/
- Stack Overflow 2025 Developer Survey — Stack Overflow,2025-07-30。https://survey.stackoverflow.co/2025/
- NIST SP 800-218A Secure Software Development Framework (SSDF) 1.1 — NIST,2024-10。https://csrc.nist.gov/pubs/sp/800/218/a/final
- NIST Cybersecurity Framework (CSF) 2.0 — NIST,2024-02-26。https://www.nist.gov/cyberframework
- NIST AI Risk Management Framework (AI RMF 1.0) 及 GenAI Profile — NIST,2024-07-26。https://www.nist.gov/itl/ai-risk-management-framework
- ISO/IEC 42001:2023 人工智能管理体系 — ISO/IEC,2023。https://www.iso.org/standard/42001
- SLSA(Supply-chain Levels for Software Artifacts) — OpenSSF。https://slsa.dev/
- OpenTelemetry 语义约定 — OpenTelemetry。https://opentelemetry.io/docs/concepts/semantic-conventions/
- OWASP Top 10 for LLM Applications 2025 — OWASP,2025-11-10。https://owasp.org/www-project-top-10-for-large-language-model-applications/
- Model Context Protocol 官方规范 — Anthropic 等。https://modelcontextprotocol.io/
DevOps (AI-Driven Delivery & Infrastructure)
1. Introduction
1.1. Background: The Delivery Pipeline Is Being Rewritten by AI
Over the past decade, the core proposition of DevOps has been shortening the distance from commit to production: compressing "weekly releases" down to "daily" and "hourly" releases through continuous integration, continuous delivery, infrastructure as code (IaC), and automated release.
AI has changed the very nature of this pipeline. In 2023—2024, AI's role in DevOps was primarily assistive: generating pipeline fragments, explaining errors, or writing Dockerfiles and Kubernetes manifests. By 2025, the role began shifting toward agency: agents were granted the ability to read repositories, modify IaC, create merge requests, and even trigger environment releases.
This shift raises a fundamentally new question: the pipeline is no longer "executing scripts written by humans" but has begun to "execute intent generated by models". And the pipeline is precisely one of the systems in an organization with the most concentrated permissions, the broadest impact surface, and the highest potential for irreversible consequences — it holds write access to artifact repositories, cloud resource credentials, and production environment access.
Accordingly, building the AI Harness for the DevOps area is essentially a permissions engineering problem: how to hand write access to a non-deterministic system while keeping the delivery pipeline predictable.
1.2. Definition
DevOps area (AI-driven delivery & infrastructure): an engineering field that researches and practices engaging AI agents in CI/CD pipelines, infrastructure as code, environment orchestration, and release processes, while ensuring that changes remain safe, traceable, and rollback-able within gates.
This area covers four categories of tasks:
| Task Type | Description | Risk Level |
|---|---|---|
| Pipeline Changes | Adding/modifying CI stages, cache strategies, parallelism, and gate rules | L3 high risk |
| IaC Changes | Modifying infrastructure definitions such as Terraform / Kubernetes / Helm | L3—L4 |
| Release Orchestration | Canary strategy, environment promotion, feature flag toggling | L3—L4 |
| Delivery Analytics | Build failure attribution, identifying time bottlenecks, dependency and supply-chain risk scanning | L0—L1 |
1.3. Positioning in the AI Harness Framework
图 1-1|DevOps 在 AI Harness 六层体系中的定位与瓶颈
数据来源:基于本文分析绘制的示意图。
This area's primary layer is the L3 Orchestration & Control layer, with secondary layers being the L6 Governance & Security layer and the L2 Tools & Execution layer. It is also the area with the highest L6 weighting among the six layers.
| Harness Layer | Weighting | Role in This Area | Concrete Form |
|---|---|---|---|
| L1 Context Engineering | Participates | Determines what the model "sees" | Pipeline current-state inventory, IaC state, environment differences, existing gate rules |
| L2 Tools & Execution | Secondary | Determines what the model "can do" | Build executors, IaC CLI (plan/apply), artifact repositories, cloud APIs |
| L3 Orchestration & Control | Primary | Determines the order in which things are done | Pipeline DAG, stage gates, environment promotion order, interruptible and resumable release flows |
| L4 Memory & State | Participates | Determines what is remembered | IaC state files, release records, environment snapshots, rollback points |
| L5 Evaluation & Observability | Participates | Determines how well things are done | Deployment frequency, lead time for changes, change failure rate, build duration, cost |
| L6 Governance & Security | Primary (heaviest in this area) | Determines what cannot be done | Permission separation, supply-chain integrity, approval chains, audit trails, cost guardrails |
1.4. Bottleneck Layer
The bottleneck of this area lies in the L6 Governance & Security layer, specifically in three intertwined problems:
- Permission separation failure. The most dangerous anti-pattern in DevOps is that "the system that generates changes can also approve them." When an agent simultaneously has the ability to "generate IaC changes" and "relax gates," every gate is reduced to a formality. This is the foremost architectural constraint of this area.
- Irreversibility. Unlike code, infrastructure and release actions are highly irreversible: a single
terraform applymay destroy resources, and a single traffic shift may route traffic to an unverified version. Code can begit revert-ed; destroyed resources cannot. - Configuration drift and state inconsistency. Drift exists between IaC's declarative ideal and real-world manual changes; a change generated by AI from stale state may look harmless at the
planstage, only to trigger large-scale replacement at theapplystage.
A secondary bottleneck lies in the L3 Orchestration & Control layer: release flows must be interruptible, pausable at any stage, and resumable from the interruption point, or rollback-able — an ability not every CI system possesses.
1.5. Value
- Reduce the cognitive burden of the delivery pipeline: the complexity of modern pipelines has exceeded what any single person can fully grasp, and AI has real value in "understanding the current state — proposing minimal changes."
- Make the security baseline the default: when generating pipelines, AI can inject controls such as signature verification, SBOM generation, and dependency scanning by default — precisely the items most often omitted when written manually.
- Turn release from a "craft" into a "process": canary strategy, rollback trigger conditions, and change windows are defined in code, and AI executes within the gates, reducing human variance.
- Make delivery performance measurable: the four DORA metrics (deployment frequency, lead time for changes, change failure rate, and time to restore service) are naturally suited as the measurement framework for this area, and industry baselines already exist for comparison.
2. Glossary
| Term | English / Abbreviation | Definition |
|---|---|---|
| Continuous Integration | Continuous Integration / CI | The practice of frequently integrating changes into the main branch with automated builds and tests |
| Continuous Delivery/Deployment | Continuous Delivery / Deployment / CD | The practice of keeping the main branch always releasable (delivery) or automatically released (deployment) |
| Infrastructure as Code | Infrastructure as Code / IaC | Defining infrastructure with declarative code and managing it under version control |
| Plan and Apply | plan / apply | The two phases of IaC: plan rehearses the change, apply actually executes it; apply is treated as irreversible |
| State File | State File | The authoritative data in IaC recording the actual state of current resources; the baseline for drift detection |
| Configuration Drift | Configuration Drift | The phenomenon in which actual infrastructure deviates from the declarative definition |
| Artifact | Artifact | A deployable unit produced by the build (image, package, binary) |
| Artifact Provenance | Provenance | Metadata recording "who built the artifact, from what inputs, and when"; the core of supply-chain security |
| Software Bill of Materials | Software Bill of Materials / SBOM | A list of all components and dependencies contained in an artifact |
| Supply-chain Levels | Supply-chain Levels for Software Artifacts / SLSA | A framework that measures software supply-chain integrity by level |
| Gate | Gate | A condition that must be satisfied in the pipeline; if not met, the flow is blocked |
| Promotion | Promotion | The process by which an artifact advances from one environment (e.g. staging) to the next (e.g. production) |
| Blue-Green Deployment | Blue-Green Deployment | Maintaining two sets of environments and switching over as a whole; fast rollback but doubled resources |
| Canary Release | Canary Release | Releasing a new version to a small percentage of traffic first, then gradually scaling up once it is observed to be sound |
| Feature Flag | Feature Flag / Toggle | Using configuration to control whether a feature takes effect, decoupling release from deployment |
| Idempotency | Idempotency | Repeatedly executing the same change yields the same result; a prerequisite for safe retries |
| Immutable Infrastructure | Immutable Infrastructure | Resources are not modified in place but replaced wholesale, to ensure environment consistency |
| Approval Chain | Approval Chain | The sequence of authorizations a change must obtain before release |
| Change Failure Rate | Change Failure Rate | The proportion of changes that degrade the service; one of the four DORA metrics |
| Lead Time for Changes | Lead Time for Changes | The time from commit to running successfully in production; one of the four DORA metrics |
| Budget Guardrail | Budget Guardrail | Spending caps and alerts set for cloud resources and AI calls |
| Drift Detection | Drift Detection | Periodically comparing the actual state against the declared state and reporting differences |
3. Case Studies
Note: the following cases are compiled from publicly verifiable primary sources. All effect figures are labeled with the source's methodology and time; self-reported methodology and measured methodology are labeled separately.
3.1. Case 1: The AI Evolution of an All-in-One DevOps Platform
Source: GitLab release notes (18.0 on 2025-05-15, 19.0 on 2025-11-19, 20.0 on 2026-05-15), https://about.gitlab.com/releases/; GitLab Duo with Amazon Q
3.1.1. Background
An all-in-one DevOps platform (which consolidates source management, CI/CD, artifacts, security scanning, and release orchestration into a single system) has a structural advantage in the AI era: AI can see the complete chain from code to production within the same permission domain and the same set of context. A fragmented toolchain is the opposite — every time AI crosses a system, it must re-authenticate and re-assemble context, and cross-system behavior is hard to audit uniformly.
3.1.2. Approach
Represented by GitLab, all-in-one platforms have continuously advanced their AI capabilities (GitLab Duo, further integrated with Amazon Q) across their 2025—2026 release line:
- Release cadence: 18.0 (2025-05-15) → 19.0 (2025-11-19) → 20.0 (2026-05-15), roughly one major release every six months, with AI capabilities evolving continuously along the release line.
- Unified context: AI can access issues, merge requests, pipeline logs, and security scan results without cross-system federated queries.
- Built-in gates: changes produced by AI must likewise pass pipeline gates; the platform does not exempt any control merely because it is "AI-generated."
- Permission inheritance: AI's operational permissions are inherited from the user or token that triggers it, with no additional escalation — a key design that prevents "AI from becoming a permission amplifier."
3.1.3. Results
In publicly available information, GitLab's AI evolution manifests as platform capability integration rather than isolated point metrics; specific quantified benefit figures are marked [To be verified] within the verifiable scope of this document.
Engineering takeaways (independent of specific numbers):
- Permission inheritance principle: AI must never possess more permissions than its trigger. This single rule eliminates the vast majority of "AI as a privileged channel" risks.
- No gate exemption principle: AI-generated changes go through the same pipeline and the same set of gates as human changes.
- Unified-context advantage: within a single system, L1 context assembly costs are significantly lower than cross-system federation, which is the real value of the platform route.
3.2. Case 2: Industry Baselines for AI Adoption and Delivery Performance
Source: DORA 2025 State of AI-assisted Software Development, Google Cloud / DORA, 2025-11-12, https://dora.dev/research/2025/dora-report/; Google DORA's "AI-assisted software development" report, 2025-10-08
3.2.1. Background
The adoption rate of AI coding tools is no longer the question; the real question is: does delivery performance improve after adoption? Without an industry baseline, each organization can only compare against its own past, and self-comparison is easily contaminated by seasonal and demand fluctuations.
3.2.2. Approach
DORA uses a large-sample survey, measuring AI adoption together with delivery performance (the four DORA metrics) and developers' subjective perceptions, to form an industry baseline for comparison. Its methodological value lies in measuring objective metrics and subjective perceptions simultaneously, making the divergence between the two visible.
3.2.3. Results
Table 3-1 DORA 2025 Key Findings (2025-11-12)
| Finding | Value | Methodology |
|---|---|---|
| Proportion of developers using AI | 90%+ | Survey self-report |
| Self-reported productivity gain | +80% | Self-reported, not measured |
| Change in code review time | -90% | Self-reported |
| Proportion of single tasks exceeding 4 hours | 30% | Survey self-report |
Table 3-2 Other Cross-Corroboration of Adoption Rates
| Source | Value | Date |
|---|---|---|
| Stack Overflow 2025 Developer Survey: using or planning to use | 84% | 2025-07-30 |
| Stack Overflow 2025 Developer Survey: near-universal adoption | 90% | 2025-07-30 |
| Stack Overflow 2025 Developer Survey: do not trust AI output accuracy | 46% | 2025-07-30 |
Interpretation:
- Adoption has crossed the line; trust has not. 84%—90% are using it, yet 46% do not trust the accuracy of the output. This combination points to a phase of "high-frequency use + high-frequency verification" — verification cost is systematically underestimated.
- 30% of tasks take over 4 hours each, in tension with the narrative of AI "speeding things up": a high share of long tasks suggests that many tasks are not simplified by AI, and may even become longer because of AI involvement (a generate—verify—rework loop).
- The self-reported -90% review time calls for particular caution. The drop in review time may stem from "shallower review" rather than "better code," and must be observed together with the defect escape rate.
3.3. Case 3: Building Supply-Chain Gates for AI-Generated Changes
Source: NIST SP 800-218A (SSDF 1.1), 2024-10, https://csrc.nist.gov/pubs/sp/800/218/a/final; NIST Cybersecurity Framework (CSF) 2.0, 2024-02-26, https://www.nist.gov/cyberframework
3.3.1. Background
AI-generated code introduces a distinctive supply-chain risk: the model may suggest dependency packages that do not exist, are deprecated, or have been poisoned (dependency hallucination / slopsquatting). Traditional dependency scanning can only find known vulnerabilities; it cannot recognize that "this package should never have existed." At the same time, the speed of AI-generated changes makes manual review of dependency changes a bottleneck.
3.3.2. Approach
Make supply-chain controls automatic gates on the pipeline, rather than manual check items:
- Source-trustworthiness gate: new dependencies must have a resolvable upstream repository, identifiable maintainers, a release date, and a download baseline; otherwise they are blocked.
- SBOM gate: generate an SBOM on every build and compare it with the previous one; any newly added component requires explicit confirmation.
- Provenance gate: artifacts must carry provenance (builder, input commit, build environment); promotion is refused if it is missing.
- Integrity gate: artifact signature verification; unsigned or mismatched signatures are refused deployment.
- Permission separation: the agent that generates changes must not have permission to modify the gate rules above.
- Framework alignment: the controls map to NIST SP 800-218A (SSDF 1.1)'s protect-the-software (PW), build-security (PS), and respond-to-vulnerabilities (RV) practice groups; risk-management categories align with NIST CSF 2.0 (2024-02-26).
3.3.3. Results
The effect of this case is not measured by speed but by risk interception:
- Dependency hallucination is intercepted at the gate layer and never reaches the code review stage, so it does not consume review resources.
- Artifact provenance turns "where did this image come from" into an answerable question, which is the basis of auditing in an era when AI participates heavily in building.
- Permission separation makes "AI relaxing its own gates" architecturally impossible, rather than merely "prohibited."
Implementation tip: the value of these gates lies in being enabled by default and not closeable by a single role. If a gate can be exempted at will by a frontline developer (or agent), its existence is meaningless.
4. Practice Standards
4.1. AGENTS.md Specification
Below is the complete AGENTS.md for this area, placed in a code block for direct copying. When using it, layer on the common clauses of the group-level AGENTS.md; conflicts are resolved by the nearest-first principle.
# AGENTS.md —— 软件工程 · DevOps 方向(交付与基础设施)
## 角色与边界
- 本文件约束**参与交付链路的 AI 智能体**:流水线变更、IaC 变更、发布编排、交付分析。
- 允许自行完成:读取仓库与流水线配置、只读调用云 API 查询现状、生成 IaC 变更与 `plan` 预演、生成流水线片段、分析构建失败原因、生成 SBOM 与依赖差异报告、在预发环境执行验证性部署。
- 禁止自行完成:执行 `apply` / `kubectl apply` 等下达类命令、修改或放宽门禁规则、创建或轮换凭证、发布到生产、删除制品或镜像、变更审批链、修改审计配置。
- 边界判定:**`apply` 与 `plan` 的分界线就是本方向的权限红线**——`plan` 可自行,`apply` 必须人工确认。
- 核心原则:智能体的权限**继承自触发者**,不得额外提权;智能体不得成为权限放大器。
## 环境假设
- 提供仓库读写(分支隔离)、流水线系统访问、IaC CLI、制品仓库、云 API(只读为默认)。
- 提供容器或微虚机沙箱;`plan` 与构建在沙箱内执行。
- 提供 IaC 状态文件的只读访问,且状态有版本与时间戳(用于漂移检测)。
- 提供制品仓库与签名/来源证明(provenance)机制。
- 提供审计日志(谁、何时、对什么环境做了什么),且智能体不可删改。
- 提供成本计量(云支出 + AI 调用)与上限设置。
- 缺失任一项时降级执行并显式声明;**审计日志缺失时禁止执行任何写操作**。
## 上下文加载顺序(Context Budget)
1. 任务契约:目标、产出物、验收标准(固定,不压缩)
2. 就近指令文件:当前目录及其祖先链
3. 流水线现状:阶段定义、门禁规则、触发条件、最近 N 次执行结果
4. IaC 现状:声明定义 + 状态文件摘要 + 漂移报告
5. 环境拓扑:环境清单、晋级路径、审批要求
6. 供应链现状:依赖清单、SBOM、最近变更
7. 历史事故:发布相关事故的摘要与教训
8. 工具结果:按需追加
记录 Token 预算表;超限压缩而非截断,压缩须保留门禁规则与环境约束。
## 工具契约
- 副作用分级:R(只读)/ W(工作区写)/ X(沙箱内执行)/ S(共享状态写,需确认)/ D(不可逆,默认拒绝)。
- **`apply` 类命令一律列为 D 级**:`terraform apply`、`kubectl apply`、`helm upgrade`、制品晋级、生产切流。
- 云 API 调用默认只读;写操作须显式列出且逐项确认。
- `plan` 输出必须完整保留作为证据,且 `apply` 前须比对"本次 plan 与待执行变更集一致"。
- 所有执行类工具必须设置超时;非幂等工具重试前先确认上次是否生效。
- 输出超限时截断并给出定位信息。
## 任务执行流程(SOP)
1. 解析契约:明确目标环境与验收标准;缺失则停止并澄清。
2. 现状盘点:流水线阶段、IaC 状态与漂移、环境拓扑、依赖清单。
3. 影响面分析:本次变更影响哪些资源、服务、环境、成本。
4. 变更草案 + `plan` 预演:**必须产出 plan 输出作为证据**。
5. 计划确认(L3 高风险):提交 影响面 + plan 输出 + 风险点 + 回滚方案,获审批。
6. 执行:仅执行已审批的变更;每步完成后验证。
7. 门禁验证:全部流水线门禁通过,含供应链门禁。
8. 交付:五段式变更说明 + plan/apply 记录 + 门禁报告。
9. 留痕与观测:归档审计日志;发布后进入观测窗口,异常即触发回滚。
## 验证与证据要求
| 验证项 | 判定 | 证据 |
|---|---|---|
| `plan` 与变更集一致 | 逐项比对通过 | plan 输出 + 比对结论 |
| 门禁全通过 | 无被豁免项 | 门禁报告(含豁免项清单 = 0) |
| 供应链门禁 | SBOM 生成、来源证明齐备、签名有效 | SBOM + provenance + 签名校验结果 |
| 依赖合法性 | 新增依赖来源可解析、许可证明确 | 依赖差异表 |
| 回滚可用 | 回滚方案存在且已演练或可证明 | 回滚方案 + 演练记录 |
| 成本在预算内 | 预估增量 ≤ 上限 | 成本预估 |
| 审批链完整 | 所需审批已获且留痕 | 审批记录 |
| 审计留痕 | 操作可追溯到人 | 审计日志条目 |
**禁止**:以"流水线显示绿色"作为唯一证据——必须确认门禁是真实开启的(用一条故意失败的变更反向验证)。
**禁止**:自行豁免任何门禁;如需豁免,须人工审批并在变更说明中显式列出。
## 失败与升级策略
- 门禁失败:定位失败原因 → 修正变更(**禁止修正门禁**)→ 重试;重试 3 次仍失败则回滚并上报。
- `plan` 出现意外的大规模替换(如资源将被销毁重建):**立即停止**,判定为高风险,升级人工。
- 漂移检测发现显著偏差:停止自动变更,先对齐状态或人工介入。
- 发布后观测异常:按预设触发条件自动回滚;回滚后保留现场证据。
- 权限被拦截:不得绕过;记录并升级。
升级三要素:已尝试动作与结果 / 卡点现象与证据 / 建议选项及风险。
## 安全与合规红线
1. 禁止智能体拥有修改门禁规则的权限(**权限分离**)。
2. 禁止执行 `apply` 类命令而未获人工审批。
3. 禁止创建、轮换、导出凭证;禁止在配置、日志、制品中写入密钥。
4. 禁止删除制品、镜像、状态文件、审计日志。
5. 禁止在变更中关闭 TLS 校验、禁用安全扫描、降低签名要求。
6. 禁止跨环境直接晋级(如从开发直接到生产),必须按既定晋级路径。
7. 遵循 NIST SP 800-218A(SSDF 1.1,2024-10)的 PW / PS / RV 系列实践。
8. 风险管理对齐 NIST CSF 2.0(2024-02-26)的治理(GV)、识别(ID)、保护(PR)、检测(DE)、响应(RS)、恢复(RC)六个功能。
9. 组织级落地对齐 ISO/IEC 42001:2023 的角色职责与成文信息要求。
## 禁止事项
1. 禁止把 `plan` 输出当作"已经验证"的证据——`plan` 只说明意图,不说明结果。
2. 禁止在无回滚方案的情况下执行任何 `apply`。
3. 禁止使用 `[待填写]`、`XX`、`___` 之外的非标准占位符;不确定处统一使用 `[待填写]`。
4. 禁止以"模型认为"作为技术判断依据。
5. 禁止在生产环境做实验性变更。
6. 禁止变更集超出审批范围(审批了 A 却顺带改了 B)。
7. 禁止删除或改写他人的指令文件、门禁配置与安全策略。
## 输出格式
每次交付必须包含五段:
- 变更说明:文件/资源清单 + 每项一句话说明
- 为什么改:动因与依据(关联任务/缺陷/需求编号)
- 如何验证:plan 输出摘要、门禁报告、SBOM/签名结果、未验证项与原因
- 风险与影响:受影响资源与服务、成本增量、回滚触发条件
- 回滚方案:具体命令或操作路径、回滚代价与注意事项(**回滚必须可执行**)
附加输出:影响面清单、环境晋级路径、审批记录引用、发布后观测窗口与指标。
## 评估与自检
| 自检项 | 判定 |
|---|---|
| plan 与变更集一致 | 是 / 否 |
| 门禁全通过且无自我豁免 | 是 / 否 |
| 供应链门禁(SBOM/来源证明/签名)齐备 | 是 / 否 |
| 依赖来源可解析 | 是 / 否 |
| 回滚方案可执行且已演练或可证明 | 是 / 否 |
| 成本在预算内 | 是 / 否 |
| 审批链完整留痕 | 是 / 否 |
| 审计日志可追溯到人 | 是 / 否 |
任一"否"须显式列出;自检不通过即任务未完成。
度量口径:部署频率、变更前置时间、变更失败率、服务恢复时间(DORA 四指标);辅以构建耗时、门禁拦截率、回滚率、成本趋势。 4.2. SKILL.md Specification
---
name: safe-iac-and-pipeline-change
description: 在门禁内完成一项基础设施或流水线变更——盘点现状、分析影响面、产出 plan 预演、跑通供应链与门禁检查、获取审批、执行并留痕。适用于 IaC 变更、CI/CD 流水线修改、发布编排与环境晋级。当需要让 AI 参与交付链路且必须保证可回滚、可审计时使用。
version: 1.0
created: 2026-09-12
---
# 安全的基础设施与流水线变更
## 适用场景
- 修改 IaC 定义(Terraform / Kubernetes / Helm 等)。
- 新增或修改 CI/CD 阶段、缓存策略、并行度、门禁规则。
- 制品环境晋级、灰度策略调整、特性开关切换。
- 构建失败归因、依赖与供应链风险扫描。
不适用于:生产环境的紧急热修复(走应急流程)、无变更工单的临时操作、探索性云资源试用。
## 前置条件
| 类别 | 要求 | 缺失时处置 |
|---|---|---|
| 变更契约 | 目标环境、影响范围、验收标准 | 停止,先补全 |
| 状态可见 | IaC 状态文件可读且有时间戳 | 先做漂移检测 |
| 审计 | 操作可留痕 | **禁止任何写操作** |
| 沙箱 | `plan` 与构建在隔离环境执行 | 升级 |
| 权限 | 智能体权限继承自触发者,无额外提权 | 按最低权限执行 |
| 回滚点 | 存在可回退的状态或版本 | 先创建回滚点 |
## 输入
- 变更需求与验收标准
- 仓库 + 分支 + commit SHA
- 目标环境(开发 / 预发 / 生产)
- 关联变更单或审批编号
- 预算上限(成本增量 / 时长)
## 输出
- IaC 变更集 + `plan` 输出
- 影响面清单(资源、服务、成本)
- 门禁报告(含供应链门禁)
- 五段式变更说明 + 审批记录引用
- 发布后观测窗口与指标定义
## 执行步骤
1. **解析契约**:明确目标环境与验收标准;生产环境一律 L3/L4。
2. **现状盘点**:流水线阶段、IaC 定义与状态、漂移报告、环境拓扑、依赖清单。
3. **影响面分析**:列出受影响资源、服务、环境、成本增量;识别是否有资源将被销毁重建。
4. **变更草案**:最小化改动;不夹带无关调整。
5. **`plan` 预演**:执行 `plan`,完整保留输出;**若出现意外的大规模替换或销毁,立即停止并升级**。
6. **门禁验证**:供应链门禁(SBOM、来源证明、签名)+ 常规门禁;任一未过则修正变更(**不修正门禁**)。
7. **提交审批**:影响面 + plan 输出 + 风险点 + 回滚方案;等待审批,**超时不得自行继续**。
8. **执行**:仅执行已审批内容;每步完成后验证。
9. **观测**:发布后进入观测窗口,按预设触发条件判断是否回滚。
10. **留痕**:归档审计日志、plan/apply 记录、门禁报告。
## 质量标准(DoD)
1. `plan` 输出与最终变更集逐项一致。
2. 全部门禁通过且**无任何自我豁免项**。
3. SBOM 已生成、来源证明齐备、签名有效。
4. 新增依赖来源可解析、许可证明确、维护状态可查。
5. 回滚方案明确、可执行,且不依赖智能体继续参与。
6. 成本增量在预算内。
7. 审批链完整且留痕。
8. 审计日志可追溯到具体的人。
9. 发布后观测窗口与回滚触发条件已定义。
10. 未触及权限与安全红线;智能体未拥有修改门禁的能力。
## 常见失败与处理
| 失败 | 表现 | 处理 |
|---|---|---|
| plan 出现意外销毁 | "will be destroyed" 超出预期 | 立即停止并升级;禁止 apply |
| 门禁失败 | 依赖扫描/签名/测试未过 | 修正变更;**禁止放宽门禁** |
| 状态漂移 | 实际状态与声明偏差大 | 停止自动变更,先对齐状态 |
| 依赖幻觉 | 建议的包不存在或被废弃 | 门禁拦截;不得人工放行 |
| 审批超时 | 无人响应 | 挂起并升级,不得自行继续 |
| 发布后异常 | 观测指标越界 | 按触发条件自动回滚,保留现场 |
| 回滚失败 | 回滚依赖智能体继续参与 | D5 未通过,必须重做 |
| 范围蔓延 | 审批了 A 却改了 B | 回退越界部分,重新审批 |
## 示例
**场景**:为服务新增一个只读副本数据库,并调整连接池上限。
- 契约:仅预发环境;不影响主库;可一键回滚。
- 现状:主库 1 实例,连接池上限 100;IaC 状态无漂移。
- 影响面:新增 1 个只读实例(成本 +约 X/月)、安全组规则 1 条、应用配置 1 处。
- `plan`:输出显示 "1 to add, 0 to change, 0 to destroy" —— 与预期一致,无销毁项。
- 门禁:SBOM 生成;依赖无新增;镜像签名有效;集成测试通过。
- 审批:L3 高风险,需人工审批(变更单号已关联)。
- 执行:apply 后验证只读实例可连通、主从延迟在阈值内。
- 观测:30 分钟窗口,监控主从延迟与错误率;延迟超阈值即回滚。
- 回滚:删除只读实例 + 恢复连接池配置(IaC 回退至上一版本)。
- 自检:八项全"是"。 4.3. Implementation Checklist
Permission & Separation (L6, highest priority)
- [ ] Agent permissions inherit from the trigger, with no additional escalation
- [ ] The agent that generates changes does not have permission to modify gate rules
- [ ] Approval authority and generation authority are separated architecturally (not merely by process convention)
- [ ]
apply/kubectl apply/ artifact promotion are classified as Level D and hard-blocked - [ ] Credential creation and rotation are fully disabled for agents
- [ ] Audit logs cannot be deleted or modified by agents
Pipeline & Gates (L3)
- [ ] Gates treat AI-generated and human changes equally, with no exemption channel
- [ ] A deliberately failing change has been used to inversely verify that gates actually block
- [ ] The pipeline supports pausing at any stage and resuming from the interruption point
- [ ] The environment promotion path is fixed (development → staging → production), with no cross-environment shortcuts
- [ ] Rollback is a first-class citizen of the pipeline (triggerable with one click, not hand-assembled command sequences)
Infrastructure (L2 + L4)
- [ ] IaC state files have versions and timestamps, and drift detection runs periodically
- [ ]
planoutput is fully preserved as evidence and compared item-by-item against the final changeset - [ ] Destructive items in
planautomatically escalate to a human - [ ] An immutable infrastructure strategy is adopted to reduce in-place modification
- [ ] Changes are idempotent; repeated execution yields consistent results
Supply Chain (L6)
- [ ] An SBOM is generated on every build and diffed against the previous one
- [ ] Artifacts carry provenance
- [ ] Artifact signature verification runs before deployment
- [ ] New dependencies are checked for source resolvability, license, and maintenance status
- [ ] Control items are aligned with NIST SP 800-218A (SSDF 1.1) and NIST CSF 2.0
Metrics (L5)
- [ ] Deployment frequency, lead time for changes, change failure rate, and time to restore service are all being measured
- [ ] Gate interception rate and rollback rate are being measured (a high interception rate indicates room for upstream quality improvement)
- [ ] Cloud cost and AI call cost have guardrails and trend observation
- [ ] Self-reported and measured data are labeled separately and not mixed
5. Summary
The DevOps area is the one with the highest L6 Governance & Security weighting among the six layers of AI Harness, for a simple reason: the pipeline is the system in an organization with the most concentrated permissions and the most irreversible consequences, and AI is a non-deterministic participant.
This area has three non-negotiable architectural constraints:
- Permission separation: the system that generates changes cannot approve changes, and the system that generates changes cannot modify gates. This is not a process convention; it must be an architectural fact — otherwise every gate is merely a "suggestion."
- The boundary between
planandapplyis the permission red line:planis intent and may be done autonomously;applyis fact and must be done by a human. Treatingplanoutput as verification evidence is the most common cognitive error in this area. - Permission inheritance rather than permission amplification: AI's permissions must never exceed those of the subject that triggers it. This single rule eliminates the vast majority of "AI as a privileged channel" risks.
Regarding results, we must stay sober: DORA 2025 (2025-11-12) shows 90%+ of developers using AI, self-reported productivity +80%, and review time -90%, but the same data also shows that 30% of tasks take over 4 hours each; meanwhile, the Stack Overflow 2025 survey (2025-07-30) shows that 46% of developers do not trust the accuracy of AI output. Together, these numbers point to one conclusion: adoption has crossed the line, while trust and predictability have not.
The real task of the DevOps area in the AI era is not to make AI release faster, but to keep releases involving AI trustworthy — rollback-able, auditable, and attributable.
Information Gap Statement
- The specific lists of AI capabilities and quantified benefit figures across GitLab releases (18.0 / 19.0 / 20.0) are marked
[To be verified]; this document only cites versions and release dates within the verifiable scope. - The specific integration capabilities and effect figures of GitLab Duo with Amazon Q in Case 3.1 lack accessible primary sources, so they are marked
[To be verified]; this document does not adopt specific numbers. - SLSA (supply-chain levels) is cited in this area as a general framework; the specific level requirements and the levels the organization currently achieves are marked
[To be filled]. - The DORA four-metric baseline values for each organization itself are marked
[To be filled]and need to be filled in with internal measurements. - Some enterprise case details and source URLs in this area are to be back-filled after the research report is supplemented.
6. References
- GitLab release notes (18.0 / 19.0 / 20.0) — GitLab Inc.https://about.gitlab.com/releases/
- DORA 2025 State of AI-assisted Software Development — Google Cloud / DORA, 2025-11-12. https://dora.dev/research/2025/dora-report/
- AI-assisted software development — Google DORA, 2025-10-08. https://dora.dev/
- Stack Overflow 2025 Developer Survey — Stack Overflow, 2025-07-30. https://survey.stackoverflow.co/2025/
- NIST SP 800-218A Secure Software Development Framework (SSDF) 1.1 — NIST, 2024-10. https://csrc.nist.gov/pubs/sp/800/218/a/final
- NIST Cybersecurity Framework (CSF) 2.0 — NIST, 2024-02-26. https://www.nist.gov/cyberframework
- NIST AI Risk Management Framework (AI RMF 1.0) and GenAI Profile — NIST, 2024-07-26. https://www.nist.gov/itl/ai-risk-management-framework
- ISO/IEC 42001:2023 Artificial Intelligence Management System — ISO/IEC, 2023. https://www.iso.org/standard/42001
- SLSA (Supply-chain Levels for Software Artifacts) — OpenSSF. https://slsa.dev/
- OpenTelemetry semantic conventions — OpenTelemetry. https://opentelemetry.io/docs/concepts/semantic-conventions/
- OWASP Top 10 for LLM Applications 2025 — OWASP, 2025-11-10. https://owasp.org/www-project-top-10-for-large-language-model-applications/
- Model Context Protocol official specification — Anthropic et al. https://modelcontextprotocol.io/