@actiondock/core 2.5.1 → 2.7.0
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/dist/app/app.d.ts +14 -1
- package/dist/app/app.js +88 -222
- package/dist/app/static-index.d.ts +39 -0
- package/dist/app/static-index.js +164 -0
- package/dist/app/types.d.ts +5 -0
- package/dist/catalog/action-index.js +6 -4
- package/dist/catalog/package-catalog.js +2 -1
- package/dist/doctor/checks/index.d.ts +5 -0
- package/dist/doctor/checks/index.js +5 -0
- package/dist/doctor/checks/project-locate.d.ts +6 -0
- package/dist/doctor/checks/project-locate.js +36 -0
- package/dist/doctor/checks/project.d.ts +6 -0
- package/dist/doctor/checks/project.js +383 -0
- package/dist/doctor/checks/registry.d.ts +13 -0
- package/dist/doctor/checks/registry.js +207 -0
- package/dist/doctor/checks/runtime.d.ts +13 -0
- package/dist/doctor/checks/runtime.js +90 -0
- package/dist/doctor/checks/storage.d.ts +5 -0
- package/dist/doctor/checks/storage.js +34 -0
- package/dist/doctor/context.d.ts +35 -0
- package/dist/doctor/context.js +11 -0
- package/dist/doctor/doctor.d.ts +5 -0
- package/dist/doctor/doctor.js +33 -602
- package/dist/errors.d.ts +22 -0
- package/dist/errors.js +22 -0
- package/dist/execution/service.js +14 -9
- package/dist/export/templates.js +42 -30
- package/dist/host/host.d.ts +33 -0
- package/dist/host/host.js +222 -362
- package/dist/host/routing.d.ts +92 -0
- package/dist/host/routing.js +238 -0
- package/dist/host/types.d.ts +8 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/input/advice.d.ts +100 -0
- package/dist/input/advice.js +767 -0
- package/dist/input/describe.d.ts +106 -0
- package/dist/input/describe.js +176 -0
- package/dist/input/file-input.d.ts +54 -0
- package/dist/input/file-input.js +124 -0
- package/dist/input/flat-decode.d.ts +11 -0
- package/dist/input/flat-decode.js +13 -0
- package/dist/input/flat-errors.d.ts +72 -0
- package/dist/input/flat-errors.js +87 -0
- package/dist/input/flat-materializer.d.ts +29 -0
- package/dist/input/flat-materializer.js +179 -0
- package/dist/input/flat-parser.d.ts +50 -0
- package/dist/input/flat-parser.js +169 -0
- package/dist/input/flat-predicates.d.ts +34 -0
- package/dist/input/flat-predicates.js +50 -0
- package/dist/input/index.d.ts +14 -0
- package/dist/input/index.js +14 -0
- package/dist/input/input-resolver.d.ts +63 -0
- package/dist/input/input-resolver.js +254 -0
- package/dist/input/json-depth-scanner.d.ts +17 -0
- package/dist/input/json-depth-scanner.js +49 -0
- package/dist/input/metadata.d.ts +99 -0
- package/dist/input/metadata.js +99 -0
- package/dist/input/stdin-input.d.ts +26 -0
- package/dist/input/stdin-input.js +125 -0
- package/dist/input/utf8.d.ts +19 -0
- package/dist/input/utf8.js +36 -0
- package/dist/input/validation-mapper.d.ts +27 -0
- package/dist/input/validation-mapper.js +144 -0
- package/dist/ipc/host.js +38 -0
- package/dist/json/index.d.ts +1 -0
- package/dist/json/index.js +1 -0
- package/dist/json/value-validator.d.ts +88 -0
- package/dist/json/value-validator.js +330 -0
- package/dist/platform/types.d.ts +7 -0
- package/dist/process/control-arbiter.d.ts +107 -0
- package/dist/process/control-arbiter.js +251 -0
- package/dist/process/diagnostics-sink.d.ts +26 -0
- package/dist/process/diagnostics-sink.js +35 -0
- package/dist/process/index.d.ts +7 -0
- package/dist/process/index.js +7 -0
- package/dist/process/input-dispatcher.d.ts +88 -0
- package/dist/process/input-dispatcher.js +240 -0
- package/dist/process/managed-record.d.ts +78 -0
- package/dist/process/managed-record.js +1 -0
- package/dist/process/process-manager.d.ts +15 -56
- package/dist/process/process-manager.js +119 -707
- package/dist/process/reservation-table.d.ts +39 -0
- package/dist/process/reservation-table.js +80 -0
- package/dist/process/run-executor.d.ts +16 -0
- package/dist/process/run-executor.js +155 -0
- package/dist/process/terminal-output-cache.d.ts +66 -0
- package/dist/process/terminal-output-cache.js +132 -0
- package/dist/profile/client-actions.d.ts +56 -0
- package/dist/profile/client-actions.js +215 -0
- package/dist/profile/client-config.d.ts +20 -0
- package/dist/profile/client-config.js +51 -0
- package/dist/profile/client-health.d.ts +14 -0
- package/dist/profile/client-health.js +69 -0
- package/dist/profile/client-playbooks.d.ts +19 -0
- package/dist/profile/client-playbooks.js +36 -0
- package/dist/profile/client-query.d.ts +30 -0
- package/dist/profile/client-query.js +70 -0
- package/dist/profile/client-runs.d.ts +42 -0
- package/dist/profile/client-runs.js +58 -0
- package/dist/profile/client-state.d.ts +56 -0
- package/dist/profile/client-state.js +83 -0
- package/dist/profile/client-transport.d.ts +61 -0
- package/dist/profile/client-transport.js +156 -0
- package/dist/profile/client.d.ts +23 -142
- package/dist/profile/client.js +28 -588
- package/dist/profile/manager.js +1 -1
- package/dist/project/closure.d.ts +4 -4
- package/dist/project/closure.js +11 -5
- package/dist/project/init.js +2 -2
- package/dist/project/loader.d.ts +0 -25
- package/dist/project/loader.js +1 -154
- package/dist/project/transactions.d.ts +12 -14
- package/dist/project/transactions.js +60 -836
- package/dist/registry/registry.js +6 -4
- package/dist/registry/resolve.js +1 -1
- package/dist/runtime/action-registry.d.ts +45 -0
- package/dist/runtime/action-registry.js +108 -0
- package/dist/runtime/clock.d.ts +5 -17
- package/dist/runtime/clock.js +5 -15
- package/dist/runtime/context.d.ts +3 -0
- package/dist/runtime/context.js +17 -56
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.js +3 -0
- package/dist/runtime/package-runner-factory.d.ts +82 -0
- package/dist/runtime/package-runner-factory.js +186 -0
- package/dist/runtime/run-persistence.d.ts +85 -0
- package/dist/runtime/run-persistence.js +111 -0
- package/dist/runtime/runner.d.ts +25 -45
- package/dist/runtime/runner.js +130 -354
- package/dist/runtime/standalone.d.ts +25 -2
- package/dist/runtime/standalone.js +305 -87
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +1 -0
- package/dist/schema/validator.d.ts +10 -0
- package/dist/schema/validator.js +48 -54
- package/dist/server/dispatcher.d.ts +8 -3
- package/dist/server/dispatcher.js +16 -40
- package/dist/server/routes/runs.js +6 -4
- package/dist/server/security.d.ts +1 -7
- package/dist/server/security.js +2 -13
- package/dist/storage/clock.d.ts +25 -0
- package/dist/storage/clock.js +23 -0
- package/dist/storage/data-dir-lock.d.ts +3 -36
- package/dist/storage/data-dir-lock.js +48 -881
- package/dist/storage/index.d.ts +8 -1
- package/dist/storage/index.js +8 -2
- package/dist/storage/lazy.js +1 -0
- package/dist/storage/lock-core.d.ts +162 -0
- package/dist/storage/lock-core.js +885 -0
- package/dist/storage/sqlite.d.ts +19 -6
- package/dist/storage/sqlite.js +81 -89
- package/dist/storage/types.d.ts +27 -5
- package/dist/storage/types.js +21 -0
- package/dist/storage/utils.d.ts +22 -0
- package/dist/storage/utils.js +34 -0
- package/dist/target/local.d.ts +1 -0
- package/dist/target/local.js +23 -17
- package/dist/target/remote-errors.d.ts +21 -0
- package/dist/target/remote-errors.js +51 -0
- package/dist/target/remote-polling.d.ts +35 -0
- package/dist/target/remote-polling.js +104 -0
- package/dist/target/remote.d.ts +4 -0
- package/dist/target/remote.js +108 -301
- package/dist/target/sse-parser.d.ts +35 -0
- package/dist/target/sse-parser.js +163 -0
- package/dist/target/target.js +2 -0
- package/dist/target/types.d.ts +6 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/net.d.ts +10 -0
- package/dist/utils/net.js +16 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { RuntimeStorage } from "./types.js";
|
|
2
2
|
export { DataDirLock, type DataDirLockInfo, isProcessAlive, } from "./data-dir-lock.js";
|
|
3
|
+
export * from "./clock.js";
|
|
3
4
|
export * from "./driver.js";
|
|
4
5
|
export * from "./lazy.js";
|
|
5
6
|
export * from "./mask.js";
|
|
6
7
|
export * from "./params.js";
|
|
7
8
|
export * from "./sqlite.js";
|
|
8
9
|
export * from "./types.js";
|
|
10
|
+
export * from "./utils.js";
|
|
9
11
|
/**
|
|
10
12
|
* 解析并计算目标 SQLite 数据库文件的绝对路径。
|
|
11
13
|
*
|
|
@@ -26,14 +28,19 @@ export declare function resolveDatabasePath(packageId: string, options?: {
|
|
|
26
28
|
/**
|
|
27
29
|
* 工厂函数:为指定 Package 创建或连接 RuntimeStorage 实例。
|
|
28
30
|
*
|
|
31
|
+
* 默认旁观打开:不收割库内遗留非终态运行(recoverOrphans 默认 false),
|
|
32
|
+
* 供 CLI 查询类命令安全并发访问持有者进程正在写入的同一库文件;
|
|
33
|
+
* 执行宿主路径应传入 recoverOrphans: true 或后续显式调用 recoverDeadSessionRuns。
|
|
34
|
+
*
|
|
29
35
|
* @param packageId 目标 Package ID
|
|
30
|
-
* @param options 存储配置参数(支持 dataDir, inMemory, customHome)
|
|
36
|
+
* @param options 存储配置参数(支持 dataDir, inMemory, customHome, recoverOrphans)
|
|
31
37
|
*/
|
|
32
38
|
export declare function createStorage(packageId: string, options?: {
|
|
33
39
|
projectRoot?: string;
|
|
34
40
|
dataDir?: string;
|
|
35
41
|
inMemory?: boolean;
|
|
36
42
|
customHome?: string;
|
|
43
|
+
recoverOrphans?: boolean;
|
|
37
44
|
}): RuntimeStorage;
|
|
38
45
|
/**
|
|
39
46
|
* 解析全局共享数据库(global.db)文件的绝对路径。
|
package/dist/storage/index.js
CHANGED
|
@@ -2,12 +2,14 @@ import { join, relative, resolve } from "node:path";
|
|
|
2
2
|
import { assertValidPackageId, getActionDockHome, isPathOutsideBoundary } from "../utils/index.js";
|
|
3
3
|
import { SqliteRuntimeStorage } from "./sqlite.js";
|
|
4
4
|
export { DataDirLock, isProcessAlive, } from "./data-dir-lock.js";
|
|
5
|
+
export * from "./clock.js";
|
|
5
6
|
export * from "./driver.js";
|
|
6
7
|
export * from "./lazy.js";
|
|
7
8
|
export * from "./mask.js";
|
|
8
9
|
export * from "./params.js";
|
|
9
10
|
export * from "./sqlite.js";
|
|
10
11
|
export * from "./types.js";
|
|
12
|
+
export * from "./utils.js";
|
|
11
13
|
/**
|
|
12
14
|
* 解析并计算目标 SQLite 数据库文件的绝对路径。
|
|
13
15
|
*
|
|
@@ -47,12 +49,16 @@ export function resolveDatabasePath(packageId, options = {}) {
|
|
|
47
49
|
/**
|
|
48
50
|
* 工厂函数:为指定 Package 创建或连接 RuntimeStorage 实例。
|
|
49
51
|
*
|
|
52
|
+
* 默认旁观打开:不收割库内遗留非终态运行(recoverOrphans 默认 false),
|
|
53
|
+
* 供 CLI 查询类命令安全并发访问持有者进程正在写入的同一库文件;
|
|
54
|
+
* 执行宿主路径应传入 recoverOrphans: true 或后续显式调用 recoverDeadSessionRuns。
|
|
55
|
+
*
|
|
50
56
|
* @param packageId 目标 Package ID
|
|
51
|
-
* @param options 存储配置参数(支持 dataDir, inMemory, customHome)
|
|
57
|
+
* @param options 存储配置参数(支持 dataDir, inMemory, customHome, recoverOrphans)
|
|
52
58
|
*/
|
|
53
59
|
export function createStorage(packageId, options = {}) {
|
|
54
60
|
const dbPath = resolveDatabasePath(packageId, options);
|
|
55
|
-
return new SqliteRuntimeStorage({ dbPath, packageId });
|
|
61
|
+
return new SqliteRuntimeStorage({ dbPath, packageId, recoverOrphans: options.recoverOrphans });
|
|
56
62
|
}
|
|
57
63
|
/**
|
|
58
64
|
* 解析全局共享数据库(global.db)文件的绝对路径。
|
package/dist/storage/lazy.js
CHANGED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 目录锁元数据通用契约。
|
|
3
|
+
* 工程锁与数据目录锁共用同一物理布局,仅部分字段按场景取舍。
|
|
4
|
+
*/
|
|
5
|
+
export interface DirectoryLockMetadata {
|
|
6
|
+
pid?: number;
|
|
7
|
+
sessionToken?: string;
|
|
8
|
+
lockToken?: string;
|
|
9
|
+
guardToken?: string;
|
|
10
|
+
childPids?: number[];
|
|
11
|
+
createdAt?: number | string;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 带宽限期检测的锁状态快照。
|
|
16
|
+
*/
|
|
17
|
+
export interface LockGraceState {
|
|
18
|
+
exists: boolean;
|
|
19
|
+
isDir: boolean;
|
|
20
|
+
info?: DirectoryLockMetadata;
|
|
21
|
+
inGracePeriod: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 接管守卫(reclaim guard)状态快照。
|
|
25
|
+
*/
|
|
26
|
+
export interface ReclaimGuardState {
|
|
27
|
+
exists: boolean;
|
|
28
|
+
active: boolean;
|
|
29
|
+
isStale: boolean;
|
|
30
|
+
holderPid?: number;
|
|
31
|
+
guardToken?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 检查目标进程是否处于存活状态。
|
|
35
|
+
*
|
|
36
|
+
* @param pid 待检测的进程标识符
|
|
37
|
+
*/
|
|
38
|
+
export declare function isProcessAlive(pid: number): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* 读取排他锁元数据并执行宽限期检测。
|
|
41
|
+
*/
|
|
42
|
+
export declare function readLockWithGracePeriod(lockPath: string, gracePeriodMs?: number, deadline?: number): LockGraceState;
|
|
43
|
+
/**
|
|
44
|
+
* 检查接管守卫(reclaim guard)目录状态。
|
|
45
|
+
*
|
|
46
|
+
* - 若目录不存在:返回非活跃。
|
|
47
|
+
* - 若处于宽限期内或持有者存活:返回活跃,禁止抢先创建主锁。
|
|
48
|
+
* - 若持有者已死亡且超过宽限期:返回陈旧,可供安全清理。
|
|
49
|
+
*/
|
|
50
|
+
export declare function checkReclaimGuard(reclaimPath: string, gracePeriodMs?: number): ReclaimGuardState;
|
|
51
|
+
/**
|
|
52
|
+
* 尝试原子获取接管守卫(reclaim guard)。
|
|
53
|
+
* 基于 mkdirSync 原子创建目录并写入自身元数据与唯一 guardToken。
|
|
54
|
+
*/
|
|
55
|
+
export declare function tryAcquireReclaimGuard(reclaimPath: string, pid: number, guardToken: string): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* 安全清理陈旧接管守卫(reclaim guard)。
|
|
58
|
+
* 采用原子重命名检疫并严格核对 guardToken 与持有者存活状态,确保仅删除目标陈旧 guard,严禁误删活跃守卫或并发新守卫。
|
|
59
|
+
*
|
|
60
|
+
* @param reclaimPath 目标守卫路径
|
|
61
|
+
* @param expectedGuardToken 预期持有的守卫令牌(必填,拒绝未指定令牌的盲目清理)
|
|
62
|
+
*/
|
|
63
|
+
export declare function safeRemoveStaleReclaimGuard(reclaimPath: string, expectedGuardToken: string): void;
|
|
64
|
+
/**
|
|
65
|
+
* 从隔离或回滚临时目录名称中解析操作者 PID 与隔离生成时间戳。
|
|
66
|
+
* 命名规范:*.(quarantine|rollback|release).<pid>.<timestamp>.<uuid> 或 *.orphan.<timestamp>.<uuid>
|
|
67
|
+
*/
|
|
68
|
+
export declare function parseQuarantineTimestamp(entryName: string): {
|
|
69
|
+
operatorPid?: number;
|
|
70
|
+
timestamp?: number;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* 清理过期的隔离目录(GC 回收机制)。
|
|
74
|
+
* 实施分流存活校验,防止误删活跃持锁者与回滚中目录,同时防止孤儿目录无限泄漏:
|
|
75
|
+
* - 共同前置条件:存活年龄必须超过 maxAgeMs(默认 10000ms),未超期前严禁清理(保持宽限期)。
|
|
76
|
+
* - 活跃隔离目录(quarantine / rollback / release):若 operatorPid 存活或内部 metadata.json 记录的 pid 与 childPids 存活,跳过不予清理。
|
|
77
|
+
* - 孤儿脱离目录(orphan):内部旧 metadata.pid 不再作为续命依据;提取其内部 orphanToken,仅当当前规范主路径(主锁目录与 reclaim 目录)依然持有该凭证时保守跳过;规范路径不存在或已变更凭据时直接安全清理。
|
|
78
|
+
*/
|
|
79
|
+
export declare function cleanStaleQuarantines(parentDir: string, basePrefix: string, maxAgeMs?: number, deadline?: number): void;
|
|
80
|
+
/**
|
|
81
|
+
* 安全回滚当前进程创建的主锁。
|
|
82
|
+
* 优先核对 lockToken,回退核对 sessionToken,防止误删接管者或并发新锁。
|
|
83
|
+
*/
|
|
84
|
+
export declare function safeRollbackLock(lockPath: string, expectedSessionToken: string, expectedLockToken?: string): void;
|
|
85
|
+
/**
|
|
86
|
+
* 安全隔离并清理陈旧主锁。
|
|
87
|
+
* 隔离后复核元数据,确保仅删除目标陈旧锁,若已被更新或仍有存活所有者则恢复原位。
|
|
88
|
+
*/
|
|
89
|
+
export declare function safeQuarantineStaleLock(lockPath: string, expectedSessionToken?: string, expectedLockToken?: string): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* 安全释放主锁。
|
|
92
|
+
* 仅当锁目录中持有当前 lockToken / sessionToken 时才删除,杜绝删除他人新锁。
|
|
93
|
+
* 传入 gcAfterRelease 时在释放结束后以主锁文件名为前缀触发一轮隔离目录 GC。
|
|
94
|
+
*/
|
|
95
|
+
export declare function safeReleaseLock(lockPath: string, expectedSessionToken: string, expectedLockToken?: string, options?: {
|
|
96
|
+
gcAfterRelease?: boolean;
|
|
97
|
+
}): void;
|
|
98
|
+
/**
|
|
99
|
+
* 目录锁获取流程的各类超时错误消息模板。
|
|
100
|
+
* 由上层模块注入,保证各领域错误文案与错误码完全保持原语义。
|
|
101
|
+
*/
|
|
102
|
+
export interface DirectoryLockMessages {
|
|
103
|
+
/** 等待活跃接管守卫超时 */
|
|
104
|
+
timeoutWaitingReclaimGuard(holderPid?: number): string;
|
|
105
|
+
/** 因他人活跃接管守卫导致获取主锁超时 */
|
|
106
|
+
timeoutAcquireBlockedByGuard(holderPid?: number): string;
|
|
107
|
+
/** 获取主锁通用超时 */
|
|
108
|
+
timeoutAcquire(): string;
|
|
109
|
+
/** 等待主锁元数据宽限期超时 */
|
|
110
|
+
timeoutGracePeriod(): string;
|
|
111
|
+
/** 争抢接管守卫超时 */
|
|
112
|
+
timeoutGuardContention(): string;
|
|
113
|
+
/** 接管陈旧主锁超时 */
|
|
114
|
+
timeoutReclaimStale(): string;
|
|
115
|
+
/** 创建新主锁超时 */
|
|
116
|
+
timeoutCreate(): string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* 目录锁获取流程配置。
|
|
120
|
+
* 上层模块以此注入锁路径、令牌、错误构造与领域差异钩子。
|
|
121
|
+
*/
|
|
122
|
+
export interface AcquireDirectoryLockConfig<T> {
|
|
123
|
+
/** 主锁目录完整路径 */
|
|
124
|
+
lockPath: string;
|
|
125
|
+
/** 主锁所在父目录(用于隔离目录 GC) */
|
|
126
|
+
parentDir: string;
|
|
127
|
+
/** 主锁目录在父目录中的基础名称前缀 */
|
|
128
|
+
basePrefix: string;
|
|
129
|
+
/** 待写入主锁的元数据 JSON 文本 */
|
|
130
|
+
metadataContent: string;
|
|
131
|
+
/** 自身会话令牌 */
|
|
132
|
+
sessionToken: string;
|
|
133
|
+
/** 自身内部排他锁令牌 */
|
|
134
|
+
lockToken: string;
|
|
135
|
+
/** 获取锁的超时时间,默认 5000ms */
|
|
136
|
+
acquireTimeoutMs?: number;
|
|
137
|
+
/** 构造带错误码的占用异常 */
|
|
138
|
+
createLockError(message: string): Error & {
|
|
139
|
+
code: string;
|
|
140
|
+
};
|
|
141
|
+
/** 各类超时场景的错误消息模板 */
|
|
142
|
+
messages: DirectoryLockMessages;
|
|
143
|
+
/** 陈旧锁持有者复核回调:若持有者仍阻断接管则直接抛错 */
|
|
144
|
+
assertStaleHolderReclaimable(info: DirectoryLockMetadata): void;
|
|
145
|
+
/** 成功获取主锁后的返回值构造 */
|
|
146
|
+
onAcquired(): T;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* 目录锁统一获取仲裁流程。
|
|
150
|
+
*
|
|
151
|
+
* 仲裁规则:
|
|
152
|
+
* - 引入所有竞争者均遵守的原子 reclaim guard 机制(lockPath.reclaim),每个 guard 具备全局唯一 guardToken。
|
|
153
|
+
* - 基于原子目录创建 mkdirSync(lockPath, { mode: 0o700 }) 确立所有权,并在其下存放 metadata.json。
|
|
154
|
+
* - 若检测到 reclaim guard 存在且处于宽限期内或持有者存活,必须等待,禁止抢先创建主锁。
|
|
155
|
+
* - 若锁目录已存在,通过宽限期机制防止将并发写入中的元数据误判为锁死亡。
|
|
156
|
+
* - 若持有者仍存活(判定由 assertStaleHolderReclaimable 注入),抛出上层领域错误拒绝并发接管。
|
|
157
|
+
* - 当识别到主锁为陈旧锁时,竞争者必须先原子竞争获取 reclaim guard。
|
|
158
|
+
* - 仅成功获取 reclaim guard 的唯一胜利者获准执行:复核主锁陈旧性 -> 验证并清理陈旧主锁 -> 原子创建新主锁并写入自身元数据 -> 清理 reclaim guard。
|
|
159
|
+
* - 竞争失败者等待并 continue 重试;若 reclaim guard 持有者意外崩溃,其他竞争者在超过宽限期且 PID 已死后通过 safeRemoveStaleReclaimGuard 核对 guardToken 并清理。
|
|
160
|
+
* - 严禁在获取新主锁遇到 EEXIST 时盲目 rmSync;后检发现他人活跃 guard 时,仅通过 safeRollbackLock 核对自身 sessionToken 回滚自身锁。
|
|
161
|
+
*/
|
|
162
|
+
export declare function acquireDirectoryLock<T>(config: AcquireDirectoryLockConfig<T>): T;
|