dsh-web
zhu1090093659/dsh-webDeepSeek Harness(DSH)Web 插件聚合生态包 · 一切皆插件,创意工坊分发(dsh-market.com)
Adaptive memory for AI. A DeepSeek Harness plugin prototype for selective recall, configurable context budgets, and history compaction, designed to reduce token usage while preserving conversational continuity.
The unreleased framework adds explicit project scopes, cross-session Hebbian graphs, lifecycle deletion/scrubbing, a shared local manager and paired baseline/ablation validation. Hebbian and affect remain enabled in full mode; disabling them is an experimental control only. Offline tests do not establish live DSH compatibility or production cost savings. See the framework guide, evidence audit, and reference review.
Adaptive Memory for AI · DeepSeek Harness plugin · v0.3.0-alpha.1 development
REMI is a context and long-term memory plugin for DeepSeek Harness. It observes durable DSH session events, stores retrievable memories in SQLite, and assembles a bounded runtime-context window before each model request.
REMI is not a standalone web application, does not replace the Harness Agent Loop, and does not train or fine-tune a model.
Status: Experimental. Do not use REMI in production environments yet.
See CHANGELOG.md for release changes. v0.2.1 evidence remains in the validation note. The v0.3 current-truth path has completed one isolated live DSH run; protocol, evidence, and remaining caveats are recorded in the validation note.
user/message, assistant/message, and tool/result through session/event.node:sqlite module.agent/inbox/claimed and injects one bounded runtime-context snapshot through system-prompt/assemble.ctx.llm.stream(); no model training is involved, and failures fall back to a local heuristic.BasicCompactionEngine, preserving the Harness compaction transaction while replacing only the checkpoint summarizer.RetrievalTrace records in SQLite.contentAwareRetrievalEnabled defaults to true; set it to false for the original raw-v0.2 scoring ablation. windowHygieneEnabled also defaults to true; disable only this option for the content-aware-v1 ablation without the new window admission rules. minLexicalCoverage defaults to 0.15 and prevents recency, importance, affect or hash collisions alone from admitting unrelated candidates. Questions and acknowledgements remain in SQLite and traces for audit, but do not enter a window-hygiene-v2 model window or Hebbian reinforcement. Classification is a bilingual heuristic, not verification that a claim is true.
Traces include scoringVersion, contentKind, utilityFactor, queryCoverage, focusOverlap, and an explicit admission decision such as current-query, conditional, focus-mismatch, or redundant. They contain scores and hashes, not the extracted focus terms. Content-aware embeddings are recomputed from the scoring view, so existing raw embeddings and records require no destructive migration. The benchmark includes a no_window_hygiene ablation; do not compare reports from different scoring versions without labeling them.
^22.19.0 || >=24.0.011.x0.1.5-rc.2, or a DSH Desktop build verified for compatibilityThe compile-time baseline is DeepSeek Harness commit c291e7961a515f6d7af9304e7fd1d257929aef26. See API compatibility for the verified contracts and upgrade checklist.
git clone https://github.com/Hoshino910/REMI.git
cd REMI
pnpm install
pnpm build
pnpm typecheck
pnpm test
The built DSH plugin entry is:
packages/dsh-adapter/dist/index.js
Two configuration examples are included:
standard/ptc presets.id: compaction-basic at the root.Update the plugin and data paths before starting DSH:
- id: selective-memory
name: 'file:///C:/path/to/REMI/packages/dsh-adapter/dist/index.js'
config:
databasePath: 'C:/path/to/dsh-data/remi.sqlite'
telemetryPath: 'C:/path/to/dsh-data/remi-telemetry.jsonl'
telemetryEnabled: true
transparentWindowEnabled: true
currentTruthEnabled: false
retrievalTokenBudget: 1400
retrievalLimit: 8
minRetrievalScore: 0.12
similarityWeight: 0.55
recencyWeight: 0.15
importanceWeight: 0.10
associationWeight: 0.15
emotionWeight: 0.05
hebbianEnabled: true
affectEnabled: true
emotionAnalysisEnabled: false
compactionSummaryTokenBudget: 900
compactionThresholdRatio: 0.80
compactionRetainRatio: 0.16
autoCompaction: true
On Windows, the packaged DSH Desktop ESM loader requires a file:///C:/... URL for the plugin entry. A plain C:/.../index.js path is not accepted.
Start a profile with an additional patch:
dsh --profile web --patch C:/path/to/cordis.patch.yml
Only one ctx.compaction provider may exist in a Cordis realm. Disable the original compaction-basic provider or replace the complete isolated compaction group as shown in the examples.
| Option | Default | Description |
|---|---|---|
databasePath | .dsh-memory/memory.sqlite | SQLite sidecar path; use an absolute path for deployments |
telemetryPath | .dsh-memory/telemetry.jsonl | JSONL telemetry path |
telemetryEnabled | true | Enable JSONL telemetry |
maxCandidates | 2000 | Maximum memories loaded for one retrieval |
maxMemoryChars | 8000 | Maximum characters stored from one observed event |
The SQLite database contains raw conversation text. Protect it at least as strictly as the Harness session store. Do not commit SQLite, WAL, SHM, or telemetry files to Git.
| Option | Default | Description |
|---|---|---|
transparentWindowEnabled | true | Add a REMI runtime-context snapshot during prompt assembly |
windowHygieneEnabled | true | Exclude current-turn echoes, low-utility/non-assertive records, explicit sibling entities, and duplicates |
retrievalTokenBudget | 1400 | Final rendered token budget for one memory window |
retrievalLimit | 8 | Maximum memories in one window |
minRetrievalScore | 0.12 | Minimum normalized candidate score |
recencyHalfLifeDays | 30 | Time scale for hyperbolic recency decay |
similarityWeight | 0.55 | Text similarity weight |
recencyWeight | 0.15 | Recency weight |
importanceWeight | 0.10 | Message importance weight |
associationWeight | 0.15 | Hebbian association weight |
emotionWeight | 0.05 | Affect similarity weight |
Weights are normalized at runtime. retrievalTokenBudget applies only to the rendered REMI <memory-context> block; it is not a hard limit for the complete model request.
| Option | Default | Description |
|---|---|---|
currentTruthEnabled | false | Enable deterministic correction detection and atomic fact supersession |
This alpha feature deliberately accepts only explicit forms such as Change the Cedar service port from 6389 to 8247 or 将 Cedar 服务端口从 6389 改为 8247. The subject and optional previous value must identify exactly one active memory. If no target is found, several records match, or the message is conditional (may, might, 可能, 考虑), REMI stores the event normally and does not mutate any existing record.
Superseded records remain in SQLite for audit. They are excluded from ordinary retrieval and Hebbian reinforcement, but may be returned when the query explicitly asks for history. This parser is a conservative lifecycle control, not a general fact extraction or truth-verification model.
| Option | Default | Description |
|---|---|---|
hebbianEnabled | true | Enable co-activation edges |
hebbianSeedLimit | 4 | High-scoring seed memories used for graph expansion |
hebbianEdgeLimit | 256 | Maximum association edges read per retrieval |
hebbianLearningRate | 0.08 | Reinforcement coefficient for one co-activation |
hebbianMaxWeight | 1 | Maximum stored edge weight |
hebbianHalfLifeDays | 45 | Exponential edge-weight half-life |
hebbianMaxEdgesPerSession | 2048 | Maximum stored edges per session; weaker and older edges are pruned first |
An edge means that two active statement memories were selected together. Graph expansion cannot bypass the lifecycle, statement-kind, lexical-coverage, or focus gates. It only reorders otherwise eligible candidates. An edge does not establish factual correctness, causality, or a user preference, and it does not train a neural network.
| Option | Default | Description |
|---|---|---|
emotionAnalysisEnabled | false | Request structured affect JSON from a DSH model |
emotionAnalysisProvider | empty | Optional fixed provider; otherwise use the session route |
emotionAnalysisModel | empty | Optional fixed model; set it together with the provider |
emotionAnalysisMaxTokens | 160 | Maximum output tokens for the classifier call |
Model analysis uses the provider already configured in DSH. It is an inference-only request with a strict JSON prompt. On failure, REMI records the error and continues with a local heuristic.
interface EmotionVector {
valence: number // -1..1
arousal: number // 0..1
dominance: number // 0..1
labels: string[] // up to three short labels
confidence: number // 0..1
source: 'model' | 'heuristic' | 'fallback'
}
Affect values are low-weight retrieval hints. They must not be treated as a psychological diagnosis or as a durable fact about the user.
| Option | Default | Description |
|---|---|---|
autoCompaction | true | Enable official token-pressure compaction |
compactionSummaryTokenBudget | 900 | Estimated budget for the extractive checkpoint |
compactionThresholdRatio | 0.80 | Trigger ratio relative to model context capacity |
compactionRetainRatio | 0.16 | Recent source-text ratio retained by the transaction |
REMI subclasses BasicCompactionEngine. Locks, token-pressure checks, surface replacement, manual flush, and the compaction/start → compaction/summary → compaction/end transaction remain owned by DeepSeek Harness.
flowchart TD
A["session/event"] --> B["SQLite memory store"]
B --> C["hashed cosine + lexical Jaccard"]
D["agent/inbox/claimed"] --> C
C --> E["recency + importance + association + affect"]
E --> F["token-budget packing"]
F --> G["system-prompt/assemble"]
G --> H["replaceable runtime-context snapshot"]
I["DSH token pressure"] --> J["official compaction transaction"]
J --> K["extractive continuity checkpoint"]
The observer converts text from user, assistant, and tool-result events into MemoryRecord values. When current-truth handling is enabled, explicit user corrections first pass through the deterministic resolver; a unique match is replaced in one SQLite transaction. Messages generated by REMI and compaction checkpoints are ignored to prevent feedback loops. (session_id, source_event_seq) provides idempotency when an event is replayed.
REMI observes live events after installation. It does not backfill older session history automatically.
The local deterministic similarity placeholder is:
Similarity = 0.65 × hashed bag-of-tokens cosine
+ 0.35 × lexical Jaccard
The default candidate score is:
Score = 0.55 × Similarity
+ 0.15 × Recency
+ 0.10 × Importance
+ 0.15 × Association
+ 0.05 × Affect
Recency uses 1 / (1 + ageDays / halfLifeDays). After packing candidates, REMI measures the complete rendered <memory-context> and removes the lowest-priority selected items until the configured budget is satisfied.
REMI captures the current direct user query at agent/inbox/claimed, then performs asynchronous retrieval in the cooperative system-prompt/assemble waterfall. Its context has the stable name dsh-selective-memory:transparent-window.
“Transparent” means that users do not have to copy summaries or manage context blocks manually. It does not mean hidden or unlogged injection.
Schema v4 contains:
memories: text, hashed embedding, importance, affect, access counters, source metadata, lifecycle status, validity interval, and supersession links;retrieval_traces: complete scoring and selection traces;memory_associations: canonical session-local co-activation edges;session_scopes: immutable host owner/project bindings;content_tombstones: exact-content replay suppression;schema_meta: schema version and graph namespace migration flag.Opening an older database performs additive migrations; v4 adds scopes and tombstones and namespaces legacy session graph keys transactionally. Back up an inactive database before upgrading. See the framework guide for rollback limits.
JSONL event types:
plugin/startedmemory/ingestedmemory/correctionmemory/retrievalmemory/windowmemory/emotion-analysismemory/compactionplugin/errorJSONL telemetry contains a stable query fingerprint, not the raw query or memory text. SQLite retrieval traces include component scores, selection decisions, token counts, query affect metadata, timing, and privacy-preserving graph counters: seeds, edges read/applied/pruned/stored, boosted candidates, reinforcement-eligible memories, and proposed/reinforced pairs.
Run the included dataset:
pnpm benchmark
Run a custom JSONL dataset:
node packages/benchmark/dist/cli.js C:/path/to/dataset.jsonl
Exercise graph priming and the no_hebbian control:
pnpm benchmark:graph
See examples/benchmark/sample.jsonl for the basic input shape and examples/benchmark/graph-ablation.jsonl for a primed graph case. Cases may include primingQueries to build graph state before the measured query. The runner exposes full, no_window_hygiene, no_hebbian, no_affect, similarity_only, no_recency, and no_importance, and reports graph activity separately. Its hitRateAtK is a string-evidence pipeline check, not a complete quality evaluation.
packages/
core/ # DSH-independent types, scoring, budgeting, compaction, traces
store-sqlite/ # SQLite MemoryStore and schema migration
dsh-adapter/ # DSH events, context window, affect calls, compaction, telemetry
benchmark/ # Replay, paired validation and independent DSH meter
manager/ # Explicit-ID local management service and CLI
examples/
deepseek-harness/ # Cordis group and root-overlay examples
benchmark/ # Minimal benchmark dataset
docs/
API_COMPATIBILITY.md
packages/core imports no DeepSeek Harness modules and makes no model calls. DSH lifecycle integration and model routing are isolated in packages/dsh-adapter.
pnpm build
pnpm typecheck
pnpm test
pnpm benchmark
Current verification results:
REMI_LIVE_OK;no_window_hygiene. This fixture verifies mechanics, not model-answer quality or production cost savings.low-utility, sibling entities as focus-mismatch, explicit future recall with utilityFactor = 1, and instruction-wrapped duplicate facts as one selected plus one redundant candidate.The headless smoke test used a deterministic local provider to verify lifecycle integration and ctx.llm.stream(). The isolated current-truth, transparent-window, and long-context runs used the configured live DSH model path. Provider retries were counted as provider behavior; SQLite lifecycle state and REMI telemetry were checked independently. See the current-truth validation note, window-hygiene validation note, and long-context validation note for the exact evidence boundaries.
ctx.tokenMeter and model capacity.Early testing notice: Do not use this plugin in production environments.