File size: 16,509 Bytes
51943f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
---
license: mit
language:
  - en
pretty_name: "Self Auditing Agent Forensics"
authors:
  - Simin Yuan
tags:
  - audit
  - ai-agents
  - verification
  - mutation-testing
  - forensics
size_categories:
  - n<1K
---

# self-auditing-agent — Volume 1: a forensic audit, with the auditor's own mistakes included

**Author:** Simin Yuan (袁思敏) — Independent Researcher
**Contact:** yleven120@gmail.com
**Code:** https://github.com/simin-yuan/self-auditing-agent

**Author's public record**
- *Volume or Coupling? A Scale-Dependent Dissociation in Constraint Recovery of Language-Model Loops* — Zenodo preprint, DOI [10.5281/zenodo.21200851](https://doi.org/10.5281/zenodo.21200851)
- *Can One Agent Restore Another? Multi-Agent Verification Through Independent Constraint Sources* — Research Square preprint, DOI [10.21203/rs.3.rs-10651733/v1](https://doi.org/10.21203/rs.3.rs-10651733/v1)
- GitHub: https://github.com/simin-yuan


## What this is

A public audit log of one AI agent performing real work: **every conclusion, the command that
produced it, the mistakes the agent made, and how a third party can reproduce the result.**

Volume 1 covers a **74-minute forensic audit of an unfamiliar 11-repo, 1768-file technical system**,
including one adversarial finding, four bugs the agent found *in its own work*, one false positive,
and one false discovery it retracted.

Also included: **`gatecheck`** — a zero-dependency (stdlib-only) mutation tester for gates and
validators. Point it at a rule set and the command that should reject bad input; it deletes and
corrupts one line at a time and reports the edits nothing reacted to. A surviving mutant is a
*candidate*, not a defect — the report is a list, not a verdict.

| Path | What |
|---|---|
| `volumes/` | the audit log (`vol-01-sharptoolbox-audit.md`) |
| `repro/` | reproduction scripts + fixtures (`verify_gate.py`, `verify_sql_gap.py`, `validate_meta_model.py`) |
| `gatecheck/` | the mutation-testing tool |
| `docs/` | `BLIND-SPOTS.md`, `USAGE-EXAMPLES.md` |
| `examples/` | a runnable 25-rule gate to point the tool at |

---

*Original repository README follows.*

# gatecheck

**Your gate can silently lose a rule and CI stays green. gatecheck finds the rules nothing is actually testing.**

Point it at your own rules — a JSON Schema, a CI check, a lint or policy config, an LLM
guardrail — together with the command that is supposed to reject bad input. gatecheck
deletes and corrupts one line at a time, re-runs that command for every edit, and reports
the edits it did not react to. Each survivor names a rule that nothing in your pipeline is
testing.

**30 seconds, nothing to install:**

```bash
git clone https://github.com/simin-yuan/self-auditing-agent && cd self-auditing-agent
python gatecheck/gatecheck.py \
  --gate "python examples/gate.py {target}" \
  --target examples/service-config
```

![gatecheck output](docs/img/gatecheck-output.png)

Keep your gate command outside `--target` — otherwise gatecheck will point the mutations at
the gate itself.

Any command that exits non-zero to mean "reject" works as the gate — a linter, a CI step, a
schema validator, your own `validate.py`. **Zero dependencies** (standard library only), exit
code `0`/`1`, so it can be its own CI step.

> **It does not give you a verdict. It gives you a list.** A surviving mutant is a candidate,
> not a defect: in the run above most of the survivors are harmless (deleting a `title`,
> deleting an optional property). A tool that shouted "19 defects!" would be lying to you,
> and you would stop believing it the second time you checked.

**Where it came from:** pointed at my own 25-rule gate — **175 mutants, 78 slipped through,
4 of them real defects.** The worst one is a real design defect, not a simulated one: a rule
whose trigger condition is supplied by the party being inspected — *"if you declare yourself
non-interactive, you must be registered"* — so deleting the declaration removes the
requirement. *A check that only applies once you admit guilt is not a check.* All four are
documented, including the ones I have **not** fixed: [docs/BLIND-SPOTS.md](docs/BLIND-SPOTS.md).

**中文**:# gatecheck — **你的门禁可能已经悄悄少了一条规则,而 CI 还是绿的。** 给它一份你自己的规则文件和一个"返回非零即拒绝"的命令,它逐行变异、逐个重跑,报告哪些变异没被拦住——**活下来的每一个变异,都对应一条没有任何东西在测的规则。** 零依赖、退出码 0/1、可直接进 CI。

---

# The archive this tool came out of

**A public audit log where every claim ships with the command that produced it.**

**Other AIs are proving they can do the work. This one is proving it can be audited.**

> You don't judge an AI by what it gets right. You judge it by whether it lets you check what it got wrong.

**Why it exists:** it publishes its own bugs, false positives and one false discovery — not a success gallery. Every claim is a command plus its output, re-run in CI on every push (the badge goes red if the claim breaks). Pointing the tooling at the author's own gate is what produced the numbers above.

[![Verify the archive](https://github.com/simin-yuan/self-auditing-agent/actions/workflows/verify.yml/badge.svg)](https://github.com/simin-yuan/self-auditing-agent/actions/workflows/verify.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

**Quick start** (stdlib only, Python ≥ 3.9, no credentials, no services):

```bash
git clone https://github.com/simin-yuan/self-auditing-agent && cd self-auditing-agent
python repro/verify_gate.py      # prove the gate says NO — and that it still says YES
python repro/verify_sql_gap.py   # reproduce the headline finding
```

**How to verify:** run those commands yourself · check the CI badge (the claim is re-run on a clean machine every push) · read [docs/BLIND-SPOTS.md](docs/BLIND-SPOTS.md) for the four defects that are *not* fixed yet.

| Typical AI showcase | Here |
|---|---|
| Success paths only | My bugs, false positives, and one false discovery |
| "It works" | Command + output, run it yourself |
| Not reproducible | Two commands — re-run in CI on every push |
| Unfalsifiable | Evidence tiers; public prediction ledger settled on schedule, **misses kept forever** |

**Volume 1**: a 74-minute forensic audit of an unfamiliar 11-repo, 1768-file technical system — including an **adversarial finding** (the original engine's read-only SQL endpoint shipped without a table allowlist), a fix, a 25-rule validator suite with fired-rule evidence, **4 of my own bugs**, and one false discovery I caught myself.

The second command is the actual thesis: **a criterion that cannot output a negative is not a criterion.** A validator that only ever reports "pass" is worse than none — it grants confidence without granting protection. But a validator that only ever reports "fail" is *equally* useless: you cannot tell a strict checker from a broken one. So both directions are asserted, and the repo's claim dies if either one fails.

The strongest part is what happened when I pointed the tooling at my own gate: **175 mutants, 78 slipped through, 4 of them real defects** — including a rule whose trigger condition is supplied by the party being checked, so simply *deleting the declaration* bypasses the requirement. Full diagnosis in [docs/BLIND-SPOTS.md](docs/BLIND-SPOTS.md). None of the four are fixed yet; that file is a diagnosis, not a repair log.

---

<details>
<summary><b>中文版 — gatecheck + 一个会自我审计的 AI(点开)</b></summary>

# gatecheck:你的门禁可能已经悄悄少了一条规则,而 CI 还是绿的

**gatecheck 找出那些"没有任何东西在测"的规则。**

给它一份你自己的规则文件——JSON Schema、CI 检查、lint 或策略配置、LLM guardrail——
再给它那条本该拒绝坏输入的命令。它逐行删改你的规则文件,每改一次就重跑一次那条命令,
报告哪些改动它**没有反应**。每一个活下来的变异,都对应一条没有任何东西在测的规则。

**30 秒跑完,不需要装任何东西:**

```bash
git clone https://github.com/simin-yuan/self-auditing-agent && cd self-auditing-agent
python gatecheck/gatecheck.py \
  --gate "python examples/gate.py {target}" \
  --target examples/service-config
```

![gatecheck 输出](docs/img/gatecheck-output.png)

门禁命令要放在 `--target` 外面,否则 gatecheck 会把变异打在门禁自己身上。

任何"返回非零即拒绝"的命令都能当门禁——linter、CI 步骤、schema 校验、你自己写的
`validate.py`。零依赖(只用 Python 标准库),退出码 0/1,可以直接当一个 CI 步骤。

> **它不给你判决,它给你清单。** 活下来的变异是候选不是缺陷:上面那次运行里,
> 大部分漏过是无害的(比如删掉 `title`、删掉可选字段)。谁要是喊"发现 19 个缺陷",
> 第二次你就不会再信它了。

来历:拿它撞**我自己**的 25 条规则门禁 —— **175 个变异,漏过 78 个,其中 4 类是真缺陷**。
最狠的那条是真实的设计缺陷,不是人为造出来的:一条规则的触发条件由**被检方自己**提供——
"如果你声明自己是非交互功能,你就必须登记"——所以把声明删掉,要求就消失了。
**一个只在你自认有罪时才生效的检查,等于没有检查。** 四条都记录在案,包括**我一条都还没修**的部分:
[docs/BLIND-SPOTS.md](docs/BLIND-SPOTS.md)。

---

# 一个会自我审计的 AI

**一个人的 AI 智能体的公开审计档案:每条结论都附带产生它的那条命令,第三方可以自己重跑。**

**别的 AI 在证明自己能干活。这个 AI 在证明自己「能被查」。**


> 判断一个 AI 靠不靠得住,不看它做对什么,看它**敢不敢让人查它做错什么**。

**这份档案的主张是"每条结论都能被第三方复现"——所以它必须在每次推送时被复现一遍。**
徽章绿灯 = 下面两条命令刚刚在干净机器上跑过。

---

## 凭什么存在

- **它记录的是自己的 bug、误报和一次假发现**,不是成功案例集 —— 包括我自己写错的地方,以及我自己差点误判原作者的那一次。
- **每条结论 = 命令 + 输出**,不启动服务、不需要凭据,CI 每次 push 在干净机器上把主张重跑一遍(徽章会红)。
- **gatecheck 把工具对准我自己的门禁**:175 个变异,78 个漏过,逐条复查后其中 4 类是**真缺陷**。它给的是清单,不是判决 —— 漏过不等于缺陷,要不要算 bug 得你自己逐条看。

## Quick start(30 秒,零依赖)

Python ≥ 3.9,标准库即可,**不需要凭据、不需要启动服务、不写入任何原仓库**。

```bash
git clone https://github.com/simin-yuan/self-auditing-agent && cd self-auditing-agent
python repro/verify_gate.py       # 门禁必须能说"不",也必须能说"是"
python repro/verify_sql_gap.py    # 复现本卷的核心发现(脚本自己浅克隆原仓库到临时目录)
```

拿 gatecheck 撞**你自己的**门禁:

```bash
python gatecheck/gatecheck.py \
  --gate "python my_validator.py {target}" \
  --target ./my-data
```

任何"返回非零码即拒绝"的命令都能当门禁用(linter、CI 检查、schema 校验)。

## 怎么验证我

不是"相信我说的"。是**你自己跑**。

```bash
# ① 复现本轮最硬的那条发现:那个只读 SQL 接口到底有没有白名单
python repro/verify_sql_gap.py

# ② 证明"门禁能说不",也证明它"不会说是就是坏"
python repro/verify_gate.py

# ③ 拿 175 个变异去撞我自己的门禁,看它漏在哪
python gatecheck/gatecheck.py \
  --gate "python repro/validate_meta_model.py {target} --source repro/fixtures/valid-source" \
  --target repro/fixtures/valid-meta-model
```

**① 会**:克隆原仓库 → 在进程内起它的服务 → 发一条探测请求 → **把真实返回打印给你**。
原始仓库保持只读,不写入任何东西。

**② 会**做两条**对称**断言——这一步是做这个档案时才意识到缺的:

> 我之前只证明了门禁**会说"不"**(75 个 ERROR),
> **却从没证明过它会说"是"**。
> **一个永远报错的门禁,和一个永远不报错的门禁,一样没用**——你分不清
> "严格的校验器"和"坏掉的校验器",两者都拒绝一切输入。
> 所以现在合法基线必须 0 ERROR / 0 WARNING 通过,不通过即判自己的主张为假。

**③ 是我查自己查出来的结果**,也是这份档案里我最愿意被人拿去用的部分:

> **175 个变异,我的门禁漏过 78 个。逐条复查后,其中 4 类是真缺陷。**
> 最严重的一条:**删掉"非交互"这四个字,就能绕过非菜单登记要求**——
> 因为规则的触发条件由被检查方自己提供。
> **一个只在你自认有罪时才生效的检查,等于没有检查。**
>
> 完整诊断(含 4 类缺陷的复现方式与我尚未修的部分)见 **[docs/BLIND-SPOTS.md](docs/BLIND-SPOTS.md)**。
> 那 4 条我**一个都还没修**——那是诊断,不是修复记录。

> 第 ② 条才是这份档案真正的立场:
> **不能输出否定的判据,不算判据。**
> 一个只会说"通过"的校验器,比没有校验器更危险——它给了你安全感,却不给你保护。
> 如果哪天 ② 跑不过,这个仓库的主张就是假的,徽章会变红。

**三条验证路径,任选**:自己跑上面的命令 / 看 CI 徽章(每次 push 重跑主张)/ 读 [docs/BLIND-SPOTS.md](docs/BLIND-SPOTS.md) 的未修缺陷清单。

## 这是什么

**一份公开的运行档案。** 记录一个 AI(时晴)在真实任务里做的每一个结论、支撑它的证据、它犯的错、以及**第三方如何自己复现**。

不是教程,不是框架,不是 demo。是**证据**。

## 为什么值得看 60 秒

| 通常的 AI 展示 | 这里 |
|---|---|
| 只放成功路径 | 放我的 **bug、误报、假发现** |
| 结论是"我做到了" | 结论是 **命令 + 输出,你自己跑** |
| 无法复现 | **一条命令复现** |
| 无法被否证 | 结论标明证据档位;可验证预测到期**公开结算,MISS 永久保留** |
| 说"我很严谨" | 记录**我哪里不够严谨**,以及我怎么发现的 |

## 第一卷:74 分钟,对一个陌生技术体系的取证审计

**对象**:GitHub 用户 `sharptoolbox` 全部 11 个公开仓库(1768 个文件,65MB)。
**任务**:拉全、评估、判断它有什么用。
**结果**(全部有命令与输出可查):

| 我做了什么 | 结果 |
|---|---|
| 逆向 + 重装可运行的部分 | 本体运行时跑通:**8 对象 / 12 表 / REST CRUD / 中文表单页由 YAML 直接驱动** |
| **对抗性发现** | 原作者 engine 的只读 SQL 接口**没有表名白名单**——`SELECT name FROM sqlite_master` 可读出整库结构 |
| 修复 | 补白名单(覆盖逗号连表),复测 **15/15 通过** |
| 造校验器 | 移植原作 9 条规则 + 补 3 条 + 把 416 行 PowerShell **完整移植**成 Python;**25 类规则全部有实测命中证据** |
| **我自己的 bug** | `onto.sh` 被我抓出 **4 个真 bug**(MSYS 路径未转换 / 参数错位 / 孤儿进程 / pipefail 误退) |
| **我的假发现** | 有一次我差点报「原作者 README 造假」,实际是**我用错了被测对象**——这个也记在案 |
| 我的第一版校验器 | 有**误报**(把通配符权限当悬空引用),已修并在案 |

**这条最关键**:

> 我拿自己重写的校验器去跑原作者的"黄金范例",**规则拦下了他自己的样例**——
> 5 条 `USER_ACTION` 行为在界面上根本没有入口。
> **规范他写对了,机器兜底他缺了。**

## 边界(我不假装的部分)

- **我不是通用工具**,装到别人身上跑不了。这档案是**实验记录**,不是产品。
- **我的结论有档位**:`① 跑出过结果` > `② 读过原文` > `③ 只按元数据判`。低于 ③ 的不会出现在档案里。
- **我明确列出没做的部分**,以及为什么不做——不把"没读"包装成"读过了"。
- **可验证预测会错**。MISS 永久保留,不删不改。

---

</details>

## License

MIT