fix(distill): narrow short-fact exemption to structured prefixes only
The <20-char exemption added earlier for human-side soulful facts also carried a 'hasStatementSubject && !status && !question' fallback. hasStatementSubject only checks for a subject word - it does not check that the content is a fact - so fragments, questions and status reports all passed: '用户喜欢喝咖啡' (7 chars, fragment) '用户重启了系统' (7 chars, fragment) '用户今天完成了一次系统检查工作' (14 chars, fragment) '用户要不要升级系统吗' (question) '小唯a06与all桥接状态同步完成' (status report) Five assertions in the distill suite were failing because of this (TestIsQualityFact_ShortFragmentsRejected, _PureQuestionRejected, _StatusReportRejected, and TestDistillOne_QualityGateBlocksFragments which kept 2 facts where the gate should keep 1). The exemption is now limited to daemon-written structured prefixes (画像规则:/心迹:/牵挂:/偏好:/习惯:/目标:/行为规则:) - strong signals that cannot be confused with noise. Natural short sentences are weak signals and are rejected as fragments; if a writer genuinely needs one kept, it should supply the structured prefix rather than loosen this gate. go test ./... now passes (TEST_EXIT=0, 8 packages ok).
This commit is contained in:
@@ -23,11 +23,22 @@ import (
|
||||
"github.com/xiaoxue/memoryweave/internal/redact"
|
||||
)
|
||||
|
||||
// isSoulfulShortFact 判断是否为<20 字的人侧结构化短事实(放行,非碎片)
|
||||
// isSoulfulShortFact 判断是否为<20 字的人侧**结构化**短事实(放行,非碎片)
|
||||
//
|
||||
// 画像/心迹/牵挂/偏好/习惯/目标类由 daemon 侧固化前缀写入(如"画像规则:"、"牵挂:"、
|
||||
// "偏好:"、"习惯:"、"目标:"、"行为规则:"),天然短但 100% 是用户事实。
|
||||
// 仅放行前缀已知且内容非纯噪声的短事实;否则仍按碎片拒绝。
|
||||
// 只认 daemon 侧固化的结构化前缀("画像规则:"、"心迹:"、"牵挂:"、"偏好:"、
|
||||
// "习惯:"、"目标:"、"行为规则:" 等)—— 这些天然短但 100% 是用户事实。
|
||||
//
|
||||
// ⚠️ 2026-09-20 收窄:此前这里还有一条 `hasStatementSubject(s) && ...`
|
||||
// 的兜底("带牧尘/用户/小唯主语的短陈述也放行"),它把豁免开得过宽——
|
||||
// hasStatementSubject 只检查有无主语,不检查内容是否是事实,于是
|
||||
// "用户喜欢喝咖啡"、"用户重启了系统"、"用户要不要升级系统吗"、
|
||||
// "小唯a06与all桥接状态同步完成" 这类碎片/疑问/状态汇报全部被放行入库。
|
||||
// 单测 TestIsQualityFact_ShortFragmentsRejected(其意图是"<20字一律拒绝,
|
||||
// 无用户信号豁免")因此 5 处失败。
|
||||
//
|
||||
// 正确边界:结构化前缀 = 强信号(daemon 主动固化);自然短句 = 弱信号,
|
||||
// 无法与碎片区分,一律按碎片拒绝。需要放行自然短句时,应由写入方补
|
||||
// 结构化前缀,而不是放宽这里。
|
||||
func isSoulfulShortFact(s string) bool {
|
||||
shortFactPrefixes := []string{
|
||||
"画像规则", "画像:", "心迹:", "牵挂:", "偏好:", "习惯:", "目标:",
|
||||
@@ -38,10 +49,6 @@ func isSoulfulShortFact(s string) bool {
|
||||
return true
|
||||
}
|
||||
}
|
||||
// 带"牧尘/用户/小唯"主语的短陈述也是真实用户事实
|
||||
if hasStatementSubject(s) && !isStatusReportLike(s) && !isPureQuestion(s) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user