@lmzhen/dsh-evolution-curator 0.39.2 → 0.40.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 CHANGED
@@ -124,6 +124,7 @@ var EvolutionCurator = class EvolutionCurator extends Service {
124
124
  }).isBlocked(name);
125
125
  }
126
126
  io;
127
+ homeFence;
127
128
  enabled;
128
129
  /** This row's live config (G1 §8.3): its volatile fields are resolved at USE time. */
129
130
  config;
@@ -181,6 +182,7 @@ var EvolutionCurator = class EvolutionCurator extends Service {
181
182
  });
182
183
  if (!verifyPromptBundle(PROMPT_BUNDLE)) throw new Error("dsh-evolution prompt bundle integrity check failed; refusing to run the curator");
183
184
  this.io = evolutionIoAdapter(() => ctx.evolutionIo.provider());
185
+ this.homeFence = ctx.get("evolutionMutationAuthority")?.homeFence;
184
186
  this.skills = newSkillLibrary({
185
187
  authority: authorityFrom({ origin: "background_review" }),
186
188
  config,
@@ -648,6 +650,7 @@ var EvolutionCurator = class EvolutionCurator extends Service {
648
650
  mutexTail = Promise.resolve();
649
651
  /** Cross-process tree lock shared with merge runs; curator mutations take it only around apply. */
650
652
  async withMergeTreeLock(body) {
653
+ if (this.homeFence !== void 0) return await this.homeFence.run(body);
651
654
  const acquired = await acquireTreeWriteLock({
652
655
  io: this.io,
653
656
  home: evolutionHome()
@@ -806,7 +809,7 @@ var EvolutionCurator = class EvolutionCurator extends Service {
806
809
  if (!dryRun) try {
807
810
  await mutateUsage(root, this.io, (map) => {
808
811
  for (const [name, record] of usage) if (!map.has(name)) map.set(name, { ...record });
809
- });
812
+ }, { ...this.homeFence === void 0 ? {} : { fence: this.homeFence } });
810
813
  } catch (error) {
811
814
  this.ctx.logger.warn(`evolution-curator: failed to persist the seeded usage baseline on a session-blocked run (${error instanceof Error ? error.message : String(error)})`);
812
815
  }
@@ -823,7 +826,7 @@ var EvolutionCurator = class EvolutionCurator extends Service {
823
826
  if (!dryRun) try {
824
827
  await mutateUsage(root, this.io, (map) => {
825
828
  for (const [name, record] of usage) if (!map.has(name)) map.set(name, { ...record });
826
- });
829
+ }, { ...this.homeFence === void 0 ? {} : { fence: this.homeFence } });
827
830
  } catch (error) {
828
831
  this.ctx.logger.warn(`evolution-curator: failed to persist the seeded usage baseline on a session-blocked run (${error instanceof Error ? error.message : String(error)})`);
829
832
  }
@@ -1181,9 +1184,12 @@ var EvolutionCurator = class EvolutionCurator extends Service {
1181
1184
  let skipped = [];
1182
1185
  await mutateUsage(root, this.io, (disk) => {
1183
1186
  skipped = foldCuratorFields(disk, usage, stateOwned, runStartStates);
1184
- }, { onQuarantine: (message) => {
1185
- this.ctx.logger.warn(`evolution-curator: ${message}`);
1186
- } });
1187
+ }, {
1188
+ onQuarantine: (message) => {
1189
+ this.ctx.logger.warn(`evolution-curator: ${message}`);
1190
+ },
1191
+ ...this.homeFence === void 0 ? {} : { fence: this.homeFence }
1192
+ });
1187
1193
  if (skipped.length > 0) this.ctx.logger.warn(`evolution-curator: lifecycle fold skipped ${skipped.length} name(s) whose on-disk state moved during the run (a concurrent curator/tool won): ${skipped.join(", ")}`);
1188
1194
  } catch {
1189
1195
  this.ctx.logger.warn("evolution-curator: failed to persist usage sidecar");
@@ -1233,10 +1239,14 @@ var EvolutionCurator = class EvolutionCurator extends Service {
1233
1239
  * each report name is unique per runId.
1234
1240
  */
1235
1241
  async retainReports(keep = 20, errorKeep = 10) {
1236
- await transactIo(this.io, reportsSweepLockTarget(), async () => {
1237
- await this.sweepReports(keep, errorKeep);
1238
- return null;
1239
- });
1242
+ const sweep = async () => {
1243
+ await transactIo(this.io, reportsSweepLockTarget(), async () => {
1244
+ await this.sweepReports(keep, errorKeep);
1245
+ return null;
1246
+ });
1247
+ };
1248
+ if (this.homeFence !== void 0) await this.homeFence.run(sweep);
1249
+ else await sweep();
1240
1250
  }
1241
1251
  /** The sweep `retainReports` holds the per-home lock for. A caller MUST hold
1242
1252
  * that lock: the listing and the deletions are not atomic on their own.
@@ -1467,9 +1477,12 @@ var EvolutionCurator = class EvolutionCurator extends Service {
1467
1477
  record.archived_at = (/* @__PURE__ */ new Date()).toISOString();
1468
1478
  }
1469
1479
  }
1470
- }, { onQuarantine: (message) => {
1471
- this.ctx.logger.warn(`evolution-curator: ${message}`);
1472
- } });
1480
+ }, {
1481
+ onQuarantine: (message) => {
1482
+ this.ctx.logger.warn(`evolution-curator: ${message}`);
1483
+ },
1484
+ ...this.homeFence === void 0 ? {} : { fence: this.homeFence }
1485
+ });
1473
1486
  } catch (error) {
1474
1487
  this.ctx.logger.warn(`evolution-curator: failed to persist consolidate usage state: ${error instanceof Error ? error.message : String(error)}`);
1475
1488
  }
@@ -211,6 +211,7 @@ export declare class EvolutionCurator extends Service {
211
211
  /** Read-only scope gate for sibling plugins (merge): name blocked by curator sets. */
212
212
  isBlocked(name: string): Promise<boolean>;
213
213
  private readonly io;
214
+ private readonly homeFence;
214
215
  private readonly enabled;
215
216
  /** This row's live config (G1 §8.3): its volatile fields are resolved at USE time. */
216
217
  private readonly config;
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.39.2",
4
+ "version": "0.40.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -27,21 +27,21 @@
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
29
  "@deepseek-ai/schemastery": "^3.18.5",
30
- "@lmzhen/dsh-evolution-core": "^0.39.2"
30
+ "@lmzhen/dsh-evolution-core": "^0.40.0"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@deepseek-ai/cordis": "^4.0.5",
34
34
  "@deepseek-ai/dsh-llm": "^0.2.2-rc.0",
35
35
  "@deepseek-ai/dsh-session": "^0.2.2-rc.0",
36
- "@lmzhen/dsh-evolution-io": "^0.39.2",
37
- "@lmzhen/dsh-evolution-state": "^0.39.2"
36
+ "@lmzhen/dsh-evolution-io": "^0.40.0",
37
+ "@lmzhen/dsh-evolution-state": "^0.40.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@deepseek-ai/dsh-llm": "^0.2.2-rc.0",
41
41
  "@deepseek-ai/dsh-session": "^0.2.2-rc.0",
42
- "@lmzhen/dsh-evolution-core": "^0.39.2",
43
- "@lmzhen/dsh-evolution-io": "^0.39.2",
44
- "@lmzhen/dsh-evolution-state": "^0.39.2"
42
+ "@lmzhen/dsh-evolution-core": "^0.40.0",
43
+ "@lmzhen/dsh-evolution-io": "^0.40.0",
44
+ "@lmzhen/dsh-evolution-state": "^0.40.0"
45
45
  },
46
46
  "engines": {
47
47
  "dsh": ">=0.2.2-rc.0 <0.2.3-0"