lingshu-skill 5.52.0 → 5.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # 更新日志
2
2
 
3
+ ## v5.53(2026-12-04)
4
+
5
+ ### 🧠 自我认知四桶真实填充(SELF-MODEL-FILL)
6
+
7
+ 四桶长期为空(strengths/uncertainties/autobiography),排查发现两个数据通路依赖**真实数据里不存在的字段**:
8
+ - `uncertainties` 要求 insight 带 confidence 0.4~0.6 ——实测 23 条 insight 里 **0 条**有该字段(只有教训库用)
9
+ - `strengths` 要求带 emotion 字段 ——实测高重要度记忆 **emo 全为 None**
10
+
11
+ **改用真实存在的信号**:
12
+ - `uncertainties` ← `superseded_by`(被新结论取代的旧记忆):"曾经以为…"是认知修正最诚实的痕迹
13
+ - `strengths` ← 重要度≥0.75 且 `access_count`≥3:被系统反复召回=真的在用,不靠自夸
14
+ - `limitations` ← 补 `mistake` 类记忆(13 条)——原路只认 correction=True(全库仅 1 条)
15
+
16
+ **实测**:strengths 8 / uncertainties 8 / limitations 9,全部可溯源到具体记忆。
17
+
18
+ ### 🌊 心情流水快照(MOOD-SNAPSHOT)
19
+
20
+ emotion_timeline 长期只有 1 条——根因是 `auto_appraise` 只在 `extract`(封存对话)时调用,日常 remember/capture 不经过它。
21
+
22
+ **补充**:daily_drift 每天写一条**实测** EMA 快照进 emotions.jsonl(genesis=False,标"每日快照")——不是编造情绪,是把真实测得的心情记进流水,让时间线有连续曲线。20h 内只记一次。
23
+
24
+ ### 🛡️ PERSONA-GUARD v3(守卫自身缺陷修正)
25
+
26
+ 本轮排查中发现 v2 守卫方向错了:无条件拒绝空态写入会让**首次初始化返回 None**,连锁崩掉 overview 与全部单测(实测 9/11、10/12、3/5 挂)。
27
+
28
+ **修正**:只在【会丢数据】时拦(盘上已有名字/特质/历史 + 产物为空);首次创建必须放行;`compile_persona` 任何分支都不返回 None。
29
+
30
+ ### 🐛 附带发现
31
+
32
+ 四桶条目必须是**纯字符串**——`_ensure_self_model` 会丢弃 dict 类型条目(v5.52 的 {ts,text} 形式被静默清空,导致 added 报 8 但桶里为 0)。
33
+
34
+ ---
35
+
3
36
  ## v5.52(2026-12-04)
4
37
 
5
38
  ### 🌱 内驱真实演化(DRIVE-EVOLVE)
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > 名字取自《黄帝内经》:**算力给思考,人格给灵魂,记忆给生命。**
4
4
 
5
- > 当前版本 **v5.52**(变更见 [CHANGELOG.md](CHANGELOG.md))
5
+ > 当前版本 **v5.53**(变更见 [CHANGELOG.md](CHANGELOG.md))
6
6
 
7
7
  > 🔁 **双仓库镜像**:GitHub(主)与 Gitee(镜像)保持同步——[gitee.com/htmcwy_0/lingshu-skill](https://gitee.com/htmcwy_0/lingshu-skill)。灵枢的更新检查会探测两边最新提交,**谁更新就自动从谁拉取**;任一边不可达(Gitee 匿名风控 / GitHub 限额)时走另一边兜底。
8
8
 
package/SKILL-lite.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: lingshu-lite
3
3
  title: 灵枢-lite
4
- version: 5.52
4
+ version: 5.53
5
5
  description: 灵枢记忆系统的精简版说明书,给 3B 以下本地小模型或第一次用的人。只保留最有用的核心:分层记忆(含冷热自动归档)、模糊回忆、工作记忆、人格初识;砍掉高风险自动能力(自动做梦合并、自动情绪评估、自动提炼知识库)——小模型做这些容易把幻觉固化落盘。当用户提到"记住这个""你还记得吗""你记得什么""上下文快满了"且宿主是小模型时使用。
6
6
  ---
7
7
 
package/SKILL-tiny.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: lingshu-tiny
3
3
  title: 灵枢-tiny
4
- version: 5.52
4
+ version: 5.53
5
5
  description: 灵枢记忆系统的最小试用版说明书。只剩三件事:startup 带回上次的记忆、remember 记下值得记的、recall 想不起来时捞回来。给第一次接触灵枢的人或最小模型:先跑通这三条拿到真实收益,再决定要不要升级完整版。当用户提到"记住这个""你还记得吗"且你不想背整套机制时使用。
6
6
  ---
7
7
 
package/SKILL.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: lingshu
3
3
  title: 灵枢
4
- version: 5.52
4
+ version: 5.53
5
5
  description: 类脑持久记忆/人格/成长。跨会话记住事情、长出人格、上下文将满时做梦整理。用户提记忆/记住/上次/人格/设定/性格/知识库/笔记/日志/成长/自我进化/工作记忆,或新会话需恢复关系上下文时用。纯本地零依赖。
6
6
  ---
7
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lingshu-skill",
3
- "version": "5.52.0",
3
+ "version": "5.53.0",
4
4
  "description": "Brain-inspired persistent memory, persona and growth system for AI coding agents. Local-only, zero-dependency Python. Requires Python 3.10+.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "PATCH_NOTES.md": "9296e524f743f358fd11115598398a754cfd69534526dde9c8ad85f14a418f89",
3
3
  "README.md": "3d634d743b085eebd2cbb5dd3a00edfa728ed23947e20cc29e7c3b29087ec043",
4
- "engine/CHANGELOG.md": "76a08f52bd161749f4082c9b37577311f8218061b6039d433dcd528169e14810",
5
- "engine/README.md": "b62f1d4a798283bb6a4afa7b4a8121b4d6eaea482e2fcf3f99f04b5d9f0b08d8",
6
- "engine/SKILL-lite.md": "18ffc0d9680323b9819f4c25fb60faed14cc4d47b80c7ce8f92aba46d1fe055b",
7
- "engine/SKILL-tiny.md": "5aa8b2fb9c2b8fa042bd06353871d9b9e01e5f0e27a88924e27bf8c3d0b4fdb6",
8
- "engine/SKILL.md": "22e911b2143e955428edffe8bdd762cbbcc81335a039499184f864d3ed80d1e5",
4
+ "engine/CHANGELOG.md": "f78c8e0c25e06a9159234968e3ed49bc210d7f93a2909e69e74006cab462d629",
5
+ "engine/README.md": "d5de5721d86c45a053701ba38c1aad6a96a4245d2f58ecc30344113f34950184",
6
+ "engine/SKILL-lite.md": "e75a6f1ad684802287754eccb7cd4bfad483d59b19e94721bdd7af8cf30fac87",
7
+ "engine/SKILL-tiny.md": "befeea374148268fe9016314de09c21cfa4921e77a8ee90e4e69faae571b27f7",
8
+ "engine/SKILL.md": "1e7f1a21c69be1ae4bf9356c5447b13608d217fa08186c52987cfa51ab68ec35",
9
9
  "engine/assets/panel.html": "1b015d80e2d6ec8d52eee7a970f535877938adddc1cef0fd6629778e87f63c42",
10
10
  "engine/docs/commands.md": "0ce8c88e5d2d04a8055b45c060ebd53b50c52b79b650312e2ee440845804ca4b",
11
11
  "engine/docs/mechanics.md": "aa9683c827ed3419106e84d847ab16dc310c27fc62f588184192aaa1617523cc",
@@ -61,7 +61,7 @@
61
61
  "engine/scripts/panel_splash.py": "36cd59e593ce52557a180a8767bfa9cd9c803f0cccaa141e7da8babd5a35e925",
62
62
  "engine/scripts/panel_update.py": "6ff1a0687c05e3ef4ae846058abea4dacf985a3fe6adcdbb4eef1b38e27139b5",
63
63
  "engine/scripts/panels.py": "9db94038c2c11fc5da0f2f7c3292d01053acfaf1b74f1517a1f1c4402895fef4",
64
- "engine/scripts/persona.py": "6e02738f34eb13ee3344c4de26859973ec8221d8b7b45576d48b5e94e283d94b",
64
+ "engine/scripts/persona.py": "49f4a62e7268c4e63f51599c27eae3dcf40421067db3fdb45027f9f3f573ef9b",
65
65
  "engine/scripts/prepublish_tests.py": "8d116de1edd3ab57584a6a2749598cf127e918383da67e50118601e5a3970c2a",
66
66
  "engine/scripts/release.py": "b4271c06802d6154e90715cc566e4104f5d6de0b9efa6f4907643e686bb5c48e",
67
67
  "engine/scripts/retriever.py": "85a35f8f660767cff1c068e722b51e3b5623c4dffe4822527eee96f9220240d3",
@@ -1,5 +1,38 @@
1
1
  # 更新日志
2
2
 
3
+ ## v5.53(2026-12-04)
4
+
5
+ ### 🧠 自我认知四桶真实填充(SELF-MODEL-FILL)
6
+
7
+ 四桶长期为空(strengths/uncertainties/autobiography),排查发现两个数据通路依赖**真实数据里不存在的字段**:
8
+ - `uncertainties` 要求 insight 带 confidence 0.4~0.6 ——实测 23 条 insight 里 **0 条**有该字段(只有教训库用)
9
+ - `strengths` 要求带 emotion 字段 ——实测高重要度记忆 **emo 全为 None**
10
+
11
+ **改用真实存在的信号**:
12
+ - `uncertainties` ← `superseded_by`(被新结论取代的旧记忆):"曾经以为…"是认知修正最诚实的痕迹
13
+ - `strengths` ← 重要度≥0.75 且 `access_count`≥3:被系统反复召回=真的在用,不靠自夸
14
+ - `limitations` ← 补 `mistake` 类记忆(13 条)——原路只认 correction=True(全库仅 1 条)
15
+
16
+ **实测**:strengths 8 / uncertainties 8 / limitations 9,全部可溯源到具体记忆。
17
+
18
+ ### 🌊 心情流水快照(MOOD-SNAPSHOT)
19
+
20
+ emotion_timeline 长期只有 1 条——根因是 `auto_appraise` 只在 `extract`(封存对话)时调用,日常 remember/capture 不经过它。
21
+
22
+ **补充**:daily_drift 每天写一条**实测** EMA 快照进 emotions.jsonl(genesis=False,标"每日快照")——不是编造情绪,是把真实测得的心情记进流水,让时间线有连续曲线。20h 内只记一次。
23
+
24
+ ### 🛡️ PERSONA-GUARD v3(守卫自身缺陷修正)
25
+
26
+ 本轮排查中发现 v2 守卫方向错了:无条件拒绝空态写入会让**首次初始化返回 None**,连锁崩掉 overview 与全部单测(实测 9/11、10/12、3/5 挂)。
27
+
28
+ **修正**:只在【会丢数据】时拦(盘上已有名字/特质/历史 + 产物为空);首次创建必须放行;`compile_persona` 任何分支都不返回 None。
29
+
30
+ ### 🐛 附带发现
31
+
32
+ 四桶条目必须是**纯字符串**——`_ensure_self_model` 会丢弃 dict 类型条目(v5.52 的 {ts,text} 形式被静默清空,导致 added 报 8 但桶里为 0)。
33
+
34
+ ---
35
+
3
36
  ## v5.52(2026-12-04)
4
37
 
5
38
  ### 🌱 内驱真实演化(DRIVE-EVOLVE)
@@ -2,7 +2,7 @@
2
2
 
3
3
  > 名字取自《黄帝内经》:**算力给思考,人格给灵魂,记忆给生命。**
4
4
 
5
- > 当前版本 **v5.52**(变更见 [CHANGELOG.md](CHANGELOG.md))
5
+ > 当前版本 **v5.53**(变更见 [CHANGELOG.md](CHANGELOG.md))
6
6
 
7
7
  > 🔁 **双仓库镜像**:GitHub(主)与 Gitee(镜像)保持同步——[gitee.com/htmcwy_0/lingshu-skill](https://gitee.com/htmcwy_0/lingshu-skill)。灵枢的更新检查会探测两边最新提交,**谁更新就自动从谁拉取**;任一边不可达(Gitee 匿名风控 / GitHub 限额)时走另一边兜底。
8
8
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: lingshu-lite
3
3
  title: 灵枢-lite
4
- version: 5.52
4
+ version: 5.53
5
5
  description: 灵枢记忆系统的精简版说明书,给 3B 以下本地小模型或第一次用的人。只保留最有用的核心:分层记忆(含冷热自动归档)、模糊回忆、工作记忆、人格初识;砍掉高风险自动能力(自动做梦合并、自动情绪评估、自动提炼知识库)——小模型做这些容易把幻觉固化落盘。当用户提到"记住这个""你还记得吗""你记得什么""上下文快满了"且宿主是小模型时使用。
6
6
  ---
7
7
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: lingshu-tiny
3
3
  title: 灵枢-tiny
4
- version: 5.52
4
+ version: 5.53
5
5
  description: 灵枢记忆系统的最小试用版说明书。只剩三件事:startup 带回上次的记忆、remember 记下值得记的、recall 想不起来时捞回来。给第一次接触灵枢的人或最小模型:先跑通这三条拿到真实收益,再决定要不要升级完整版。当用户提到"记住这个""你还记得吗"且你不想背整套机制时使用。
6
6
  ---
7
7
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: lingshu
3
3
  title: 灵枢
4
- version: 5.52
4
+ version: 5.53
5
5
  description: 类脑持久记忆/人格/成长。跨会话记住事情、长出人格、上下文将满时做梦整理。用户提记忆/记住/上次/人格/设定/性格/知识库/笔记/日志/成长/自我进化/工作记忆,或新会话需恢复关系上下文时用。纯本地零依赖。
6
6
  ---
7
7
 
@@ -270,11 +270,17 @@ def compile_persona() -> dict:
270
270
  _disk_now = _slurp_json(HOME / "persona.json") if (HOME / "persona.json").exists() else None
271
271
  _disk_named = bool((( _disk_now or {}).get("identity") or {}).get("名字"))
272
272
  _incoming_named = bool(((p.get("identity") or {}).get("名字") or "").strip())
273
- if _disk_named and not _incoming_named:
273
+ # PERSONA-GUARD v3:只在【会丢数据】时拦(盘上已有实质内容 + 产物为空),
274
+ # 首次创建(无文件/盘上空)必须放行——v2 的无条件拒绝让初始化返回 None,
275
+ # 连锁崩掉 overview 与全部单测(12-04 03:22 实测)。
276
+ _disk_sub = (bool(str((_disk_now.get("identity") or {}).get("名字") or "").strip())
277
+ or bool(_disk_now.get("traits") or {})
278
+ or bool(_disk_now.get("history") or [])) if isinstance(_disk_now, dict) else False
279
+ if _disk_sub and not _incoming_named and not (p.get("traits") or {}):
274
280
  log_event("persona",
275
- "compile_persona 拒绝覆盖:盘上人格有名字而重建产物为空态——疑似竞态,已拦下。",
281
+ "compile_persona 拒绝覆盖:盘上已有实质人格而被空态重建覆盖——已拦下。",
276
282
  level="error")
277
- return _slurp_json(HOME / "persona.json") # 返回盘上完好人格
283
+ return _disk_now if isinstance(_disk_now, dict) else default_persona()
278
284
  atomic_json(HOME / "persona.json", p)
279
285
  # SPEED-1 缓存同步失效:compile_persona 直写绕过了 save_persona 的失效点
280
286
  global _lp_cache, _lp_cache_mtime, _lp_cache_time
@@ -1469,6 +1475,26 @@ def daily_drift(days: int = 1) -> dict:
1469
1475
  applied = True
1470
1476
  audit_log("ai", "daily_drift", "state.mood_score",
1471
1477
  f"{int(cur)}→{new}(近{days}天 net={net})")
1478
+ # —— 心情快照(MOOD-SNAPSHOT v5.53)——
1479
+ # 历史问题:emotion_timeline 只有 1 条——因为 auto_appraise 只在 extract(封存对话)
1480
+ # 时调用,日常 remember/capture 不经过它。补一条**每��实测**的 EMA 快照进
1481
+ # emotions.jsonl(genesis=False,标 source=daily-snapshot):
1482
+ # 不是编造情绪,是把当天真实测得的心情记进流水,让时间线有连续曲线。
1483
+ try:
1484
+ import emotion as _emo
1485
+ _m = _emo.mood_now()
1486
+ if _m.get("active") or _m.get("label") not in (None, "", "平静"):
1487
+ _mood_hist = p.setdefault("state", {}).setdefault("_mood_snap_ts", 0)
1488
+ if now - _num(_mood_hist, 0) >= 20 * 3600: # 20h 内只记一次
1489
+ _emo.feel(_m.get("label") or "平静",
1490
+ intensity=max(0.05, min(0.6, _num(_m.get("intensity"), 0.1))),
1491
+ why=f"每日心情快照:{_m.get('label')}(强度 {_num(_m.get('intensity'), 0):.0%})",
1492
+ about="每日快照", genesis=False)
1493
+ p["state"]["_mood_snap_ts"] = now
1494
+ applied = True
1495
+ except Exception as _e:
1496
+ log_event("persona", f"心情快照写入失败(不影响其他):{_e}", level="warn")
1497
+
1472
1498
  # —— 内驱演化(DRIVE-EVOLVE v5.52)——
1473
1499
  # 历史问题:mind_tune 只有 CLI 手动路径,从初识后好奇/理智永远不变。
1474
1500
  # 这里用【真实信号】驱动(都可追溯到记忆库),每天最多 ±2,带 history 留痕:
@@ -2625,61 +2651,94 @@ def self_model_autosink() -> dict:
2625
2651
  sm["autobiography"].sort(key=lambda e: _num(e.get("ts"), 0), reverse=True)
2626
2652
  del sm["autobiography"][_SELF_MODEL_MAX:]
2627
2653
 
2628
- # —— 路 3:灰区洞察 → uncertainties(IDEA-10)——
2629
- # confidence 0.4~0.6 的 insight:"半懂不懂"是最真实的困惑。
2654
+ # —— 路 3:被取代的旧结论 → uncertainties(IDEA-10 实装版)——
2655
+ # 原实现要求 insight 带 confidence 0.4~0.6 字段,但实测 23 条 insight 里
2656
+ # **0 条有 confidence**(该字段只有教训库用)→ 死代码。
2657
+ # 改用真实存在的信号:superseded_by(被新结论取代的旧记忆)——
2658
+ # "我当时是这么想的,后来发现不成立"正是最诚实的认知修正痕迹。
2630
2659
  try:
2631
2660
  import memory as _mem
2632
2661
  uncer: list = []
2633
2662
  for r in _mem.load_all():
2634
- if not isinstance(r, dict) or r.get("kind") != "insight":
2635
- continue
2636
- conf = _num(r.get("confidence"), -1)
2637
- if not (0.4 <= conf < 0.6):
2663
+ if not isinstance(r, dict) or not r.get("superseded_by"):
2638
2664
  continue
2639
2665
  ts_r = _num(r.get("ts"), 0) or _num(r.get("created"), 0)
2640
- if now - ts_r > 14 * 86400:
2666
+ if now - ts_r > 90 * 86400: # 三个月前的旧账不再翻
2641
2667
  continue
2642
- t = str(r.get("text") or r.get("summary") or "").strip()
2643
- if t:
2644
- uncer.append({"ts": ts_r, "text": t[:160]})
2645
- uncer.sort(key=lambda e: e["ts"], reverse=True)
2646
- existing_u = {e.get("text") for e in sm["uncertainties"]}
2647
- for e in uncer[:8]:
2648
- if e["text"] in existing_u:
2668
+ t0 = str(r.get("text") or r.get("summary") or "").strip()
2669
+ if not t0:
2649
2670
  continue
2650
- sm["uncertainties"].append(e)
2651
- added["uncertainties"].append(e["text"])
2652
- del sm["uncertainties"][_SELF_MODEL_MAX:]
2671
+ uncer.append((ts_r, "曾经以为:" + t0[:140]))
2672
+ uncer.sort(key=lambda e: e[0], reverse=True)
2673
+ existing_u = set(sm["uncertainties"])
2674
+ for _ts, txt in uncer[:8]:
2675
+ if txt in existing_u:
2676
+ continue
2677
+ sm["uncertainties"].append(txt) # 纯字符串:_ensure_self_model 只保留 str
2678
+ added["uncertainties"].append(txt)
2679
+ if len(sm["uncertainties"]) > _SELF_MODEL_MAX:
2680
+ del sm["uncertainties"][:-_SELF_MODEL_MAX]
2653
2681
  except Exception as e:
2654
- log_event("persona", f"self_model_autosink 灰区困惑路失败:{e}", level="warn")
2682
+ log_event("persona", f"self_model_autosink 被取代结论路失败:{e}", level="warn")
2655
2683
 
2656
- # —— 路 4:被反复验证的高价值洞察 → strengths(IDEA-10)——
2657
- # 重要度 ≥0.8 + 被召回 ≥3 次 + 带正面情绪标记 = "反复用上且被验证"。
2684
+ # —— 路 4:反复被召回使用的高价值结论 → strengths(IDEA-10 实装版)——
2685
+ # 原实现要求 importance>=0.8 + access_count>=3 + 带 emotion 字段,
2686
+ # 但实测高重要度记忆 emo 几乎全为 None → 死代码。
2687
+ # 改用真实信号:importance>=0.75 且 access_count>=3——
2688
+ # 被系统反复召回 = 真的在用,这是能力最硬的证据(不靠自夸)。
2658
2689
  try:
2659
2690
  import memory as _mem
2660
2691
  strengths_cand: list = []
2661
2692
  for r in _mem.load_all():
2662
- if not isinstance(r, dict) or r.get("kind") not in ("insight", "fact"):
2693
+ if not isinstance(r, dict):
2663
2694
  continue
2664
- if _num(r.get("importance"), 0) < 0.8:
2695
+ if r.get("kind") not in ("insight", "fact"):
2665
2696
  continue
2666
- if int(_num(r.get("access_count"), 0)) < 3:
2697
+ if _num(r.get("importance"), 0) < 0.75:
2667
2698
  continue
2668
- if not r.get("emotion"):
2699
+ _acc = int(_num(r.get("access_count"), 0))
2700
+ if _acc < 3:
2669
2701
  continue
2670
- t = str(r.get("text") or r.get("summary") or "").strip()
2671
- if t:
2672
- strengths_cand.append({"ts": _num(r.get("created"), 0), "text": t[:160]})
2673
- strengths_cand.sort(key=lambda e: e["ts"], reverse=True)
2674
- existing_s = {e.get("text") for e in sm["strengths"]}
2675
- for e in strengths_cand[:8]:
2676
- if e["text"] in existing_s:
2702
+ t0 = str(r.get("text") or r.get("summary") or "").strip()
2703
+ if not t0:
2704
+ continue
2705
+ strengths_cand.append((_num(r.get("created"), 0),
2706
+ f"(被召回 {_acc} 次)" + t0[:130]))
2707
+ strengths_cand.sort(key=lambda e: e[0], reverse=True)
2708
+ existing_s = set(sm["strengths"])
2709
+ for _ts, txt in strengths_cand[:8]:
2710
+ if txt in existing_s:
2711
+ continue
2712
+ sm["strengths"].append(txt) # 纯字符串:_ensure_self_model 只保留 str
2713
+ added["strengths"].append(txt)
2714
+ if len(sm["strengths"]) > _SELF_MODEL_MAX:
2715
+ del sm["strengths"][:-_SELF_MODEL_MAX]
2716
+ except Exception as e:
2717
+ log_event("persona", f"self_model_autosink 反复使用路失败:{e}", level="warn")
2718
+
2719
+ # —— 路 5:mistake 类记忆 → limitations 补充源(实装版)——
2720
+ # 原路1只认 correction=True,实测全库仅 1 条 → 短板几乎不积累。
2721
+ # mistake 类(13 条)是"我犯过的错"的一等公民,本该进短板桶。
2722
+ try:
2723
+ import memory as _mem
2724
+ mist = []
2725
+ for r in _mem.load_all():
2726
+ if not isinstance(r, dict) or r.get("kind") != "mistake":
2727
+ continue
2728
+ t0 = str(r.get("text") or "").strip()
2729
+ if t0:
2730
+ mist.append((_num(r.get("created"), 0), t0))
2731
+ mist.sort(key=lambda x: x[0], reverse=True)
2732
+ existing_l = set(sm["limitations"])
2733
+ for _ts, t0 in mist[:8]:
2734
+ if t0 in existing_l:
2677
2735
  continue
2678
- sm["strengths"].append(e)
2679
- added["strengths"].append(e["text"])
2680
- del sm["strengths"][_SELF_MODEL_MAX:]
2736
+ sm["limitations"].append(t0)
2737
+ added["limitations"].append(t0)
2738
+ if len(sm["limitations"]) > _SELF_MODEL_MAX:
2739
+ del sm["limitations"][:-_SELF_MODEL_MAX]
2681
2740
  except Exception as e:
2682
- log_event("persona", f"self_model_autosink 优势验证路失败:{e}", level="warn")
2741
+ log_event("persona", f"self_model_autosink mistake 路失败:{e}", level="warn")
2683
2742
 
2684
2743
  save_persona(p)
2685
2744
  audit_log("ai", "self_model_autosink", "self_model",
@@ -270,11 +270,17 @@ def compile_persona() -> dict:
270
270
  _disk_now = _slurp_json(HOME / "persona.json") if (HOME / "persona.json").exists() else None
271
271
  _disk_named = bool((( _disk_now or {}).get("identity") or {}).get("名字"))
272
272
  _incoming_named = bool(((p.get("identity") or {}).get("名字") or "").strip())
273
- if _disk_named and not _incoming_named:
273
+ # PERSONA-GUARD v3:只在【会丢数据】时拦(盘上已有实质内容 + 产物为空),
274
+ # 首次创建(无文件/盘上空)必须放行——v2 的无条件拒绝让初始化返回 None,
275
+ # 连锁崩掉 overview 与全部单测(12-04 03:22 实测)。
276
+ _disk_sub = (bool(str((_disk_now.get("identity") or {}).get("名字") or "").strip())
277
+ or bool(_disk_now.get("traits") or {})
278
+ or bool(_disk_now.get("history") or [])) if isinstance(_disk_now, dict) else False
279
+ if _disk_sub and not _incoming_named and not (p.get("traits") or {}):
274
280
  log_event("persona",
275
- "compile_persona 拒绝覆盖:盘上人格有名字而重建产物为空态——疑似竞态,已拦下。",
281
+ "compile_persona 拒绝覆盖:盘上已有实质人格而被空态重建覆盖——已拦下。",
276
282
  level="error")
277
- return _slurp_json(HOME / "persona.json") # 返回盘上完好人格
283
+ return _disk_now if isinstance(_disk_now, dict) else default_persona()
278
284
  atomic_json(HOME / "persona.json", p)
279
285
  # SPEED-1 缓存同步失效:compile_persona 直写绕过了 save_persona 的失效点
280
286
  global _lp_cache, _lp_cache_mtime, _lp_cache_time
@@ -1469,6 +1475,26 @@ def daily_drift(days: int = 1) -> dict:
1469
1475
  applied = True
1470
1476
  audit_log("ai", "daily_drift", "state.mood_score",
1471
1477
  f"{int(cur)}→{new}(近{days}天 net={net})")
1478
+ # —— 心情快照(MOOD-SNAPSHOT v5.53)——
1479
+ # 历史问题:emotion_timeline 只有 1 条——因为 auto_appraise 只在 extract(封存对话)
1480
+ # 时调用,日常 remember/capture 不经过它。补一条**每��实测**的 EMA 快照进
1481
+ # emotions.jsonl(genesis=False,标 source=daily-snapshot):
1482
+ # 不是编造情绪,是把当天真实测得的心情记进流水,让时间线有连续曲线。
1483
+ try:
1484
+ import emotion as _emo
1485
+ _m = _emo.mood_now()
1486
+ if _m.get("active") or _m.get("label") not in (None, "", "平静"):
1487
+ _mood_hist = p.setdefault("state", {}).setdefault("_mood_snap_ts", 0)
1488
+ if now - _num(_mood_hist, 0) >= 20 * 3600: # 20h 内只记一次
1489
+ _emo.feel(_m.get("label") or "平静",
1490
+ intensity=max(0.05, min(0.6, _num(_m.get("intensity"), 0.1))),
1491
+ why=f"每日心情快照:{_m.get('label')}(强度 {_num(_m.get('intensity'), 0):.0%})",
1492
+ about="每日快照", genesis=False)
1493
+ p["state"]["_mood_snap_ts"] = now
1494
+ applied = True
1495
+ except Exception as _e:
1496
+ log_event("persona", f"心情快照写入失败(不影响其他):{_e}", level="warn")
1497
+
1472
1498
  # —— 内驱演化(DRIVE-EVOLVE v5.52)——
1473
1499
  # 历史问题:mind_tune 只有 CLI 手动路径,从初识后好奇/理智永远不变。
1474
1500
  # 这里用【真实信号】驱动(都可追溯到记忆库),每天最多 ±2,带 history 留痕:
@@ -2625,61 +2651,94 @@ def self_model_autosink() -> dict:
2625
2651
  sm["autobiography"].sort(key=lambda e: _num(e.get("ts"), 0), reverse=True)
2626
2652
  del sm["autobiography"][_SELF_MODEL_MAX:]
2627
2653
 
2628
- # —— 路 3:灰区洞察 → uncertainties(IDEA-10)——
2629
- # confidence 0.4~0.6 的 insight:"半懂不懂"是最真实的困惑。
2654
+ # —— 路 3:被取代的旧结论 → uncertainties(IDEA-10 实装版)——
2655
+ # 原实现要求 insight 带 confidence 0.4~0.6 字段,但实测 23 条 insight 里
2656
+ # **0 条有 confidence**(该字段只有教训库用)→ 死代码。
2657
+ # 改用真实存在的信号:superseded_by(被新结论取代的旧记忆)——
2658
+ # "我当时是这么想的,后来发现不成立"正是最诚实的认知修正痕迹。
2630
2659
  try:
2631
2660
  import memory as _mem
2632
2661
  uncer: list = []
2633
2662
  for r in _mem.load_all():
2634
- if not isinstance(r, dict) or r.get("kind") != "insight":
2635
- continue
2636
- conf = _num(r.get("confidence"), -1)
2637
- if not (0.4 <= conf < 0.6):
2663
+ if not isinstance(r, dict) or not r.get("superseded_by"):
2638
2664
  continue
2639
2665
  ts_r = _num(r.get("ts"), 0) or _num(r.get("created"), 0)
2640
- if now - ts_r > 14 * 86400:
2666
+ if now - ts_r > 90 * 86400: # 三个月前的旧账不再翻
2641
2667
  continue
2642
- t = str(r.get("text") or r.get("summary") or "").strip()
2643
- if t:
2644
- uncer.append({"ts": ts_r, "text": t[:160]})
2645
- uncer.sort(key=lambda e: e["ts"], reverse=True)
2646
- existing_u = {e.get("text") for e in sm["uncertainties"]}
2647
- for e in uncer[:8]:
2648
- if e["text"] in existing_u:
2668
+ t0 = str(r.get("text") or r.get("summary") or "").strip()
2669
+ if not t0:
2649
2670
  continue
2650
- sm["uncertainties"].append(e)
2651
- added["uncertainties"].append(e["text"])
2652
- del sm["uncertainties"][_SELF_MODEL_MAX:]
2671
+ uncer.append((ts_r, "曾经以为:" + t0[:140]))
2672
+ uncer.sort(key=lambda e: e[0], reverse=True)
2673
+ existing_u = set(sm["uncertainties"])
2674
+ for _ts, txt in uncer[:8]:
2675
+ if txt in existing_u:
2676
+ continue
2677
+ sm["uncertainties"].append(txt) # 纯字符串:_ensure_self_model 只保留 str
2678
+ added["uncertainties"].append(txt)
2679
+ if len(sm["uncertainties"]) > _SELF_MODEL_MAX:
2680
+ del sm["uncertainties"][:-_SELF_MODEL_MAX]
2653
2681
  except Exception as e:
2654
- log_event("persona", f"self_model_autosink 灰区困惑路失败:{e}", level="warn")
2682
+ log_event("persona", f"self_model_autosink 被取代结论路失败:{e}", level="warn")
2655
2683
 
2656
- # —— 路 4:被反复验证的高价值洞察 → strengths(IDEA-10)——
2657
- # 重要度 ≥0.8 + 被召回 ≥3 次 + 带正面情绪标记 = "反复用上且被验证"。
2684
+ # —— 路 4:反复被召回使用的高价值结论 → strengths(IDEA-10 实装版)——
2685
+ # 原实现要求 importance>=0.8 + access_count>=3 + 带 emotion 字段,
2686
+ # 但实测高重要度记忆 emo 几乎全为 None → 死代码。
2687
+ # 改用真实信号:importance>=0.75 且 access_count>=3——
2688
+ # 被系统反复召回 = 真的在用,这是能力最硬的证据(不靠自夸)。
2658
2689
  try:
2659
2690
  import memory as _mem
2660
2691
  strengths_cand: list = []
2661
2692
  for r in _mem.load_all():
2662
- if not isinstance(r, dict) or r.get("kind") not in ("insight", "fact"):
2693
+ if not isinstance(r, dict):
2663
2694
  continue
2664
- if _num(r.get("importance"), 0) < 0.8:
2695
+ if r.get("kind") not in ("insight", "fact"):
2665
2696
  continue
2666
- if int(_num(r.get("access_count"), 0)) < 3:
2697
+ if _num(r.get("importance"), 0) < 0.75:
2667
2698
  continue
2668
- if not r.get("emotion"):
2699
+ _acc = int(_num(r.get("access_count"), 0))
2700
+ if _acc < 3:
2669
2701
  continue
2670
- t = str(r.get("text") or r.get("summary") or "").strip()
2671
- if t:
2672
- strengths_cand.append({"ts": _num(r.get("created"), 0), "text": t[:160]})
2673
- strengths_cand.sort(key=lambda e: e["ts"], reverse=True)
2674
- existing_s = {e.get("text") for e in sm["strengths"]}
2675
- for e in strengths_cand[:8]:
2676
- if e["text"] in existing_s:
2702
+ t0 = str(r.get("text") or r.get("summary") or "").strip()
2703
+ if not t0:
2704
+ continue
2705
+ strengths_cand.append((_num(r.get("created"), 0),
2706
+ f"(被召回 {_acc} 次)" + t0[:130]))
2707
+ strengths_cand.sort(key=lambda e: e[0], reverse=True)
2708
+ existing_s = set(sm["strengths"])
2709
+ for _ts, txt in strengths_cand[:8]:
2710
+ if txt in existing_s:
2711
+ continue
2712
+ sm["strengths"].append(txt) # 纯字符串:_ensure_self_model 只保留 str
2713
+ added["strengths"].append(txt)
2714
+ if len(sm["strengths"]) > _SELF_MODEL_MAX:
2715
+ del sm["strengths"][:-_SELF_MODEL_MAX]
2716
+ except Exception as e:
2717
+ log_event("persona", f"self_model_autosink 反复使用路失败:{e}", level="warn")
2718
+
2719
+ # —— 路 5:mistake 类记忆 → limitations 补充源(实装版)——
2720
+ # 原路1只认 correction=True,实测全库仅 1 条 → 短板几乎不积累。
2721
+ # mistake 类(13 条)是"我犯过的错"的一等公民,本该进短板桶。
2722
+ try:
2723
+ import memory as _mem
2724
+ mist = []
2725
+ for r in _mem.load_all():
2726
+ if not isinstance(r, dict) or r.get("kind") != "mistake":
2727
+ continue
2728
+ t0 = str(r.get("text") or "").strip()
2729
+ if t0:
2730
+ mist.append((_num(r.get("created"), 0), t0))
2731
+ mist.sort(key=lambda x: x[0], reverse=True)
2732
+ existing_l = set(sm["limitations"])
2733
+ for _ts, t0 in mist[:8]:
2734
+ if t0 in existing_l:
2677
2735
  continue
2678
- sm["strengths"].append(e)
2679
- added["strengths"].append(e["text"])
2680
- del sm["strengths"][_SELF_MODEL_MAX:]
2736
+ sm["limitations"].append(t0)
2737
+ added["limitations"].append(t0)
2738
+ if len(sm["limitations"]) > _SELF_MODEL_MAX:
2739
+ del sm["limitations"][:-_SELF_MODEL_MAX]
2681
2740
  except Exception as e:
2682
- log_event("persona", f"self_model_autosink 优势验证路失败:{e}", level="warn")
2741
+ log_event("persona", f"self_model_autosink mistake 路失败:{e}", level="warn")
2683
2742
 
2684
2743
  save_persona(p)
2685
2744
  audit_log("ai", "self_model_autosink", "self_model",