@lmzhen/dsh-evolution-policy 0.3.22 → 0.3.23

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.
Files changed (2) hide show
  1. package/lib/index.js +32 -25
  2. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Service } from "@deepseek-ai/cordis";
2
2
  import z from "@deepseek-ai/schemastery";
3
- import { DEFAULT_ARCHIVE_AFTER_DAYS, DEFAULT_CURATOR_INTERVAL_HOURS, DEFAULT_MAX_OPS_PER_PLAN, DEFAULT_MEMORY_CHAR_LIMIT, DEFAULT_REVIEW_MEMORY_INTERVAL, DEFAULT_REVIEW_SKILL_INTERVAL, DEFAULT_SKILL_CONTENT_CHARS, DEFAULT_STALE_AFTER_DAYS, DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, DEFAULT_USER_CHAR_LIMIT, EVOLUTION_WRITE_TOOLS, FORBIDDEN_CONTROL_KEYS } from "@lmzhen/dsh-evolution-core";
3
+ import { DEFAULT_ARCHIVE_AFTER_DAYS, DEFAULT_CURATOR_INTERVAL_HOURS, DEFAULT_MAX_OPS_PER_PLAN, DEFAULT_MEMORY_CHAR_LIMIT, DEFAULT_REVIEW_MEMORY_INTERVAL, DEFAULT_REVIEW_SKILL_INTERVAL, DEFAULT_SKILL_CONTENT_CHARS, DEFAULT_STALE_AFTER_DAYS, DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, DEFAULT_USER_CHAR_LIMIT, EVOLUTION_WRITE_TOOLS, FORBIDDEN_CONTROL_KEYS, clampedNumber } from "@lmzhen/dsh-evolution-core";
4
4
  //#region lib/types/index.js
5
5
  /**
6
6
  * Immutable evolution policy service.
@@ -8,22 +8,22 @@ import { DEFAULT_ARCHIVE_AFTER_DAYS, DEFAULT_CURATOR_INTERVAL_HOURS, DEFAULT_MAX
8
8
  * @module @lmzhen/dsh-evolution-policy
9
9
  */
10
10
  const Config = z.object({
11
- reviewMemoryInterval: z.number().default(DEFAULT_REVIEW_MEMORY_INTERVAL),
12
- reviewSkillInterval: z.number().default(DEFAULT_REVIEW_SKILL_INTERVAL),
13
- substantiveMinToolCalls: z.number().default(DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS),
14
- substantiveMinUserChars: z.number().default(DEFAULT_SUBSTANTIVE_MIN_USER_CHARS),
15
- substantiveMinAgentChars: z.number().default(DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS),
11
+ reviewMemoryInterval: z.number().min(1).default(DEFAULT_REVIEW_MEMORY_INTERVAL),
12
+ reviewSkillInterval: z.number().min(1).default(DEFAULT_REVIEW_SKILL_INTERVAL),
13
+ substantiveMinToolCalls: z.number().min(1).default(DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS),
14
+ substantiveMinUserChars: z.number().min(1).default(DEFAULT_SUBSTANTIVE_MIN_USER_CHARS),
15
+ substantiveMinAgentChars: z.number().min(1).default(DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS),
16
16
  reviewMode: z.string().default("subagent"),
17
17
  memoryReviewModel: z.string().default("deepseek-v4-flash"),
18
18
  skillReviewModel: z.string().default("deepseek-v4-pro"),
19
19
  curatorModel: z.string().default("deepseek-v4-pro"),
20
- memoryChars: z.number().default(DEFAULT_MEMORY_CHAR_LIMIT),
21
- userChars: z.number().default(DEFAULT_USER_CHAR_LIMIT),
22
- skillContentChars: z.number().default(DEFAULT_SKILL_CONTENT_CHARS),
23
- maxOpsPerPlan: z.number().default(DEFAULT_MAX_OPS_PER_PLAN),
24
- curatorIntervalHours: z.number().default(DEFAULT_CURATOR_INTERVAL_HOURS),
25
- staleAfterDays: z.number().default(DEFAULT_STALE_AFTER_DAYS),
26
- archiveAfterDays: z.number().default(DEFAULT_ARCHIVE_AFTER_DAYS),
20
+ memoryChars: z.number().min(1).default(DEFAULT_MEMORY_CHAR_LIMIT),
21
+ userChars: z.number().min(1).default(DEFAULT_USER_CHAR_LIMIT),
22
+ skillContentChars: z.number().min(1).default(DEFAULT_SKILL_CONTENT_CHARS),
23
+ maxOpsPerPlan: z.number().min(1).default(DEFAULT_MAX_OPS_PER_PLAN),
24
+ curatorIntervalHours: z.number().min(1).default(DEFAULT_CURATOR_INTERVAL_HOURS),
25
+ staleAfterDays: z.number().min(1).default(DEFAULT_STALE_AFTER_DAYS),
26
+ archiveAfterDays: z.number().min(1).default(DEFAULT_ARCHIVE_AFTER_DAYS),
27
27
  protectedSkillNames: z.array(z.string()).default([])
28
28
  });
29
29
  var EvolutionPolicy = class extends Service {
@@ -35,26 +35,33 @@ var EvolutionPolicy = class extends Service {
35
35
  const tools = toolCtx.get("tools");
36
36
  toolCtx.effect(() => tools.guard((exec) => this.guardReason(exec.name, exec.arguments)), "evolution-policy.tools-guard");
37
37
  });
38
+ const clamped = [];
39
+ const field = (name, value, fallback) => {
40
+ const result = clampedNumber(value, fallback, { min: 1 });
41
+ if (value !== void 0 && result !== value) clamped.push(name);
42
+ return result;
43
+ };
38
44
  this.snapshot = Object.freeze({
39
45
  version: 1,
40
- reviewMemoryInterval: config.reviewMemoryInterval ?? DEFAULT_REVIEW_MEMORY_INTERVAL,
41
- reviewSkillInterval: config.reviewSkillInterval ?? DEFAULT_REVIEW_SKILL_INTERVAL,
42
- substantiveMinToolCalls: config.substantiveMinToolCalls ?? DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS,
43
- substantiveMinUserChars: config.substantiveMinUserChars ?? DEFAULT_SUBSTANTIVE_MIN_USER_CHARS,
44
- substantiveMinAgentChars: config.substantiveMinAgentChars ?? DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS,
46
+ reviewMemoryInterval: field("reviewMemoryInterval", config.reviewMemoryInterval, DEFAULT_REVIEW_MEMORY_INTERVAL),
47
+ reviewSkillInterval: field("reviewSkillInterval", config.reviewSkillInterval, DEFAULT_REVIEW_SKILL_INTERVAL),
48
+ substantiveMinToolCalls: field("substantiveMinToolCalls", config.substantiveMinToolCalls, DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS),
49
+ substantiveMinUserChars: field("substantiveMinUserChars", config.substantiveMinUserChars, DEFAULT_SUBSTANTIVE_MIN_USER_CHARS),
50
+ substantiveMinAgentChars: field("substantiveMinAgentChars", config.substantiveMinAgentChars, DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS),
45
51
  reviewMode: config.reviewMode === "inject" ? "inject" : "subagent",
46
52
  memoryReviewModel: config.memoryReviewModel ?? "deepseek-v4-flash",
47
53
  skillReviewModel: config.skillReviewModel ?? "deepseek-v4-pro",
48
54
  curatorModel: config.curatorModel ?? "deepseek-v4-pro",
49
- memoryChars: config.memoryChars ?? DEFAULT_MEMORY_CHAR_LIMIT,
50
- userChars: config.userChars ?? DEFAULT_USER_CHAR_LIMIT,
51
- skillContentChars: config.skillContentChars ?? DEFAULT_SKILL_CONTENT_CHARS,
52
- maxOpsPerPlan: config.maxOpsPerPlan ?? DEFAULT_MAX_OPS_PER_PLAN,
53
- curatorIntervalHours: config.curatorIntervalHours ?? DEFAULT_CURATOR_INTERVAL_HOURS,
54
- staleAfterDays: config.staleAfterDays ?? DEFAULT_STALE_AFTER_DAYS,
55
- archiveAfterDays: config.archiveAfterDays ?? DEFAULT_ARCHIVE_AFTER_DAYS,
55
+ memoryChars: field("memoryChars", config.memoryChars, DEFAULT_MEMORY_CHAR_LIMIT),
56
+ userChars: field("userChars", config.userChars, DEFAULT_USER_CHAR_LIMIT),
57
+ skillContentChars: field("skillContentChars", config.skillContentChars, DEFAULT_SKILL_CONTENT_CHARS),
58
+ maxOpsPerPlan: field("maxOpsPerPlan", config.maxOpsPerPlan, DEFAULT_MAX_OPS_PER_PLAN),
59
+ curatorIntervalHours: field("curatorIntervalHours", config.curatorIntervalHours, DEFAULT_CURATOR_INTERVAL_HOURS),
60
+ staleAfterDays: field("staleAfterDays", config.staleAfterDays, DEFAULT_STALE_AFTER_DAYS),
61
+ archiveAfterDays: field("archiveAfterDays", config.archiveAfterDays, DEFAULT_ARCHIVE_AFTER_DAYS),
56
62
  protectedSkillNames: Object.freeze([...new Set(["plan", ...config.protectedSkillNames ?? []])])
57
63
  });
64
+ if (clamped.length > 0) ctx.logger.warn(`evolution-policy: ${clamped.join(", ")} provided an invalid value; falling back to the default`);
58
65
  }
59
66
  get() {
60
67
  return this.snapshot;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-policy",
3
3
  "description": "Immutable evolution policy service (community build)",
4
- "version": "0.3.22",
4
+ "version": "0.3.23",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -31,7 +31,7 @@
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
33
  "@deepseek-ai/schemastery": "^3.18.1",
34
- "@lmzhen/dsh-evolution-core": "^0.3.22"
34
+ "@lmzhen/dsh-evolution-core": "^0.3.23"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",