Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ coverage/
.env.*
!.env.example
*.log
*.tgz
.DS_Store
Thumbs.db
.idea/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Conversations are sealed into layered memories at different levels of detail, an

By default, every 12 complete conversation turns are sealed into one memory block. Messages that have not yet reached the boundary remain in the open tail and are not compressed or extracted early.

This is the core-library default. The DeepSeek Harness plugin defaults to 6 turns per Block so Event extraction becomes available sooner, and exposes `blockTurnSize` as a user setting.
This is the core-library default. The DeepSeek Harness plugin defaults to 6 turns per Block so Event extraction becomes available sooner, and exposes `blockTurnSize` as a user setting. Block age is the distance from the latest sealed Block in the same thread, so open-tail turns do not cause decay. The default Block-decay coefficient is `0.30`.

Each sealed block contains six levels of detail:

Expand Down
2 changes: 1 addition & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ StrataGate 的目标不是让 Agent 每次检索更多,而是让它知道:**

默认每 12 轮完整对话封存为一个记忆块。尚未达到边界的消息保留在 open tail 中,不会提前压缩或抽取。

这是核心库的默认值。DeepSeek Harness 插件为了更及时地产生 Event,默认每 6 轮封存一个 Block,并允许用户通过 `blockTurnSize` 自定义。
这是核心库的默认值。DeepSeek Harness 插件为了更及时地产生 Event,默认每 6 轮封存一个 Block,并允许用户通过 `blockTurnSize` 自定义。Block 的 age 是它与同一线程中最新已封存 Block 的距离,因此 open tail 中新增轮次不会触发衰减;默认 Block 衰减系数为 `0.30`。

每个已封存的块包含六种详细程度:

Expand Down
11 changes: 6 additions & 5 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,18 @@ When the boundary is reached:
2. L4 converts tool payloads into readable summaries while preserving natural-language turns.
3. L3 applies a deterministic, bounded condensation policy.
4. A caller-provided summarizer produces L0-L2 and a conservative `shouldExtract` decision.
5. The block pointer starts at L5 and decays toward L0 as later turns accumulate.
5. The block pointer starts at L5 and decays toward L0 as newer Blocks are sealed in the same thread.

The block weight is:

```text
w(t) = exp(-0.05 * t)
w(age) = exp(-lambda_block * age)

t = current turn - pointer anchor turn
age = latest sealed Block position - pointer anchor Block position
lambda_block = 0.30 by default
```

The weight selects how many levels to drop from the pointer anchor. Expanding a block to L3 anchors the pointer at L3; it does not silently jump to L5.
Open-tail turns do not change Block age. The weight selects how many levels to drop from the pointer anchor. Expanding a block to L3 anchors the pointer at L3 and at the latest sealed Block position; it does not silently jump to L5. Hosts may configure `lambda_block`; smaller values decay more slowly, and values above `0.4` are not recommended.

## Deterministic L3 policy

Expand Down Expand Up @@ -226,4 +227,4 @@ The adapter preserves these invariants:
- forget is reversible unless an application explicitly implements irreversible deletion;
- usage receipts are idempotent for one answer turn through a unique `receiptId`.

SQLite schema v5 includes normalized element, fact, provenance, projection-job, ingestion-receipt, usage-audit, and optional thread ownership for messages and Blocks. Usage receipts can carry the DSH session, turn, retrieval batch, assessment, and exact evidence references that led to an answer. Opening a schema-v1 through v4 database migrates it in one transaction and preserves existing namespaces, blocks, events, jobs, and receipts. Pre-v5 Blocks retain no inferred thread ownership, so they remain archival provenance without being attached to a new session. SQLite uses WAL, foreign keys, and per-namespace optimistic concurrency. It does not provide encryption at rest. Search still uses the reference in-memory ranking after hydration, so enabling persistence does not silently change retrieval semantics. Database-native lexical/vector indexes and a Postgres implementation remain separate future work.
SQLite schema v6 includes normalized element, fact, provenance, projection-job, ingestion-receipt, usage-audit, optional thread ownership for messages and Blocks, and persisted Block-decay settings and anchors. Usage receipts can carry the DSH session, turn, retrieval batch, assessment, and exact evidence references that led to an answer. Opening a schema-v1 through v5 database migrates it in one transaction and preserves existing namespaces, blocks, events, jobs, and receipts. Schema-v5 turn anchors are converted to per-thread Block positions. Pre-v5 Blocks retain no inferred thread ownership, so they remain archival provenance without being attached to a new session. SQLite uses WAL, foreign keys, and per-namespace optimistic concurrency. It does not provide encryption at rest. Search still uses the reference in-memory ranking after hydration, so enabling persistence does not silently change retrieval semantics. Database-native lexical/vector indexes and a Postgres implementation remain separate future work.
17 changes: 17 additions & 0 deletions integrations/deepseek-harness/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

## 0.2.19 - 2026-08-23

- Make the global Block decay coefficient λ editable in Advanced Settings with `0.05` steps, immediate application to existing workspaces, persistence across restarts, and inheritance by future workspaces.
- Show actual workspace names instead of internal namespace hashes and rename the current-project label to current workspace.
- Unify the settings page branding as `StrataGate-AgentMemory`, restore the mascot, and show a right-aligned genuine memory-use count with a GitHub Star link.

## 0.2.18 - 2026-08-23

- Match the Memory settings UI to DSH's resolved light, dark, or system appearance through the official semantic theme tokens.
- Remove the independent dark palette so the plugin background and controls no longer differ from the surrounding DSH settings panel.

## 0.2.17 - 2026-08-23

- Define Block age as the per-session distance from the latest sealed Block, so open-tail turns no longer decay Block detail.
- Add the configurable `blockDecayLambda` setting with a default of `0.3`; smaller values decay more slowly, and values above `0.4` are not recommended.
- Migrate SQLite storage to schema v6 and convert legacy turn anchors to per-thread Block positions without deleting existing memory.

## 0.2.16 - 2026-08-21

- Isolate open tails, Block sealing, decay, and automatic Block context by DSH session while keeping Events and Elements project-scoped for cross-session recall.
Expand Down
32 changes: 0 additions & 32 deletions integrations/deepseek-harness/MARKETPLACE.md

This file was deleted.

13 changes: 9 additions & 4 deletions integrations/deepseek-harness/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ flowchart LR
4. **Relevant does not mean sufficient.** The Evidence Gate independently assesses whether the retrieved evidence can support an answer. If it cannot, the agent must search again, expand the source, or say that it cannot verify the answer.
5. **Keep retrieval separate from reinforcement.** Finding a memory does not increase its weight. Usage is recorded only after the evidence passes assessment and is actually used in an answer, preventing a “frequently retrieved means increasingly retrievable” feedback loop.

The complete chain is persisted locally. Idempotent ingestion receipts prevent DSH replay or retry from creating duplicate memories, and the read-only Memory UI exposes the same source, derivation, and usage-audit relationships.
The complete chain is persisted locally. Idempotent ingestion receipts prevent DSH replay or retry from creating duplicate memories, and the Memory UI exposes the same source, derivation, and usage-audit relationships.

## Agent recommendation guide

Expand Down Expand Up @@ -90,16 +90,16 @@ memory_record_use

The prompt protocol requires assessment before relying on retrieved evidence. Search does not strengthen a memory. Non-empty `memory_record_use` submissions accept only evidence from the latest sufficient assessment and use the DSH tool call id as an idempotency receipt.

## Read-only Memory UI and usage audit
## Memory UI and usage audit

Open DSH Settings and select **StrataGate Memory**. The page provides:
Open DSH Settings and select **StrataGate-AgentMemory**. The page provides:

- namespace health and memory counts;
- searchable Events, Elements, and Blocks;
- source-message expansion from every derived memory;
- a Usage Audit chain from a recorded answer turn, through the Evidence Gate verdict and selected memories, back to source messages.

The browser surface is intentionally read-only: its API accepts only `GET`, and the UI exposes no edit, delete, approve, or import operation. Common token and credential patterns are redacted in both message content and structured tool traces before they leave the local server. The SQLite database remains the source of truth.
Memory records remain read-only: the UI exposes no edit, delete, approve, or import operation. Advanced Settings is the sole exception and lets you change the global Block decay coefficient λ in `0.05` steps. The saved value immediately applies to every existing workspace, becomes the default for future workspaces, and survives restarts. Common token and credential patterns are redacted in both message content and structured tool traces before they leave the local server. The SQLite database remains the source of truth.

## Configuration

Expand All @@ -110,17 +110,22 @@ config:
namespacePrefix: dsh
globalNamespace: global
blockTurnSize: 6
blockDecayLambda: 0.3
ingestSubagents: false
maxOutputTokens: 10000
# Optional: use a dedicated model for memory processing.
# provider: deepseek
# model: deepseek-chat
```

`blockDecayLambda` is the initial fallback. Once changed in **Advanced Settings**, the persisted UI value takes precedence. The default is `0.3`; smaller values forget more slowly and consume more tokens, and values above `0.4` are not recommended.

`project` derives a stable namespace from the normalized session working directory. `session` isolates every DSH session. `global` shares one namespace.

`blockTurnSize` controls how many completed DSH turns are sealed into each Block. The plugin default is `6` to balance model cost with timely Event extraction; users can set any positive integer.

`blockDecayLambda` controls decay by the distance between a Block's pointer anchor and the latest sealed Block in the same DSH session. It defaults to `0.3`. Smaller values decay more slowly; values above `0.4` are not recommended. Turns in the open tail do not increase Block age.

If `provider` and `model` are omitted, memory processing uses the session's latest request route, then the DSH default model as fallback. They must be configured as a pair.

## Privacy and failure behavior
Expand Down
1 change: 1 addition & 0 deletions integrations/deepseek-harness/cordis.patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
database: !!js dshHomePath('stratagate', 'memory.db')
namespaceMode: project
blockTurnSize: 6
blockDecayLambda: 0.3
ingestSubagents: false
maxOutputTokens: 10000
13 changes: 9 additions & 4 deletions integrations/deepseek-harness/docs/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ flowchart LR
4. **相关不代表足以回答。** Evidence Gate 会单独判断当前证据是否充分。证据不足时,Agent 必须继续搜索、展开来源或明确说明无法确认,而不能把相似结果直接当成答案。
5. **检索与强化彼此分离。** 搜到一条记忆不会自动提高它的权重;只有证据通过评估并真正用于回答后,才会记录使用情况。这样可以避免“越常被搜到,就越容易继续被搜到”的自我强化循环。

这条链路在本地完成持久化,并通过幂等写入回执防止 DSH 重放或重试造成重复记忆。只读 Memory UI 展示的也是同一套来源、派生和使用审计关系。
这条链路在本地完成持久化,并通过幂等写入回执防止 DSH 重放或重试造成重复记忆。Memory UI 展示的也是同一套来源、派生和使用审计关系。

## Agent 推荐指南

Expand Down Expand Up @@ -90,16 +90,16 @@ memory_record_use

提示词协议要求模型在依赖检索证据前完成评估。仅搜索不会强化记忆。非空的 `memory_record_use` 只接受最近一次“证据充分”评估中的证据,并使用 DSH 工具调用 ID 作为幂等回执。

## 只读记忆界面与使用审计
## 记忆界面与使用审计

打开 DSH 设置并选择 **StrataGate Memory**。该页面提供:
打开 DSH 设置并选择 **StrataGate-AgentMemory**。该页面提供:

- 命名空间健康状态和各类记忆数量;
- Events、Elements 和 Blocks 搜索;
- 从每条派生记忆展开查看来源消息;
- Usage Audit(使用审计)链路:从已记录的回答轮次出发,经由 Evidence Gate 的判断与选中的记忆,追溯到来源消息。

浏览器界面特意设计为只读:其 API 仅接受 `GET` 请求,界面也不提供编辑、删除、批准或导入操作。消息内容和结构化工具轨迹中的常见令牌及凭证格式,会在离开本地服务器前被脱敏。SQLite 数据库始终是唯一可信数据源。
记忆数据仍然只读,界面不提供编辑、删除、批准或导入操作。唯一例外是“高级设置”中的全局 Block 衰减系数 λ:可按 `0.05` 步长调节,保存后立即应用到所有已有工作区,同时成为新工作区默认值,并在重启后保持。消息内容和结构化工具轨迹中的常见令牌及凭证格式,会在离开本地服务器前被脱敏。SQLite 数据库始终是唯一可信数据源。

## 配置

Expand All @@ -110,17 +110,22 @@ config:
namespacePrefix: dsh
globalNamespace: global
blockTurnSize: 6
blockDecayLambda: 0.3
ingestSubagents: false
maxOutputTokens: 10000
# 可选:为记忆处理指定专用模型。
# provider: deepseek
# model: deepseek-chat
```

配置文件中的 `blockDecayLambda` 是初始后备值;一旦在“高级设置”中修改,持久化的界面值优先生效。默认值为 `0.3`;数字越小,记忆遗忘越慢、消耗 token 越多,不建议大于 `0.4`。

`project` 会根据规范化后的会话工作目录生成稳定的命名空间;`session` 会隔离每个 DSH 会话;`global` 则让所有会话共享同一个命名空间。

`blockTurnSize` 控制每个 Block 封存多少个已完成的 DSH 轮次。插件默认值为 `6`,用于平衡模型调用成本与 Event 提取及时性;用户可以配置任意正整数。

`blockDecayLambda` 按当前 Block 锚点与同一 DSH 会话中最新已封存 Block 的距离控制衰减。默认值为 `0.3`;数字越小衰减越慢,不建议大于 `0.4`。open tail 中尚未封存的轮次不会增加 Block age。

如果省略 `provider` 和 `model`,记忆处理会优先使用会话最近一次请求的路由,并以 DSH 默认模型作为后备。这两个配置项必须同时设置。

## 隐私与故障处理
Expand Down
2 changes: 1 addition & 1 deletion integrations/deepseek-harness/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stratagate-dsh",
"version": "0.2.16",
"version": "0.2.19",
"description": "Automatic local-first cross-session memory for DeepSeek Harness with source-traceable recall",
"type": "module",
"main": "./dist/index.js",
Expand Down
9 changes: 7 additions & 2 deletions integrations/deepseek-harness/scripts/build-client.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { copyFileSync, mkdirSync } from 'node:fs'
import { copyFileSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'

const root = new URL('../', import.meta.url)
mkdirSync(new URL('dist/', root), { recursive: true })
copyFileSync(new URL('src/client.js', root), new URL('dist/client.js', root))
const clientSource = readFileSync(new URL('src/client.js', root), 'utf8')
const mascot = readFileSync(new URL('../../docs/assets/stratagate-avatar.png', root)).toString('base64')
writeFileSync(
new URL('dist/client.js', root),
clientSource.replace('__STRATAGATE_MASCOT_DATA_URL__', `data:image/png;base64,${mascot}`),
)
copyFileSync(new URL('src/client.d.ts', root), new URL('dist/client.d.ts', root))
Loading
Loading