@restregular/dsh-memory 0.3.0 → 0.3.1

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.
@@ -240,6 +240,12 @@ export class LocalMemoryService {
240
240
  this.cfg = resolveConfig(config)
241
241
  this.rerankBudget = new DailyBudget(this.cfg.llm.dailyBudgetTokens)
242
242
  this.store = new MemoryStore(this.cfg.storeDir, { onWarn: (m) => console.warn(`[dsh-memory-local] ${m}`) })
243
+ // Identity BEFORE the eager load (issue #1): ScopeStore skips its sidecar
244
+ // validation entirely while the identity is unset (`if (this.vecIdentity && …)`),
245
+ // so loading first would accept vectors from a previous embedding model
246
+ // whenever the dimensions matched — and the next flush would then rewrite the
247
+ // header as the new model, making the mismatch permanent.
248
+ this.store.setVecIdentity(this.cfg.vector.model, this.cfg.vector.dims)
243
249
  this.store.loadAll(this.cfg.projectEnabled && this.cfg.globalEnabled ? [this.defaultScope, 'global'] : [this.defaultScope])
244
250
  this.embed = new EmbedClient({
245
251
  endpoint: this.cfg.vector.endpoint,
@@ -247,8 +253,6 @@ export class LocalMemoryService {
247
253
  dims: this.cfg.vector.dims,
248
254
  timeoutMs: this.cfg.vector.timeoutMs,
249
255
  })
250
- // sidecar validation: model/dims change discards old vectors on load
251
- this.store.setVecIdentity(this.cfg.vector.model, this.cfg.vector.dims)
252
256
  this.startMaintenance()
253
257
  this.startEmbedServer()
254
258
  }
@@ -198,6 +198,12 @@ export class ScopeStore {
198
198
  discard(`identity mismatch (${trimmed.slice(1)} != ${this.vecIdentity})`)
199
199
  return
200
200
  }
201
+ // Loading before the identity is declared means NO validation happens
202
+ // (the guards below are all identity-gated). That ordering bug shipped
203
+ // once — see RestRegular/dsh-memory#1 — so make any recurrence visible.
204
+ if (!this.vecIdentity) {
205
+ this.events.onWarn?.(`${this.scope}: loading a vector sidecar before setVecIdentity(); its ${trimmed.slice(1)} vectors are accepted unvalidated`)
206
+ }
201
207
  sawHeader = true
202
208
  continue
203
209
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-memory",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "DeepSeek Harness 本地长期记忆:JSONL 存储 + 本地向量检索(BGE-M3)+ 四个模型工具 + 自动召回注入。",
5
5
  "type": "module",
6
6
  "exports": {