---
name: diff_ownership
when: 'Diff 归属, 变更追踪, CAS 校验, 代码变更'
scope: ['*']
products:
  - '*'
id: ka-pattern-diff_ownership
asset_kind: pattern
lifecycle_status: active
authority: supporting
routes:
  - '*'
primary_triggers:
  - Diff 归属
  - 变更追踪
  - CAS 校验
  - 代码变更
priority: P2
specificity: 3
version: 1.1.0
last_reviewed: '2026-06-01'
consumes: []
emits: []
secondary_triggers: []
negative_triggers: []
type: pattern
stages: ["*"]
owner_mechanism_id: mc-engine-runtime
---

## 决策规则

- diff_ownership 追踪代码变更归属：owned / inherited / external
- CAS 校验确保 diff 与源文件一致
- scope 目录展开排除外部目录的 diff
- experimental: 只做状态模型和 CAS 校验，不替换现有写入流程

## 验收项

- [AC-01] Diff 归属分类正确
- [AC-02] CAS 校验通过
- [AC-03] scope 排除外部 diff
- [AC-04] 冲突检测正常

## 何时使用

experimental: 只做状态模型和 CAS 校验，不替换现有写入流程，不新增 hard block

## 是否 hard block

否。此能力为 advisory 状态，违规仅产生 advisory 警告，不阻断流程。

## 证据要求

- Diff 归属分类测试通过
- CAS 校验生命周期测试通过
- 冲突检测测试通过
-

## 人工确认/降级边界

- 此能力可被开发者决策覆盖
- 升级到 enforced 需满足 promotion_conditions 并通过 lifecycle_test_files 测试
- 降级/禁用需经 sf_capability_update + 人工确认
