@fungi.computer/watchdog 0.1.0 → 0.1.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/docs/api/index.md CHANGED
@@ -28,10 +28,10 @@ new WatchdogError(failureKind, cause?): WatchdogError;
28
28
 
29
29
  ###### Parameters
30
30
 
31
- | Parameter | Type | Description |
32
- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
33
- | `failureKind` | \| `"store_unavailable"` \| `"store_invalid"` \| `"claim_unavailable"` \| `"execution_failed"` \| `"settlement_rejected"` \| `"wake_unavailable"` \| `"liveness_unavailable"` | - |
34
- | `cause?` | `unknown` | The original thrown value, kept for server-side diagnosis only. `cause` is already the closed category above, so this is a separate field. |
31
+ | Parameter | Type | Description |
32
+ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
33
+ | `failureKind` | \| `"store_unavailable"` \| `"store_invalid"` \| `"claim_unavailable"` \| `"drain_failed"` \| `"execution_failed"` \| `"settlement_rejected"` \| `"wake_unavailable"` \| `"liveness_unavailable"` | - |
34
+ | `cause?` | `unknown` | The original thrown value, kept for server-side diagnosis only. `cause` is already the closed category above, so this is a separate field. |
35
35
 
36
36
  ###### Returns
37
37
 
@@ -58,6 +58,7 @@ readonly cause:
58
58
  | "store_unavailable"
59
59
  | "store_invalid"
60
60
  | "claim_unavailable"
61
+ | "drain_failed"
61
62
  | "execution_failed"
62
63
  | "settlement_rejected"
63
64
  | "wake_unavailable"
@@ -81,17 +82,22 @@ readonly optional underlying?: unknown;
81
82
  ### WatchdogExecutor
82
83
 
83
84
  ```ts
84
- type WatchdogExecutor = (job, signal) => Promise<WatchdogExecutionDecision>;
85
+ type WatchdogExecutor = (
86
+ job,
87
+ signal,
88
+ attempt,
89
+ ) => Promise<WatchdogExecutionDecision>;
85
90
  ```
86
91
 
87
92
  Promise host executor for one generic running job.
88
93
 
89
94
  #### Parameters
90
95
 
91
- | Parameter | Type |
92
- | --------- | ---------------------------------------------------- |
93
- | `job` | [`WatchdogRunningJob`](effect.md#watchdogrunningjob) |
94
- | `signal` | `AbortSignal` |
96
+ | Parameter | Type |
97
+ | --------- | ------------------------------------------------------------- |
98
+ | `job` | [`WatchdogRunningJob`](effect.md#watchdogrunningjob) |
99
+ | `signal` | `AbortSignal` |
100
+ | `attempt` | [`WatchdogAttempt`](effect.md#watchdogattempt) \| `undefined` |
95
101
 
96
102
  #### Returns
97
103
 
@@ -107,6 +113,7 @@ type WatchdogOptions = Readonly<{
107
113
  owner: WatchdogSqliteOwner;
108
114
  isAlive: (job) => Promise<boolean>;
109
115
  execute: WatchdogExecutor;
116
+ retryPolicy?: (job) => Promise<WatchdogRetryPolicy | undefined>;
110
117
  wake: Readonly<{
111
118
  recompute: () => Promise<void>;
112
119
  }>;
@@ -122,7 +129,7 @@ Options for constructing the Promise facade.
122
129
 
123
130
  ```ts
124
131
  type WatchdogRuntime = Readonly<{
125
- hasPendingWork: () => Promise<boolean>;
132
+ wakeState: (now) => Promise<WatchdogWakeState>;
126
133
  ingest: (job) => Promise<WatchdogIngestResult>;
127
134
  read: (jobId) => Promise<WatchdogReadResult>;
128
135
  readQueueHead: (queue) => Promise<WatchdogQueueHead>;
@@ -159,7 +166,7 @@ type WatchdogApi = Readonly<{
159
166
  (options): Promise<ConcurrentWatchdogRuntime>;
160
167
  (options): Promise<
161
168
  Readonly<{
162
- hasPendingWork: () => Promise<boolean>;
169
+ wakeState: (now) => Promise<WatchdogWakeState>;
163
170
  ingest: (job) => Promise<WatchdogIngestResult>;
164
171
  read: (jobId) => Promise<WatchdogReadResult>;
165
172
  readQueueHead: (queue) => Promise<WatchdogQueueHead>;
@@ -188,6 +195,12 @@ Promise facade over the canonical Effect-owned runtime.
188
195
 
189
196
  ## References
190
197
 
198
+ ### WatchdogCompletingJobSchema
199
+
200
+ Re-exports [WatchdogCompletingJobSchema](effect.md#watchdogcompletingjobschema)
201
+
202
+ ---
203
+
191
204
  ### WatchdogCancellationIntentSchema
192
205
 
193
206
  Re-exports
@@ -263,6 +276,12 @@ Re-exports [EffectWatchdogExecutor](effect.md#effectwatchdogexecutor)
263
276
 
264
277
  ---
265
278
 
279
+ ### WatchdogCompletingJob
280
+
281
+ Re-exports [WatchdogCompletingJob](effect.md#watchdogcompletingjob)
282
+
283
+ ---
284
+
266
285
  ### WatchdogCancellationDecision
267
286
 
268
287
  Re-exports
@@ -410,6 +429,24 @@ Re-exports
410
429
 
411
430
  ---
412
431
 
432
+ ### WatchdogWakeState
433
+
434
+ Re-exports [WatchdogWakeState](effect.md#watchdogwakestate)
435
+
436
+ ---
437
+
438
+ ### WatchdogRetryPolicy
439
+
440
+ Re-exports [WatchdogRetryPolicy](effect.md#watchdogretrypolicy)
441
+
442
+ ---
443
+
444
+ ### WatchdogAttempt
445
+
446
+ Re-exports [WatchdogAttempt](effect.md#watchdogattempt)
447
+
448
+ ---
449
+
413
450
  ### watchdogSqliteValueSchema
414
451
 
415
452
  Re-exports [watchdogSqliteValueSchema](effect.md#watchdogsqlitevalueschema)
@@ -57,9 +57,9 @@ Open the shared Effect engine on a migrated PostgreSQL database.
57
57
 
58
58
  #### Parameters
59
59
 
60
- | Parameter | Type |
61
- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
62
- | `options` | `Readonly`\<\{ `execute`: [`WatchdogExecutor`](index.md#watchdogexecutor); `wake`: `Readonly`\<\{ `recompute`: () => `Promise`\<`void`\>; \}\>; `now?`: () => `number`; \}\> & `Readonly`\<\{ `database`: `Pick`\<`Pool`, `"query"`\>; \}\> |
60
+ | Parameter | Type |
61
+ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
62
+ | `options` | `Readonly`\<\{ `execute`: [`WatchdogExecutor`](index.md#watchdogexecutor); `retryPolicy?`: (`job`) => `Promise`\< \| `Readonly`\<\{ `baseMs`: `number`; `maxMs`: `number`; `limit`: `Readonly`\<...\> \| `Readonly`\<...\>; \}\> \| `undefined`\>; `wake`: `Readonly`\<\{ `recompute`: () => `Promise`\<`void`\>; \}\>; `now?`: () => `number`; \}\> & `Readonly`\<\{ `database`: `Pick`\<`Pool`, `"query"`\>; \}\> |
63
63
 
64
64
  #### Returns
65
65
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/watchdog",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "description": "Payload-blind durable work scheduling and settlement core",
6
6
  "type": "module",
@@ -39,7 +39,8 @@
39
39
  "effect": "4.0.2",
40
40
  "@cloudflare/workers-types": "5.20260828.1",
41
41
  "pg": "8.23.0",
42
- "@types/pg": "8.23.1"
42
+ "@types/pg": "8.23.1",
43
+ "@fungi.computer/almanac": "0.2.1"
43
44
  },
44
45
  "devDependencies": {
45
46
  "@types/node": "24.13.3",