Skip to content

effect

@fungi.computer/watchdog


@fungi.computer/watchdog / effect

WatchdogQueuedJob = Schema.Schema.Type<typeof WatchdogQueuedJobSchema>>

Generic durable work waiting for execution.


WatchdogSettledJob = Schema.Schema.Type<typeof WatchdogSettledJobSchema>>

Generic durable work with a terminal outcome.


WatchdogSettledRecord = Readonly<{ sequence: number; job: WatchdogSettledJob; }>

One bounded terminal-job recovery record with its durable ordering cursor.


WatchdogRunningJob = Schema.Schema.Type<typeof WatchdogRunningJobSchema>>

Generic durable work held by Watchdog’s private claim.


WatchdogStoredJob = Schema.Schema.Type<typeof WatchdogStoredJobSchema>>

Any publicly readable lifecycle state for a generic job.


WatchdogExecutionDecision = Schema.Schema.Type<typeof WatchdogExecutionDecisionSchema>>

Terminal decision returned by the host executor.


WatchdogCancellationIntent = Schema.Schema.Type<typeof WatchdogCancellationIntentSchema>>

Owner-issued durable cancellation intent.


WatchdogCancellationDecision = Readonly<{ status: "recorded" | "replayed"; intent: WatchdogCancellationIntent; }> | Readonly<{ status: "conflict" | "missing"; }>

Result of recording an owner cancellation in its surrounding transaction.


WatchdogTransactionalProjection = Readonly<{ readQueueHead: (queue) => WatchdogQueueHead; enqueueAcceptedJob: (job) => void; recordCancellationIntent: (intent) => WatchdogCancellationDecision; }>

Narrow synchronous seam for owner-atomic queue inspection, ingest, and cancellation.


WatchdogReadResult = Schema.Schema.Type<typeof WatchdogReadResultSchema>>

Result of reading one generic job and its cancellation state.


WatchdogQueueHead = Schema.Schema.Type<typeof WatchdogQueueHeadSchema>>

Current queued or running job for one queue, excluding terminal history.


WatchdogIngestResult = Schema.Schema.Type<typeof WatchdogIngestResultSchema>>

Result of idempotent durable ingest.


WatchdogCancellationResult = Schema.Schema.Type<typeof WatchdogCancellationResultSchema>>

Result of recording a cancellation through the asynchronous runtime.


EffectWatchdogExecutor = Readonly<{ execute: (job) => Effect.Effect<WatchdogExecutionDecision, WatchdogError>>; }>

Effect-native host executor for one generic running job.


WatchdogSqliteValue = ArrayBuffer | string | number | null

SQLite scalar accepted by Watchdog’s structural owner capability.


WatchdogSqliteCursor<Row> > = Readonly<{ toArray: () => readonly Row[]; }>

Structural result cursor required by Watchdog’s SQLite implementation.

Row extends Record<string, WatchdogSqliteValue> = Record<string, WatchdogSqliteValue>


WatchdogSqliteOwner = Readonly<{ sql: Readonly<{ exec: <Row>>(statement, …bindings) => WatchdogSqliteCursor<Row>>; }>; transactionSync: <A>>(operation) => A; }>

Native owner-local SQLite capability consumed by Watchdog.


EffectWatchdogOptions = Readonly<{ owner: WatchdogSqliteOwner; isAlive: (job) => Effect.Effect<boolean, WatchdogError>>; executor: EffectWatchdogExecutor; wake: Readonly<{ recompute: () => Effect.Effect<void, WatchdogError>>; }>; }>

Effect-native construction inputs for the deep SQLite Watchdog.


WatchdogTickResult = Readonly<{ status: "busy"; }> | Readonly<{ status: "no_ready"; }> | Readonly<{ status: "settled"; job: WatchdogSettledJob; }>

Result of one bounded deep tick.


WatchdogRuntimeEffect = Readonly<{ hasPendingWork: Effect.Effect<boolean, WatchdogError>>; ingest: (job) => Effect.Effect<WatchdogIngestResult, WatchdogError>>; read: (jobId) => Effect.Effect<WatchdogReadResult, WatchdogError>>; readQueueHead: (queue) => Effect.Effect<WatchdogQueueHead, WatchdogError>>; readSettled: (limit, afterSequence?) => Effect.Effect<readonly WatchdogSettledRecord[], WatchdogError>>; tick: () => Effect.Effect<WatchdogTickResult, WatchdogError>>; cancel: (input) => Effect.Effect<WatchdogCancellationResult, WatchdogError>>; purge: (queue) => Effect.Effect<void, WatchdogError>>; transactional: WatchdogTransactionalProjection; }>

Effect-native Watchdog runtime surface.

const WatchdogQueuedJobSchema: Struct<{ jobId: filter<filter<typeof String$>>>>; queue: filter<filter<typeof String$>>>>; lane: filter<filter<typeof String$>>>>; priority: filter<filter<typeof Int>>>>; payload: typeof Unknown; recovery: optional<Struct<{ maxRecoveries: filter<filter<typeof Int>>>>; }>>; state: Literal<["queued"]>; }>

The public queued-job grammar. Payload is deliberately uninterpreted.


const WatchdogSettledJobSchema: Struct<{ jobId: filter<filter<typeof String$>>>>; queue: filter<filter<typeof String$>>>>; lane: filter<filter<typeof String$>>>>; priority: filter<filter<typeof Int>>>>; payload: typeof Unknown; recovery: optional<Struct<{ maxRecoveries: filter<filter<typeof Int>>>>; }>>; state: Literal<["settled"]>; outcome: Literal<["completed", "failed", "cancelled", "outcome_unknown", "interrupted"]>; }>

The public terminal-job grammar.


const WatchdogRunningJobSchema: Struct<{ jobId: filter<filter<typeof String$>>>>; queue: filter<filter<typeof String$>>>>; lane: filter<filter<typeof String$>>>>; priority: filter<filter<typeof Int>>>>; payload: typeof Unknown; recovery: optional<Struct<{ maxRecoveries: filter<filter<typeof Int>>>>; }>>; state: Literal<["running"]>; }>

The public running-job grammar. Private claim data is deliberately absent.


const WatchdogStoredJobSchema: Union<[Struct<{ jobId: filter<filter<typeof String$>>>>; queue: filter<filter<typeof String$>>>>; lane: filter<filter<typeof String$>>>>; priority: filter<filter<typeof Int>>>>; payload: typeof Unknown; recovery: optional<Struct<{ maxRecoveries: filter<filter<typeof Int>>>>; }>>; state: Literal<["queued"]>; }>, Struct<{ jobId: filter<filter<typeof String$>>>>; queue: filter<filter<typeof String$>>>>; lane: filter<filter<typeof String$>>>>; priority: filter<filter<typeof Int>>>>; payload: typeof Unknown; recovery: optional<Struct<{ maxRecoveries: filter<filter<typeof Int>>>>; }>>; state: Literal<["running"]>; }>, Struct<{ jobId: filter<filter<typeof String$>>>>; queue: filter<filter<typeof String$>>>>; lane: filter<filter<typeof String$>>>>; priority: filter<filter<typeof Int>>>>; payload: typeof Unknown; recovery: optional<Struct<{ maxRecoveries: filter<filter<typeof Int>>>>; }>>; state: Literal<["settled"]>; outcome: Literal<["completed", "failed", "cancelled", "outcome_unknown", "interrupted"]>; }>]>

The complete public job lifecycle grammar.


const WatchdogExecutionDecisionSchema: Union<[Struct<{ kind: Literal<["completed"]>; }>, Struct<{ kind: Literal<["failed"]>; }>, Struct<{ kind: Literal<["cancelled"]>; }>, Struct<{ kind: Literal<["outcome_unknown"]>; }>]>

Terminal decisions returned by the execution adapter.


const WatchdogCancellationIntentSchema: Struct<{ jobId: filter<filter<typeof String$>>>>; cancellationId: filter<filter<typeof String$>>>>; onlyIfQueued: optional<typeof Boolean$>>; }>

Durable cancellation requested by the enclosing owner.


const WatchdogReadResultSchema: Union<[Struct<{ status: Literal<["found"]>; job: Union<[Struct<{ jobId: filter<filter<typeof String$>>>>; queue: filter<filter<typeof String$>>>>; lane: filter<filter<typeof String$>>>>; priority: filter<filter<typeof Int>>>>; payload: typeof Unknown; recovery: optional<Struct<{ maxRecoveries: …; }>>; state: Literal<["queued"]>; }>, Struct<{ jobId: filter<filter<typeof String$>>>>; queue: filter<filter<typeof String$>>>>; lane: filter<filter<typeof String$>>>>; priority: filter<filter<typeof Int>>>>; payload: typeof Unknown; recovery: optional<Struct<{ maxRecoveries: …; }>>; state: Literal<["running"]>; }>, Struct<{ jobId: filter<filter<typeof String$>>>>; queue: filter<filter<typeof String$>>>>; lane: filter<filter<typeof String$>>>>; priority: filter<filter<typeof Int>>>>; payload: typeof Unknown; recovery: optional<Struct<{ maxRecoveries: …; }>>; state: Literal<["settled"]>; outcome: Literal<["completed", "failed", "cancelled", "outcome_unknown", "interrupted"]>; }>]>; cancellation: Union<[Struct<{ status: Literal<["absent"]>; }>, Struct<{ status: Literal<["present"]>; cancellation: Struct<{ jobId: filter<…>; cancellationId: filter<…>; onlyIfQueued: optional<…>; }>; }>]>; }>, Struct<{ status: Literal<["missing"]>; }>]>

Results returned by public job inspection.


const WatchdogQueueHeadSchema: Union<[Struct<{ state: Literal<["idle"]>; }>, Struct<{ state: Literal<["queued", "running"]>; jobId: filter<filter<typeof String$>>>>; cancellationRequested: typeof Boolean$; }>]>

Bounded current-work projection for one generic queue.


const WatchdogIngestResultSchema: Union<[Struct<{ status: Literal<["queued"]>; }>, Struct<{ status: Literal<["duplicate"]>; }>]>

Results returned by idempotent public ingest.


const WatchdogCancellationResultSchema: Union<[Struct<{ status: Literal<["recorded", "replayed"]>; }>, Struct<{ status: Literal<["conflict", "missing"]>; }>]>

Results returned by durable cancellation recording.

makeRuntime(options): Effect<Readonly<{ hasPendingWork: Effect<boolean, WatchdogError>>; ingest: (job) => Effect<{ status: "queued"; } | { status: "duplicate"; }, WatchdogError>>; read: (jobId) => Effect<{ status: "found"; job: { jobId: string; queue: string; lane: string; priority: number; payload: unknown; recovery?: { maxRecoveries: …; }; state: "queued"; } | { jobId: string; queue: string; lane: string; priority: number; payload: unknown; recovery?: { maxRecoveries: …; }; state: "running"; } | { jobId: string; queue: string; lane: string; priority: number; payload: unknown; recovery?: { maxRecoveries: …; }; state: "settled"; outcome: "completed" | "failed" | "cancelled" | "outcome_unknown" | "interrupted"; }; cancellation: { status: "absent"; } | { status: "present"; cancellation: { jobId: string; cancellationId: string; onlyIfQueued?: … | … | …; }; }; } | { status: "missing"; }, WatchdogError>>; readQueueHead: (queue) => Effect<{ state: "idle"; } | { state: "queued" | "running"; jobId: string; cancellationRequested: boolean; }, WatchdogError>>; readSettled: (limit, afterSequence?) => Effect<readonly Readonly<{ sequence: number; job: { jobId: string; queue: string; lane: string; priority: number; payload: unknown; recovery?: { maxRecoveries: …; }; state: "settled"; outcome: "completed" | "failed" | "cancelled" | "outcome_unknown" | "interrupted"; }; }>[], WatchdogError>>; tick: () => Effect<WatchdogTickResult, WatchdogError>>; cancel: (input) => Effect<{ status: "replayed" | "recorded"; } | { status: "missing" | "conflict"; }, WatchdogError>>; purge: (queue) => Effect<void, WatchdogError>>; transactional: WatchdogTransactionalProjection; }>, WatchdogError>>

One deep tick over Watchdog-owned owner-local SQLite state.

EffectWatchdogOptions

Effect<Readonly<{ hasPendingWork: Effect<boolean, WatchdogError>; ingest: (job) => Effect<{ status: "queued"; } | { status: "duplicate"; }, WatchdogError>; read: (jobId) => Effect<{ status: "found"; job: { jobId: string; queue: string; lane: string; priority: number; payload: unknown; recovery?: { maxRecoveries: …; }; state: "queued"; } | { jobId: string; queue: string; lane: string; priority: number; payload: unknown; recovery?: { maxRecoveries: …; }; state: "running"; } | { jobId: string; queue: string; lane: string; priority: number; payload: unknown; recovery?: { maxRecoveries: …; }; state: "settled"; outcome: "completed" | "failed" | "cancelled" | "outcome_unknown" | "interrupted"; }; cancellation: { status: "absent"; } | { status: "present"; cancellation: { jobId: string; cancellationId: string; onlyIfQueued?: … | … | …; }; }; } | { status: "missing"; }, WatchdogError>; readQueueHead: (queue) => Effect<{ state: "idle"; } | { state: "queued" | "running"; jobId: string; cancellationRequested: boolean; }, WatchdogError>; readSettled: (limit, afterSequence?) => Effect<readonly Readonly<{ sequence: number; job: { jobId: string; queue: string; lane: string; priority: number; payload: unknown; recovery?: { maxRecoveries: …; }; state: "settled"; outcome: "completed" | "failed" | "cancelled" | "outcome_unknown" | "interrupted"; }; }>[], WatchdogError>; tick: () => Effect<WatchdogTickResult, WatchdogError>; cancel: (input) => Effect<{ status: "replayed" | "recorded"; } | { status: "missing" | "conflict"; }, WatchdogError>; purge: (queue) => Effect<void, WatchdogError>; transactional: WatchdogTransactionalProjection; }>, WatchdogError>