@lmzhen/dsh-evolution-state-storage 0.3.61 → 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/lib/index.js +8 -1
- package/lib/types/index.d.ts +15 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -50,6 +50,13 @@ const canResolvePending = (status) => status === "pending" || status === "execut
|
|
|
50
50
|
/** Releasing a claim on an executing record rolls it back to pending (a
|
|
51
51
|
* runner FAILURE is retryable); other statuses pass through unchanged. */
|
|
52
52
|
const releasedStatus = (status) => status === "executing" ? "pending" : status;
|
|
53
|
+
/** P2-4 (v15): the live pending map/table is BOUNDED — both providers keep at
|
|
54
|
+
* most this many resolved (approved/rejected) records, dropping the oldest by
|
|
55
|
+
* `resolvedAt`. Single source (the v15 audit found the bound was json-only,
|
|
56
|
+
* so domain deployments grew the table without bound). The audit ARCHIVE
|
|
57
|
+
* sidecar that json maintains beyond the cap stays json-specific (domain has
|
|
58
|
+
* no sidecar facility) — declared in both READMEs. */
|
|
59
|
+
const PENDING_RESOLVED_CAP = 200;
|
|
53
60
|
var EvolutionStateStorageRegistry = class extends Service {
|
|
54
61
|
providers = /* @__PURE__ */ new Map();
|
|
55
62
|
constructor(ctx) {
|
|
@@ -81,4 +88,4 @@ var EvolutionStateStorageRegistry = class extends Service {
|
|
|
81
88
|
}
|
|
82
89
|
};
|
|
83
90
|
//#endregion
|
|
84
|
-
export { CURATOR_STATE_FILE, CURATOR_STATE_KEY, CURATOR_STATE_TABLE, EvolutionStateStorageRegistry, EvolutionStateStorageRegistry as default, PENDING_ARCHIVE_BAK_FILE, PENDING_ARCHIVE_FILE, PENDING_LEGACY_FILE, PENDING_STATE_FILE, PENDING_TABLE, PROVIDER_DOMAIN, PROVIDER_JSON, REVIEW_STATE_FILE, REVIEW_STATE_TABLE, canClaimPending, canResolvePending, releasedStatus };
|
|
91
|
+
export { CURATOR_STATE_FILE, CURATOR_STATE_KEY, CURATOR_STATE_TABLE, EvolutionStateStorageRegistry, EvolutionStateStorageRegistry as default, PENDING_ARCHIVE_BAK_FILE, PENDING_ARCHIVE_FILE, PENDING_LEGACY_FILE, PENDING_RESOLVED_CAP, PENDING_STATE_FILE, PENDING_TABLE, PROVIDER_DOMAIN, PROVIDER_JSON, REVIEW_STATE_FILE, REVIEW_STATE_TABLE, canClaimPending, canResolvePending, releasedStatus };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -24,6 +24,13 @@ export declare const canResolvePending: (status: PendingStatus) => boolean;
|
|
|
24
24
|
/** Releasing a claim on an executing record rolls it back to pending (a
|
|
25
25
|
* runner FAILURE is retryable); other statuses pass through unchanged. */
|
|
26
26
|
export declare const releasedStatus: (status: PendingStatus) => PendingStatus;
|
|
27
|
+
/** P2-4 (v15): the live pending map/table is BOUNDED — both providers keep at
|
|
28
|
+
* most this many resolved (approved/rejected) records, dropping the oldest by
|
|
29
|
+
* `resolvedAt`. Single source (the v15 audit found the bound was json-only,
|
|
30
|
+
* so domain deployments grew the table without bound). The audit ARCHIVE
|
|
31
|
+
* sidecar that json maintains beyond the cap stays json-specific (domain has
|
|
32
|
+
* no sidecar facility) — declared in both READMEs. */
|
|
33
|
+
export declare const PENDING_RESOLVED_CAP = 200;
|
|
27
34
|
/**
|
|
28
35
|
* Claim lifecycle (S3.3): pending →(claim)→ executing →(resolve)→ approved/rejected.
|
|
29
36
|
* release() rolls executing back to pending (failure path). A crash between
|
|
@@ -81,8 +88,14 @@ export interface EvolutionStateStorage {
|
|
|
81
88
|
transactCuratorState(task: (current: CuratorStateRecord | null) => CuratorStateRecord | null): Promise<void>;
|
|
82
89
|
listPending(status?: PendingStatus): Promise<PendingRecord[]>;
|
|
83
90
|
savePending(record: PendingRecord): Promise<void>;
|
|
84
|
-
/**
|
|
85
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Atomically transition a pending record exactly once.
|
|
93
|
+
* @param expectedClaimId - when given, the transition applies only while the
|
|
94
|
+
* record is STILL claimed by this approver (P2-2, v14). A record resolved or
|
|
95
|
+
* re-claimed by another writer is left untouched and reported as
|
|
96
|
+
* `applied: false`, so an approve can never overwrite a concurrent reject.
|
|
97
|
+
*/
|
|
98
|
+
tryResolvePending(id: string, status: Exclude<PendingStatus, 'pending'>, expectedClaimId?: string): Promise<PendingResolution>;
|
|
86
99
|
/** Atomically mark a pending record as claimed by one approver, or return null. */
|
|
87
100
|
claimPending(id: string, claimId: string): Promise<PendingRecord | null>;
|
|
88
101
|
/** Release this claim when the replay runner cannot complete. */
|