@oatscenter/trellis 0.100.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.
Files changed (264) hide show
  1. package/README.md +59 -0
  2. package/auth/authorization/client_context.d.ts +61 -0
  3. package/auth/authorization/client_context.js +266 -0
  4. package/auth/authorization/nats_registry.d.ts +41 -0
  5. package/auth/authorization/nats_registry.js +283 -0
  6. package/auth/authorization/provider_cache.d.ts +90 -0
  7. package/auth/authorization/provider_cache.js +783 -0
  8. package/auth/authorization/refresh.d.ts +46 -0
  9. package/auth/authorization/refresh.js +246 -0
  10. package/auth/authorization/types.d.ts +207 -0
  11. package/auth/authorization/types.js +60 -0
  12. package/auth/authorization_context.d.ts +11 -0
  13. package/auth/authorization_context.js +10 -0
  14. package/auth/browser/flow_types.d.ts +84 -0
  15. package/auth/browser/flow_types.js +70 -0
  16. package/auth/browser/portal.d.ts +21 -0
  17. package/auth/browser/portal.js +307 -0
  18. package/auth/browser/storage.d.ts +26 -0
  19. package/auth/browser/storage.js +224 -0
  20. package/auth/browser.d.ts +11 -0
  21. package/auth/browser.js +10 -0
  22. package/auth/browser_recovery.d.ts +13 -0
  23. package/auth/browser_recovery.js +38 -0
  24. package/auth/device_activation.d.ts +134 -0
  25. package/auth/device_activation.js +376 -0
  26. package/auth/http_error.d.ts +12 -0
  27. package/auth/http_error.js +32 -0
  28. package/auth/keys.d.ts +5 -0
  29. package/auth/keys.js +63 -0
  30. package/auth/mod.d.ts +16 -0
  31. package/auth/mod.js +16 -0
  32. package/auth/proof.d.ts +31 -0
  33. package/auth/proof.js +95 -0
  34. package/auth/protocol_wasm/trellis_protocol_wasm.d.ts +138 -0
  35. package/auth/protocol_wasm/trellis_protocol_wasm.js +605 -0
  36. package/auth/protocol_wasm/trellis_protocol_wasm_bg.wasm +0 -0
  37. package/auth/protocol_wasm/trellis_protocol_wasm_bytes.d.ts +1 -0
  38. package/auth/protocol_wasm/trellis_protocol_wasm_bytes.js +2 -0
  39. package/auth/protocol_wasm.d.ts +179 -0
  40. package/auth/protocol_wasm.js +133 -0
  41. package/auth/session_auth.d.ts +30 -0
  42. package/auth/session_auth.js +77 -0
  43. package/auth/session_proof.d.ts +53 -0
  44. package/auth/session_proof.js +43 -0
  45. package/auth/time.d.ts +6 -0
  46. package/auth/time.js +7 -0
  47. package/auth/trellis_id.d.ts +1 -0
  48. package/auth/trellis_id.js +5 -0
  49. package/auth/utils.d.ts +10 -0
  50. package/auth/utils.js +69 -0
  51. package/auth.d.ts +1 -0
  52. package/auth.js +1 -0
  53. package/caller.d.ts +111 -0
  54. package/caller.js +85 -0
  55. package/client.d.ts +14 -0
  56. package/client.js +1 -0
  57. package/client_connect.d.ts +143 -0
  58. package/client_connect.js +1097 -0
  59. package/codec.d.ts +13 -0
  60. package/codec.js +192 -0
  61. package/connection.d.ts +107 -0
  62. package/connection.js +396 -0
  63. package/device/activation.d.ts +42 -0
  64. package/device/activation.js +319 -0
  65. package/device.d.ts +80 -0
  66. package/device.js +687 -0
  67. package/env.d.ts +2 -0
  68. package/env.js +10 -0
  69. package/errors/AuthError.d.ts +30 -0
  70. package/errors/AuthError.js +34 -0
  71. package/errors/KVError.d.ts +30 -0
  72. package/errors/KVError.js +36 -0
  73. package/errors/OperationLifecycleError.d.ts +110 -0
  74. package/errors/OperationLifecycleError.js +142 -0
  75. package/errors/RemoteError.d.ts +61 -0
  76. package/errors/RemoteError.js +72 -0
  77. package/errors/SchemaValidationError.d.ts +48 -0
  78. package/errors/SchemaValidationError.js +49 -0
  79. package/errors/StoreError.d.ts +21 -0
  80. package/errors/StoreError.js +31 -0
  81. package/errors/TransferError.d.ts +21 -0
  82. package/errors/TransferError.js +31 -0
  83. package/errors/TransportError.d.ts +29 -0
  84. package/errors/TransportError.js +33 -0
  85. package/errors/TrellisError.d.ts +15 -0
  86. package/errors/TrellisError.js +15 -0
  87. package/errors/ValidationError.d.ts +50 -0
  88. package/errors/ValidationError.js +59 -0
  89. package/errors/index.d.ts +254 -0
  90. package/errors/index.js +238 -0
  91. package/generated.d.ts +4 -0
  92. package/generated.js +3 -0
  93. package/generated_support.d.ts +120 -0
  94. package/generated_support.js +359 -0
  95. package/globals.d.ts +9 -0
  96. package/globals.js +16 -0
  97. package/health_transport.d.ts +18 -0
  98. package/health_transport.js +32 -0
  99. package/helpers.d.ts +11 -0
  100. package/helpers.js +53 -0
  101. package/index.d.ts +2 -0
  102. package/index.js +2 -0
  103. package/internal_sdk/generated/apis/auth/mod.d.ts +805 -0
  104. package/internal_sdk/generated/apis/auth/mod.js +958 -0
  105. package/internal_sdk/generated/apis/core/mod.d.ts +79 -0
  106. package/internal_sdk/generated/apis/core/mod.js +93 -0
  107. package/internal_sdk/generated/apis/events/mod.d.ts +224 -0
  108. package/internal_sdk/generated/apis/events/mod.js +313 -0
  109. package/internal_sdk/generated/apis/health/mod.d.ts +106 -0
  110. package/internal_sdk/generated/apis/health/mod.js +132 -0
  111. package/internal_sdk/generated/apis/index.d.ts +7 -0
  112. package/internal_sdk/generated/apis/index.js +8 -0
  113. package/internal_sdk/generated/apis/jobs/mod.d.ts +176 -0
  114. package/internal_sdk/generated/apis/jobs/mod.js +209 -0
  115. package/internal_sdk/generated/apis/state/mod.d.ts +104 -0
  116. package/internal_sdk/generated/apis/state/mod.js +139 -0
  117. package/internal_sdk/generated/index.d.ts +4 -0
  118. package/internal_sdk/generated/index.js +5 -0
  119. package/internal_sdk/generated/package.json +18 -0
  120. package/internal_sdk/generated/participants/cli/mod.d.ts +402 -0
  121. package/internal_sdk/generated/participants/cli/mod.js +460 -0
  122. package/internal_sdk/generated/participants/cli/types.d.ts +2 -0
  123. package/internal_sdk/generated/participants/cli/types.js +3 -0
  124. package/internal_sdk/generated/participants/console/mod.d.ts +489 -0
  125. package/internal_sdk/generated/participants/console/mod.js +579 -0
  126. package/internal_sdk/generated/participants/console/types.d.ts +2 -0
  127. package/internal_sdk/generated/participants/console/types.js +3 -0
  128. package/internal_sdk/generated/participants/eventsRuntime/mod.d.ts +64 -0
  129. package/internal_sdk/generated/participants/eventsRuntime/mod.js +42 -0
  130. package/internal_sdk/generated/participants/eventsRuntime/types.d.ts +2 -0
  131. package/internal_sdk/generated/participants/eventsRuntime/types.js +3 -0
  132. package/internal_sdk/generated/participants/healthRuntime/mod.d.ts +58 -0
  133. package/internal_sdk/generated/participants/healthRuntime/mod.js +36 -0
  134. package/internal_sdk/generated/participants/healthRuntime/types.d.ts +2 -0
  135. package/internal_sdk/generated/participants/healthRuntime/types.js +3 -0
  136. package/internal_sdk/generated/participants/index.d.ts +8 -0
  137. package/internal_sdk/generated/participants/index.js +9 -0
  138. package/internal_sdk/generated/participants/jobsRuntime/mod.d.ts +64 -0
  139. package/internal_sdk/generated/participants/jobsRuntime/mod.js +42 -0
  140. package/internal_sdk/generated/participants/jobsRuntime/types.d.ts +2 -0
  141. package/internal_sdk/generated/participants/jobsRuntime/types.js +3 -0
  142. package/internal_sdk/generated/participants/platform/mod.d.ts +164 -0
  143. package/internal_sdk/generated/participants/platform/mod.js +149 -0
  144. package/internal_sdk/generated/participants/platform/types.d.ts +7 -0
  145. package/internal_sdk/generated/participants/platform/types.js +5 -0
  146. package/internal_sdk/generated/participants/portal/mod.d.ts +131 -0
  147. package/internal_sdk/generated/participants/portal/mod.js +109 -0
  148. package/internal_sdk/generated/participants/portal/types.d.ts +2 -0
  149. package/internal_sdk/generated/participants/portal/types.js +3 -0
  150. package/internal_sdk/generated/types/_internal/p0.d.ts +13511 -0
  151. package/internal_sdk/generated/types/_internal/p0.js +6105 -0
  152. package/internal_sdk/generated/types/index.d.ts +2951 -0
  153. package/internal_sdk/generated/types/index.js +1477 -0
  154. package/jobs.d.ts +309 -0
  155. package/jobs.js +389 -0
  156. package/kv.d.ts +85 -0
  157. package/kv.js +330 -0
  158. package/operations.d.ts +189 -0
  159. package/operations.js +847 -0
  160. package/package.json +73 -0
  161. package/pagination.d.ts +25 -0
  162. package/pagination.js +117 -0
  163. package/participant.d.ts +6 -0
  164. package/participant.js +6 -0
  165. package/participant_runtime/api.d.ts +131 -0
  166. package/participant_runtime/api.js +42 -0
  167. package/participant_runtime/json.d.ts +16 -0
  168. package/participant_runtime/json.js +193 -0
  169. package/participant_runtime/metadata.d.ts +34 -0
  170. package/participant_runtime/metadata.js +4 -0
  171. package/participant_runtime/participant.d.ts +200 -0
  172. package/participant_runtime/participant.js +330 -0
  173. package/participant_runtime/schemas.d.ts +347 -0
  174. package/participant_runtime/schemas.js +211 -0
  175. package/participant_runtime/surface_names.d.ts +16 -0
  176. package/participant_runtime/surface_names.js +34 -0
  177. package/portable.d.ts +30 -0
  178. package/portable.js +14 -0
  179. package/provider.d.ts +69 -0
  180. package/provider.js +68 -0
  181. package/runtime_transport.d.ts +25 -0
  182. package/runtime_transport.js +48 -0
  183. package/service/mod.d.ts +14 -0
  184. package/service/mod.js +13 -0
  185. package/service/outbox_inbox.d.ts +259 -0
  186. package/service/outbox_inbox.js +908 -0
  187. package/service/runtime/bootstrap.d.ts +56 -0
  188. package/service/runtime/bootstrap.js +226 -0
  189. package/service/runtime/core.d.ts +46 -0
  190. package/service/runtime/core.js +1747 -0
  191. package/service/runtime/health.d.ts +97 -0
  192. package/service/runtime/health.js +153 -0
  193. package/service/runtime/health_schemas.d.ts +23 -0
  194. package/service/runtime/health_schemas.js +20 -0
  195. package/service/runtime/internal_jobs/active-job.d.ts +40 -0
  196. package/service/runtime/internal_jobs/active-job.js +91 -0
  197. package/service/runtime/internal_jobs/bindings.d.ts +40 -0
  198. package/service/runtime/internal_jobs/bindings.js +1 -0
  199. package/service/runtime/internal_jobs/cancellation-registry.d.ts +13 -0
  200. package/service/runtime/internal_jobs/cancellation-registry.js +55 -0
  201. package/service/runtime/internal_jobs/heartbeat.d.ts +33 -0
  202. package/service/runtime/internal_jobs/heartbeat.js +65 -0
  203. package/service/runtime/internal_jobs/job-manager.d.ts +126 -0
  204. package/service/runtime/internal_jobs/job-manager.js +821 -0
  205. package/service/runtime/internal_jobs/key-coordinator.d.ts +280 -0
  206. package/service/runtime/internal_jobs/key-coordinator.js +747 -0
  207. package/service/runtime/internal_jobs/projection.d.ts +3 -0
  208. package/service/runtime/internal_jobs/projection.js +42 -0
  209. package/service/runtime/internal_jobs/runtime-worker.d.ts +126 -0
  210. package/service/runtime/internal_jobs/runtime-worker.js +454 -0
  211. package/service/runtime/internal_jobs/types.d.ts +246 -0
  212. package/service/runtime/internal_jobs/types.js +163 -0
  213. package/service/runtime/logger.d.ts +2 -0
  214. package/service/runtime/logger.js +7 -0
  215. package/service/runtime/runtime.d.ts +16 -0
  216. package/service/runtime/runtime.js +1 -0
  217. package/service/runtime/service.d.ts +372 -0
  218. package/service/runtime/service.js +1896 -0
  219. package/service/runtime/transfer/download.d.ts +27 -0
  220. package/service/runtime/transfer/download.js +1 -0
  221. package/service/runtime/transfer/protocol.d.ts +15 -0
  222. package/service/runtime/transfer/protocol.js +46 -0
  223. package/service/runtime/transfer/queue.d.ts +18 -0
  224. package/service/runtime/transfer/queue.js +136 -0
  225. package/service/runtime/transfer/upload.d.ts +40 -0
  226. package/service/runtime/transfer/upload.js +27 -0
  227. package/service/runtime/transfer.d.ts +62 -0
  228. package/service/runtime/transfer.js +763 -0
  229. package/session.d.ts +862 -0
  230. package/session.js +3407 -0
  231. package/store.d.ts +71 -0
  232. package/store.js +412 -0
  233. package/store_entry.d.ts +20 -0
  234. package/store_entry.js +75 -0
  235. package/tasks.d.ts +10 -0
  236. package/tasks.js +28 -0
  237. package/telemetry/carrier.d.ts +8 -0
  238. package/telemetry/carrier.js +20 -0
  239. package/telemetry/core.d.ts +7 -0
  240. package/telemetry/core.js +14 -0
  241. package/telemetry/env.d.ts +2 -0
  242. package/telemetry/env.js +10 -0
  243. package/telemetry/init.d.ts +2 -0
  244. package/telemetry/init.js +7 -0
  245. package/telemetry/metrics.d.ts +81 -0
  246. package/telemetry/metrics.js +267 -0
  247. package/telemetry/mod.d.ts +13 -0
  248. package/telemetry/mod.js +8 -0
  249. package/telemetry/nats.d.ts +6 -0
  250. package/telemetry/nats.js +6 -0
  251. package/telemetry/result.d.ts +1 -0
  252. package/telemetry/result.js +18 -0
  253. package/telemetry/runtime.d.ts +1 -0
  254. package/telemetry/runtime.js +141 -0
  255. package/telemetry/trace.d.ts +4 -0
  256. package/telemetry/trace.js +26 -0
  257. package/telemetry/trellis.d.ts +1 -0
  258. package/telemetry/trellis.js +1 -0
  259. package/telemetry.d.ts +1 -0
  260. package/telemetry.js +1 -0
  261. package/transfer.d.ts +112 -0
  262. package/transfer.js +525 -0
  263. package/transfer_protocol.d.ts +1 -0
  264. package/transfer_protocol.js +13 -0
@@ -0,0 +1,280 @@
1
+ import type { NatsConnection } from "@nats-io/nats-core";
2
+ import type { JobContext, JobEvent, JobState } from "./types.ts";
3
+ export type JobKeyStalePolicy = "fail-stale" | "block";
4
+ export type JobQueueWhenFull = "reject" | "coalesce" | "replace-oldest";
5
+ export type JobKeyConcurrencyBinding = {
6
+ key: string[];
7
+ maxActive?: number;
8
+ heartbeatIntervalMs?: number;
9
+ heartbeatTtlMs?: number;
10
+ stalePolicy?: JobKeyStalePolicy;
11
+ };
12
+ export type JobQueuePolicyBinding = {
13
+ maxQueuedPerKey?: number;
14
+ whenFull?: JobQueueWhenFull;
15
+ };
16
+ export type NormalizedJobKeyPolicy = {
17
+ key: string[];
18
+ maxActive: number;
19
+ heartbeatIntervalMs: number;
20
+ heartbeatTtlMs: number;
21
+ stalePolicy: JobKeyStalePolicy;
22
+ queue: {
23
+ maxQueuedPerKey: number;
24
+ whenFull: JobQueueWhenFull;
25
+ };
26
+ };
27
+ export type DerivedJobKey = {
28
+ service: string;
29
+ jobType: string;
30
+ key: string;
31
+ keyHash: string;
32
+ kvKey: string;
33
+ };
34
+ export type JobKeyQueued = {
35
+ jobId: string;
36
+ createdAt: string;
37
+ requestId: string;
38
+ context: JobContext;
39
+ submissionId?: string;
40
+ };
41
+ export type JobKeyActiveSlot = {
42
+ jobId: string;
43
+ slotToken: string;
44
+ instanceId: string;
45
+ startedAt: string;
46
+ heartbeatAt: string;
47
+ leaseExpiresAt: string;
48
+ tries: number;
49
+ context: JobContext;
50
+ };
51
+ export type JobKeyState = {
52
+ version: 1;
53
+ service: string;
54
+ jobType: string;
55
+ key: string;
56
+ keyHash: string;
57
+ maxActive: number;
58
+ maxQueuedPerKey?: number;
59
+ active: JobKeyActiveSlot[];
60
+ queued: JobKeyQueued[];
61
+ staleTakeoverCount: number;
62
+ updatedAt: string;
63
+ coalescedBySubmissionId?: Record<string, {
64
+ existingJobId: string;
65
+ reason: "queue-full" | "active-limit";
66
+ }>;
67
+ acceptedBySubmissionId?: Record<string, {
68
+ jobId: string;
69
+ }>;
70
+ replacedBySubmissionId?: Record<string, ReplacedQueuedJob>;
71
+ };
72
+ export type JobKeyIdentity = {
73
+ service: string;
74
+ jobType: string;
75
+ id: string;
76
+ };
77
+ export type ReplacedQueuedJob = JobKeyIdentity & {
78
+ createdAt: string;
79
+ requestId: string;
80
+ context: JobContext;
81
+ };
82
+ export type JobAdmissionRequest = {
83
+ service: string;
84
+ jobType: string;
85
+ jobId: string;
86
+ payload: unknown;
87
+ context: JobContext;
88
+ createdAt: string;
89
+ policy: NormalizedJobKeyPolicy;
90
+ strictCreate: boolean;
91
+ submissionId?: string;
92
+ };
93
+ export type JobAdmissionOutcome = {
94
+ kind: "accepted";
95
+ key: string;
96
+ keyHash: string;
97
+ state: JobKeyState;
98
+ } | {
99
+ kind: "rejected";
100
+ key: string;
101
+ reason: "active-limit" | "queue-depth" | "stale-blocked";
102
+ active: number;
103
+ queued: number;
104
+ limit: number;
105
+ } | {
106
+ kind: "coalesced";
107
+ key: string;
108
+ existing: JobKeyIdentity;
109
+ reason: "queue-full" | "active-limit";
110
+ } | {
111
+ kind: "replaced";
112
+ key: string;
113
+ keyHash: string;
114
+ replaced: ReplacedQueuedJob;
115
+ state: JobKeyState;
116
+ };
117
+ export type ActiveSlotAcquireRequest = {
118
+ service: string;
119
+ jobType: string;
120
+ jobId: string;
121
+ payload: unknown;
122
+ context: JobContext;
123
+ workEventType?: JobEvent["eventType"];
124
+ lifecycleState?: JobState;
125
+ tries: number;
126
+ instanceId: string;
127
+ now: string;
128
+ policy: NormalizedJobKeyPolicy;
129
+ };
130
+ export type ActiveSlotAcquireOutcome = {
131
+ kind: "acquired";
132
+ key: string;
133
+ keyHash: string;
134
+ slotToken: string;
135
+ stale: JobKeyActiveSlot[];
136
+ state: JobKeyState;
137
+ } | {
138
+ kind: "blocked";
139
+ key: string;
140
+ reason: "active-limit" | "not-queued" | "stale-blocked";
141
+ active: number;
142
+ queued: number;
143
+ limit: number;
144
+ };
145
+ export type ActiveSlotLease = {
146
+ key: string;
147
+ keyHash: string;
148
+ slotToken: string;
149
+ policy: NormalizedJobKeyPolicy;
150
+ };
151
+ export type ActiveSlotRenewOutcome = {
152
+ kind: "renewed";
153
+ state: JobKeyState;
154
+ } | {
155
+ kind: "lost";
156
+ };
157
+ export type ActiveSlotReleaseOutcome = {
158
+ kind: "released";
159
+ state: JobKeyState;
160
+ } | {
161
+ kind: "staleCompletion";
162
+ };
163
+ export type JobKeyCoordinator = {
164
+ admitCreate(request: JobAdmissionRequest): Promise<JobAdmissionOutcome>;
165
+ restoreReplacedQueuedJob(args: {
166
+ service: string;
167
+ jobType: string;
168
+ replacementJobId: string;
169
+ replaced: ReplacedQueuedJob;
170
+ payload: unknown;
171
+ now: string;
172
+ policy: NormalizedJobKeyPolicy;
173
+ submissionId?: string;
174
+ }): Promise<QueuedJobRestoreOutcome>;
175
+ removeQueuedJob(args: {
176
+ service: string;
177
+ jobType: string;
178
+ jobId: string;
179
+ payload: unknown;
180
+ now: string;
181
+ policy: NormalizedJobKeyPolicy;
182
+ submissionId?: string;
183
+ }): Promise<QueuedJobRemovalOutcome>;
184
+ removeQueuedJobById?(args: {
185
+ service: string;
186
+ jobType: string;
187
+ jobId: string;
188
+ now: string;
189
+ }): Promise<QueuedJobRemovalOutcome>;
190
+ acquireActiveSlot(request: ActiveSlotAcquireRequest): Promise<ActiveSlotAcquireOutcome>;
191
+ renewHeartbeat(args: {
192
+ service: string;
193
+ jobType: string;
194
+ jobId: string;
195
+ lease: ActiveSlotLease;
196
+ now: string;
197
+ }): Promise<ActiveSlotRenewOutcome>;
198
+ releaseActiveSlot(args: {
199
+ service: string;
200
+ jobType: string;
201
+ jobId: string;
202
+ lease: ActiveSlotLease;
203
+ now: string;
204
+ }): Promise<ActiveSlotReleaseOutcome>;
205
+ };
206
+ export type QueuedJobRemovalOutcome = {
207
+ kind: "removed";
208
+ state: JobKeyState;
209
+ } | {
210
+ kind: "not-found";
211
+ };
212
+ export type QueuedJobRestoreOutcome = {
213
+ kind: "restored";
214
+ state: JobKeyState;
215
+ };
216
+ /** Normalizes keyed queue policy defaults when bindings omit normalized values. */
217
+ export declare function normalizeJobKeyPolicy(args: {
218
+ keyConcurrency: JobKeyConcurrencyBinding;
219
+ queue?: JobQueuePolicyBinding;
220
+ }): NormalizedJobKeyPolicy;
221
+ /** Derives the display key and stable hash for a keyed job payload. */
222
+ export declare function deriveJobKey(args: {
223
+ service: string;
224
+ jobType: string;
225
+ payload: unknown;
226
+ template: string[];
227
+ }): Promise<DerivedJobKey>;
228
+ /** Produces a stable SHA-256 hex hash for a display key. */
229
+ export declare function stableKeyHash(value: string): Promise<string>;
230
+ /** Applies keyed admission policy to an existing key state. */
231
+ export declare function reduceAdmission(args: {
232
+ state: JobKeyState | undefined;
233
+ derived: DerivedJobKey;
234
+ request: Omit<JobAdmissionRequest, "payload" | "policy">;
235
+ policy: NormalizedJobKeyPolicy;
236
+ }): JobAdmissionOutcome;
237
+ /** Restores the replaced queued reservation when replacement lifecycle publish fails. */
238
+ export declare function reduceRestoreReplacedQueuedJob(args: {
239
+ state: JobKeyState | undefined;
240
+ derived: DerivedJobKey;
241
+ replacementJobId: string;
242
+ replaced: ReplacedQueuedJob;
243
+ now: string;
244
+ policy: NormalizedJobKeyPolicy;
245
+ submissionId?: string;
246
+ }): QueuedJobRestoreOutcome;
247
+ /** Applies active slot acquisition policy to an existing key state. */
248
+ export declare function reduceAcquireActiveSlot(args: {
249
+ state: JobKeyState | undefined;
250
+ derived: DerivedJobKey;
251
+ request: Omit<ActiveSlotAcquireRequest, "payload" | "policy">;
252
+ policy: NormalizedJobKeyPolicy;
253
+ slotToken: string;
254
+ }): ActiveSlotAcquireOutcome;
255
+ /** Removes a queued keyed-job reservation when work is terminal before start. */
256
+ export declare function reduceRemoveQueuedJob(args: {
257
+ state: JobKeyState | undefined;
258
+ jobId: string;
259
+ now: string;
260
+ submissionId?: string;
261
+ }): QueuedJobRemovalOutcome;
262
+ /** Renews a matching active slot lease in key state. */
263
+ export declare function reduceRenewHeartbeat(args: {
264
+ state: JobKeyState | undefined;
265
+ jobId: string;
266
+ slotToken: string;
267
+ now: string;
268
+ policy: NormalizedJobKeyPolicy;
269
+ }): ActiveSlotRenewOutcome;
270
+ /** Releases a matching active slot or reports a stale completion. */
271
+ export declare function reduceReleaseActiveSlot(args: {
272
+ state: JobKeyState | undefined;
273
+ jobId: string;
274
+ slotToken: string;
275
+ now: string;
276
+ }): ActiveSlotReleaseOutcome;
277
+ /** Creates a NATS KV backed coordinator for the Trellis-owned JOBS_KEYS bucket. */
278
+ export declare function createNatsJobKeyCoordinator(nats: NatsConnection, bucketPrefix?: string): JobKeyCoordinator;
279
+ /** Returns whether an unknown value is a well-formed keyed job coordination state. */
280
+ export declare function isJobKeyState(value: unknown): value is JobKeyState;