stratagate-dsh 0.2.76 → 0.2.78

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,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.78 - 2026-09-21
4
+
5
+ - Derive Block summaries and Events from a provenance-preserving compact view of L5 messages, omitting large code and bounding oversized tool payloads while keeping full raw evidence in L5.
6
+ - Preserve message IDs and validate Event `sourceMessageIds` against the original L5 block so tool-trace compaction does not weaken evidence links.
7
+
8
+ ## 0.2.77 - 2026-09-21
9
+
10
+ - Treat an empty Event store as a normal idle state so a new workspace no longer reports an unfinished 0/0 knowledge graph update.
11
+
3
12
  ## 0.2.76 - 2026-09-20
4
13
 
5
14
  - Track exact Event provenance for Graph node names, aliases, and tags without changing the SQLite schema, while keeping legacy metadata visible only when every potential source remains exposable.
package/README.md CHANGED
@@ -98,9 +98,7 @@ Short-term decay gradually reduces the detail that older conversations contribut
98
98
 
99
99
  ## How it works
100
100
 
101
- ![Figure 1: StrataGate workflow—memory formation, automatic activation, active retrieval, and evidence assessment (Chinese labels)](docs/assets/aaed14b0b43a76334008117f6ca104af.png)
102
-
103
- *The four-round retrieval budget in Figure 1 is an example evaluation setting. Integrations control their own retrieval loops and budgets. The diagrams use Chinese labels; the accompanying text explains each mechanism in English.*
101
+ ![Figure 1: StrataGate workflow—memory formation, automatic activation, active retrieval, and evidence assessment](docs/assets/stratagate-overall-flow-en.png)
104
102
 
105
103
  StrataGate's workflow covers memory formation, recall when answering, and feedback after adoption.
106
104
 
@@ -156,7 +154,7 @@ StrataGate separately manages conversation detail, long-term information updates
156
154
 
157
155
  Recent discussions usually need their full detail. Older conversations can remain in context as concise views. StrataGate stores several levels of detail for the same conversation block and gradually reduces what older Blocks display by default as more conversation accumulates.
158
156
 
159
- ![Figure 2: Short-term memory—L0–L5 views, display decay, and on-demand expansion (Chinese labels)](docs/assets/41fc676096d0a13337a1c03aaf8f499b.png)
157
+ ![Figure 2: Short-term memory—L0–L5 views, display decay, and on-demand expansion](docs/assets/stratagate-short-term-memory-en.png)
160
158
 
161
159
  **One conversation block, six levels of detail.**
162
160
 
@@ -169,11 +167,15 @@ Each fully processed Block contains these views:
169
167
  | L0 | Title and tags | Identify a piece of history with minimal context |
170
168
  | L1 | Short summary | Understand the discussion's topic |
171
169
  | L2 | Key facts | Review decisions, constraints, plans, and outcomes |
172
- | L3 | Rule-condensed dialogue | Preserve the discussion while removing bounded redundancy |
173
- | L4 | Readable, near-verbatim dialogue | Check fuller language context |
170
+ | L3 | Deterministically condensed dialogue | Remove standalone fillers from a fixed allowlist; keep only the first duplicate long or code-like paragraph; retain tool names and result summaries |
171
+ | L4 | Near-verbatim dialogue without internal messages | Remove system messages; only trim outer whitespace and add role labels to user and assistant text; retain names and summaries for recognized tool records |
174
172
  | L5 | Source messages and tool records | Verify provenance and specific details |
175
173
 
176
- The model produces L0–L2 summaries. Code generates L3 and L4 deterministically. L3 may condense standalone greetings, pure confirmations, repeated long pasted content, and tool arguments; it does not perform free-form semantic paraphrasing.
174
+ The model produces L0–L2 summaries. L3 and L4 do not use model paraphrasing; code generates them with these fixed rules:
175
+
176
+ - **L4:** Remove system messages. User and assistant text is preserved except for trimming outer whitespace and adding `User`, `Assistant`, or other role labels. Recognized structured tool records retain the tool name and a result summary of at most 160 characters while omitting raw `arguments`, `params`, `input`, and `request` fields. Tool-role text that is not recognized as tool JSON remains unchanged.
177
+ - **L3:** Condense further without semantic rewriting. A sentence is removed only when, after trailing punctuation is stripped, it exactly matches a fixed filler allowlist such as `ok`, `thanks`, `got it`, `好的`, `明白`, `收到`, `谢谢`, or `可以`. After whitespace normalization and case folding, code-like paragraphs and paragraphs of at least 80 characters are deduplicated: the first copy remains verbatim, and later exact duplicates become an omission marker. Tool records use the same name-and-result-summary form as L4.
178
+ - **Length guard:** If generated L4 would be longer than L5, L5 is used instead. If L3 would be longer than L4, L4 is used instead, preserving `L3 ≤ L4 ≤ L5`.
177
179
 
178
180
  Source records are saved first, followed by summarization and Event processing. Only a fully processed, ready Block can replace its corresponding native history and participate in decay.
179
181
 
@@ -181,11 +183,9 @@ Source records are saved first, followed by summarization and Event processing.
181
183
 
182
184
  Display changes follow exponential decay:
183
185
 
184
- $$
185
- w_{\text{block}}(age)=e^{-\lambda_{\text{block}}\,age}
186
- $$
186
+ <p align="center"><strong>w<sub>block</sub>(age) = e<sup>−λ<sub>block</sub> · age</sup></strong></p>
187
187
 
188
- The default $\lambda_{\text{block}}$ is **0.30**. Code maps weight ranges to display levels. Smaller coefficients preserve detail for longer and therefore consume more context.
188
+ The default decay coefficient λ<sub>block</sub> is **0.30**. Code maps weight ranges to display levels. Smaller coefficients preserve detail for longer and therefore consume more context.
189
189
 
190
190
  In this formula, `age` is the distance between the current display anchor and the latest ready Block in the same conversation. It measures conversation progress, **not elapsed calendar days**. Unsealed turns and Blocks still awaiting model processing do not advance this decay.
191
191
 
@@ -220,7 +220,7 @@ Older conversations can therefore remain lightweight during ordinary use while r
220
220
 
221
221
  Short-term memory retains a discussion's context. Long-term memory extracts information worth using in future sessions. StrataGate records decisions, preferences, plans, and changes as Events, then uses those Events to organize a knowledge graph.
222
222
 
223
- ![Figure 4: Long-term memory updates—Event extraction, historical relationships, and the current-state graph (Chinese labels)](docs/assets/fc07e5b6e1cc07c115faa773a2718aa9.png)
223
+ ![Figure 4: Long-term memory updates—Event extraction, historical relationships, and the current-state graph](docs/assets/stratagate-long-term-update-en.png)
224
224
 
225
225
  **Event cards record what happened and retain their sources.**
226
226
 
@@ -299,33 +299,27 @@ The model assesses semantic sufficiency. Code validates references and protocol
299
299
 
300
300
  These checks make retrieval traceable and auditable, but the model can still misjudge evidence. When sufficient information is unavailable, the agent should continue searching or state that it cannot confirm the answer.
301
301
 
302
- Integrations control active-retrieval loops and budgets. The four-round limit in Figure 1 is an example evaluation setting, not a fixed limit for every integration.
303
-
304
302
  <a id="use-only-reinforcement"></a>
305
303
 
306
304
  ### 4. Reinforce only memories actually used: more adoptions mean slower future decay
307
305
 
308
306
  Long-term memories also decay as conversations progress. Here, the changing quantity is an Event's weight, which participates in later recall and ranking. Unlike a short-term Block, an Event does not move through L0–L5 display levels as its weight decays.
309
307
 
310
- ![Figure 3: Long-term memory weights—natural decay, retrieval without reinforcement, and adoption-based reinforcement (Chinese labels)](docs/assets/cecc9d191a4b9bf22a479623e2ebdc1d.png)
308
+ ![Figure 3: Long-term memory weights—natural decay, retrieval without reinforcement, and adoption-based reinforcement](docs/assets/stratagate-long-term-weight-en.png)
311
309
 
312
310
  **New Events have an initial weight that decays when they are not adopted.**
313
311
 
314
312
  The base Event-weight function is:
315
313
 
316
- $$
317
- w(t,n)=\max\left(floor,e^{-\lambda(n)t}\right)
318
- $$
314
+ <p align="center"><strong>w(t,n) = max(floor, e<sup>−λ(n)t</sup>)</strong></p>
319
315
 
320
- $$
321
- \lambda(n)=\frac{0.15}{1+1.5\ln(n)}
322
- $$
316
+ <p align="center"><strong>λ(n) = 0.15 / (1 + 1.5 ln(n))</strong></p>
323
317
 
324
318
  Here:
325
319
 
326
- - $t$ is the difference between the current turn and the last adoption turn; new Events start counting from creation;
327
- - $n$ is the internal adoption count, initialized to 1 and incremented for each recorded adoption;
328
- - $floor$ is the minimum weight assigned according to the memory's criticality.
320
+ - `t` is the difference between the current turn and the last adoption turn; new Events start counting from creation;
321
+ - `n` is the internal adoption count, initialized to 1 and incremented for each recorded adoption;
322
+ - `floor` is the minimum weight assigned according to the memory's criticality.
329
323
 
330
324
  Long-term decay also uses conversation turns rather than elapsed wall-clock time. Lower weight may reduce a memory's priority in later recall, but decay does not delete its historical record.
331
325
 
@@ -553,6 +547,12 @@ Contributions are welcome—whether you are fixing a bug, improving documentatio
553
547
 
554
548
  To get started, read [`CONTRIBUTING.md`](CONTRIBUTING.md). It explains how to set up the monorepo, run checks and tests, choose a useful area to work on, and prepare a focused pull request. If you are unsure whether an idea fits the project, [open an issue](https://github.com/diqierjia/StrataGate-AgentMemory/issues) before investing in a large change.
555
549
 
550
+ ## Contributors
551
+
552
+ <a href="https://github.com/diqierjia/StrataGate-AgentMemory/graphs/contributors">
553
+ <img src="https://contrib.rocks/image?repo=diqierjia/StrataGate-AgentMemory" alt="StrataGate contributors" />
554
+ </a>
555
+
556
556
  ## License
557
557
 
558
558
  StrataGate is available under the [MIT License](LICENSE).
package/README.zh-CN.md CHANGED
@@ -99,8 +99,6 @@ DSH_HOME/stratagate/memory.db
99
99
 
100
100
  ![图 1:StrataGate 整体处理流程——记忆形成、自动激活、主动检索与证据判断](docs/assets/aaed14b0b43a76334008117f6ca104af.png)
101
101
 
102
- *图 1 中的四次检索预算为示例评测配置;具体检索循环和预算由接入方控制。*
103
-
104
102
  StrataGate 的工作过程分为记忆形成、回答时找回,以及采用后的反馈。
105
103
 
106
104
  ### 1. 对话积累,形成分层短期记忆
@@ -168,11 +166,15 @@ DeepSeek Harness 插件默认每 **6 轮**完整对话封存一个 Block,一
168
166
  | L0 | 标题和标签 | 用最少内容标识这段历史 |
169
167
  | L1 | 简短摘要 | 快速了解讨论主题 |
170
168
  | L2 | 关键事实 | 查看决定、约束、计划和结果 |
171
- | L3 | 按规则精简的对话 | 保留讨论过程,去除明确冗余 |
172
- | L4 | 接近原文的可读对话 | 核对更完整的语言上下文 |
169
+ | L3 | 确定性精简对话 | 删除固定白名单中的独立寒暄或确认;重复的长段落与代码只保留第一次;工具调用保留名称和结果摘要 |
170
+ | L4 | 去除内部记录的近原文对话 | 过滤 system 消息;用户和助手正文只裁剪首尾空白并添加角色标签;可识别的工具记录保留名称和结果摘要 |
173
171
  | L5 | 原始消息与工具记录 | 查证来源及具体细节 |
174
172
 
175
- L0–L2 由模型概括生成;L3、L4 由程序按照确定性规则生成。L3 可以精简独立寒暄、纯确认、重复长粘贴内容和工具参数等,不进行自由语义改写。
173
+ L0–L2 由模型概括生成;L3、L4 不调用模型改写,而是由程序按以下固定规则生成:
174
+
175
+ - **L4:** 删除 system 消息;用户和助手正文只裁剪首尾空白并添加 `User`、`Assistant` 等角色标签。对于能够识别的结构化工具记录,只保留工具名称和最长 160 字符的结果摘要,省略原始 `arguments`、`params`、`input` 和 `request`;无法识别为工具 JSON 的 tool 正文保持原样。
176
+ - **L3:** 在不改写语义的前提下进一步精简。只有当整句去掉末尾标点后命中固定白名单时,才删除 `ok`、`thanks`、`好的`、`明白`、`收到`、`谢谢`、`可以` 等独立寒暄或确认。程序把连续空白合并并忽略大小写后,对代码型段落或至少 80 字符的长段落去重:第一次保留原文,之后的完全重复内容替换为省略标记。工具记录采用与 L4 相同的名称和结果摘要形式。
177
+ - **长度保护:** 如果生成的 L4 比 L5 更长,就直接使用 L5;如果 L3 比 L4 更长,就直接使用 L4,确保 `L3 ≤ L4 ≤ L5`。
176
178
 
177
179
  原始记录先保存,摘要和事件处理随后进行。只有处理完成、进入就绪状态的 Block,才会替换对应的原生历史并参与衰减。
178
180
 
@@ -180,11 +182,9 @@ L0–L2 由模型概括生成;L3、L4 由程序按照确定性规则生成。L
180
182
 
181
183
  Block 的展示变化由指数衰减控制:
182
184
 
183
- $$
184
- w_{\text{block}}(age)=e^{-\lambda_{\text{block}}\,age}
185
- $$
185
+ <p align="center"><strong>w<sub>block</sub>(age) = e<sup>−λ<sub>block</sub> · age</sup></strong></p>
186
186
 
187
- 其中,$\lambda_{\text{block}}$ 默认取 **0.30**,程序根据权重区间选择当前展示层级。系数越小,详细内容保留得越久,相应占用的上下文也越多。
187
+ 其中,衰减系数 λ<sub>block</sub> 默认取 **0.30**,程序根据权重区间选择当前展示层级。系数越小,详细内容保留得越久,相应占用的上下文也越多。
188
188
 
189
189
  公式中的 `age` 按当前展示锚点与同一会话最新就绪 Block 之间的距离计算。它衡量的是对话积累的进度,**不是现实中经过的天数**。尚未封存的对话,以及仍在等待模型处理的 Block,都不会推动这项衰减。
190
190
 
@@ -298,8 +298,6 @@ $$
298
298
 
299
299
  这些检查使检索过程可以追踪和核验,但模型仍可能误判证据。没有找到足够信息时,应继续查找,或在回答中明确说明无法确认。
300
300
 
301
- 主动检索的循环和预算由接入方控制。图 1 中的“最多 4 次”表示示例评测配置,不是所有接入场景的固定限制。
302
-
303
301
  <a id="use-only-reinforcement"></a>
304
302
 
305
303
  ### 4. 只强化实际使用的记忆:采用越多,之后衰减越慢
@@ -312,19 +310,15 @@ $$
312
310
 
313
311
  长期 Event 的基础权重函数为:
314
312
 
315
- $$
316
- w(t,n)=\max\left(floor,e^{-\lambda(n)t}\right)
317
- $$
313
+ <p align="center"><strong>w(t,n) = max(floor, e<sup>−λ(n)t</sup>)</strong></p>
318
314
 
319
- $$
320
- \lambda(n)=\frac{0.15}{1+1.5\ln(n)}
321
- $$
315
+ <p align="center"><strong>λ(n) = 0.15 / (1 + 1.5 ln(n))</strong></p>
322
316
 
323
317
  其中:
324
318
 
325
- - $t$ 是当前轮次与上次采用轮次的差,新事件从创建时开始计算;
326
- - $n$ 是内部采用计数,初始化为 1,每次记录采用后增加 1;
327
- - $floor$ 是根据记忆重要程度设置的最低权重。
319
+ - `t` 是当前轮次与上次采用轮次的差,新事件从创建时开始计算;
320
+ - `n` 是内部采用计数,初始化为 1,每次记录采用后增加 1;
321
+ - `floor` 是根据记忆重要程度设置的最低权重。
328
322
 
329
323
  长期权重衰减同样按对话轮次计算,而不是按现实时间计算。较低的权重可能降低一条记忆在后续召回中的优先级,但不会因衰减而删除它的历史记录。
330
324
 
@@ -563,6 +557,12 @@ benchmarks/ 机器可读实验结果
563
557
 
564
558
  请先阅读 [`CONTRIBUTING.zh-CN.md`](CONTRIBUTING.zh-CN.md),其中包含 monorepo 开发环境、检查与测试命令、适合参与的方向,以及提交 Pull Request 的建议。如果还不确定一个想法是否适合项目,建议先[创建 Issue](https://github.com/diqierjia/StrataGate-AgentMemory/issues),再投入较大的改动。
565
559
 
560
+ ## 贡献者
561
+
562
+ <a href="https://github.com/diqierjia/StrataGate-AgentMemory/graphs/contributors">
563
+ <img src="https://contrib.rocks/image?repo=diqierjia/StrataGate-AgentMemory" alt="StrataGate 贡献者" />
564
+ </a>
565
+
566
566
  ## 许可证
567
567
 
568
568
  StrataGate 使用 [MIT License](LICENSE)。