@lmzhen/dsh-evolution-state-json 0.3.67 → 0.3.68

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 +7 -13
  2. package/package.json +7 -7
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import z from "@deepseek-ai/schemastery";
2
2
  import { evolutionHome, makeSerialQueue, transactIo } from "@lmzhen/dsh-evolution-core";
3
- import { CURATOR_STATE_FILE, CURATOR_STATE_KEY, CURATOR_STATE_TABLE, PENDING_ARCHIVE_BAK_FILE, PENDING_ARCHIVE_FILE, PENDING_LEGACY_FILE, PENDING_RESOLVED_CAP, PENDING_STATE_FILE, PENDING_TABLE, PROVIDER_JSON, REVIEW_STATE_FILE, REVIEW_STATE_SESSION_CAP, REVIEW_STATE_TABLE, assertCloneable, canClaimPending, canResolvePending, recordIssue, releasedStatus } from "@lmzhen/dsh-evolution-state-storage";
3
+ import { CURATOR_STATE_FILE, CURATOR_STATE_KEY, CURATOR_STATE_TABLE, PENDING_ARCHIVE_BAK_FILE, PENDING_ARCHIVE_FILE, PENDING_LEGACY_FILE, PENDING_RESOLVED_CAP, PENDING_STATE_FILE, PENDING_TABLE, PROVIDER_JSON, REVIEW_STATE_FILE, REVIEW_STATE_SESSION_CAP, REVIEW_STATE_TABLE, assertCloneable, canClaimPending, canResolvePending, recordIssue, releasedStatus, selectPendingOverflow, selectSessionOverflow } from "@lmzhen/dsh-evolution-state-storage";
4
4
  import { isAbsolute, join } from "node:path";
5
5
  //#region lib/types/index.js
6
6
  /**
@@ -296,18 +296,11 @@ function apply(ctx, rawConfig = {}) {
296
296
  * live work and are never trimmed. Returns the pruned map (rather than
297
297
  * mutating in place) plus the evicted records. */
298
298
  function enforceResolvedCap(map) {
299
- const resolved = Object.values(map).filter((record) => (record.status === "approved" || record.status === "rejected") && record.kind !== "capability");
300
- if (resolved.length <= PENDING_RESOLVED_CAP$1) return {
299
+ const oldest = selectPendingOverflow(Object.values(map), PENDING_RESOLVED_CAP$1);
300
+ if (oldest.length === 0) return {
301
301
  map,
302
302
  evicted: []
303
303
  };
304
- const overflow = resolved.length - PENDING_RESOLVED_CAP$1;
305
- const entryTime = (record) => {
306
- if (!record.resolvedAt) return Number.MAX_SAFE_INTEGER;
307
- const parsed = Date.parse(record.resolvedAt);
308
- return Number.isNaN(parsed) ? Number.MAX_SAFE_INTEGER : parsed;
309
- };
310
- const oldest = resolved.sort((a, b) => entryTime(a) - entryTime(b)).slice(0, overflow);
311
304
  const oldestKeys = /* @__PURE__ */ new Set();
312
305
  for (const [key, value] of Object.entries(map)) if (oldest.includes(value)) oldestKeys.add(key);
313
306
  const kept = {};
@@ -384,9 +377,10 @@ function apply(ctx, rawConfig = {}) {
384
377
  };
385
378
  const others = Object.keys(stamped).filter((id) => id !== sessionId);
386
379
  if (others.length < REVIEW_STATE_SESSION_CAP) return stamped;
387
- const stampOf = (id) => stamped[id]?.updatedAt ?? 0;
388
- others.sort((a, b) => stampOf(a) - stampOf(b));
389
- const evict = new Set(others.slice(0, others.length - REVIEW_STATE_SESSION_CAP + 1));
380
+ const evict = new Set(selectSessionOverflow(others, {
381
+ keyOf: (id) => id,
382
+ stampOf: (id) => stamped[id]?.updatedAt ?? 0
383
+ }));
390
384
  const pruned = {};
391
385
  for (const [id, row] of Object.entries(stamped)) if (!evict.has(id)) pruned[id] = row;
392
386
  return pruned;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-state-json",
3
3
  "description": "JSON-file evolution state provider over the IO seam (community build)",
4
- "version": "0.3.67",
4
+ "version": "0.3.68",
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.67"
34
+ "@lmzhen/dsh-evolution-core": "^0.3.68"
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.67",
40
- "@lmzhen/dsh-evolution-state-storage": "^0.3.67"
39
+ "@lmzhen/dsh-evolution-io": "^0.3.68",
40
+ "@lmzhen/dsh-evolution-state-storage": "^0.3.68"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
44
- "@lmzhen/dsh-evolution-io": "^0.3.67",
45
- "@lmzhen/dsh-evolution-state-storage": "^0.3.67",
46
- "@lmzhen/dsh-evolution-io-node": "^0.3.67"
44
+ "@lmzhen/dsh-evolution-io": "^0.3.68",
45
+ "@lmzhen/dsh-evolution-state-storage": "^0.3.68",
46
+ "@lmzhen/dsh-evolution-io-node": "^0.3.68"
47
47
  }
48
48
  }