@lmzhen/dsh-memory-files 0.21.0 → 0.22.0
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/lib/index.js +6 -18
- package/package.json +7 -7
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import z from "@deepseek-ai/schemastery";
|
|
4
|
-
import { DEFAULT_CONSOLIDATION_FAILURES, DEFAULT_MEMORY_CHAR_LIMIT, DEFAULT_USER_CHAR_LIMIT, MemoryStore,
|
|
4
|
+
import { DEFAULT_CONSOLIDATION_FAILURES, DEFAULT_MEMORY_CHAR_LIMIT, DEFAULT_USER_CHAR_LIMIT, MemoryStore, clampOnce, evolutionIoAdapter, liveBool, makeSerialQueue, paramRowId, payloadText, unwrapLive, userSetKeys } from "@lmzhen/dsh-evolution-core";
|
|
5
5
|
//#region lib/types/index.js
|
|
6
6
|
/**
|
|
7
7
|
* Local layered memory provider for `ctx.memory`.
|
|
@@ -29,27 +29,15 @@ function apply(ctx, rawConfig = {}) {
|
|
|
29
29
|
});
|
|
30
30
|
const clampedKeys = /* @__PURE__ */ new Set();
|
|
31
31
|
/**
|
|
32
|
-
* One live numeric row field as the platform resolved it.
|
|
33
|
-
* @param value - the field, or its volatile reference.
|
|
34
|
-
* @returns the current plain value, or undefined when nothing supplied one.
|
|
35
|
-
*/
|
|
36
|
-
const liveNumber = (value) => typeof value === "object" ? value.get() : value;
|
|
37
|
-
/**
|
|
38
32
|
* Clamp one supplied numeric value, warning once per key.
|
|
39
33
|
* @param name - the config key, for the warning.
|
|
40
34
|
* @param value - the value as supplied by the deployment or the user.
|
|
41
35
|
* @param fallback - the package default a corrected value falls back to.
|
|
42
36
|
* @returns the value the store may use.
|
|
43
37
|
*/
|
|
44
|
-
const field = (name, value, fallback) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (current !== void 0 && result !== current && !clampedKeys.has(name)) {
|
|
48
|
-
clampedKeys.add(name);
|
|
49
|
-
ctx.logger.warn(`memory-files: ${name} provided an invalid value; falling back to the default`);
|
|
50
|
-
}
|
|
51
|
-
return result;
|
|
52
|
-
};
|
|
38
|
+
const field = (name, value, fallback) => clampOnce(clampedKeys, (message) => {
|
|
39
|
+
ctx.logger.warn(message);
|
|
40
|
+
}, `memory-files: ${name}`, value, fallback, 1);
|
|
53
41
|
const floorLimit = (value) => Math.floor(value);
|
|
54
42
|
const policyBudget = () => {
|
|
55
43
|
const snapshot = ctx.get("evolutionPolicy")?.get?.();
|
|
@@ -72,7 +60,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
72
60
|
* @param id - the canonical registry id.
|
|
73
61
|
* @returns the value the platform resolved (user layer included), or undefined.
|
|
74
62
|
*/
|
|
75
|
-
const canonicalBudget = (id) =>
|
|
63
|
+
const canonicalBudget = (id) => unwrapLive(id === "memoryChars" ? rawConfig.memoryChars : rawConfig.userChars);
|
|
76
64
|
/**
|
|
77
65
|
* Whether the OPERATOR set this budget on THIS ROW (G0/S0.4 + G1).
|
|
78
66
|
*
|
|
@@ -103,7 +91,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
103
91
|
const memoryChars = () => floorLimit(field("memoryCharLimit", budget("memoryChars"), DEFAULT_MEMORY_CHAR_LIMIT));
|
|
104
92
|
const userChars = () => floorLimit(field("userCharLimit", budget("userChars"), DEFAULT_USER_CHAR_LIMIT));
|
|
105
93
|
const consolidationFailures = () => field("maxConsolidationFailures", rawConfig.maxConsolidationFailures, DEFAULT_CONSOLIDATION_FAILURES);
|
|
106
|
-
const addDatePrefix = () => rawConfig.addDatePrefix
|
|
94
|
+
const addDatePrefix = () => liveBool(rawConfig.addDatePrefix);
|
|
107
95
|
const policyAtMount = policyBudget();
|
|
108
96
|
if (explicitBudget("memoryChars") && policyAtMount.memory !== void 0 && memoryChars() !== policyAtMount.memory) ctx.logger.warn(`memory-files: the row's memoryChars=${memoryChars()} contradicts evolution-policy memoryChars=${policyAtMount.memory} — the store enforces the row value while the review plans against the policy value; align them or leave the row unset`);
|
|
109
97
|
if (explicitBudget("userChars") && policyAtMount.user !== void 0 && userChars() !== policyAtMount.user) ctx.logger.warn(`memory-files: the row's userChars=${userChars()} contradicts evolution-policy userChars=${policyAtMount.user} — same divergence as memoryChars`);
|
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.
|
|
4
|
+
"version": "0.22.0",
|
|
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.4",
|
|
30
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
30
|
+
"@lmzhen/dsh-evolution-core": "^0.22.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
34
|
-
"@lmzhen/dsh-evolution-io": "^0.
|
|
35
|
-
"@lmzhen/dsh-memory": "^0.
|
|
34
|
+
"@lmzhen/dsh-evolution-io": "^0.22.0",
|
|
35
|
+
"@lmzhen/dsh-memory": "^0.22.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
39
|
-
"@lmzhen/dsh-evolution-io": "^0.
|
|
40
|
-
"@lmzhen/dsh-memory": "^0.
|
|
38
|
+
"@lmzhen/dsh-evolution-core": "^0.22.0",
|
|
39
|
+
"@lmzhen/dsh-evolution-io": "^0.22.0",
|
|
40
|
+
"@lmzhen/dsh-memory": "^0.22.0"
|
|
41
41
|
}
|
|
42
42
|
}
|