@lmzhen/dsh-evolution-state-domain 0.1.0-rc.6 → 0.1.0-rc.60

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
@@ -18,6 +18,8 @@ const reviewStateSchema = z.object({
18
18
  lastTurn: z.number().int().nonnegative()
19
19
  });
20
20
  const curatorStateSchema = z.object({
21
+ /** Optional record-shape version; legacy records without it stay compatible. */
22
+ schemaVersion: z.number().int().nonnegative().optional(),
21
23
  lastRunAt: z.number().nonnegative(),
22
24
  runCount: z.number().int().nonnegative(),
23
25
  lastSummary: z.string(),
@@ -52,14 +54,38 @@ const EVOLUTION_DOMAIN = defineDomain({
52
54
  pending: domainTable(pendingSchema)
53
55
  }
54
56
  });
57
+ /**
58
+ * Bounded open() retry (rc.42 audit P1-4, package-private): a rejected open
59
+ * used to poison the shared `opening` promise forever, so one transient
60
+ * backend failure (lock, busy) took the provider down until process restart.
61
+ * Transient failures now recover within the budget; deterministic failures
62
+ * (corrupt domain version) surface after it, and the cleared promise lets a
63
+ * later call start a fresh budget.
64
+ */
65
+ const OPEN_MAX_ATTEMPTS = 3;
66
+ const OPEN_RETRY_BASE_MS = 100;
55
67
  function apply(ctx) {
56
68
  let domain = null;
57
69
  let opening = null;
58
70
  async function ensure() {
59
71
  if (domain) return domain;
60
- const facility = ctx.get("storageDomain");
61
- if (!facility) throw new Error("evolution-state-domain requires @deepseek-ai/dsh-storage-domain");
62
- opening ??= facility.open(EVOLUTION_DOMAIN);
72
+ if (!opening) {
73
+ opening = (async () => {
74
+ const facility = ctx.get("storageDomain");
75
+ if (!facility) throw new Error("evolution-state-domain requires @deepseek-ai/dsh-storage-domain");
76
+ let lastError;
77
+ for (let attempt = 1; attempt <= OPEN_MAX_ATTEMPTS; attempt += 1) try {
78
+ return await facility.open(EVOLUTION_DOMAIN);
79
+ } catch (error) {
80
+ lastError = error;
81
+ if (attempt < OPEN_MAX_ATTEMPTS) await new Promise((resolve) => setTimeout(resolve, OPEN_RETRY_BASE_MS * 2 ** (attempt - 1)));
82
+ }
83
+ throw lastError;
84
+ })();
85
+ opening.catch(() => {
86
+ opening = null;
87
+ });
88
+ }
63
89
  domain = await opening;
64
90
  return domain;
65
91
  }
@@ -18,6 +18,7 @@ export declare const reviewStateSchema: z.ZodObject<{
18
18
  lastTurn: z.ZodNumber;
19
19
  }, z.core.$strip>;
20
20
  export declare const curatorStateSchema: z.ZodObject<{
21
+ schemaVersion: z.ZodOptional<z.ZodNumber>;
21
22
  lastRunAt: z.ZodNumber;
22
23
  runCount: z.ZodNumber;
23
24
  lastSummary: z.ZodString;
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.1.0-rc.6",
4
+ "version": "0.1.0-rc.60",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -35,14 +35,14 @@
35
35
  "zod": "^3.0.0"
36
36
  },
37
37
  "peerDependencies": {
38
- "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",
38
+ "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
39
39
  "@deepseek-ai/cordis": "^4.0.1",
40
- "@deepseek-ai/dsh-storage-domain": "^0.1.0-rc.6",
41
- "@lmzhen/dsh-evolution-state-storage": "^0.1.0-rc.6"
40
+ "@deepseek-ai/dsh-storage-domain": "^0.1.1-rc.2",
41
+ "@lmzhen/dsh-evolution-state-storage": "^0.1.0-rc.60"
42
42
  },
43
43
  "devDependencies": {
44
- "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",
45
- "@deepseek-ai/dsh-storage-domain": "^0.1.0-rc.6",
46
- "@lmzhen/dsh-evolution-state-storage": "^0.1.0-rc.6"
44
+ "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
45
+ "@deepseek-ai/dsh-storage-domain": "^0.1.1-rc.2",
46
+ "@lmzhen/dsh-evolution-state-storage": "^0.1.0-rc.60"
47
47
  }
48
48
  }