@lmzhen/dsh-evolution-feedback 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.
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import z from "@deepseek-ai/schemastery";
2
- import { EVENT_LOG_VERSION, appendEvolutionEvent, eventsFile, evolutionIoAdapter, evolutionRoot, listEventArchives, parseEvolutionEvents, readEvolutionTimeline, transactIo } from "@lmzhen/dsh-evolution-core";
2
+ import { EVENT_LOG_VERSION, appendEvolutionEvent, clampedNumber, eventsFile, evolutionIoAdapter, evolutionRoot, listEventArchives, parseEvolutionEvents, readEvolutionTimeline, transactIo } from "@lmzhen/dsh-evolution-core";
3
3
  import { join } from "node:path";
4
4
  //#region lib/types/index.js
5
5
  /**
@@ -362,10 +362,23 @@ function synthesizeFeedbackEvents(aggregate) {
362
362
  }
363
363
  const name = "evolution-feedback";
364
364
  const Config = z.object({
365
- qualityWarnThreshold: z.number().default(-.25),
365
+ qualityWarnThreshold: z.number().min(-1).max(1).default(-.25),
366
366
  path: z.string().default("")
367
367
  });
368
+ /** Resolve the effective quality warn threshold, clamped to its [-1, 1] domain
369
+ * (G3.1). 0 and negative values are legal (a lower threshold is stricter); NaN,
370
+ * ±Infinity and out-of-range values fall back to the default -0.25. Exported so
371
+ * the clamp is directly testable; `apply` warns when a value was corrected. */
372
+ function resolveQualityWarnThreshold(config) {
373
+ return clampedNumber(config.qualityWarnThreshold ?? -.25, -.25, {
374
+ min: -1,
375
+ max: 1
376
+ });
377
+ }
368
378
  function apply(ctx, rawConfig = {}) {
379
+ const configuredThreshold = rawConfig.qualityWarnThreshold ?? -.25;
380
+ const qualityWarnThreshold = resolveQualityWarnThreshold(rawConfig);
381
+ if (qualityWarnThreshold !== configuredThreshold) ctx.logger.warn(`evolution-feedback: qualityWarnThreshold=${String(configuredThreshold)} is invalid; falling back to the default -0.25`);
369
382
  const feedback = new EvolutionFeedback(void 0, evolutionRoot(), rawConfig.path || void 0, (message) => {
370
383
  ctx.logger.warn(message);
371
384
  });
@@ -388,7 +401,7 @@ function apply(ctx, rawConfig = {}) {
388
401
  baseRecord(target, rating, note, kind ?? "session");
389
402
  if (kind === "skill") {
390
403
  const score = feedback.score(target, "skill");
391
- const warn = score < (rawConfig.qualityWarnThreshold ?? -.25);
404
+ const warn = score < qualityWarnThreshold;
392
405
  skillUsage.setQuality(target, score, warn).catch((error) => {
393
406
  skillCtx.logger.warn(error);
394
407
  });
@@ -400,4 +413,4 @@ function apply(ctx, rawConfig = {}) {
400
413
  }, "evolution-feedback.records");
401
414
  }
402
415
  //#endregion
403
- export { Config, EvolutionFeedback, apply, migrateFeedbackEvents, name };
416
+ export { Config, EvolutionFeedback, apply, migrateFeedbackEvents, name, resolveQualityWarnThreshold };
@@ -73,6 +73,11 @@ export interface Config {
73
73
  path?: string;
74
74
  }
75
75
  export declare const Config: z<Config>;
76
+ /** Resolve the effective quality warn threshold, clamped to its [-1, 1] domain
77
+ * (G3.1). 0 and negative values are legal (a lower threshold is stricter); NaN,
78
+ * ±Infinity and out-of-range values fall back to the default -0.25. Exported so
79
+ * the clamp is directly testable; `apply` warns when a value was corrected. */
80
+ export declare function resolveQualityWarnThreshold(config: Config): number;
76
81
  export declare function apply(ctx: Context, rawConfig?: Config): void;
77
82
  export {};
78
83
  //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-feedback",
3
3
  "description": "Feedback-to-quality scoring for self-evolution (community build)",
4
- "version": "0.3.22",
4
+ "version": "0.3.23",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -31,18 +31,18 @@
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",
38
38
  "@deepseek-ai/cordis": "^4.0.1",
39
- "@lmzhen/dsh-evolution-io": "^0.3.22",
40
- "@lmzhen/dsh-skill-usage": "^0.3.22"
39
+ "@lmzhen/dsh-evolution-io": "^0.3.23",
40
+ "@lmzhen/dsh-skill-usage": "^0.3.23"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
44
- "@lmzhen/dsh-evolution-io": "^0.3.22",
45
- "@lmzhen/dsh-evolution-io-node": "^0.3.22",
46
- "@lmzhen/dsh-skill-usage": "^0.3.22"
44
+ "@lmzhen/dsh-evolution-io": "^0.3.23",
45
+ "@lmzhen/dsh-evolution-io-node": "^0.3.23",
46
+ "@lmzhen/dsh-skill-usage": "^0.3.23"
47
47
  }
48
48
  }