fix(billing): 删任务/删项目级联吞 ACTIVE 预留致 reserved_balance 永久冻结(审计 I2)

- 根因: CreditReservation.task 是 OneToOneField(CASCADE), AITask.project 也是 CASCADE
  —— 删项目→级联删任务→ACTIVE 预留行被吞, 账户冻结份额永不归还(实测 4 账户漂移共 ¥42,
  且随删项目持续增长)
- 修法: billing/signals.py 挂 AITask pre_delete, 删除前先 release_credit 释放(级联同样
  触发, release 自带行锁+幂等); apps.py ready() 接线
- 回归测试 x3: 直删任务/删项目级联/已扣费不重复释放
- qa/repair_reserved_drift.py: 存量漂移回填脚本(dry-run 默认, --apply 落 RELEASE 流水),
  已对线上 4 账户执行并复验清零
- qa/function-audit/output: 本轮 18 页模拟点击审计报告(0 真死按钮 0 JS 报错)

验证: 后端测试 213/213 通过, django check 无警告
补齐 aab4d7e: 该提交带走了 signals.py 之外的测试轮改动, 信号挂载点与回归测试在本提交收口

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
zyc
2026-07-02 13:07:09 +08:00
co-authored by Claude Fable 5
parent aab4d7ea4c
commit dcc5d7fe50
43 changed files with 4860 additions and 3143 deletions
+202 -214
View File
@@ -4,12 +4,12 @@
"url": "http://127.0.0.1:5173/library",
"mode": "quick",
"tally": {
"total": 38,
"works": 23,
"total": 28,
"works": 27,
"dead": 0,
"error": 0,
"disabled": 1,
"skipped": 13,
"disabled": 0,
"skipped": 0,
"noop": 1,
"blocked": 0
},
@@ -28,8 +28,8 @@
"url": true,
"overlay": false,
"self": false,
"mutations": 26,
"api": 0
"mutations": 47,
"api": 1
}
},
{
@@ -46,7 +46,7 @@
"url": false,
"overlay": false,
"self": false,
"mutations": 17,
"mutations": 19,
"api": 0
}
},
@@ -64,7 +64,7 @@
"url": false,
"overlay": true,
"self": false,
"mutations": 14,
"mutations": 17,
"api": 0
}
},
@@ -82,8 +82,8 @@
"url": true,
"overlay": false,
"self": true,
"mutations": 26,
"api": 0
"mutations": 47,
"api": 1
}
},
{
@@ -100,7 +100,7 @@
"url": true,
"overlay": false,
"self": true,
"mutations": 25,
"mutations": 34,
"api": 0
}
},
@@ -109,8 +109,8 @@
"tag": "a",
"role": "",
"cls": "",
"label": "视频项目",
"href": "/projects",
"label": "模特库",
"href": "/models",
"disabled": false,
"active": false,
"verdict": "works",
@@ -118,8 +118,8 @@
"url": true,
"overlay": false,
"self": true,
"mutations": 20,
"api": 0
"mutations": 22,
"api": 1
}
},
{
@@ -127,8 +127,8 @@
"tag": "a",
"role": "",
"cls": "",
"label": "图片生成",
"href": "/asset-factory",
"label": "视频项目",
"href": "/projects",
"disabled": false,
"active": false,
"verdict": "works",
@@ -144,6 +144,24 @@
"idx": 7,
"tag": "a",
"role": "",
"cls": "",
"label": "图片生成",
"href": "/asset-factory",
"disabled": false,
"active": false,
"verdict": "works",
"signals": {
"url": true,
"overlay": false,
"self": true,
"mutations": 41,
"api": 3
}
},
{
"idx": 8,
"tag": "a",
"role": "",
"cls": "active",
"label": "资产库",
"href": "/library",
@@ -154,12 +172,12 @@
"url": false,
"overlay": false,
"self": false,
"mutations": 17,
"mutations": 19,
"api": 0
}
},
{
"idx": 8,
"idx": 9,
"tag": "a",
"role": "",
"cls": "",
@@ -172,12 +190,12 @@
"url": true,
"overlay": false,
"self": true,
"mutations": 20,
"api": 0
"mutations": 37,
"api": 3
}
},
{
"idx": 9,
"idx": 10,
"tag": "a",
"role": "",
"cls": "",
@@ -190,12 +208,30 @@
"url": true,
"overlay": false,
"self": true,
"mutations": 22,
"mutations": 69,
"api": 4
}
},
{
"idx": 11,
"tag": "a",
"role": "",
"cls": "",
"label": "垃圾桶",
"href": "/trash",
"disabled": false,
"active": false,
"verdict": "works",
"signals": {
"url": true,
"overlay": false,
"self": false,
"mutations": 24,
"api": 1
}
},
{
"idx": 10,
"idx": 12,
"tag": "a",
"role": "",
"cls": "",
@@ -208,12 +244,30 @@
"url": true,
"overlay": false,
"self": true,
"mutations": 49,
"mutations": 54,
"api": 2
}
},
{
"idx": 11,
"idx": 13,
"tag": "div",
"role": "button",
"cls": "user",
"label": "账户",
"href": "",
"disabled": false,
"active": false,
"verdict": "works",
"signals": {
"url": false,
"overlay": false,
"self": true,
"mutations": 22,
"api": 0
}
},
{
"idx": 14,
"tag": "a",
"role": "",
"cls": "",
@@ -226,12 +280,12 @@
"url": true,
"overlay": false,
"self": false,
"mutations": 25,
"api": 0
"mutations": 46,
"api": 1
}
},
{
"idx": 12,
"idx": 15,
"tag": "button",
"role": "",
"cls": "icon-btn",
@@ -244,12 +298,12 @@
"url": true,
"overlay": false,
"self": false,
"mutations": 23,
"mutations": 26,
"api": 1
}
},
{
"idx": 13,
"idx": 16,
"tag": "button",
"role": "",
"cls": "btn.btn-edit-toggle",
@@ -262,34 +316,16 @@
"url": false,
"overlay": false,
"self": true,
"mutations": 20,
"mutations": 8,
"api": 0
}
},
{
"idx": 14,
"tag": "button",
"role": "",
"cls": "btn.btn-primary",
"label": "上传资产",
"href": "",
"disabled": false,
"active": false,
"verdict": "works",
"signals": {
"url": false,
"overlay": true,
"self": false,
"mutations": 4,
"api": 0
}
},
{
"idx": 15,
"idx": 17,
"tag": "div",
"role": "",
"cls": "tab.active",
"label": "人物 15",
"label": "模特上身图 3",
"href": "",
"disabled": false,
"active": true,
@@ -302,48 +338,12 @@
"api": 0
}
},
{
"idx": 16,
"tag": "div",
"role": "",
"cls": "tab",
"label": "场景 22",
"href": "",
"disabled": false,
"active": false,
"verdict": "works",
"signals": {
"url": false,
"overlay": false,
"self": true,
"mutations": 81,
"api": 0
}
},
{
"idx": 17,
"tag": "div",
"role": "",
"cls": "tab",
"label": "商品图 39",
"href": "",
"disabled": false,
"active": false,
"verdict": "works",
"signals": {
"url": false,
"overlay": false,
"self": true,
"mutations": 121,
"api": 0
}
},
{
"idx": 18,
"tag": "div",
"role": "",
"cls": "tab",
"label": "成片 23",
"label": "平台套图 3",
"href": "",
"disabled": false,
"active": false,
@@ -352,8 +352,8 @@
"url": false,
"overlay": false,
"self": true,
"mutations": 84,
"api": 0
"mutations": 9,
"api": 3
}
},
{
@@ -361,7 +361,7 @@
"tag": "div",
"role": "",
"cls": "tab",
"label": "我的上传 3",
"label": "自由创作 1",
"href": "",
"disabled": false,
"active": false,
@@ -370,8 +370,8 @@
"url": false,
"overlay": false,
"self": true,
"mutations": 51,
"api": 0
"mutations": 9,
"api": 3
}
},
{
@@ -379,7 +379,7 @@
"tag": "div",
"role": "",
"cls": "tab",
"label": "未分类 0",
"label": "视频成品 7",
"href": "",
"disabled": false,
"active": false,
@@ -388,12 +388,66 @@
"url": false,
"overlay": false,
"self": true,
"mutations": 26,
"api": 0
"mutations": 6,
"api": 1
}
},
{
"idx": 21,
"tag": "div",
"role": "",
"cls": "tab",
"label": "其他 46",
"href": "",
"disabled": false,
"active": false,
"verdict": "works",
"signals": {
"url": false,
"overlay": false,
"self": true,
"mutations": 15,
"api": 3
}
},
{
"idx": 22,
"tag": "button",
"role": "",
"cls": "chip",
"label": "资产类型",
"href": "",
"disabled": false,
"active": false,
"verdict": "works",
"signals": {
"url": false,
"overlay": true,
"self": false,
"mutations": 21,
"api": 0
}
},
{
"idx": 23,
"tag": "div",
"role": "button",
"cls": "mi.selected",
"label": "全部类型",
"href": "",
"disabled": false,
"active": true,
"verdict": "works",
"signals": {
"url": false,
"overlay": true,
"self": false,
"mutations": 3,
"api": 0
}
},
{
"idx": 24,
"tag": "button",
"role": "",
"cls": "chip",
@@ -404,36 +458,18 @@
"verdict": "works",
"signals": {
"url": false,
"overlay": true,
"self": false,
"mutations": 8,
"api": 0
"overlay": false,
"self": true,
"mutations": 39,
"api": 1
}
},
{
"idx": 22,
"tag": "div",
"idx": 25,
"tag": "article",
"role": "button",
"cls": "mi.selected",
"label": "最近添加",
"href": "",
"disabled": false,
"active": true,
"verdict": "works",
"signals": {
"url": false,
"overlay": true,
"self": false,
"mutations": 8,
"api": 0
}
},
{
"idx": 23,
"tag": "button",
"role": "",
"cls": "btn.btn-ghost",
"label": "取消",
"cls": "asset-card.audio",
"label": "AUDIO配音 · 场 4 · 句 2未分类 · AI 生成",
"href": "",
"disabled": false,
"active": false,
@@ -442,110 +478,62 @@
"url": false,
"overlay": false,
"self": true,
"mutations": 10,
"mutations": 8,
"api": 1
}
},
{
"idx": 26,
"tag": "article",
"role": "button",
"cls": "asset-card.image",
"label": "ea9d4d0ecc5334fbd780a7217bcdd3430597562a5a3f0-w2",
"href": "",
"disabled": false,
"active": false,
"verdict": "works",
"signals": {
"url": false,
"overlay": false,
"self": true,
"mutations": 6,
"api": 0
}
},
{
"idx": 24,
"tag": "button",
"role": "",
"cls": "btn.btn-primary",
"label": "上传资产",
"href": "",
"disabled": true,
"active": false,
"verdict": "disabled"
},
{
"idx": 25,
"label": "",
"tag": "",
"verdict": "stale"
},
{
"idx": 26,
"label": "",
"tag": "",
"verdict": "stale"
},
{
"idx": 27,
"label": "",
"tag": "",
"verdict": "stale"
},
{
"idx": 28,
"label": "",
"tag": "",
"verdict": "stale"
},
{
"idx": 29,
"label": "",
"tag": "",
"verdict": "stale"
},
{
"idx": 30,
"label": "",
"tag": "",
"verdict": "stale"
},
{
"idx": 31,
"label": "",
"tag": "",
"verdict": "stale"
},
{
"idx": 32,
"label": "",
"tag": "",
"verdict": "stale"
},
{
"idx": 33,
"label": "",
"tag": "",
"verdict": "stale"
},
{
"idx": 34,
"label": "",
"tag": "",
"verdict": "stale"
},
{
"idx": 35,
"label": "",
"tag": "",
"verdict": "stale"
},
{
"idx": 36,
"label": "",
"tag": "",
"verdict": "stale"
},
{
"idx": 37,
"label": "",
"tag": "",
"verdict": "stale"
"tag": "article",
"role": "button",
"cls": "asset-card.image",
"label": "ea9d4d0ecc5334fbd780a7217bcdd3430597562a5a3f0-w2",
"href": "",
"disabled": false,
"active": false,
"verdict": "works",
"signals": {
"url": false,
"overlay": false,
"self": true,
"mutations": 4,
"api": 0
}
}
],
"missing": [
"搜索",
"E E2E 桥接测试团队 20260529",
"余额 ¥14,907.00",
"账户",
"余额 ¥14,072.00",
"管理资产",
"上传资产",
"性别",
"年龄段",
"角色标签",
"来源",
"最近使用"
"最近使用",
"人物 2",
"场景 1",
"商品图 5",
"成片 1",
"我的上传 4",
"未分类 7"
]
}