effect
@fungi.computer/watchdog / effect
effect
Section titled “effect”Type Aliases
Section titled “Type Aliases”WatchdogQueuedJob
Section titled “WatchdogQueuedJob”WatchdogQueuedJob =
Schema.Schema.Type<typeofWatchdogQueuedJobSchema>>
Generic durable work waiting for execution.
WatchdogSettledJob
Section titled “WatchdogSettledJob”WatchdogSettledJob =
Schema.Schema.Type<typeofWatchdogSettledJobSchema>>
Generic durable work with a terminal outcome.
WatchdogSettledRecord
Section titled “WatchdogSettledRecord”WatchdogSettledRecord =
Readonly<{sequence:number;job:WatchdogSettledJob; }>
One bounded terminal-job recovery record with its durable ordering cursor.
WatchdogRunningJob
Section titled “WatchdogRunningJob”WatchdogRunningJob =
Schema.Schema.Type<typeofWatchdogRunningJobSchema>>
Generic durable work held by Watchdog’s private claim.
WatchdogStoredJob
Section titled “WatchdogStoredJob”WatchdogStoredJob =
Schema.Schema.Type<typeofWatchdogStoredJobSchema>>
Any publicly readable lifecycle state for a generic job.
WatchdogExecutionDecision
Section titled “WatchdogExecutionDecision”WatchdogExecutionDecision =
Schema.Schema.Type<typeofWatchdogExecutionDecisionSchema>>
Terminal decision returned by the host executor.
WatchdogCancellationIntent
Section titled “WatchdogCancellationIntent”WatchdogCancellationIntent =
Schema.Schema.Type<typeofWatchdogCancellationIntentSchema>>
Owner-issued durable cancellation intent.
WatchdogCancellationDecision
Section titled “WatchdogCancellationDecision”WatchdogCancellationDecision =
Readonly<{status:"recorded"|"replayed";intent:WatchdogCancellationIntent; }> |Readonly<{status:"conflict"|"missing"; }>
Result of recording an owner cancellation in its surrounding transaction.
WatchdogTransactionalProjection
Section titled “WatchdogTransactionalProjection”WatchdogTransactionalProjection =
Readonly<{readQueueHead: (queue) =>WatchdogQueueHead;enqueueAcceptedJob: (job) =>void;recordCancellationIntent: (intent) =>WatchdogCancellationDecision; }>
Narrow synchronous seam for owner-atomic queue inspection, ingest, and cancellation.
WatchdogReadResult
Section titled “WatchdogReadResult”WatchdogReadResult =
Schema.Schema.Type<typeofWatchdogReadResultSchema>>
Result of reading one generic job and its cancellation state.
WatchdogQueueHead
Section titled “WatchdogQueueHead”WatchdogQueueHead =
Schema.Schema.Type<typeofWatchdogQueueHeadSchema>>
Current queued or running job for one queue, excluding terminal history.
WatchdogIngestResult
Section titled “WatchdogIngestResult”WatchdogIngestResult =
Schema.Schema.Type<typeofWatchdogIngestResultSchema>>
Result of idempotent durable ingest.
WatchdogCancellationResult
Section titled “WatchdogCancellationResult”WatchdogCancellationResult =
Schema.Schema.Type<typeofWatchdogCancellationResultSchema>>
Result of recording a cancellation through the asynchronous runtime.
EffectWatchdogExecutor
Section titled “EffectWatchdogExecutor”EffectWatchdogExecutor =
Readonly<{execute: (job) =>Effect.Effect<WatchdogExecutionDecision,WatchdogError>>; }>
Effect-native host executor for one generic running job.
WatchdogSqliteValue
Section titled “WatchdogSqliteValue”WatchdogSqliteValue =
ArrayBuffer|string|number|null
SQLite scalar accepted by Watchdog’s structural owner capability.
WatchdogSqliteCursor
Section titled “WatchdogSqliteCursor”WatchdogSqliteCursor<
Row> > =Readonly<{toArray: () => readonlyRow[]; }>
Structural result cursor required by Watchdog’s SQLite implementation.
Type Parameters
Section titled “Type Parameters”Row extends Record<string,
WatchdogSqliteValue> = Record<string,
WatchdogSqliteValue>
WatchdogSqliteOwner
Section titled “WatchdogSqliteOwner”WatchdogSqliteOwner =
Readonly<{sql:Readonly<{exec: <Row>>(statement, …bindings) =>WatchdogSqliteCursor<Row>>; }>;transactionSync: <A>>(operation) =>A; }>
Native owner-local SQLite capability consumed by Watchdog.
EffectWatchdogOptions
Section titled “EffectWatchdogOptions”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
Section titled “WatchdogTickResult”WatchdogTickResult =
Readonly<{status:"busy"; }> |Readonly<{status:"no_ready"; }> |Readonly<{status:"settled";job:WatchdogSettledJob; }>
Result of one bounded deep tick.
WatchdogRuntimeEffect
Section titled “WatchdogRuntimeEffect”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<readonlyWatchdogSettledRecord[],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.
Variables
Section titled “Variables”WatchdogQueuedJobSchema
Section titled “WatchdogQueuedJobSchema”
constWatchdogQueuedJobSchema:Struct<{jobId:filter<filter<typeofString$>>>>;queue:filter<filter<typeofString$>>>>;lane:filter<filter<typeofString$>>>>;priority:filter<filter<typeofInt>>>>;payload: typeofUnknown;recovery:optional<Struct<{maxRecoveries:filter<filter<typeofInt>>>>; }>>;state:Literal<["queued"]>; }>
The public queued-job grammar. Payload is deliberately uninterpreted.
WatchdogSettledJobSchema
Section titled “WatchdogSettledJobSchema”
constWatchdogSettledJobSchema:Struct<{jobId:filter<filter<typeofString$>>>>;queue:filter<filter<typeofString$>>>>;lane:filter<filter<typeofString$>>>>;priority:filter<filter<typeofInt>>>>;payload: typeofUnknown;recovery:optional<Struct<{maxRecoveries:filter<filter<typeofInt>>>>; }>>;state:Literal<["settled"]>;outcome:Literal<["completed","failed","cancelled","outcome_unknown","interrupted"]>; }>
The public terminal-job grammar.
WatchdogRunningJobSchema
Section titled “WatchdogRunningJobSchema”
constWatchdogRunningJobSchema:Struct<{jobId:filter<filter<typeofString$>>>>;queue:filter<filter<typeofString$>>>>;lane:filter<filter<typeofString$>>>>;priority:filter<filter<typeofInt>>>>;payload: typeofUnknown;recovery:optional<Struct<{maxRecoveries:filter<filter<typeofInt>>>>; }>>;state:Literal<["running"]>; }>
The public running-job grammar. Private claim data is deliberately absent.
WatchdogStoredJobSchema
Section titled “WatchdogStoredJobSchema”
constWatchdogStoredJobSchema:Union<[Struct<{jobId:filter<filter<typeofString$>>>>;queue:filter<filter<typeofString$>>>>;lane:filter<filter<typeofString$>>>>;priority:filter<filter<typeofInt>>>>;payload: typeofUnknown;recovery:optional<Struct<{maxRecoveries:filter<filter<typeofInt>>>>; }>>;state:Literal<["queued"]>; }>,Struct<{jobId:filter<filter<typeofString$>>>>;queue:filter<filter<typeofString$>>>>;lane:filter<filter<typeofString$>>>>;priority:filter<filter<typeofInt>>>>;payload: typeofUnknown;recovery:optional<Struct<{maxRecoveries:filter<filter<typeofInt>>>>; }>>;state:Literal<["running"]>; }>,Struct<{jobId:filter<filter<typeofString$>>>>;queue:filter<filter<typeofString$>>>>;lane:filter<filter<typeofString$>>>>;priority:filter<filter<typeofInt>>>>;payload: typeofUnknown;recovery:optional<Struct<{maxRecoveries:filter<filter<typeofInt>>>>; }>>;state:Literal<["settled"]>;outcome:Literal<["completed","failed","cancelled","outcome_unknown","interrupted"]>; }>]>
The complete public job lifecycle grammar.
WatchdogExecutionDecisionSchema
Section titled “WatchdogExecutionDecisionSchema”
constWatchdogExecutionDecisionSchema: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.
WatchdogCancellationIntentSchema
Section titled “WatchdogCancellationIntentSchema”
constWatchdogCancellationIntentSchema:Struct<{jobId:filter<filter<typeofString$>>>>;cancellationId:filter<filter<typeofString$>>>>;onlyIfQueued:optional<typeofBoolean$>>; }>
Durable cancellation requested by the enclosing owner.
WatchdogReadResultSchema
Section titled “WatchdogReadResultSchema”
constWatchdogReadResultSchema:Union<[Struct<{status:Literal<["found"]>;job:Union<[Struct<{jobId:filter<filter<typeofString$>>>>;queue:filter<filter<typeofString$>>>>;lane:filter<filter<typeofString$>>>>;priority:filter<filter<typeofInt>>>>;payload: typeofUnknown;recovery:optional<Struct<{maxRecoveries: …; }>>;state:Literal<["queued"]>; }>,Struct<{jobId:filter<filter<typeofString$>>>>;queue:filter<filter<typeofString$>>>>;lane:filter<filter<typeofString$>>>>;priority:filter<filter<typeofInt>>>>;payload: typeofUnknown;recovery:optional<Struct<{maxRecoveries: …; }>>;state:Literal<["running"]>; }>,Struct<{jobId:filter<filter<typeofString$>>>>;queue:filter<filter<typeofString$>>>>;lane:filter<filter<typeofString$>>>>;priority:filter<filter<typeofInt>>>>;payload: typeofUnknown;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.
WatchdogQueueHeadSchema
Section titled “WatchdogQueueHeadSchema”
constWatchdogQueueHeadSchema:Union<[Struct<{state:Literal<["idle"]>; }>,Struct<{state:Literal<["queued","running"]>;jobId:filter<filter<typeofString$>>>>;cancellationRequested: typeofBoolean$; }>]>
Bounded current-work projection for one generic queue.
WatchdogIngestResultSchema
Section titled “WatchdogIngestResultSchema”
constWatchdogIngestResultSchema:Union<[Struct<{status:Literal<["queued"]>; }>,Struct<{status:Literal<["duplicate"]>; }>]>
Results returned by idempotent public ingest.
WatchdogCancellationResultSchema
Section titled “WatchdogCancellationResultSchema”
constWatchdogCancellationResultSchema:Union<[Struct<{status:Literal<["recorded","replayed"]>; }>,Struct<{status:Literal<["conflict","missing"]>; }>]>
Results returned by durable cancellation recording.
Functions
Section titled “Functions”makeRuntime()
Section titled “makeRuntime()”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<readonlyReadonly<{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.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”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>