@lmzhen/dsh-memory-files 0.3.81 → 0.3.83

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @deepseek-ai/dsh-memory-files
1
+ # @lmzhen/dsh-memory-files
2
2
 
3
3
  Local layered memory provider
4
4
 
@@ -8,7 +8,7 @@ Local layered memory provider
8
8
 
9
9
  #### What the model sees
10
10
 
11
- `@deepseek-ai/dsh-memory-files` registers no direct prompt or tool schema itself. Model-visible effects are owned by the packages that consume this service.
11
+ `@lmzhen/dsh-memory-files` registers no direct prompt or tool schema itself. Model-visible effects are owned by the packages that consume this service.
12
12
 
13
13
  #### Token effect
14
14
 
@@ -20,6 +20,8 @@ Independent of request-prefix construction. This package does not alter the asse
20
20
 
21
21
  ## Known Limitations and Deferred Work
22
22
 
23
+ - **The memory budget is configured in two places.** `memoryCharLimit`/`userCharLimit` (this package) is what the STORE enforces; `evolution-policy`'s `memoryChars`/`userChars` is what the review pipeline PLANS against. An UNSET limit here follows the mounted policy (row order permitting — the policy must already be mounted when this row assembles), an explicit value wins, and an explicit value that contradicts the policy warns once at load. `/evolution doctor` re-checks the pair at run time and reports a `memory budget:` finding, which also catches the row-order case. "Unset" is read as "equal to the schema default": the loader fills defaults into the row config, so a row that pins the default value explicitly is indistinguishable from one that omits it.
24
+
23
25
 
24
26
  - `providerName` (default `files`) is the name this provider registers under. Nothing selects it implicitly: `memory.provider` pins the registry to one name (V27 G6.3), and with the pin empty the FIRST registered provider serves every read/write — so with two providers mounted, set the pin or the choice is row order.
25
27
 
package/lib/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
+ import { resolve } from "node:path";
2
3
  import z from "@deepseek-ai/schemastery";
3
4
  import { DEFAULT_CONSOLIDATION_FAILURES, DEFAULT_MEMORY_CHAR_LIMIT, DEFAULT_USER_CHAR_LIMIT, MemoryStore, clampedNumber, evolutionIoAdapter, makeSerialQueue } from "@lmzhen/dsh-evolution-core";
4
5
  //#region lib/types/index.js
@@ -25,15 +26,28 @@ function apply(ctx, rawConfig = {}) {
25
26
  return result;
26
27
  };
27
28
  const floorLimit = (value) => Math.floor(value);
29
+ const policyBudget = () => {
30
+ const snapshot = ctx.get("evolutionPolicy")?.get?.();
31
+ return {
32
+ memory: snapshot?.memoryChars,
33
+ user: snapshot?.userChars
34
+ };
35
+ };
36
+ const budget = policyBudget();
37
+ const schemaDefaults = Config["~standard"].validate({}).value;
38
+ const explicitLimit = (name) => rawConfig[name] !== void 0 && rawConfig[name] !== schemaDefaults[name];
28
39
  const config = Object.assign({}, rawConfig, {
29
- memoryCharLimit: floorLimit(field("memoryCharLimit", rawConfig.memoryCharLimit, DEFAULT_MEMORY_CHAR_LIMIT)),
30
- userCharLimit: floorLimit(field("userCharLimit", rawConfig.userCharLimit, DEFAULT_USER_CHAR_LIMIT)),
40
+ memoryCharLimit: floorLimit(field("memoryCharLimit", explicitLimit("memoryCharLimit") ? rawConfig.memoryCharLimit : budget.memory, DEFAULT_MEMORY_CHAR_LIMIT)),
41
+ userCharLimit: floorLimit(field("userCharLimit", explicitLimit("userCharLimit") ? rawConfig.userCharLimit : budget.user, DEFAULT_USER_CHAR_LIMIT)),
31
42
  maxConsolidationFailures: field("maxConsolidationFailures", rawConfig.maxConsolidationFailures, DEFAULT_CONSOLIDATION_FAILURES)
32
43
  });
33
44
  if (clamped.length > 0) ctx.logger.warn(`memory-files: ${clamped.join(", ")} provided an invalid value; falling back to the default`);
45
+ if (explicitLimit("memoryCharLimit") && budget.memory !== void 0 && config.memoryCharLimit !== budget.memory) ctx.logger.warn(`memory-files: memoryCharLimit=${config.memoryCharLimit} contradicts evolution-policy memoryChars=${budget.memory} — the store enforces the row value while the review plans against the policy value; align them or leave the row unset`);
46
+ if (explicitLimit("userCharLimit") && budget.user !== void 0 && config.userCharLimit !== budget.user) ctx.logger.warn(`memory-files: userCharLimit=${config.userCharLimit} contradicts evolution-policy userChars=${budget.user} — same divergence as memoryCharLimit`);
34
47
  const io = evolutionIoAdapter(() => ctx.evolutionIo.provider());
35
48
  const serializedWrite = makeSerialQueue();
36
- const resolvedRoot = (config.root || "").trim();
49
+ const trimmedRoot = (config.root || "").trim();
50
+ const resolvedRoot = trimmedRoot === "" ? "" : resolve(trimmedRoot);
37
51
  const store = new MemoryStore({
38
52
  memoryCharLimit: config.memoryCharLimit,
39
53
  userCharLimit: config.userCharLimit,
@@ -66,6 +80,14 @@ function apply(ctx, rawConfig = {}) {
66
80
  },
67
81
  renderContext: () => serializedWrite(() => store.renderContext())
68
82
  };
83
+ ctx.provide("evolutionMemoryBudget", {
84
+ memoryCharLimit: config.memoryCharLimit,
85
+ userCharLimit: config.userCharLimit,
86
+ memorySource: explicitLimit("memoryCharLimit") ? "config" : budget.memory === void 0 ? "default" : "policy",
87
+ userSource: explicitLimit("userCharLimit") ? "config" : budget.user === void 0 ? "default" : "policy",
88
+ policyMemoryChars: budget.memory,
89
+ policyUserChars: budget.user
90
+ });
69
91
  ctx.effect(() => ctx.memory.registerProvider(provider), "memory-files.provider");
70
92
  }
71
93
  //#endregion
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-memory-files",
3
3
  "description": "Local layered memory provider (community build)",
4
- "version": "0.3.81",
4
+ "version": "0.3.83",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -27,16 +27,16 @@
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
29
  "@deepseek-ai/schemastery": "^3.18.1",
30
- "@lmzhen/dsh-evolution-core": "^0.3.81"
30
+ "@lmzhen/dsh-evolution-core": "^0.3.83"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@deepseek-ai/cordis": "^4.0.1",
34
- "@lmzhen/dsh-evolution-io": "^0.3.81",
35
- "@lmzhen/dsh-memory": "^0.3.81"
34
+ "@lmzhen/dsh-evolution-io": "^0.3.83",
35
+ "@lmzhen/dsh-memory": "^0.3.83"
36
36
  },
37
37
  "devDependencies": {
38
- "@lmzhen/dsh-evolution-core": "^0.3.81",
39
- "@lmzhen/dsh-evolution-io": "^0.3.81",
40
- "@lmzhen/dsh-memory": "^0.3.81"
38
+ "@lmzhen/dsh-evolution-core": "^0.3.83",
39
+ "@lmzhen/dsh-evolution-io": "^0.3.83",
40
+ "@lmzhen/dsh-memory": "^0.3.83"
41
41
  }
42
42
  }