@lmzhen/dsh-evolution-state-storage 0.31.1 → 0.32.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/lib/index.js CHANGED
@@ -510,8 +510,8 @@ const MEDIUM_PROCESS_DECLARATION = [
510
510
  * @returns one message per claim the capability cannot back up; empty when every claim holds.
511
511
  */
512
512
  function processScopeViolations(io) {
513
- const backed = typeof io?.transact === "function";
514
- return MEDIUM_PROCESS_DECLARATION.filter((claim) => claim.scope === "cross-process" && !backed).map((claim) => claim.record + " claims cross-process (" + claim.because + ") but the mounted io exposes no transact lock");
513
+ const backed = io?.processScope === "cross-process";
514
+ return MEDIUM_PROCESS_DECLARATION.filter((claim) => claim.scope === "cross-process" && !backed).map((claim) => claim.record + " claims cross-process (" + claim.because + ") but the mounted io declares " + (io?.processScope ?? "no process scope"));
515
515
  }
516
516
  //#endregion
517
517
  //#region lib/types/index.js
@@ -7,7 +7,8 @@
7
7
  * @module @lmzhen/dsh-evolution-state-storage
8
8
  */
9
9
  import { Context, Service } from '@deepseek-ai/cordis';
10
- import type { PendingKind, PendingStatus } from './record-contract.ts';
10
+ import type { EvolutionStateStorage, PendingRecord, PendingStatus } from '@lmzhen/dsh-evolution-contract';
11
+ export type { CuratorStateRecord, EvolutionStateStorage, PendingKind, PendingRecord, PendingResolution, PendingStatus, ReviewStateRecord } from '@lmzhen/dsh-evolution-contract';
11
12
  export * from './constants.ts';
12
13
  export * from './record-contract.ts';
13
14
  export * from './conformance.ts';
@@ -74,83 +75,6 @@ export declare function selectSessionOverflow<T>(rows: readonly T[], options: {
74
75
  * the release credential; a record whose approve runs in this process is
75
76
  * refused) followed by a deliberate re-approve or reject.
76
77
  */
77
- export interface ReviewStateRecord {
78
- turnsSinceMemory: number;
79
- turnsSinceSkill: number;
80
- lastTurn: number;
81
- }
82
- export interface CuratorStateRecord {
83
- lastRunAt: number;
84
- runCount: number;
85
- lastSummary: string;
86
- paused: boolean;
87
- }
88
- export interface PendingRecord {
89
- id: string;
90
- kind: PendingKind;
91
- summary: string;
92
- args: unknown;
93
- createdAt: string;
94
- status: PendingStatus;
95
- resolvedAt?: string | undefined;
96
- claimedBy?: string | undefined;
97
- claimedAt?: string | undefined;
98
- /** 0.3.17 (E-25): who staged this (foreground vs background review) and
99
- * which session — kept so resolved audit history is attributable. */
100
- origin?: string | undefined;
101
- sessionId?: string | undefined;
102
- /** W6/G4: the platform's admission decision that resolved this record (channel/principal/
103
- * deploymentAllowsRemote). Optional and read-tolerant: records resolved before 0.2.1 (or by TTL
104
- * expiry, which has no request) carry none — readers must never backfill it. Structural shape
105
- * (not an import) keeps the storage domain independent of core's http-routes module. */
106
- decidedBy?: {
107
- readonly channel: 'connection.fetch' | 'command';
108
- readonly principal: 'owner';
109
- readonly deploymentAllowsRemote: boolean;
110
- } | undefined;
111
- }
112
- export interface PendingResolution {
113
- record: PendingRecord | null;
114
- applied: boolean;
115
- }
116
- export interface EvolutionStateStorage {
117
- readonly name: string;
118
- loadReviewState(sessionId: string): Promise<ReviewStateRecord | null>;
119
- saveReviewState(sessionId: string, record: ReviewStateRecord): Promise<void>;
120
- loadCuratorState(): Promise<CuratorStateRecord | null>;
121
- saveCuratorState(record: CuratorStateRecord): Promise<void>;
122
- /**
123
- * Atomically read-modify-write the curator-state record (S5.5): `task`
124
- * receives the current record (or null when none exists) and returns the
125
- * next record; returning null keeps the current record unchanged (the
126
- * domain update primitive cannot delete, and json aligns with it). The
127
- * whole read → transform → write runs inside one provider transact, so a
128
- * setPaused racing the run-core bookkeeping write can never interleave a
129
- * stale load with a newer save.
130
- *
131
- * V27 S4: the record handed to `task` belongs to the task — a provider must
132
- * NEVER pass the object it stores (both current providers hand out a copy:
133
- * json re-parses its medium, the domain clones its record). Mutating the
134
- * argument is not a supported way to write: a task that does so and then lets
135
- * validation refuse the result would otherwise leave a mutated object in the
136
- * provider's in-memory store.
137
- */
138
- transactCuratorState(task: (current: CuratorStateRecord | null) => CuratorStateRecord | null): Promise<void>;
139
- listPending(status?: PendingStatus): Promise<PendingRecord[]>;
140
- savePending(record: PendingRecord): Promise<void>;
141
- /**
142
- * Atomically transition a pending record exactly once.
143
- * @param expectedClaimId - when given, the transition applies only while the
144
- * record is STILL claimed by this approver (P2-2, v14). A record resolved or
145
- * re-claimed by another writer is left untouched and reported as
146
- * `applied: false`, so an approve can never overwrite a concurrent reject.
147
- */
148
- tryResolvePending(id: string, status: Exclude<PendingStatus, 'pending'>, expectedClaimId?: string): Promise<PendingResolution>;
149
- /** Atomically mark a pending record as claimed by one approver, or return null. */
150
- claimPending(id: string, claimId: string): Promise<PendingRecord | null>;
151
- /** Release this claim when the replay runner cannot complete. */
152
- releasePendingClaim(id: string, claimId: string): Promise<void>;
153
- }
154
78
  declare module '@deepseek-ai/cordis' {
155
79
  interface Context {
156
80
  evolutionStateStorage: EvolutionStateStorageRegistry;
@@ -28,8 +28,8 @@ export interface MediumProcessClaim {
28
28
  export declare const MEDIUM_PROCESS_DECLARATION: readonly MediumProcessClaim[];
29
29
  /** The capability the claims are checked against: the io the medium writes through. */
30
30
  export interface ProcessScopeProbe {
31
- /** The IO backend transact entry point, when it has one. */
32
- readonly transact?: unknown;
31
+ /** The scope the backend actually declares; `transact` alone is not proof. */
32
+ readonly processScope?: 'single-process' | 'cross-process' | undefined;
33
33
  }
34
34
  /**
35
35
  * Falsify the declaration against a capability reading.
@@ -16,6 +16,8 @@
16
16
  * @module @lmzhen/dsh-evolution-state-storage/src/record-contract
17
17
  */
18
18
  import { CURATOR_STATE_TABLE, PENDING_TABLE, REVIEW_STATE_TABLE } from './constants.ts';
19
+ import type { PendingKind, PendingStatus } from '@lmzhen/dsh-evolution-contract';
20
+ export type { PendingKind, PendingStatus } from '@lmzhen/dsh-evolution-contract';
19
21
  /** The three seam tables a record can belong to. */
20
22
  export type SeamRecordTable = typeof REVIEW_STATE_TABLE | typeof CURATOR_STATE_TABLE | typeof PENDING_TABLE;
21
23
  /** Unknown fields survive a provider round-trip (json preserves by
@@ -35,15 +37,11 @@ export declare const UNKNOWN_FIELD_POLICY: "preserve";
35
37
  * S2.9/1-10: this array is the ONE source of the vocabulary — the types, the write gate below and
36
38
  * the domain provider's schema all derive from it. A second literal copy is the E-10 drift class
37
39
  * this module exists to end. */
38
- export declare const PENDING_KINDS: readonly ["memory", "skill", "capability"];
40
+ export declare const PENDING_KINDS: readonly PendingKind[];
39
41
  /** 0.3.17 (S3.3, E-24): 'executing' = claimed, runner in flight — a fresh claim only takes
40
42
  * 'pending', and resolve accepts 'pending'/'executing', so a crash mid-approve can never
41
43
  * double-execute the runner. Same one-source rule as PENDING_KINDS. */
42
- export declare const PENDING_STATUSES: readonly ["pending", "executing", "approved", "rejected"];
43
- /** The legal kind of one pending record. */
44
- export type PendingKind = (typeof PENDING_KINDS)[number];
45
- /** The legal status of one pending record. */
46
- export type PendingStatus = (typeof PENDING_STATUSES)[number];
44
+ export declare const PENDING_STATUSES: readonly PendingStatus[];
47
45
  /**
48
46
  * The write gate for one record. Both providers call this before persisting,
49
47
  * so a record the other provider would refuse can never land.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-state-storage",
3
3
  "description": "Provider registry seam for durable evolution state (community build)",
4
- "version": "0.31.1",
4
+ "version": "0.32.1",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -25,7 +25,9 @@
25
25
  "lib/types/**/*.d.ts"
26
26
  ],
27
27
  "license": "MIT",
28
- "dependencies": {},
28
+ "dependencies": {
29
+ "@lmzhen/dsh-evolution-contract": "^0.32.1"
30
+ },
29
31
  "peerDependencies": {
30
32
  "@deepseek-ai/cordis": "^4.0.5"
31
33
  },