feat(backthink): 存档落「紧急度」精确档位(裁决 14 的精确化前置)
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

- backthink_records 自建表加 urgency TEXT NOT NULL DEFAULT ''(**不开迁移号、不动 internal/db**;对既有库幂等补列:PRAGMA 判存在 + 容忍 duplicate column,其它错误照报)
- 落库值 = 该轮**实际生效**的档位(escalatedImport 折叠后的 roundImport;她自报可上抬、事件自带高档不被她压低)——「生效值优先」而非「她的话优先」,避免与既有 escalateImport 口径打架
- Record.Urgency 的 JSON 键刻意是 urgency ⇒ WS 实时帧自然带上、前端防御性读取即刻显示(不必等重开页面)
- 思考报错行 / 未唤醒降级行 / 历史旧行 = **空串(未知)**,绝不反推(变异:【空串当 routine】⇒ 4 条测试红;【补列非幂等】⇒ 41 条红,新库启动即失败)
- 生产影响:下次启动对真实 data/cyrene.db 执行一次单列 ALTER,并记 source=services/backthink 的 Info「backthink records table upgraded」
This commit is contained in:
AskaEth committed 2026-10-05 14:10:25 +08:00
1 parent afe9afb1b5
commit 213aff2e33
5 files changed
+760 -8

No files matched your search

+22
View File
@@ -148,6 +148,28 @@ func importanceForUrgency(l urgency.Level) Importance {
}
}
// urgencyForImportance 是 importanceForUrgency 的**反向读法**:把一轮思考**实际生效**
// 的重要度还原成通用紧急度词汇,供存档携带精确档位(X2a;面板此前只能给出「下限」)。
//
// 它复用同一张既有对应关系(Critical↔critical、High↔warning),不引入任何新的门限或
// 折算规则:例行档对应 importanceForUrgency 的 Normal,而 ImportanceLow 只是「比例行
// 还安静」的心跳/启动轮 —— urgency 词汇里没有更低的档,故与 Normal 同归 routine
// (无损:routine 本就表示「安静时段照常扣下」这一类)。按档位高低比较而不是逐值
// 相等,是让将来插入更高档时它落在最高档、而不是静默掉回 routine。
//
// 取数点在 backthink.go 的 think:入参是该轮**实际生效**的重要度
// (escalatedImport 的结果,她自报的紧急度已折叠在内)。
func urgencyForImportance(i Importance) urgency.Level {
switch {
case i >= ImportanceCritical:
return urgency.LevelCritical
case i >= ImportanceHigh:
return urgency.LevelWarning
default:
return urgency.LevelRoutine
}
}
// escalateImport 把声明的紧急度叠到基础重要度上。声明只能**上抬**、绝不压低,因此
// 主题级默认(如提醒的 High)与安全域事件既得的档位不会被一句 routine 抹掉;
// 未声明(零值 LevelRoutine)时原样返回 base,没标紧急度的事件行为逐字不变。