@lmzhen/dsh-evolution-state-storage 0.3.15 → 0.3.17
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 +31 -1
- package/lib/types/index.d.ts +34 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -8,6 +8,36 @@ import { Service } from "@deepseek-ai/cordis";
|
|
|
8
8
|
* (IO-seam files) are the two shipped providers.
|
|
9
9
|
* @module @lmzhen/dsh-evolution-state-storage
|
|
10
10
|
*/
|
|
11
|
+
/** 0.3.17 (S3.3, E-24): 'executing' = claimed, runner in flight — a fresh
|
|
12
|
+
* claim only takes 'pending', and resolve accepts 'pending'/'executing', so a
|
|
13
|
+
* crash mid-approve can never double-execute the runner. */
|
|
14
|
+
const PENDING_STATUSES = [
|
|
15
|
+
"pending",
|
|
16
|
+
"executing",
|
|
17
|
+
"approved",
|
|
18
|
+
"rejected"
|
|
19
|
+
];
|
|
20
|
+
/** 0.3.17 (S3.3): the claim lifecycle as ONE transition table — BOTH
|
|
21
|
+
* providers (json/domain) must use these, never a hand-written copy (a second
|
|
22
|
+
* copy is exactly the E-10 drift class). */
|
|
23
|
+
const canClaimPending = (status) => status === "pending";
|
|
24
|
+
const canResolvePending = (status) => status === "pending" || status === "executing";
|
|
25
|
+
/** Releasing a claim on an executing record rolls it back to pending (a
|
|
26
|
+
* runner FAILURE is retryable); other statuses pass through unchanged. */
|
|
27
|
+
const releasedStatus = (status) => status === "executing" ? "pending" : status;
|
|
28
|
+
/**
|
|
29
|
+
* Claim lifecycle (S3.3): pending →(claim)→ executing →(resolve)→ approved/rejected.
|
|
30
|
+
* release() rolls executing back to pending (failure path). A crash between
|
|
31
|
+
* the runner execution and the resolve leaves the record executing+claimed:
|
|
32
|
+
* until expiry another claim is refused (no double execution), and after
|
|
33
|
+
* expiry only the operator acts — approval NEVER auto-replays an executing
|
|
34
|
+
* record (the write may already have landed; a non-idempotent replay would
|
|
35
|
+
* duplicate it). Operator options: reject (cleanup, no runner) or release +
|
|
36
|
+
* re-stage after manual verification. Release command surface is deferred.
|
|
37
|
+
*/
|
|
38
|
+
/** 0.3.17 (E-75): claim expiry single source — both providers (json/domain)
|
|
39
|
+
* previously hardcoded `10 * 60_000` independently. */
|
|
40
|
+
const CLAIM_EXPIRY_MS = 10 * 6e4;
|
|
11
41
|
var EvolutionStateStorageRegistry = class extends Service {
|
|
12
42
|
providers = /* @__PURE__ */ new Map();
|
|
13
43
|
constructor(ctx) {
|
|
@@ -32,4 +62,4 @@ var EvolutionStateStorageRegistry = class extends Service {
|
|
|
32
62
|
}
|
|
33
63
|
};
|
|
34
64
|
//#endregion
|
|
35
|
-
export { EvolutionStateStorageRegistry, EvolutionStateStorageRegistry as default };
|
|
65
|
+
export { CLAIM_EXPIRY_MS, EvolutionStateStorageRegistry, EvolutionStateStorageRegistry as default, PENDING_STATUSES, canClaimPending, canResolvePending, releasedStatus };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -7,8 +7,36 @@
|
|
|
7
7
|
* @module @deepseek-ai/dsh-evolution-state-storage
|
|
8
8
|
*/
|
|
9
9
|
import { Context, Service } from '@deepseek-ai/cordis';
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/** 0.3.17 (S3.5, D-4): 'skill_batch' removed — nothing ever created one
|
|
11
|
+
* (dead enum member); the historic value, if it ever reached disk, is read as
|
|
12
|
+
* an unknown kind by consumers rather than minted here. */
|
|
13
|
+
export type PendingKind = 'memory' | 'skill' | 'capability';
|
|
14
|
+
/** 0.3.17 (S3.3, E-24): 'executing' = claimed, runner in flight — a fresh
|
|
15
|
+
* claim only takes 'pending', and resolve accepts 'pending'/'executing', so a
|
|
16
|
+
* crash mid-approve can never double-execute the runner. */
|
|
17
|
+
export declare const PENDING_STATUSES: readonly ["pending", "executing", "approved", "rejected"];
|
|
18
|
+
export type PendingStatus = (typeof PENDING_STATUSES)[number];
|
|
19
|
+
/** 0.3.17 (S3.3): the claim lifecycle as ONE transition table — BOTH
|
|
20
|
+
* providers (json/domain) must use these, never a hand-written copy (a second
|
|
21
|
+
* copy is exactly the E-10 drift class). */
|
|
22
|
+
export declare const canClaimPending: (status: PendingStatus) => boolean;
|
|
23
|
+
export declare const canResolvePending: (status: PendingStatus) => boolean;
|
|
24
|
+
/** Releasing a claim on an executing record rolls it back to pending (a
|
|
25
|
+
* runner FAILURE is retryable); other statuses pass through unchanged. */
|
|
26
|
+
export declare const releasedStatus: (status: PendingStatus) => PendingStatus;
|
|
27
|
+
/**
|
|
28
|
+
* Claim lifecycle (S3.3): pending →(claim)→ executing →(resolve)→ approved/rejected.
|
|
29
|
+
* release() rolls executing back to pending (failure path). A crash between
|
|
30
|
+
* the runner execution and the resolve leaves the record executing+claimed:
|
|
31
|
+
* until expiry another claim is refused (no double execution), and after
|
|
32
|
+
* expiry only the operator acts — approval NEVER auto-replays an executing
|
|
33
|
+
* record (the write may already have landed; a non-idempotent replay would
|
|
34
|
+
* duplicate it). Operator options: reject (cleanup, no runner) or release +
|
|
35
|
+
* re-stage after manual verification. Release command surface is deferred.
|
|
36
|
+
*/
|
|
37
|
+
/** 0.3.17 (E-75): claim expiry single source — both providers (json/domain)
|
|
38
|
+
* previously hardcoded `10 * 60_000` independently. */
|
|
39
|
+
export declare const CLAIM_EXPIRY_MS: number;
|
|
12
40
|
export interface ReviewStateRecord {
|
|
13
41
|
turnsSinceMemory: number;
|
|
14
42
|
turnsSinceSkill: number;
|
|
@@ -30,6 +58,10 @@ export interface PendingRecord {
|
|
|
30
58
|
resolvedAt?: string | undefined;
|
|
31
59
|
claimedBy?: string | undefined;
|
|
32
60
|
claimedAt?: string | undefined;
|
|
61
|
+
/** 0.3.17 (E-25): who staged this (foreground vs background review) and
|
|
62
|
+
* which session — kept so resolved audit history is attributable. */
|
|
63
|
+
origin?: string | undefined;
|
|
64
|
+
sessionId?: string | undefined;
|
|
33
65
|
}
|
|
34
66
|
export interface PendingResolution {
|
|
35
67
|
record: PendingRecord | null;
|