liquid-loop 0.6.1__tar.gz → 0.6.2__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: liquid-loop
3
- Version: 0.6.1
3
+ Version: 0.6.2
4
4
  Summary: Self-Organizing Cognitive Memory for AI Agents — Liquid Loop theory implementation
5
5
  Author: fishbook0001
6
6
  Maintainer: fishbook0001
@@ -72,7 +72,7 @@ Dynamic: license-file
72
72
  | **Anchor** 锚点 | 晶种 | 认知关注点,有稳定性值 s ∈ [0,1] |
73
73
  | **Evidence** 证据 | 附着粒子 | 锚点下的具体观察,权重指数衰减 w×0.95ᵗ |
74
74
  | **Memory** 结晶 | 结晶体 | 2+ 条一致 Evidence 自动凝聚,有置信度 c |
75
- | **Entropy** 熵值 | 流体无序度 | 四维加权:drift×0.25 + conflict×0.25 + fragmentation×0.25 + gap×0.25 |
75
+ | **Entropy** 熵值 | 流体无序度 | 八维加权(锚点漂移 / 冲突密度 / 碎片 / 活跃间隔 / 价值衰减 / 锚定强度 / CPE 三维) |
76
76
 
77
77
  **状态判定:**
78
78
  ```
@@ -123,7 +123,7 @@ save(state, Path("."))
123
123
  # 初始化工作区(创建 .liquid/state.json)
124
124
  liquid-loop init
125
125
 
126
- # 添加锚点(支持自动四维分类)
126
+ # 添加锚点(支持自动三维分类:密度 / 认知阶段 / 流动性)
127
127
  liquid-loop anchor_add "项目目标" "完成液环论文与开源"
128
128
 
129
129
  # 注入证据
@@ -33,7 +33,7 @@
33
33
  | **Anchor** 锚点 | 晶种 | 认知关注点,有稳定性值 s ∈ [0,1] |
34
34
  | **Evidence** 证据 | 附着粒子 | 锚点下的具体观察,权重指数衰减 w×0.95ᵗ |
35
35
  | **Memory** 结晶 | 结晶体 | 2+ 条一致 Evidence 自动凝聚,有置信度 c |
36
- | **Entropy** 熵值 | 流体无序度 | 四维加权:drift×0.25 + conflict×0.25 + fragmentation×0.25 + gap×0.25 |
36
+ | **Entropy** 熵值 | 流体无序度 | 八维加权(锚点漂移 / 冲突密度 / 碎片 / 活跃间隔 / 价值衰减 / 锚定强度 / CPE 三维) |
37
37
 
38
38
  **状态判定:**
39
39
  ```
@@ -84,7 +84,7 @@ save(state, Path("."))
84
84
  # 初始化工作区(创建 .liquid/state.json)
85
85
  liquid-loop init
86
86
 
87
- # 添加锚点(支持自动四维分类)
87
+ # 添加锚点(支持自动三维分类:密度 / 认知阶段 / 流动性)
88
88
  liquid-loop anchor_add "项目目标" "完成液环论文与开源"
89
89
 
90
90
  # 注入证据
@@ -104,7 +104,7 @@ def status():
104
104
 
105
105
  @main.command()
106
106
  def anchor_list():
107
- """列出所有锚点(含四维分类 + 价值衰减)"""
107
+ """列出所有锚点(含三维分类 + 价值衰减)"""
108
108
  s = _load()
109
109
  if not s.anchors:
110
110
  click.echo("暂无锚点。使用 liquid anchor add <名称> <描述> 添加。")
@@ -52,7 +52,7 @@ def activity_gap(state: WorkspaceState) -> float:
52
52
  return min(gap / timedelta(days=7), 1.0)
53
53
 
54
54
 
55
- # 【借鉴KFG】四维熵值分量
55
+ # 熵值分量(综合见 calculate,八维加权含 CPE 三维)
56
56
 
57
57
  def value_decay_entropy(state: WorkspaceState) -> float:
58
58
  """锚点价值衰减熵。0=全部高价值, 1=全部低价值 — 纯函数,不改 state"""
@@ -63,7 +63,7 @@ class AuditChain:
63
63
  return expected == stored_hash
64
64
 
65
65
 
66
- # --- 四维分类(借鉴 KFG 4D Classifier)---
66
+ # --- 三维锚点分类(密度 / 认知阶段 / 流动性)+ 一维证据质量 ---
67
67
  DensityLevel = str # "high" | "medium" | "low"
68
68
  CognitiveStage = str # "raw" | "wip" | "crystallized" | "tooling"
69
69
  LiquidityLevel = str # "hot" | "warm" | "cold" | "frozen"
@@ -278,16 +278,25 @@ class WorkspaceState:
278
278
  e.weight = max(e.weight * 0.95, 0.1)
279
279
 
280
280
  def _nucleate(self, anchor_id: str):
281
- """成核:同锚点下 >= 2 条一致证据形成记忆结晶"""
281
+ """成核:同锚点下 >= 2 条一致证据形成记忆结晶。
282
+
283
+ 复合键判定:查重限定在当前锚点内((anchor_id, content)),避免跨锚点
284
+ 同 content 证据被错误吞掉或并入同一结晶(P0 跨锚点误结晶修复, v0.6.2)。
285
+ """
282
286
  group = [e for e in self.evidences if e.anchor_id == anchor_id]
283
287
  if len(group) < 2:
284
288
  return
285
- from collections import Counter
289
+ # 本锚点已结晶的 content 集合(复合键判定,杜绝跨锚点污染)
290
+ crystallized_contents: set[str] = set()
291
+ for m in self.memories:
292
+ for eid in m.evidence_ids:
293
+ ev = next((e for e in self.evidences if e.id == eid), None)
294
+ if ev is not None and ev.anchor_id == anchor_id:
295
+ crystallized_contents.add(m.content)
296
+ break
286
297
  content_counts = Counter(e.content for e in group)
287
298
  for content, count in content_counts.items():
288
- if count >= 2:
289
- if any(m.content == content for m in self.memories):
290
- continue
299
+ if count >= 2 and content not in crystallized_contents:
291
300
  evidence_ids = [e.id for e in group if e.content == content]
292
301
  confidence = min(count / len(group), 1.0)
293
302
  self.memories.append(Memory(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: liquid-loop
3
- Version: 0.6.1
3
+ Version: 0.6.2
4
4
  Summary: Self-Organizing Cognitive Memory for AI Agents — Liquid Loop theory implementation
5
5
  Author: fishbook0001
6
6
  Maintainer: fishbook0001
@@ -72,7 +72,7 @@ Dynamic: license-file
72
72
  | **Anchor** 锚点 | 晶种 | 认知关注点,有稳定性值 s ∈ [0,1] |
73
73
  | **Evidence** 证据 | 附着粒子 | 锚点下的具体观察,权重指数衰减 w×0.95ᵗ |
74
74
  | **Memory** 结晶 | 结晶体 | 2+ 条一致 Evidence 自动凝聚,有置信度 c |
75
- | **Entropy** 熵值 | 流体无序度 | 四维加权:drift×0.25 + conflict×0.25 + fragmentation×0.25 + gap×0.25 |
75
+ | **Entropy** 熵值 | 流体无序度 | 八维加权(锚点漂移 / 冲突密度 / 碎片 / 活跃间隔 / 价值衰减 / 锚定强度 / CPE 三维) |
76
76
 
77
77
  **状态判定:**
78
78
  ```
@@ -123,7 +123,7 @@ save(state, Path("."))
123
123
  # 初始化工作区(创建 .liquid/state.json)
124
124
  liquid-loop init
125
125
 
126
- # 添加锚点(支持自动四维分类)
126
+ # 添加锚点(支持自动三维分类:密度 / 认知阶段 / 流动性)
127
127
  liquid-loop anchor_add "项目目标" "完成液环论文与开源"
128
128
 
129
129
  # 注入证据
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "liquid-loop"
7
- version = "0.6.1"
7
+ version = "0.6.2"
8
8
  description = "Self-Organizing Cognitive Memory for AI Agents — Liquid Loop theory implementation"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -43,3 +43,32 @@ def test_auto_describe_anchor():
43
43
  state._nucleate(a.id)
44
44
  # 如果有高置信结晶,描述会被填充
45
45
  # 这里主要测试不报错
46
+
47
+
48
+ def test_nucleate_no_cross_anchor_pollution():
49
+ """P0 回归(v0.6.2):两锚点存在相同 content 证据时各自独立成核,不互相吞噬/污染。
50
+
51
+ 修复前 `_nucleate` 用全局 `m.content == content` 查重,不限定 anchor_id:
52
+ 锚点 A 已结晶 content=X 后,锚点 B 同 content 证据被 `continue` 跳过 →
53
+ 仅 1 条结晶且 B 的证据丢失。修复后应为 2 条结晶,且各自 evidence_ids 不跨锚点。
54
+ """
55
+ state = WorkspaceState()
56
+ a1 = state.add_anchor('锚点A')
57
+ a2 = state.add_anchor('锚点B')
58
+ state.add_evidence(a1.id, 'shared fact')
59
+ state.add_evidence(a1.id, 'shared fact')
60
+ state.add_evidence(a2.id, 'shared fact')
61
+ state.add_evidence(a2.id, 'shared fact')
62
+
63
+ # 每个锚点各成核 1 条结晶(共 2 条)
64
+ assert len(state.memories) == 2
65
+ # 每条结晶的 evidence_ids 必须只属于单一锚点(无跨锚点污染)
66
+ for m in state.memories:
67
+ evs = [e for e in state.evidences if e.id in m.evidence_ids]
68
+ assert len({e.anchor_id for e in evs}) == 1
69
+ # 锚点 A 与 B 的结晶分别存在
70
+ a1_ev_ids = {e.id for e in state.evidences if e.anchor_id == a1.id}
71
+ a2_ev_ids = {e.id for e in state.evidences if e.anchor_id == a2.id}
72
+ assert any(set(m.evidence_ids) == a1_ev_ids for m in state.memories)
73
+ assert any(set(m.evidence_ids) == a2_ev_ids for m in state.memories)
74
+
File without changes
File without changes