@lmzhen/dsh-evolution-state-storage 0.1.0-rc.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/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @deepseek-ai/dsh-evolution-state-storage
2
+
3
+ Provider registry seam for durable evolution state
4
+
5
+
6
+ ## Model Experience
7
+
8
+ ### Indirect model surface
9
+
10
+ #### What the model sees
11
+
12
+ `@deepseek-ai/dsh-evolution-state-storage` registers no direct prompt or tool schema itself. Model-visible effects are owned by the packages that consume this service.
13
+
14
+ #### Token effect
15
+
16
+ Zero direct token effect from this package; consumers add any model-visible tokens.
17
+
18
+ #### KV Cache effect
19
+
20
+ Independent of request-prefix construction. This package does not alter the assembled prompt or tool list.
21
+
22
+ ## Known Limitations and Deferred Work
23
+
24
+
25
+ - - Provider registry has no default medium. Mount `evolution-state-domain` or `evolution-state-json` before state reads.
26
+
package/lib/index.js ADDED
@@ -0,0 +1,35 @@
1
+ import { Service } from "@deepseek-ai/cordis";
2
+ //#region lib/types/index.js
3
+ /**
4
+ * Provider seam for durable evolution state.
5
+ *
6
+ * The state CONSUMER (`@lmzhen/dsh-evolution-state`) never touches a
7
+ * medium. Providers register here: `domain` (storage-domain KV) and `json`
8
+ * (IO-seam files) are the two shipped providers.
9
+ * @module @lmzhen/dsh-evolution-state-storage
10
+ */
11
+ var EvolutionStateStorageRegistry = class extends Service {
12
+ providers = /* @__PURE__ */ new Map();
13
+ constructor(ctx) {
14
+ super(ctx, "evolutionStateStorage");
15
+ }
16
+ registerProvider(provider) {
17
+ if (this.providers.has(provider.name)) throw new Error(`evolution state storage provider "${provider.name}" already registered`);
18
+ this.providers.set(provider.name, provider);
19
+ return () => {
20
+ if (this.providers.get(provider.name) === provider) this.providers.delete(provider.name);
21
+ };
22
+ }
23
+ provider(name) {
24
+ if (name) {
25
+ const provider = this.providers.get(name);
26
+ if (provider) return provider;
27
+ throw new Error(`evolution state storage provider "${name}" is not registered`);
28
+ }
29
+ const first = this.providers.values().next().value;
30
+ if (!first) throw new Error("no evolution state storage provider registered; mount @lmzhen/dsh-evolution-state-json or @lmzhen/dsh-evolution-state-domain");
31
+ return first;
32
+ }
33
+ };
34
+ //#endregion
35
+ export { EvolutionStateStorageRegistry, EvolutionStateStorageRegistry as default };
@@ -0,0 +1,8 @@
1
+ //#region lib/types/invariant.js
2
+ const PACKAGE_NAME = "@deepseek-ai/dsh-evolution-state-storage";
3
+ const name = "evolution-state-storage-invariant";
4
+ const inject = ["invariants"];
5
+ const install = () => {};
6
+ const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
7
+ //#endregion
8
+ export { apply, inject, name };
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Provider seam for durable evolution state.
3
+ *
4
+ * The state CONSUMER (`@deepseek-ai/dsh-evolution-state`) never touches a
5
+ * medium. Providers register here: `domain` (storage-domain KV) and `json`
6
+ * (IO-seam files) are the two shipped providers.
7
+ * @module @deepseek-ai/dsh-evolution-state-storage
8
+ */
9
+ import { Context, Service } from '@deepseek-ai/cordis';
10
+ export type PendingKind = 'memory' | 'skill' | 'skill_batch' | 'capability';
11
+ export type PendingStatus = 'pending' | 'approved' | 'rejected';
12
+ export interface ReviewStateRecord {
13
+ turnsSinceMemory: number;
14
+ turnsSinceSkill: number;
15
+ lastTurn: number;
16
+ }
17
+ export interface CuratorStateRecord {
18
+ lastRunAt: number;
19
+ runCount: number;
20
+ lastSummary: string;
21
+ paused: boolean;
22
+ }
23
+ export interface PendingRecord {
24
+ id: string;
25
+ kind: PendingKind;
26
+ summary: string;
27
+ args: unknown;
28
+ createdAt: string;
29
+ status: PendingStatus;
30
+ resolvedAt?: string | undefined;
31
+ claimedBy?: string | undefined;
32
+ claimedAt?: string | undefined;
33
+ }
34
+ export interface PendingResolution {
35
+ record: PendingRecord | null;
36
+ applied: boolean;
37
+ }
38
+ export interface EvolutionStateStorage {
39
+ readonly name: string;
40
+ loadReviewState(sessionId: string): Promise<ReviewStateRecord | null>;
41
+ saveReviewState(sessionId: string, record: ReviewStateRecord): Promise<void>;
42
+ loadCuratorState(): Promise<CuratorStateRecord | null>;
43
+ saveCuratorState(record: CuratorStateRecord): Promise<void>;
44
+ listPending(status?: PendingStatus): Promise<PendingRecord[]>;
45
+ savePending(record: PendingRecord): Promise<void>;
46
+ /** Atomically transition a pending record exactly once. */
47
+ tryResolvePending(id: string, status: Exclude<PendingStatus, 'pending'>): Promise<PendingResolution>;
48
+ /** Atomically mark a pending record as claimed by one approver, or return null. */
49
+ claimPending(id: string, claimId: string): Promise<PendingRecord | null>;
50
+ /** Release this claim when the replay runner cannot complete. */
51
+ releasePendingClaim(id: string, claimId: string): Promise<void>;
52
+ }
53
+ declare module '@deepseek-ai/cordis' {
54
+ interface Context {
55
+ evolutionStateStorage: EvolutionStateStorageRegistry;
56
+ }
57
+ }
58
+ export declare class EvolutionStateStorageRegistry extends Service {
59
+ private readonly providers;
60
+ constructor(ctx: Context);
61
+ registerProvider(provider: EvolutionStateStorage): () => void;
62
+ provider(name?: string): EvolutionStateStorage;
63
+ }
64
+ export default EvolutionStateStorageRegistry;
65
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ export declare const name = "evolution-state-storage-invariant";
3
+ export declare const inject: string[];
4
+ export declare const apply: (ctx: Context) => Promise<() => void>;
5
+ //# sourceMappingURL=invariant.d.ts.map
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@lmzhen/dsh-evolution-state-storage",
3
+ "description": "Provider registry seam for durable evolution state (community build)",
4
+ "version": "0.1.0-rc.1",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/lmzhen/dsh-evolution.git",
11
+ "directory": "packages/dsh-evolution-state-storage"
12
+ },
13
+ "type": "module",
14
+ "main": "lib/index.js",
15
+ "types": "lib/types/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./lib/types/index.d.ts",
19
+ "default": "./lib/index.js"
20
+ },
21
+ "./invariant": {
22
+ "types": "./lib/types/invariant.d.ts",
23
+ "default": "./lib/invariant.js"
24
+ },
25
+ "./package.json": "./package.json"
26
+ },
27
+ "files": [
28
+ "lib/index.js",
29
+ "lib/invariant.js",
30
+ "lib/types/**/*.d.ts",
31
+ "lib/types/invariant.d.ts"
32
+ ],
33
+ "license": "MIT",
34
+ "dependencies": {},
35
+ "peerDependencies": {
36
+ "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",
37
+ "@deepseek-ai/cordis": "^4.0.1"
38
+ },
39
+ "devDependencies": {
40
+ "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6"
41
+ }
42
+ }