@lmzhen/dsh-evolution-curator 0.59.6 → 0.60.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.
package/lib/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { settingsPort } from "@lmzhen/dsh-evolution-adapter/ports";
1
+ import { settingsPort } from "@lmzhen/dsh-evolution-platform/ports";
2
2
  import { Service } from "@deepseek-ai/cordis";
3
3
  import { AUTHORING_SPLIT_LINE_CHARS, CURATOR_DRY_RUN_BANNER, CURATOR_PROMPT, DEFAULT_ARCHIVE_AFTER_DAYS, DEFAULT_CURATOR_BOOT_GRACE_SECONDS, DEFAULT_CURATOR_INTERVAL_HOURS, DEFAULT_CURATOR_MODEL, DEFAULT_CURATOR_REVIEW_MAX_TOKENS, DEFAULT_MIN_IDLE_HOURS, DEFAULT_REVIEW_TIMEOUT_MS, DEFAULT_SKILL_LIMITS, DEFAULT_SOFT_BODY_TOKENS, DEFAULT_STALE_AFTER_DAYS, EvolutionGateSet, HomeAuthority, INSTANCE_KEYS, MAX_TIMER_DELAY_MS, PROMPT_BUNDLE, SKILL_NAME_RE, UPSTREAM_LIMIT_CHARS_PER_TOKEN, authorityFrom, buildCuratorRunReport, claimInstance, clampOnce, clampedNumber, computeDedupGroups, computeLifecycleTransitions, computePrefixClusters, computeQualityScores, computeScopeView, contentHash, emptyRecord, eventsFile, evolutionHome, evolutionIoAdapter, foldCuratorFields, isPresent, isUnknown, liveBool, loadSuppressedNames, loadUsage, mutateUsage, paramRowId, parseCuratorNominations, pickWithPolicy, policyStageLimits, probeList, probeText, readEvolutionEvents, readNumberParam, releaseInstance, renderCuratorReportMarkdown, reportTime, reportsSweepLockTarget, sessionLastEventTime, sweepReports, transactIo, unwrapLive, updateSuppressedNames, usageObserved, userSetKeys, verifyPromptBundle, withTreeWrite, writeProposalReport } from "@lmzhen/dsh-evolution-core";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { dirname, join } from "node:path";
6
- import { createUserMessage } from "@lmzhen/dsh-evolution-adapter/values";
6
+ import { createUserMessage } from "@lmzhen/dsh-evolution-platform/values";
7
7
  import z from "@deepseek-ai/schemastery";
8
8
  import { DEFAULT_HEALTH_THRESHOLDS, SystemSkillWriter, blobPath, entryTarget, historyIndexFile, lintSkill, markerEntryName, newSkillLibrary, parseFrontmatter, parseHistoryIndex, relatedSkillNames, skillBodyTarget, skillSupportTarget, softBodyTokenBudget } from "@lmzhen/dsh-evolution-core/skills";
9
9
  import { EXTRACT_PROMPT_HASH } from "@lmzhen/dsh-evolution-core/extract";
@@ -220,9 +220,9 @@ var EvolutionCurator = class extends Service {
220
220
  const archiveAtBoot = this.rowNumber("archiveAfterDays", DEFAULT_ARCHIVE_AFTER_DAYS, 1);
221
221
  const staleAtBoot = this.rowNumber("staleAfterDays", DEFAULT_STALE_AFTER_DAYS, 1);
222
222
  if (archiveAtBoot < staleAtBoot) this.ctx.logger.warn(`evolution-curator: archiveAfterDays (${archiveAtBoot}) < staleAfterDays (${staleAtBoot}); using staleAfterDays as the archive threshold`);
223
- ctx.on("internal/config", function(_previous, next) {
223
+ ctx.on("internal/config", (fiber, next) => {
224
224
  const value = next();
225
- if (this !== ctx.fiber) return value;
225
+ if (fiber !== ctx.fiber) return value;
226
226
  const archive = readNumberParam(value, "archiveAfterDays");
227
227
  const stale = readNumberParam(value, "staleAfterDays");
228
228
  if (typeof archive === "number" && typeof stale === "number") validateCuratorSettings({
@@ -545,8 +545,36 @@ var EvolutionCurator = class extends Service {
545
545
  }
546
546
  }
547
547
  /** Optional curator-state service (evolution-state-json / storage-domain). */
548
+ /** A2: refresh the medium and hold the cross-process curator-state lease for one RMW. */
549
+ async withCuratorState(task) {
550
+ const authority = this.ctx.get("evolutionMutationAuthority");
551
+ let token;
552
+ if (authority !== void 0) {
553
+ for (let attempt = 0; attempt < 50; attempt += 1) {
554
+ const acquired = await authority.lease.acquire("foreground", "curator-state");
555
+ if (acquired.ok) {
556
+ token = acquired.token;
557
+ break;
558
+ }
559
+ await new Promise((resolve) => setTimeout(resolve, 10));
560
+ }
561
+ if (token === void 0) this.ctx.logger.warn("evolution-curator: curator-state lease busy; a concurrent process may still be writing the record");
562
+ }
563
+ try {
564
+ await this.ctx.get("evolutionState")?.reload?.();
565
+ return await task();
566
+ } finally {
567
+ if (token !== void 0 && authority !== void 0) await authority.lease.release(token);
568
+ }
569
+ }
548
570
  curatorStateService() {
549
- return this.ctx.get("evolutionState");
571
+ const service = this.ctx.get("evolutionState");
572
+ if (service === void 0) return void 0;
573
+ return {
574
+ loadCuratorState: () => this.withCuratorState(() => service.loadCuratorState()),
575
+ saveCuratorState: (record) => this.withCuratorState(() => service.saveCuratorState(record)),
576
+ transactCuratorState: (task) => this.withCuratorState(() => service.transactCuratorState(task))
577
+ };
550
578
  }
551
579
  /**
552
580
  * Full-state snapshot: the skills tree plus the current curator state as an
@@ -588,7 +616,14 @@ var EvolutionCurator = class extends Service {
588
616
  if (!result.ok) return result;
589
617
  const stateExtra = result.extras?.find((extra) => extra.name === "curator-state.json");
590
618
  if (stateExtra && stateService) try {
591
- await stateService.saveCuratorState(JSON.parse(stateExtra.content));
619
+ const snapshot = JSON.parse(stateExtra.content);
620
+ await stateService.transactCuratorState((current) => ({
621
+ ...snapshot.schemaVersion === void 0 ? {} : { schemaVersion: snapshot.schemaVersion },
622
+ lastRunAt: snapshot.lastRunAt,
623
+ runCount: snapshot.runCount,
624
+ lastSummary: snapshot.lastSummary,
625
+ paused: current?.paused ?? snapshot.paused
626
+ }));
592
627
  } catch (error) {
593
628
  this.ctx.logger.warn(`evolution-curator: failed to restore curator state: ${error instanceof Error ? error.message : String(error)}`);
594
629
  }
@@ -1,6 +1,6 @@
1
1
  import { Context, Service } from '@deepseek-ai/cordis';
2
2
  import type { Volatile } from '@deepseek-ai/cordis';
3
- import type { ContextFormed } from '@lmzhen/dsh-evolution-platform-contract';
3
+ import type { ContextFormed } from '@lmzhen/dsh-evolution-platform/contract';
4
4
  declare module '@deepseek-ai/dsh-llm' {
5
5
  interface MessageSourceMap {
6
6
  'evolution-curator': {
@@ -16,7 +16,7 @@ import { type SkillHealthVerdict } from '@lmzhen/dsh-evolution-core/skills';
16
16
  import { type SkillActionResult } from '@lmzhen/dsh-evolution-core/skills';
17
17
  import type { SkillVersion } from '@lmzhen/dsh-evolution-core/skills';
18
18
  import type { SkillHealthAssessment } from '@lmzhen/dsh-evolution-core/skills';
19
- import type { CuratorStateRecord } from '@lmzhen/dsh-evolution-state';
19
+ import type { CuratorStateRecord } from '@lmzhen/dsh-evolution-core/state';
20
20
  /** B-10 (v18): the optional LLM nomination pass gets its own timeout so a
21
21
  * hung/unresponsive provider cannot hold the control-plane mutex forever
22
22
  * (`run()` never returns; `restore()`/`consolidate()` queue behind it).
@@ -359,6 +359,8 @@ export declare class EvolutionCurator extends Service {
359
359
  dryRun?: boolean;
360
360
  }): Promise<CuratorNominations>;
361
361
  /** Optional curator-state service (evolution-state-json / storage-domain). */
362
+ /** A2: refresh the medium and hold the cross-process curator-state lease for one RMW. */
363
+ private withCuratorState;
362
364
  private curatorStateService;
363
365
  /**
364
366
  * Full-state snapshot: the skills tree plus the current curator state as an
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-curator",
3
3
  "description": "Deterministic skill lifecycle and recovery (community build)",
4
- "version": "0.59.6",
4
+ "version": "0.60.1",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -29,21 +29,18 @@
29
29
  "license": "MIT",
30
30
  "dependencies": {
31
31
  "@deepseek-ai/schemastery": "^3.18.5",
32
- "@lmzhen/dsh-evolution-core": "0.59.6",
33
- "@lmzhen/dsh-evolution-platform-contract": "0.59.6",
34
- "@lmzhen/dsh-evolution-adapter": "0.59.6"
32
+ "@lmzhen/dsh-evolution-core": "0.60.1",
33
+ "@lmzhen/dsh-evolution-platform": "0.60.1"
35
34
  },
36
35
  "peerDependencies": {
37
36
  "@deepseek-ai/cordis": "^4.0.5",
38
37
  "@deepseek-ai/dsh-llm": "0.2.2-rc.5",
39
- "@deepseek-ai/dsh-session": "0.2.2-rc.5",
40
- "@lmzhen/dsh-evolution-state": "^0.59.6"
38
+ "@deepseek-ai/dsh-session": "0.2.2-rc.5"
41
39
  },
42
40
  "devDependencies": {
43
41
  "@deepseek-ai/dsh-llm": "0.2.2-rc.5",
44
42
  "@deepseek-ai/dsh-session": "0.2.2-rc.5",
45
- "@lmzhen/dsh-evolution-core": "^0.59.6",
46
- "@lmzhen/dsh-evolution-state": "^0.59.6"
43
+ "@lmzhen/dsh-evolution-core": "^0.60.1"
47
44
  },
48
45
  "engines": {
49
46
  "dsh": "0.2.2-rc.5"