@lmzhen/dsh-evolution-state-domain 0.3.62 → 0.3.63

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/README.md CHANGED
@@ -23,4 +23,5 @@ Independent of request-prefix construction. This package does not alter the asse
23
23
 
24
24
 
25
25
  - Requires the host-plane `storage-domain` facility. The bundle row stays dormant when it is absent.
26
+ - P2-4 (v15): the live pending table is BOUNDED — resolved (approved/rejected) records are kept to the most recent `PENDING_RESOLVED_CAP` (200, seam constant in `evolution-state-storage`); the oldest by `resolvedAt` are deleted on resolve. The audit ARCHIVE sidecar that the json provider maintains beyond the cap is json-specific (the domain seam has no sidecar facility) — resolved records past the cap are gone, not archived.
26
27
 
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { DomainError, defineDomain, domainTable } from "@deepseek-ai/dsh-storage-domain";
3
- import { CURATOR_STATE_KEY, CURATOR_STATE_TABLE, PENDING_TABLE, PROVIDER_DOMAIN, REVIEW_STATE_TABLE, canClaimPending, canResolvePending, releasedStatus } from "@lmzhen/dsh-evolution-state-storage";
3
+ import { CURATOR_STATE_KEY, CURATOR_STATE_TABLE, PENDING_RESOLVED_CAP, PENDING_TABLE, PROVIDER_DOMAIN, REVIEW_STATE_TABLE, canClaimPending, canResolvePending, releasedStatus } from "@lmzhen/dsh-evolution-state-storage";
4
4
  //#region lib/types/index.js
5
5
  /**
6
6
  * storage-domain provider for evolution state.
@@ -195,7 +195,7 @@ function apply(ctx) {
195
195
  const table = (await ensure()).table(PENDING_TABLE);
196
196
  try {
197
197
  const resolved = { record: null };
198
- const rawRecord = await table.update(id, (current) => {
198
+ const record = await table.update(id, (current) => {
199
199
  if (!canResolvePending(current.status)) return current;
200
200
  if (expectedClaimId !== void 0 && current.claimedBy !== expectedClaimId) return current;
201
201
  resolved.record = {
@@ -205,6 +205,22 @@ function apply(ctx) {
205
205
  };
206
206
  return resolved.record;
207
207
  });
208
+ if (resolved.record !== null) {
209
+ const resolvedEntries = [...table.entries()].map(([key, record]) => ({
210
+ key,
211
+ record
212
+ })).filter((entry) => entry.record.status === "approved" || entry.record.status === "rejected");
213
+ const resolvedAtMs = (record) => {
214
+ const parsed = Date.parse(record.resolvedAt ?? "");
215
+ return Number.isNaN(parsed) ? Number.MAX_SAFE_INTEGER : parsed;
216
+ };
217
+ resolvedEntries.sort((a, b) => resolvedAtMs(a.record) - resolvedAtMs(b.record));
218
+ const evicted = resolvedEntries.slice(0, Math.max(0, resolvedEntries.length - PENDING_RESOLVED_CAP));
219
+ for (const entry of evicted) await table.delete(entry.key).catch((error) => {
220
+ ctx.logger.warn(`evolution-state-domain: pending-cap eviction for "${entry.key}" failed (will retry on the next resolve): ${error instanceof Error ? error.message : String(error)}`);
221
+ });
222
+ }
223
+ const rawRecord = record;
208
224
  if (resolved.record === null) return {
209
225
  record: rawRecord === null ? null : { ...rawRecord },
210
226
  applied: false
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-state-domain",
3
3
  "description": "storage-domain provider for evolution state (community build)",
4
- "version": "0.3.62",
4
+ "version": "0.3.63",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -36,13 +36,13 @@
36
36
  "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
37
37
  "@deepseek-ai/cordis": "^4.0.1",
38
38
  "@deepseek-ai/dsh-storage-domain": "^0.1.1-rc.2",
39
- "@lmzhen/dsh-evolution-state-storage": "^0.3.62"
39
+ "@lmzhen/dsh-evolution-state-storage": "^0.3.63"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
43
43
  "@deepseek-ai/dsh-storage-domain": "^0.1.1-rc.2",
44
44
  "@deepseek-ai/dsh-storage": "^0.1.1-rc.2",
45
45
  "@deepseek-ai/dsh-storage-json": "^0.1.1-rc.2",
46
- "@lmzhen/dsh-evolution-state-storage": "^0.3.62"
46
+ "@lmzhen/dsh-evolution-state-storage": "^0.3.63"
47
47
  }
48
48
  }