---
title: "注入缺陷目录"
---

> Documentation Index
> Fetch the complete documentation index at: https://koine.systems/llms.txt
> Use this file to discover all available pages before exploring further.

# 注入缺陷目录

> 状态：基准草案。缺陷以 [Aurora 订阅市场](https://koine.systems/examples/market/) 为基线，用于测“局部定义 + 全局分析”能否发现冲突和缺口。每条缺陷描述注入方式、预期证据和当前能否自动发现。

## 1. 缺陷格式

每条缺陷包含：

- **ID**：`D-01` 起。
- **注入**：对 gold model 的最小改动。
- **期望发现**：编译器错误、分析器 witness、`unknown`、或只能人工 review。
- **证据**：错误码、路径、反例世界、关系报告。
- **反例**：如果自动发现不了，说明为什么。

## 2. 目录

| ID | 注入 | 期望发现 | 证据 | 自动？ |
| --- | --- | --- | --- | --- |
| D-01 | 把 `exchange_rate` 的 key 改成全部参数 `key total (from, to, rate)` | 编译错误：total/partial 只能用于真子集 | key 检查 | 是 |
| D-02 | 从 `s0` 删除 `invoice_status(inv1, Draft)` | 初始世界违反 `key total (invoice)` | state 检查 | 是 |
| D-03 | 删除 `pay` 的 `require invoice_status(invoice) == Issued` | 顺序缺口：未开票也能支付 | 路径/反例 | 是（有顺序分析时） |
| D-04 | 删除 `pay` 的 `require status(order) == Placed` | 顺序缺口：Draft 订单可直接支付 | 路径/反例 | 是（有顺序分析时） |
| D-05 | 删除 `RefundRequiresPayment` axiom，并允许从 `Placed` 退款 | 状态/历史冲突：退款未支付 | axiom/路径 | 是 |
| D-06 | 添加一个 `paid_flag(order: Order)`，与 `paid` 等价但都存储 | 重复/派生候选 | 关系分析 | 部分（需证明/探索） |
| D-07 | 删除 `invoice_for(inv1, o1)` | 跨对象联动缺口 | 关系覆盖/能力问题 | 部分（可能只报告未链接） |
| D-08 | 删除 `placed_at` | 历史缺口：无法回答“何时下单” | 历史查询 | 是（如果问题要求） |
| D-09 | 删除 `charged_back_at` | 历史缺口：拒付时间不可查 | 历史查询 | 是（如果问题要求） |
| D-10 | 把 `status` 的 `key total (order)` 改成普通 key | key 唯一性/函数式读取错误 | key 检查 | 是 |
| D-11 | 删除 `NoDoubleRefund` axiom，并允许 refund + chargeback 同时发生 | 不相交冲突 | 重叠 witness | 是 |
| D-12 | 在 `refund_flow` 中交换 `issue_invoice` 和 `pay` | 顺序缺口：支付在开票前 | path 回放/拒绝 | 是（场景回放） |
| D-13 | 删除 `subscription_for(sub1, c1)` | 权限/联动缺口：订阅无归属 | 覆盖分析/能力问题 | 部分 |
| D-14 | 让 `place` 和 `pay` 都在 `T0` 且不记录 `placed_at` | 历史歧义：同一时间无法排序 | 历史查询/step index | 是（报告 ambiguous） |
| D-15 | 把 `paid` 改成 `paid(order: Order, value: Bool)` | 语义膨胀：布尔值与 flag 重复 | 关系分析/覆盖 | 部分（需 review） |

## 3. 预期证据示例

### D-01

```text
error[koine.key.total-all-params]: key total 只能用于参数真子集
  --> market.koi:83:3
  = note: exchange_rate 的 key 是全部参数 (from, to, rate)
```

### D-03

```text
gap: pay 可以在没有 Issued invoice 的世界发生
  path: s0 -> place -> pay
  witness: s1 中 invoice_status(inv1) = Draft
```

### D-05

```text
axiom violation: refunded(o1) 为真但 paid(o1) 为假
  path: s0 -> place -> refund
```

### D-06

```text
candidate: paid_flag ≡ paid
  evidence: 所有 s0 可达世界相同（holds-in-scope）
  action: 删除一个，或改成 derived relation
```

### D-11

```text
candidate: refunded 与 charged_back 可重叠
  witness: 某世界 refunded(o1) 和 charged_back(o1) 同时为真
  action: 恢复 NoDoubleRefund 或修改 transition
```

## 4. 自动发现边界

- **编译器**能抓住 D-01、D-02、D-10；不需要探索世界。
- **场景回放**能抓住 D-12；失败步和原因明确。
- **分析器**能抓住 D-03、D-04、D-05、D-11，前提是有顺序/关系分析；需要路径或 witness。
- **关系分析**对 D-06 只能给候选；等价证明可能需要归纳或 `holds-in-scope`。
- **历史查询**对 D-08、D-09、D-14 只能在“问题要求历史”时发现；如果没人问，模型不会主动报错。
- **跨对象链接**对 D-07、D-13 只能报告“可能缺失”；语义上是否有意，需要人工/Agent review。
- **D-15** 是设计味道，不是错误；需要 gloss/关系分析/评审。

## 5. 使用方式

1. 从 gold model 生成一个只注入一条缺陷的变体。
2. 给分析器/Agent 模型和失败问题，不给缺陷位置。
3. 记录：是否发现、证据类型、定位准确度、误报、修复是否正确。
4. 同一缺陷用不同机制跑：编译器、场景回放、分析器、人工 review。

## 相关

- [验证与实验计划](https://koine.systems/notes/validation-experiments/)
- [基准与能力问题](https://koine.systems/notes/benchmark-suite/)
- [Aurora 订阅市场](https://koine.systems/examples/market/)
- [实验协议](https://koine.systems/notes/experiment-protocol/)

Source: https://koine.systems/notes/defect-catalog/index.mdx
