@fungi.computer/watchdog 0.0.0-stage → 0.0.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.
@@ -0,0 +1,421 @@
1
+ <!-- Generated by Botanical API docs (TypeDoc + typedoc-plugin-markdown). Do not edit. -->
2
+
3
+ [**@fungi.computer/watchdog**](README.md)
4
+
5
+ ---
6
+
7
+ [@fungi.computer/watchdog](README.md) / index
8
+
9
+ # index
10
+
11
+ ## Classes
12
+
13
+ ### WatchdogError
14
+
15
+ Typed failures owned by the generic Watchdog engine.
16
+
17
+ #### Extends
18
+
19
+ - `Error`
20
+
21
+ #### Constructors
22
+
23
+ ##### Constructor
24
+
25
+ ```ts
26
+ new WatchdogError(failureKind, cause?): WatchdogError;
27
+ ```
28
+
29
+ ###### Parameters
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. |
35
+
36
+ ###### Returns
37
+
38
+ [`WatchdogError`](#watchdogerror)
39
+
40
+ ###### Overrides
41
+
42
+ ```ts
43
+ Error.constructor;
44
+ ```
45
+
46
+ #### Properties
47
+
48
+ ##### \_tag
49
+
50
+ ```ts
51
+ readonly _tag: "WatchdogError";
52
+ ```
53
+
54
+ ##### cause
55
+
56
+ ```ts
57
+ readonly cause:
58
+ | "store_unavailable"
59
+ | "store_invalid"
60
+ | "claim_unavailable"
61
+ | "execution_failed"
62
+ | "settlement_rejected"
63
+ | "wake_unavailable"
64
+ | "liveness_unavailable";
65
+ ```
66
+
67
+ ###### Overrides
68
+
69
+ ```ts
70
+ Error.cause;
71
+ ```
72
+
73
+ ##### underlying?
74
+
75
+ ```ts
76
+ readonly optional underlying?: unknown;
77
+ ```
78
+
79
+ ## Type Aliases
80
+
81
+ ### WatchdogExecutor
82
+
83
+ ```ts
84
+ type WatchdogExecutor = (job, signal) => Promise<WatchdogExecutionDecision>;
85
+ ```
86
+
87
+ Promise host executor for one generic running job.
88
+
89
+ #### Parameters
90
+
91
+ | Parameter | Type |
92
+ | --------- | ---------------------------------------------------- |
93
+ | `job` | [`WatchdogRunningJob`](effect.md#watchdogrunningjob) |
94
+ | `signal` | `AbortSignal` |
95
+
96
+ #### Returns
97
+
98
+ `Promise`\<[`WatchdogExecutionDecision`](effect.md#watchdogexecutiondecision)\>
99
+
100
+ ---
101
+
102
+ ### WatchdogOptions
103
+
104
+ ```ts
105
+ type WatchdogOptions = Readonly<{
106
+ concurrentLane?: string;
107
+ owner: WatchdogSqliteOwner;
108
+ isAlive: (job) => Promise<boolean>;
109
+ execute: WatchdogExecutor;
110
+ wake: Readonly<{
111
+ recompute: () => Promise<void>;
112
+ }>;
113
+ project?: WatchdogQueueProjector;
114
+ }>;
115
+ ```
116
+
117
+ Options for constructing the Promise facade.
118
+
119
+ ---
120
+
121
+ ### WatchdogRuntime
122
+
123
+ ```ts
124
+ type WatchdogRuntime = Readonly<{
125
+ hasPendingWork: () => Promise<boolean>;
126
+ ingest: (job) => Promise<WatchdogIngestResult>;
127
+ read: (jobId) => Promise<WatchdogReadResult>;
128
+ readQueueHead: (queue) => Promise<WatchdogQueueHead>;
129
+ tick: () => Promise<WatchdogTickResult>;
130
+ cancel: (input) => Promise<WatchdogCancellationResult>;
131
+ failLane: (input) => Promise<WatchdogLaneFailureResult>;
132
+ purge: (queue) => Promise<void>;
133
+ transactional: WatchdogTransactionalProjection;
134
+ }>;
135
+ ```
136
+
137
+ Promise facade over the canonical Effect runtime.
138
+
139
+ ---
140
+
141
+ ### ConcurrentWatchdogRuntime
142
+
143
+ ```ts
144
+ type ConcurrentWatchdogRuntime = WatchdogRuntime &
145
+ Readonly<{
146
+ tickConcurrent: () => Promise<WatchdogTickResult>;
147
+ }>;
148
+ ```
149
+
150
+ Promise runtime with the construction-time concurrent lane.
151
+
152
+ ---
153
+
154
+ ### WatchdogApi
155
+
156
+ ```ts
157
+ type WatchdogApi = Readonly<{
158
+ make: {
159
+ (options): Promise<ConcurrentWatchdogRuntime>;
160
+ (options): Promise<
161
+ Readonly<{
162
+ hasPendingWork: () => Promise<boolean>;
163
+ ingest: (job) => Promise<WatchdogIngestResult>;
164
+ read: (jobId) => Promise<WatchdogReadResult>;
165
+ readQueueHead: (queue) => Promise<WatchdogQueueHead>;
166
+ tick: () => Promise<WatchdogTickResult>;
167
+ cancel: (input) => Promise<WatchdogCancellationResult>;
168
+ failLane: (input) => Promise<WatchdogLaneFailureResult>;
169
+ purge: (queue) => Promise<void>;
170
+ transactional: WatchdogTransactionalProjection;
171
+ }>
172
+ >;
173
+ };
174
+ }>;
175
+ ```
176
+
177
+ Factory for the Promise facade.
178
+
179
+ ## Variables
180
+
181
+ ### Watchdog
182
+
183
+ ```ts
184
+ const Watchdog: WatchdogApi;
185
+ ```
186
+
187
+ Promise facade over the canonical Effect-owned runtime.
188
+
189
+ ## References
190
+
191
+ ### WatchdogCancellationIntentSchema
192
+
193
+ Re-exports
194
+ [WatchdogCancellationIntentSchema](effect.md#watchdogcancellationintentschema)
195
+
196
+ ---
197
+
198
+ ### WatchdogCancellationResultSchema
199
+
200
+ Re-exports
201
+ [WatchdogCancellationResultSchema](effect.md#watchdogcancellationresultschema)
202
+
203
+ ---
204
+
205
+ ### WatchdogExecutionDecisionSchema
206
+
207
+ Re-exports
208
+ [WatchdogExecutionDecisionSchema](effect.md#watchdogexecutiondecisionschema)
209
+
210
+ ---
211
+
212
+ ### WatchdogIngestResultSchema
213
+
214
+ Re-exports [WatchdogIngestResultSchema](effect.md#watchdogingestresultschema)
215
+
216
+ ---
217
+
218
+ ### WatchdogQueuedJobSchema
219
+
220
+ Re-exports [WatchdogQueuedJobSchema](effect.md#watchdogqueuedjobschema)
221
+
222
+ ---
223
+
224
+ ### WatchdogQueueHeadSchema
225
+
226
+ Re-exports [WatchdogQueueHeadSchema](effect.md#watchdogqueueheadschema)
227
+
228
+ ---
229
+
230
+ ### WatchdogReadResultSchema
231
+
232
+ Re-exports [WatchdogReadResultSchema](effect.md#watchdogreadresultschema)
233
+
234
+ ---
235
+
236
+ ### WatchdogRunningJobSchema
237
+
238
+ Re-exports [WatchdogRunningJobSchema](effect.md#watchdogrunningjobschema)
239
+
240
+ ---
241
+
242
+ ### WatchdogSettledJobSchema
243
+
244
+ Re-exports [WatchdogSettledJobSchema](effect.md#watchdogsettledjobschema)
245
+
246
+ ---
247
+
248
+ ### WatchdogStoredJobSchema
249
+
250
+ Re-exports [WatchdogStoredJobSchema](effect.md#watchdogstoredjobschema)
251
+
252
+ ---
253
+
254
+ ### EffectWatchdogOptions
255
+
256
+ Re-exports [EffectWatchdogOptions](effect.md#effectwatchdogoptions)
257
+
258
+ ---
259
+
260
+ ### EffectWatchdogExecutor
261
+
262
+ Re-exports [EffectWatchdogExecutor](effect.md#effectwatchdogexecutor)
263
+
264
+ ---
265
+
266
+ ### WatchdogCancellationDecision
267
+
268
+ Re-exports
269
+ [WatchdogCancellationDecision](effect.md#watchdogcancellationdecision)
270
+
271
+ ---
272
+
273
+ ### WatchdogCancellationIntent
274
+
275
+ Re-exports [WatchdogCancellationIntent](effect.md#watchdogcancellationintent)
276
+
277
+ ---
278
+
279
+ ### WatchdogCancellationResult
280
+
281
+ Re-exports [WatchdogCancellationResult](effect.md#watchdogcancellationresult)
282
+
283
+ ---
284
+
285
+ ### WatchdogExecutionDecision
286
+
287
+ Re-exports [WatchdogExecutionDecision](effect.md#watchdogexecutiondecision)
288
+
289
+ ---
290
+
291
+ ### WatchdogIngestResult
292
+
293
+ Re-exports [WatchdogIngestResult](effect.md#watchdogingestresult)
294
+
295
+ ---
296
+
297
+ ### WatchdogLivenessUnknown
298
+
299
+ Re-exports [WatchdogLivenessUnknown](effect.md#watchdoglivenessunknown)
300
+
301
+ ---
302
+
303
+ ### WatchdogLaneFailure
304
+
305
+ Re-exports [WatchdogLaneFailure](effect.md#watchdoglanefailure)
306
+
307
+ ---
308
+
309
+ ### WatchdogLaneFailureResult
310
+
311
+ Re-exports [WatchdogLaneFailureResult](effect.md#watchdoglanefailureresult)
312
+
313
+ ---
314
+
315
+ ### WatchdogQueuedJob
316
+
317
+ Re-exports [WatchdogQueuedJob](effect.md#watchdogqueuedjob)
318
+
319
+ ---
320
+
321
+ ### WatchdogQueueHead
322
+
323
+ Re-exports [WatchdogQueueHead](effect.md#watchdogqueuehead)
324
+
325
+ ---
326
+
327
+ ### WatchdogQueueProjector
328
+
329
+ Re-exports [WatchdogQueueProjector](effect.md#watchdogqueueprojector)
330
+
331
+ ---
332
+
333
+ ### WatchdogQueueTransition
334
+
335
+ Re-exports [WatchdogQueueTransition](effect.md#watchdogqueuetransition)
336
+
337
+ ---
338
+
339
+ ### WatchdogReadResult
340
+
341
+ Re-exports [WatchdogReadResult](effect.md#watchdogreadresult)
342
+
343
+ ---
344
+
345
+ ### WatchdogRunningJob
346
+
347
+ Re-exports [WatchdogRunningJob](effect.md#watchdogrunningjob)
348
+
349
+ ---
350
+
351
+ ### WatchdogRuntimeEffect
352
+
353
+ Re-exports [WatchdogRuntimeEffect](effect.md#watchdogruntimeeffect)
354
+
355
+ ---
356
+
357
+ ### ConcurrentWatchdogRuntimeEffect
358
+
359
+ Re-exports
360
+ [ConcurrentWatchdogRuntimeEffect](effect.md#concurrentwatchdogruntimeeffect)
361
+
362
+ ---
363
+
364
+ ### WatchdogSettledJob
365
+
366
+ Re-exports [WatchdogSettledJob](effect.md#watchdogsettledjob)
367
+
368
+ ---
369
+
370
+ ### WatchdogSqliteCursor
371
+
372
+ Re-exports [WatchdogSqliteCursor](effect.md#watchdogsqlitecursor)
373
+
374
+ ---
375
+
376
+ ### WatchdogSqliteOwner
377
+
378
+ Re-exports [WatchdogSqliteOwner](effect.md#watchdogsqliteowner)
379
+
380
+ ---
381
+
382
+ ### WatchdogSqliteValue
383
+
384
+ Re-exports [WatchdogSqliteValue](effect.md#watchdogsqlitevalue)
385
+
386
+ ---
387
+
388
+ ### WatchdogSqliteRow
389
+
390
+ Re-exports [WatchdogSqliteRow](effect.md#watchdogsqliterow)
391
+
392
+ ---
393
+
394
+ ### WatchdogStoredJob
395
+
396
+ Re-exports [WatchdogStoredJob](effect.md#watchdogstoredjob)
397
+
398
+ ---
399
+
400
+ ### WatchdogTickResult
401
+
402
+ Re-exports [WatchdogTickResult](effect.md#watchdogtickresult)
403
+
404
+ ---
405
+
406
+ ### WatchdogTransactionalProjection
407
+
408
+ Re-exports
409
+ [WatchdogTransactionalProjection](effect.md#watchdogtransactionalprojection)
410
+
411
+ ---
412
+
413
+ ### watchdogSqliteValueSchema
414
+
415
+ Re-exports [watchdogSqliteValueSchema](effect.md#watchdogsqlitevalueschema)
416
+
417
+ ---
418
+
419
+ ### watchdogSqliteRowSchema
420
+
421
+ Re-exports [watchdogSqliteRowSchema](effect.md#watchdogsqliterowschema)
@@ -0,0 +1,57 @@
1
+ <!-- Generated by Botanical API docs (TypeDoc + typedoc-plugin-markdown). Do not edit. -->
2
+
3
+ [**@fungi.computer/watchdog**](README.md)
4
+
5
+ ---
6
+
7
+ [@fungi.computer/watchdog](README.md) / node-sqlite
8
+
9
+ # node-sqlite
10
+
11
+ ## Type Aliases
12
+
13
+ ### NodeSqliteCursor
14
+
15
+ ```ts
16
+ type NodeSqliteCursor = WatchdogSqliteCursor &
17
+ Readonly<{
18
+ one: () => WatchdogSqliteRow;
19
+ }>;
20
+ ```
21
+
22
+ Materialized Node SQLite rows, including the exact-one native operation.
23
+
24
+ ---
25
+
26
+ ### NodeSqliteOwner
27
+
28
+ ```ts
29
+ type NodeSqliteOwner = Omit<WatchdogSqliteOwner, "sql"> &
30
+ Readonly<{
31
+ sql: Readonly<{
32
+ exec: (statement, ...bindings) => NodeSqliteCursor;
33
+ }>;
34
+ }>;
35
+ ```
36
+
37
+ Concrete Node adapter; generic Watchdog owners need only toArray().
38
+
39
+ ## Functions
40
+
41
+ ### fromNodeSqlite()
42
+
43
+ ```ts
44
+ function fromNodeSqlite(database): NodeSqliteOwner;
45
+ ```
46
+
47
+ Adapt a caller-owned Node SQLite database; the caller retains its lifetime.
48
+
49
+ #### Parameters
50
+
51
+ | Parameter | Type |
52
+ | ---------- | -------------- |
53
+ | `database` | `DatabaseSync` |
54
+
55
+ #### Returns
56
+
57
+ [`NodeSqliteOwner`](#nodesqliteowner)
@@ -0,0 +1,102 @@
1
+ <!-- Generated by Botanical API docs (TypeDoc + typedoc-plugin-markdown). Do not edit. -->
2
+
3
+ [**@fungi.computer/watchdog**](README.md)
4
+
5
+ ---
6
+
7
+ [@fungi.computer/watchdog](README.md) / postgres
8
+
9
+ # postgres
10
+
11
+ ## Type Aliases
12
+
13
+ ### PostgresWatchdog
14
+
15
+ ```ts
16
+ type PostgresWatchdog = AsyncWatchdogRuntime &
17
+ Readonly<{
18
+ enqueue: (client, job) => Promise<void>;
19
+ }>;
20
+ ```
21
+
22
+ PostgreSQL runtime with admission joined to the caller's checked-out client.
23
+
24
+ ---
25
+
26
+ ### PostgresPurgeStatement
27
+
28
+ ```ts
29
+ type PostgresPurgeStatement = Readonly<{
30
+ text: string;
31
+ values: readonly (string | number | null)[];
32
+ }>;
33
+ ```
34
+
35
+ Parameterized queue purge joined to a producer's existing PostgreSQL
36
+ transaction.
37
+
38
+ ## Variables
39
+
40
+ ### watchdogPostgresSchema
41
+
42
+ ```ts
43
+ const watchdogPostgresSchema: readonly string[];
44
+ ```
45
+
46
+ Package-owned schema statements, to run through the deployment migration owner.
47
+
48
+ ## Functions
49
+
50
+ ### createPostgresWatchdog()
51
+
52
+ ```ts
53
+ function createPostgresWatchdog(options): PostgresWatchdog;
54
+ ```
55
+
56
+ Open the shared Effect engine on a migrated PostgreSQL database.
57
+
58
+ #### Parameters
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"`\>; \}\> |
63
+
64
+ #### Returns
65
+
66
+ [`PostgresWatchdog`](#postgreswatchdog)
67
+
68
+ ---
69
+
70
+ ### purgePostgresQueues()
71
+
72
+ ```ts
73
+ function purgePostgresQueues(source): readonly Readonly<{
74
+ text: string;
75
+ values: readonly (string | number | null)[];
76
+ }>[];
77
+ ```
78
+
79
+ Purge every attempt in the queues yielded by trusted producer SQL.
80
+
81
+ #### Parameters
82
+
83
+ | Parameter | Type |
84
+ | --------- | --------------------------------------------------- |
85
+ | `source` | [`PostgresPurgeStatement`](#postgrespurgestatement) |
86
+
87
+ #### Returns
88
+
89
+ readonly `Readonly`\<\{ `text`: `string`; `values`: readonly (`string` \|
90
+ `number` \| `null`)[]; \}\>[]
91
+
92
+ ## References
93
+
94
+ ### AsyncWatchdogOptions
95
+
96
+ Re-exports [AsyncWatchdogOptions](d1.md#asyncwatchdogoptions)
97
+
98
+ ---
99
+
100
+ ### AsyncWatchdogRuntime
101
+
102
+ Re-exports [AsyncWatchdogRuntime](d1.md#asyncwatchdogruntime)
package/package.json CHANGED
@@ -1,6 +1,81 @@
1
1
  {
2
2
  "name": "@fungi.computer/watchdog",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.0.1",
4
+ "author": "Levi <levi@technomancy.dev>",
5
+ "description": "Payload-blind durable work scheduling and settlement core",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./effect": {
15
+ "types": "./dist/effect.d.ts",
16
+ "import": "./dist/effect.js"
17
+ },
18
+ "./d1": {
19
+ "types": "./dist/d1.d.ts",
20
+ "import": "./dist/d1.js"
21
+ },
22
+ "./postgres": {
23
+ "types": "./dist/postgres.d.ts",
24
+ "import": "./dist/postgres.js"
25
+ },
26
+ "./node-sqlite": {
27
+ "types": "./dist/node-sqlite.d.ts",
28
+ "import": "./dist/node-sqlite.js"
29
+ }
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "docs/api",
34
+ "README.md",
35
+ "LICENSE"
36
+ ],
37
+ "dependencies": {
38
+ "@fungi.computer/cairn": "0.0.1",
39
+ "effect": "4.0.2",
40
+ "@cloudflare/workers-types": "5.20260828.1",
41
+ "pg": "8.23.0",
42
+ "@types/pg": "8.23.1"
43
+ },
44
+ "devDependencies": {
45
+ "@types/node": "24.13.3",
46
+ "typescript": "5.9.3",
47
+ "vitest": "4.1.11"
48
+ },
49
+ "botanical": {
50
+ "role": "package",
51
+ "operations": {
52
+ "lint": "required",
53
+ "typecheck": "required",
54
+ "build": "required",
55
+ "test": "required",
56
+ "docs": "required",
57
+ "pack": "required",
58
+ "smoke": "required",
59
+ "stranger": "required"
60
+ }
61
+ },
62
+ "license": "MIT",
63
+ "repository": {
64
+ "type": "git",
65
+ "url": "git+https://github.com/fungi-computer/watchdog.git"
66
+ },
67
+ "scripts": {
68
+ "lint": "eslint src test --max-warnings=0 && ../../node_modules/.bin/oxlint --config ../../oxlint.config.ts --deny-warnings src test",
69
+ "typecheck": "tsc -p tsconfig.json --noEmit",
70
+ "build": "pnpm run clean && tsc -p tsconfig.build.json",
71
+ "clean": "node --input-type=module --eval \"import { rm } from 'node:fs/promises'; await rm('dist', { recursive: true, force: true });\"",
72
+ "test": "vitest run",
73
+ "docs": "tsx ../../tooling/repository/src/docs/cli.ts check --root ../..",
74
+ "docs:write": "tsx ../../tooling/repository/src/docs/cli.ts write --root ../..",
75
+ "pack": "mkdir -p ../../.botanical/watchdog-pack && pnpm pack --pack-destination ../../.botanical/watchdog-pack",
76
+ "smoke": "node --input-type=module -e \"import('./dist/index.js').then(({Watchdog}) => { if (!Watchdog) process.exit(1); })\"",
77
+ "stranger": "tsx ../../tooling/repository/src/artifacts/cli.ts --repo-root ../.. .",
78
+ "format:check": "node ../../tooling/repository/scripts/format-package-check.mjs",
79
+ "lint:anti-slop": "node ../../tooling/repository/scripts/lint-package-anti-slop.mjs"
80
+ }
6
81
  }