effect-jobs 0.1.0-alpha.0
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/CHANGELOG.md +16 -0
- package/LICENSE +22 -0
- package/README.md +142 -0
- package/dist/Job.d.ts +33 -0
- package/dist/Job.d.ts.map +1 -0
- package/dist/Job.js +66 -0
- package/dist/Job.js.map +1 -0
- package/dist/JobConsumer.d.ts +34 -0
- package/dist/JobConsumer.d.ts.map +1 -0
- package/dist/JobConsumer.js +28 -0
- package/dist/JobConsumer.js.map +1 -0
- package/dist/JobContract.d.ts +128 -0
- package/dist/JobContract.d.ts.map +1 -0
- package/dist/JobContract.js +15 -0
- package/dist/JobContract.js.map +1 -0
- package/dist/JobFailure.d.ts +51 -0
- package/dist/JobFailure.d.ts.map +1 -0
- package/dist/JobFailure.js +34 -0
- package/dist/JobFailure.js.map +1 -0
- package/dist/JobId.d.ts +5 -0
- package/dist/JobId.d.ts.map +1 -0
- package/dist/JobId.js +4 -0
- package/dist/JobId.js.map +1 -0
- package/dist/JobIdentity.d.ts +54 -0
- package/dist/JobIdentity.d.ts.map +1 -0
- package/dist/JobIdentity.js +82 -0
- package/dist/JobIdentity.js.map +1 -0
- package/dist/JobLifecycle.d.ts +173 -0
- package/dist/JobLifecycle.d.ts.map +1 -0
- package/dist/JobLifecycle.js +234 -0
- package/dist/JobLifecycle.js.map +1 -0
- package/dist/JobPayload.d.ts +18 -0
- package/dist/JobPayload.d.ts.map +1 -0
- package/dist/JobPayload.js +10 -0
- package/dist/JobPayload.js.map +1 -0
- package/dist/JobPayloadCodec.d.ts +14 -0
- package/dist/JobPayloadCodec.d.ts.map +1 -0
- package/dist/JobPayloadCodec.js +78 -0
- package/dist/JobPayloadCodec.js.map +1 -0
- package/dist/JobPolicy.d.ts +50 -0
- package/dist/JobPolicy.d.ts.map +1 -0
- package/dist/JobPolicy.js +85 -0
- package/dist/JobPolicy.js.map +1 -0
- package/dist/JobProducer.d.ts +14 -0
- package/dist/JobProducer.d.ts.map +1 -0
- package/dist/JobProducer.js +23 -0
- package/dist/JobProducer.js.map +1 -0
- package/dist/JobQueue.d.ts +16 -0
- package/dist/JobQueue.d.ts.map +1 -0
- package/dist/JobQueue.js +16 -0
- package/dist/JobQueue.js.map +1 -0
- package/dist/JobRegistry.d.ts +37 -0
- package/dist/JobRegistry.d.ts.map +1 -0
- package/dist/JobRegistry.js +47 -0
- package/dist/JobRegistry.js.map +1 -0
- package/dist/JobStore.d.ts +348 -0
- package/dist/JobStore.d.ts.map +1 -0
- package/dist/JobStore.js +19 -0
- package/dist/JobStore.js.map +1 -0
- package/dist/JobTelemetry.d.ts +7 -0
- package/dist/JobTelemetry.d.ts.map +1 -0
- package/dist/JobTelemetry.js +61 -0
- package/dist/JobTelemetry.js.map +1 -0
- package/dist/JobTransaction.d.ts +24 -0
- package/dist/JobTransaction.d.ts.map +1 -0
- package/dist/JobTransaction.js +7 -0
- package/dist/JobTransaction.js.map +1 -0
- package/dist/JobWorker.d.ts +24 -0
- package/dist/JobWorker.d.ts.map +1 -0
- package/dist/JobWorker.js +155 -0
- package/dist/JobWorker.js.map +1 -0
- package/dist/JobWorkerRuntime.d.ts +18 -0
- package/dist/JobWorkerRuntime.d.ts.map +1 -0
- package/dist/JobWorkerRuntime.js +5 -0
- package/dist/JobWorkerRuntime.js.map +1 -0
- package/dist/PollingJobWorker.d.ts +9 -0
- package/dist/PollingJobWorker.d.ts.map +1 -0
- package/dist/PollingJobWorker.js +54 -0
- package/dist/PollingJobWorker.js.map +1 -0
- package/dist/PostgreSqlDrizzleSchema.d.ts +432 -0
- package/dist/PostgreSqlDrizzleSchema.d.ts.map +1 -0
- package/dist/PostgreSqlDrizzleSchema.js +72 -0
- package/dist/PostgreSqlDrizzleSchema.js.map +1 -0
- package/dist/PostgreSqlJobs.d.ts +25 -0
- package/dist/PostgreSqlJobs.d.ts.map +1 -0
- package/dist/PostgreSqlJobs.js +38 -0
- package/dist/PostgreSqlJobs.js.map +1 -0
- package/dist/PostgreSqlSchema.d.ts +30 -0
- package/dist/PostgreSqlSchema.d.ts.map +1 -0
- package/dist/PostgreSqlSchema.js +63 -0
- package/dist/PostgreSqlSchema.js.map +1 -0
- package/dist/PostgreSqlTransaction.d.ts +42 -0
- package/dist/PostgreSqlTransaction.d.ts.map +1 -0
- package/dist/PostgreSqlTransaction.js +9 -0
- package/dist/PostgreSqlTransaction.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/JobTransaction.d.ts +16 -0
- package/dist/internal/JobTransaction.d.ts.map +1 -0
- package/dist/internal/JobTransaction.js +21 -0
- package/dist/internal/JobTransaction.js.map +1 -0
- package/dist/internal/codec/CanonicalJson.d.ts +9 -0
- package/dist/internal/codec/CanonicalJson.d.ts.map +1 -0
- package/dist/internal/codec/CanonicalJson.js +184 -0
- package/dist/internal/codec/CanonicalJson.js.map +1 -0
- package/dist/internal/codec/ProtectedProjection.d.ts +12 -0
- package/dist/internal/codec/ProtectedProjection.d.ts.map +1 -0
- package/dist/internal/codec/ProtectedProjection.js +121 -0
- package/dist/internal/codec/ProtectedProjection.js.map +1 -0
- package/dist/internal/lifecycle/Artifacts.d.ts +6 -0
- package/dist/internal/lifecycle/Artifacts.d.ts.map +1 -0
- package/dist/internal/lifecycle/Artifacts.js +49 -0
- package/dist/internal/lifecycle/Artifacts.js.map +1 -0
- package/dist/internal/lifecycle/Reconciliation.d.ts +82 -0
- package/dist/internal/lifecycle/Reconciliation.d.ts.map +1 -0
- package/dist/internal/lifecycle/Reconciliation.js +98 -0
- package/dist/internal/lifecycle/Reconciliation.js.map +1 -0
- package/dist/internal/postgresql/Producer.d.ts +14 -0
- package/dist/internal/postgresql/Producer.d.ts.map +1 -0
- package/dist/internal/postgresql/Producer.js +55 -0
- package/dist/internal/postgresql/Producer.js.map +1 -0
- package/dist/internal/postgresql/Readiness.d.ts +5 -0
- package/dist/internal/postgresql/Readiness.d.ts.map +1 -0
- package/dist/internal/postgresql/Readiness.js +53 -0
- package/dist/internal/postgresql/Readiness.js.map +1 -0
- package/dist/internal/postgresql/Rows.d.ts +45 -0
- package/dist/internal/postgresql/Rows.d.ts.map +1 -0
- package/dist/internal/postgresql/Rows.js +75 -0
- package/dist/internal/postgresql/Rows.js.map +1 -0
- package/dist/internal/postgresql/Store.d.ts +5 -0
- package/dist/internal/postgresql/Store.d.ts.map +1 -0
- package/dist/internal/postgresql/Store.js +211 -0
- package/dist/internal/postgresql/Store.js.map +1 -0
- package/dist/internal/worker/Capability.d.ts +106 -0
- package/dist/internal/worker/Capability.d.ts.map +1 -0
- package/dist/internal/worker/Capability.js +11 -0
- package/dist/internal/worker/Capability.js.map +1 -0
- package/dist/internal/worker/Drain.d.ts +22 -0
- package/dist/internal/worker/Drain.d.ts.map +1 -0
- package/dist/internal/worker/Drain.js +59 -0
- package/dist/internal/worker/Drain.js.map +1 -0
- package/dist/internal/worker/Execution.d.ts +7 -0
- package/dist/internal/worker/Execution.d.ts.map +1 -0
- package/dist/internal/worker/Execution.js +125 -0
- package/dist/internal/worker/Execution.js.map +1 -0
- package/dist/internal/worker/Results.d.ts +108 -0
- package/dist/internal/worker/Results.d.ts.map +1 -0
- package/dist/internal/worker/Results.js +3 -0
- package/dist/internal/worker/Results.js.map +1 -0
- package/package.json +169 -0
- package/specs/architecture-decisions.md +841 -0
- package/specs/core-contract.md +323 -0
- package/specs/drizzle-compatibility.md +167 -0
- package/specs/postgresql-backend.md +291 -0
- package/specs/release-qualification.md +107 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JobId.js","sourceRoot":"","sources":["../src/JobId.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,oFAAoF;AACpF,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CACrC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EACnC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAClC,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export declare const nameFormat = "^[a-z][a-z0-9.-]*$";
|
|
3
|
+
export declare const QueueName: Schema.String;
|
|
4
|
+
export declare const JobKind: Schema.String;
|
|
5
|
+
export declare const OperationName: Schema.String;
|
|
6
|
+
export declare const SlotName: Schema.String;
|
|
7
|
+
export declare const JobVersion: Schema.Int;
|
|
8
|
+
export declare const CatalogIdentity: Schema.Struct<{
|
|
9
|
+
readonly queue: Schema.String;
|
|
10
|
+
readonly kind: Schema.String;
|
|
11
|
+
readonly version: Schema.Int;
|
|
12
|
+
}>;
|
|
13
|
+
export interface CatalogIdentity<Queue extends string = string, Kind extends string = string, Version extends number = number> {
|
|
14
|
+
readonly queue: Queue;
|
|
15
|
+
readonly kind: Kind;
|
|
16
|
+
readonly version: Version;
|
|
17
|
+
}
|
|
18
|
+
declare const InvalidOperationId_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
19
|
+
readonly _tag: "InvalidOperationId";
|
|
20
|
+
} & Readonly<A>;
|
|
21
|
+
export declare class InvalidOperationId extends InvalidOperationId_base<{
|
|
22
|
+
readonly rule: "unicode-scalars" | "no-nul" | "utf8-length";
|
|
23
|
+
readonly byteLength?: number;
|
|
24
|
+
}> {
|
|
25
|
+
}
|
|
26
|
+
/** Never echoes the possibly sensitive operation ID. Equality is exact. */
|
|
27
|
+
export declare const validateOperationId: (value: string) => void;
|
|
28
|
+
export declare const OperationId: Schema.String;
|
|
29
|
+
export declare const ProducerIdentity: Schema.Struct<{
|
|
30
|
+
readonly operation: Schema.String;
|
|
31
|
+
readonly operationId: Schema.String;
|
|
32
|
+
readonly slot: Schema.String;
|
|
33
|
+
}>;
|
|
34
|
+
export interface ProducerIdentity<Operation extends string = string, Slot extends string = string> {
|
|
35
|
+
readonly operation: Operation;
|
|
36
|
+
readonly operationId: string;
|
|
37
|
+
readonly slot: Slot;
|
|
38
|
+
}
|
|
39
|
+
declare const JobDeclarationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
40
|
+
readonly _tag: "JobDeclarationError";
|
|
41
|
+
} & Readonly<A>;
|
|
42
|
+
export declare class JobDeclarationError extends JobDeclarationError_base<{
|
|
43
|
+
readonly field: "operation" | "slots" | `slots[${number}]`;
|
|
44
|
+
readonly value?: string;
|
|
45
|
+
readonly expected: string;
|
|
46
|
+
}> {
|
|
47
|
+
}
|
|
48
|
+
/** Called synchronously by the later producer factory, before returning a declaration. */
|
|
49
|
+
export declare const validateProducerDeclaration: (input: {
|
|
50
|
+
readonly operation: string;
|
|
51
|
+
readonly slots: ReadonlyArray<string>;
|
|
52
|
+
}) => void;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=JobIdentity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JobIdentity.d.ts","sourceRoot":"","sources":["../src/JobIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,EAAE,MAAM,QAAQ,CAAA;AAErC,eAAO,MAAM,UAAU,uBAAuB,CAAA;AAW9C,eAAO,MAAM,SAAS,eAAW,CAAA;AACjC,eAAO,MAAM,OAAO,eAAY,CAAA;AAChC,eAAO,MAAM,aAAa,eAAY,CAAA;AACtC,eAAO,MAAM,QAAQ,eAAY,CAAA;AACjC,eAAO,MAAM,UAAU,YAEtB,CAAA;AAED,eAAO,MAAM,eAAe;;;;EAI1B,CAAA;AACF,MAAM,WAAW,eAAe,CAC9B,KAAK,SAAS,MAAM,GAAG,MAAM,EAC7B,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import { Data, Schema } from "effect";
|
|
2
|
+
export const nameFormat = "^[a-z][a-z0-9.-]*$";
|
|
3
|
+
const namePattern = /^[a-z][a-z0-9.-]*$/u;
|
|
4
|
+
const name = (maximum) => Schema.String.pipe(Schema.check(Schema.isMinLength(1), Schema.isMaxLength(maximum), Schema.isPattern(namePattern)));
|
|
5
|
+
export const QueueName = name(64);
|
|
6
|
+
export const JobKind = name(128);
|
|
7
|
+
export const OperationName = name(128);
|
|
8
|
+
export const SlotName = name(128);
|
|
9
|
+
export const JobVersion = Schema.Int.pipe(Schema.check(Schema.isBetween({ minimum: 1, maximum: 32_767 })));
|
|
10
|
+
export const CatalogIdentity = Schema.Struct({
|
|
11
|
+
queue: QueueName,
|
|
12
|
+
kind: JobKind,
|
|
13
|
+
version: JobVersion
|
|
14
|
+
});
|
|
15
|
+
const utf8 = new TextEncoder();
|
|
16
|
+
const validScalars = (value) => {
|
|
17
|
+
for (const scalar of value) {
|
|
18
|
+
const code = scalar.codePointAt(0);
|
|
19
|
+
if (code >= 0xd800 && code <= 0xdfff) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
};
|
|
25
|
+
export class InvalidOperationId extends Data.TaggedError("InvalidOperationId") {
|
|
26
|
+
}
|
|
27
|
+
/** Never echoes the possibly sensitive operation ID. Equality is exact. */
|
|
28
|
+
export const validateOperationId = (value) => {
|
|
29
|
+
if (!validScalars(value)) {
|
|
30
|
+
throw new InvalidOperationId({ rule: "unicode-scalars" });
|
|
31
|
+
}
|
|
32
|
+
if (value.includes("\u0000")) {
|
|
33
|
+
throw new InvalidOperationId({ rule: "no-nul" });
|
|
34
|
+
}
|
|
35
|
+
const byteLength = utf8.encode(value).byteLength;
|
|
36
|
+
if (byteLength < 1 || byteLength > 256) {
|
|
37
|
+
throw new InvalidOperationId({ rule: "utf8-length", byteLength });
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
export const OperationId = Schema.String.pipe(Schema.check(Schema.makeFilter((value) => {
|
|
41
|
+
const length = utf8.encode(value).byteLength;
|
|
42
|
+
return (validScalars(value) && !value.includes("\u0000") && length >= 1 && length <= 256);
|
|
43
|
+
})));
|
|
44
|
+
export const ProducerIdentity = Schema.Struct({
|
|
45
|
+
operation: OperationName,
|
|
46
|
+
operationId: OperationId,
|
|
47
|
+
slot: SlotName
|
|
48
|
+
});
|
|
49
|
+
export class JobDeclarationError extends Data.TaggedError("JobDeclarationError") {
|
|
50
|
+
}
|
|
51
|
+
/** Called synchronously by the later producer factory, before returning a declaration. */
|
|
52
|
+
export const validateProducerDeclaration = (input) => {
|
|
53
|
+
const expected = `1–128 ASCII characters matching ${nameFormat}`;
|
|
54
|
+
if (!Schema.is(OperationName)(input.operation)) {
|
|
55
|
+
throw new JobDeclarationError({
|
|
56
|
+
field: "operation",
|
|
57
|
+
value: input.operation,
|
|
58
|
+
expected
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (input.slots.length === 0) {
|
|
62
|
+
throw new JobDeclarationError({
|
|
63
|
+
field: "slots",
|
|
64
|
+
expected: "at least one unique slot"
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const seen = new Set();
|
|
68
|
+
input.slots.forEach((slot, index) => {
|
|
69
|
+
if (!Schema.is(SlotName)(slot)) {
|
|
70
|
+
throw new JobDeclarationError({ field: `slots[${index}]`, value: slot, expected });
|
|
71
|
+
}
|
|
72
|
+
if (seen.has(slot)) {
|
|
73
|
+
throw new JobDeclarationError({
|
|
74
|
+
field: `slots[${index}]`,
|
|
75
|
+
value: slot,
|
|
76
|
+
expected: "unique declared slot"
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
seen.add(slot);
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=JobIdentity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JobIdentity.js","sourceRoot":"","sources":["../src/JobIdentity.ts"],"names":[],"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ACnB,MAAM,IAAI,mBAAmB,CAAC;gBAC5B,KAAK,EAAE,SAAS,KAAK,GAAG;gBACxB,KAAK,EAAE,IAAI;gBACX,QAAQ,EAAE,sBAAsB;aACjC,CAAC,CAAA;QACJ,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAChB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { Data, Result, Schema } from "effect";
|
|
2
|
+
/** Mechanical source bounds, not new execution-policy limits. */
|
|
3
|
+
export declare const Counter: Schema.Int;
|
|
4
|
+
export declare const LeaseToken: Schema.String;
|
|
5
|
+
export declare const BatchLimit: Schema.Int;
|
|
6
|
+
export declare const JobState: Schema.Literals<readonly ["Pending", "Active", "RetryScheduled", "Completed", "Dead", "Isolated"]>;
|
|
7
|
+
export declare const JobOwnership: Schema.Struct<{
|
|
8
|
+
readonly jobId: Schema.brand<Schema.String, "effect-jobs/JobId">;
|
|
9
|
+
readonly leaseToken: Schema.String;
|
|
10
|
+
readonly leaseExpiresAt: Schema.Int;
|
|
11
|
+
readonly lifecycleVersion: Schema.Int;
|
|
12
|
+
}>;
|
|
13
|
+
export type JobOwnership = typeof JobOwnership.Type;
|
|
14
|
+
/** Complete durable metadata. Payload validation belongs to the codec, not this Schema. */
|
|
15
|
+
export declare const JobSnapshot: Schema.Struct<{
|
|
16
|
+
readonly jobId: Schema.brand<Schema.String, "effect-jobs/JobId">;
|
|
17
|
+
readonly policy: Schema.Struct<{
|
|
18
|
+
readonly leaseDurationMillis: Schema.Int;
|
|
19
|
+
readonly attemptTimeoutMillis: Schema.Int;
|
|
20
|
+
readonly maxAttempts: Schema.Int;
|
|
21
|
+
readonly maxStalledCount: Schema.Int;
|
|
22
|
+
readonly retrySchedule: Schema.TaggedStruct<"FixedDelayV1", {
|
|
23
|
+
readonly delayMillis: Schema.Int;
|
|
24
|
+
}>;
|
|
25
|
+
readonly completedRetention: Schema.Union<readonly [Schema.TaggedStruct<"Forever", {}>, Schema.TaggedStruct<"Duration", {
|
|
26
|
+
readonly millis: Schema.Int;
|
|
27
|
+
}>]>;
|
|
28
|
+
readonly deadRetention: Schema.Union<readonly [Schema.TaggedStruct<"Forever", {}>, Schema.TaggedStruct<"Duration", {
|
|
29
|
+
readonly millis: Schema.Int;
|
|
30
|
+
}>]>;
|
|
31
|
+
}>;
|
|
32
|
+
readonly state: Schema.Literals<readonly ["Pending", "Active", "RetryScheduled", "Completed", "Dead", "Isolated"]>;
|
|
33
|
+
readonly availableAt: Schema.Int;
|
|
34
|
+
readonly updatedAt: Schema.Int;
|
|
35
|
+
readonly attemptsMade: Schema.Int;
|
|
36
|
+
readonly stalledCount: Schema.Int;
|
|
37
|
+
readonly lifecycleVersion: Schema.Int;
|
|
38
|
+
readonly leaseToken: Schema.NullOr<Schema.String>;
|
|
39
|
+
readonly leaseExpiresAt: Schema.NullOr<Schema.Int>;
|
|
40
|
+
readonly completedAt: Schema.NullOr<Schema.Int>;
|
|
41
|
+
readonly lastFailureCode: Schema.NullOr<Schema.String>;
|
|
42
|
+
}>;
|
|
43
|
+
export type JobSnapshot = typeof JobSnapshot.Type;
|
|
44
|
+
/** Retry uses the first stored policy; callers cannot replace its schedule. */
|
|
45
|
+
export declare const JobFinalization: Schema.Union<readonly [Schema.TaggedStruct<"Complete", {}>, Schema.TaggedStruct<"Retry", {
|
|
46
|
+
readonly code: Schema.String;
|
|
47
|
+
readonly notAfter: Schema.optional<Schema.Int>;
|
|
48
|
+
}>, Schema.TaggedStruct<"Dead", {
|
|
49
|
+
readonly code: Schema.String;
|
|
50
|
+
}>, Schema.TaggedStruct<"Isolate", {
|
|
51
|
+
readonly code: Schema.String;
|
|
52
|
+
}>]>;
|
|
53
|
+
export type JobFinalization = typeof JobFinalization.Type;
|
|
54
|
+
export declare const JobFinalizations: {
|
|
55
|
+
readonly $is: <Tag extends "Complete" | "Dead" | "Isolate" | "Retry">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
56
|
+
readonly _tag: "Complete";
|
|
57
|
+
}, {
|
|
58
|
+
readonly _tag: Tag;
|
|
59
|
+
}> | Extract<{
|
|
60
|
+
readonly _tag: "Retry";
|
|
61
|
+
readonly code: string;
|
|
62
|
+
readonly notAfter?: number | undefined;
|
|
63
|
+
}, {
|
|
64
|
+
readonly _tag: Tag;
|
|
65
|
+
}> | Extract<{
|
|
66
|
+
readonly _tag: "Dead";
|
|
67
|
+
readonly code: string;
|
|
68
|
+
}, {
|
|
69
|
+
readonly _tag: Tag;
|
|
70
|
+
}> | Extract<{
|
|
71
|
+
readonly _tag: "Isolate";
|
|
72
|
+
readonly code: string;
|
|
73
|
+
}, {
|
|
74
|
+
readonly _tag: Tag;
|
|
75
|
+
}>;
|
|
76
|
+
readonly $match: {
|
|
77
|
+
<Cases extends { readonly [Tag in "Complete" | "Dead" | "Isolate" | "Retry"]: (args: Extract<{
|
|
78
|
+
readonly _tag: "Complete";
|
|
79
|
+
} | {
|
|
80
|
+
readonly _tag: "Retry";
|
|
81
|
+
readonly code: string;
|
|
82
|
+
readonly notAfter?: number | undefined;
|
|
83
|
+
} | {
|
|
84
|
+
readonly _tag: "Dead";
|
|
85
|
+
readonly code: string;
|
|
86
|
+
} | {
|
|
87
|
+
readonly _tag: "Isolate";
|
|
88
|
+
readonly code: string;
|
|
89
|
+
}, {
|
|
90
|
+
readonly _tag: Tag;
|
|
91
|
+
}>) => any; }>(cases: Cases): (value: {
|
|
92
|
+
readonly _tag: "Complete";
|
|
93
|
+
} | {
|
|
94
|
+
readonly _tag: "Retry";
|
|
95
|
+
readonly code: string;
|
|
96
|
+
readonly notAfter?: number | undefined;
|
|
97
|
+
} | {
|
|
98
|
+
readonly _tag: "Dead";
|
|
99
|
+
readonly code: string;
|
|
100
|
+
} | {
|
|
101
|
+
readonly _tag: "Isolate";
|
|
102
|
+
readonly code: string;
|
|
103
|
+
}) => import("effect/Unify").Unify<ReturnType<Cases["Complete" | "Dead" | "Isolate" | "Retry"]>>;
|
|
104
|
+
<Cases extends { readonly [Tag in "Complete" | "Dead" | "Isolate" | "Retry"]: (args: Extract<{
|
|
105
|
+
readonly _tag: "Complete";
|
|
106
|
+
} | {
|
|
107
|
+
readonly _tag: "Retry";
|
|
108
|
+
readonly code: string;
|
|
109
|
+
readonly notAfter?: number | undefined;
|
|
110
|
+
} | {
|
|
111
|
+
readonly _tag: "Dead";
|
|
112
|
+
readonly code: string;
|
|
113
|
+
} | {
|
|
114
|
+
readonly _tag: "Isolate";
|
|
115
|
+
readonly code: string;
|
|
116
|
+
}, {
|
|
117
|
+
readonly _tag: Tag;
|
|
118
|
+
}>) => any; }>(value: {
|
|
119
|
+
readonly _tag: "Complete";
|
|
120
|
+
} | {
|
|
121
|
+
readonly _tag: "Retry";
|
|
122
|
+
readonly code: string;
|
|
123
|
+
readonly notAfter?: number | undefined;
|
|
124
|
+
} | {
|
|
125
|
+
readonly _tag: "Dead";
|
|
126
|
+
readonly code: string;
|
|
127
|
+
} | {
|
|
128
|
+
readonly _tag: "Isolate";
|
|
129
|
+
readonly code: string;
|
|
130
|
+
}, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Complete" | "Dead" | "Isolate" | "Retry"]>>;
|
|
131
|
+
};
|
|
132
|
+
readonly Complete: Data.TaggedEnum.ConstructorFrom<{
|
|
133
|
+
readonly _tag: "Complete";
|
|
134
|
+
}, "_tag">;
|
|
135
|
+
readonly Dead: Data.TaggedEnum.ConstructorFrom<{
|
|
136
|
+
readonly _tag: "Dead";
|
|
137
|
+
readonly code: string;
|
|
138
|
+
}, "_tag">;
|
|
139
|
+
readonly Isolate: Data.TaggedEnum.ConstructorFrom<{
|
|
140
|
+
readonly _tag: "Isolate";
|
|
141
|
+
readonly code: string;
|
|
142
|
+
}, "_tag">;
|
|
143
|
+
readonly Retry: Data.TaggedEnum.ConstructorFrom<{
|
|
144
|
+
readonly _tag: "Retry";
|
|
145
|
+
readonly code: string;
|
|
146
|
+
readonly notAfter?: number | undefined;
|
|
147
|
+
}, "_tag">;
|
|
148
|
+
};
|
|
149
|
+
declare const JobLifecycleError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
150
|
+
readonly _tag: "JobLifecycleError";
|
|
151
|
+
} & Readonly<A>;
|
|
152
|
+
export declare class JobLifecycleError extends JobLifecycleError_base<{
|
|
153
|
+
readonly reason: "invalid-snapshot" | "invalid-command" | "arithmetic-bound" | "not-eligible" | "ownership-lost" | "execution-started";
|
|
154
|
+
}> {
|
|
155
|
+
}
|
|
156
|
+
export declare const validateSnapshot: (row: unknown) => Result.Result<JobSnapshot, JobLifecycleError>;
|
|
157
|
+
/** No process clock: adapters supply one DB-time snapshot for the entire atomic write. */
|
|
158
|
+
export declare const addTimestamp: (dbNow: number, millis: number) => Result.Result<number, JobLifecycleError>;
|
|
159
|
+
export declare const isOwned: (row: JobSnapshot, ownership: JobOwnership, dbNow: number) => boolean;
|
|
160
|
+
export declare const usableLease: (row: JobSnapshot, dbNow: number, operationResponseBudgetMillis: number) => boolean;
|
|
161
|
+
export declare const attemptNumber: (row: JobSnapshot) => number;
|
|
162
|
+
/** A plan is not a write. The backend must lock/CAS the input and commit the whole transition atomically. */
|
|
163
|
+
export declare const claim: (input: unknown, leaseToken: string, dbNow: number, operationResponseBudgetMillis: number) => Result.Result<JobSnapshot, JobLifecycleError>;
|
|
164
|
+
export declare const ownershipOf: (row: JobSnapshot) => Result.Result<JobOwnership, JobLifecycleError>;
|
|
165
|
+
export declare const release: (input: unknown, expected: JobOwnership, dbNow: number, phase: "BeforeExecution" | "Executing") => Result.Result<JobSnapshot, JobLifecycleError>;
|
|
166
|
+
export declare const finalize: (input: unknown, expected: JobOwnership, command: JobFinalization, dbNow: number) => Result.Result<JobSnapshot, JobLifecycleError>;
|
|
167
|
+
export declare const recoverExpired: (input: unknown, dbNow: number) => Result.Result<JobSnapshot, JobLifecycleError>;
|
|
168
|
+
/** Only explicit validated single failures are known. Cause/defect/timeout classification is worker-owned. */
|
|
169
|
+
export declare const finalizationFromFailure: (input: unknown) => Result.Result<JobFinalization | null, JobLifecycleError>;
|
|
170
|
+
/** Pure eligibility only; domain reference coordination and atomic deletion remain app/backend obligations. */
|
|
171
|
+
export declare const cleanupEligible: (row: JobSnapshot, dbNow: number) => Result.Result<boolean, JobLifecycleError>;
|
|
172
|
+
export {};
|
|
173
|
+
//# sourceMappingURL=JobLifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JobLifecycle.d.ts","sourceRoot":"","sources":["../src/JobLifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAK7C,iEAAiE;AACjE,eAAO,MAAM,OAAO,YAEnB,CAAA;AACD,eAAO,MAAM,UAAU,eAMtB,CAAA;AACD,eAAO,MAAM,UAAU,YAEtB,CAAA;AACD,eAAO,MAAM,QAAQ,oGAOnB,CAAA;AACF,eAAO,MAAM,YAAY;;;;;EAKvB,CAAA;AACF,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AAgBnD,2FAA2F;AAC3F,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuBvB,CAAA;AACD,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAA;AAEjD,+EAA+E;AAC/E,eAAO,MAAM,eAAe;;;;;;;IAQ1B,CAAA;AACF,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAA;AACzD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAqC,CAAA;;;;AAElE,qBAAa,iBAAkB,SAAQ,uBA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EJ,8GAA8G;AAC9G,eAAO,MAAM,uBAAuB,UAC3B,OAAO,KACb,MAAM,CAAC,MAAM,CAAC,eAAe,GAAG,IAAI,EAAE,iBAAiB,CAOvD,CAAA;AAEH,+GAA+G;AAC/G,eAAO,MAAM,eAAe,QACrB,WAAW,SACT,MAAM,KACZ,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,iBAAiB,CAmBvC,CAAA"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { Data, Result, Schema } from "effect";
|
|
2
|
+
import { JobId } from "./JobId.js";
|
|
3
|
+
import { FailureCode, JobFailure } from "./JobFailure.js";
|
|
4
|
+
import { EpochMillis, PersistedJobPolicy, maximumMillis } from "./JobPolicy.js";
|
|
5
|
+
/** Mechanical source bounds, not new execution-policy limits. */
|
|
6
|
+
export const Counter = Schema.Int.pipe(Schema.check(Schema.isBetween({ minimum: 0, maximum: Number.MAX_SAFE_INTEGER })));
|
|
7
|
+
export const LeaseToken = Schema.String.pipe(Schema.check(Schema.isMinLength(1), Schema.isMaxLength(128), Schema.isPattern(/^[0-9a-f-]+$/iu)));
|
|
8
|
+
export const BatchLimit = Schema.Int.pipe(Schema.check(Schema.isBetween({ minimum: 1, maximum: 500 })));
|
|
9
|
+
export const JobState = Schema.Literals([
|
|
10
|
+
"Pending",
|
|
11
|
+
"Active",
|
|
12
|
+
"RetryScheduled",
|
|
13
|
+
"Completed",
|
|
14
|
+
"Dead",
|
|
15
|
+
"Isolated"
|
|
16
|
+
]);
|
|
17
|
+
export const JobOwnership = Schema.Struct({
|
|
18
|
+
jobId: JobId,
|
|
19
|
+
leaseToken: LeaseToken,
|
|
20
|
+
leaseExpiresAt: EpochMillis,
|
|
21
|
+
lifecycleVersion: Counter
|
|
22
|
+
});
|
|
23
|
+
const SnapshotStruct = Schema.Struct({
|
|
24
|
+
jobId: JobId,
|
|
25
|
+
policy: PersistedJobPolicy,
|
|
26
|
+
state: JobState,
|
|
27
|
+
availableAt: EpochMillis,
|
|
28
|
+
updatedAt: EpochMillis,
|
|
29
|
+
attemptsMade: Counter,
|
|
30
|
+
stalledCount: Counter,
|
|
31
|
+
lifecycleVersion: Counter,
|
|
32
|
+
leaseToken: Schema.NullOr(LeaseToken),
|
|
33
|
+
leaseExpiresAt: Schema.NullOr(EpochMillis),
|
|
34
|
+
completedAt: Schema.NullOr(EpochMillis),
|
|
35
|
+
lastFailureCode: Schema.NullOr(FailureCode)
|
|
36
|
+
});
|
|
37
|
+
/** Complete durable metadata. Payload validation belongs to the codec, not this Schema. */
|
|
38
|
+
export const JobSnapshot = SnapshotStruct.pipe(Schema.check(Schema.makeFilter((row) => row.attemptsMade <= row.policy.maxAttempts &&
|
|
39
|
+
row.stalledCount <= row.policy.maxStalledCount + 1 &&
|
|
40
|
+
(row.state === "Active"
|
|
41
|
+
? row.leaseToken !== null &&
|
|
42
|
+
row.leaseExpiresAt !== null &&
|
|
43
|
+
row.completedAt === null
|
|
44
|
+
: row.leaseToken === null && row.leaseExpiresAt === null) &&
|
|
45
|
+
(row.state === "Completed" || row.state === "Dead"
|
|
46
|
+
? row.completedAt !== null
|
|
47
|
+
: row.completedAt === null) &&
|
|
48
|
+
(!(row.state === "Pending" ||
|
|
49
|
+
row.state === "RetryScheduled" ||
|
|
50
|
+
row.state === "Active") ||
|
|
51
|
+
(row.attemptsMade < row.policy.maxAttempts &&
|
|
52
|
+
row.stalledCount <= row.policy.maxStalledCount)))));
|
|
53
|
+
/** Retry uses the first stored policy; callers cannot replace its schedule. */
|
|
54
|
+
export const JobFinalization = Schema.Union([
|
|
55
|
+
Schema.TaggedStruct("Complete", {}),
|
|
56
|
+
Schema.TaggedStruct("Retry", {
|
|
57
|
+
code: FailureCode,
|
|
58
|
+
notAfter: Schema.optional(EpochMillis)
|
|
59
|
+
}),
|
|
60
|
+
Schema.TaggedStruct("Dead", { code: FailureCode }),
|
|
61
|
+
Schema.TaggedStruct("Isolate", { code: FailureCode })
|
|
62
|
+
]);
|
|
63
|
+
export const JobFinalizations = Data.taggedEnum();
|
|
64
|
+
export class JobLifecycleError extends Data.TaggedError("JobLifecycleError") {
|
|
65
|
+
}
|
|
66
|
+
const invalid = (reason) => new JobLifecycleError({ reason });
|
|
67
|
+
const decodeSnapshot = Schema.decodeUnknownResult(JobSnapshot, {
|
|
68
|
+
onExcessProperty: "error"
|
|
69
|
+
});
|
|
70
|
+
const decodeOwnership = Schema.decodeUnknownResult(JobOwnership, {
|
|
71
|
+
onExcessProperty: "error"
|
|
72
|
+
});
|
|
73
|
+
const decodeFinalization = Schema.decodeUnknownResult(JobFinalization, {
|
|
74
|
+
onExcessProperty: "error"
|
|
75
|
+
});
|
|
76
|
+
export const validateSnapshot = (row) => Result.mapError(decodeSnapshot(row), () => invalid("invalid-snapshot"));
|
|
77
|
+
/** No process clock: adapters supply one DB-time snapshot for the entire atomic write. */
|
|
78
|
+
export const addTimestamp = (dbNow, millis) => Schema.is(EpochMillis)(dbNow) &&
|
|
79
|
+
Schema.is(EpochMillis)(millis) &&
|
|
80
|
+
millis <= maximumMillis - dbNow
|
|
81
|
+
? Result.succeed(dbNow + millis)
|
|
82
|
+
: Result.fail(invalid("arithmetic-bound"));
|
|
83
|
+
const increment = (n) => n < Number.MAX_SAFE_INTEGER
|
|
84
|
+
? Result.succeed(n + 1)
|
|
85
|
+
: Result.fail(invalid("arithmetic-bound"));
|
|
86
|
+
const validateTime = (dbNow) => Schema.is(EpochMillis)(dbNow)
|
|
87
|
+
? Result.succeed(dbNow)
|
|
88
|
+
: Result.fail(invalid("invalid-command"));
|
|
89
|
+
export const isOwned = (row, ownership, dbNow) => row.state === "Active" &&
|
|
90
|
+
row.jobId === ownership.jobId &&
|
|
91
|
+
row.leaseToken === ownership.leaseToken &&
|
|
92
|
+
row.lifecycleVersion === ownership.lifecycleVersion &&
|
|
93
|
+
row.leaseExpiresAt === ownership.leaseExpiresAt &&
|
|
94
|
+
ownership.leaseExpiresAt > dbNow;
|
|
95
|
+
export const usableLease = (row, dbNow, operationResponseBudgetMillis) => Schema.is(EpochMillis)(dbNow) &&
|
|
96
|
+
Schema.is(EpochMillis)(operationResponseBudgetMillis) &&
|
|
97
|
+
row.state === "Active" &&
|
|
98
|
+
row.leaseExpiresAt !== null &&
|
|
99
|
+
row.leaseExpiresAt - dbNow - row.policy.attemptTimeoutMillis >=
|
|
100
|
+
operationResponseBudgetMillis;
|
|
101
|
+
export const attemptNumber = (row) => row.attemptsMade + 1;
|
|
102
|
+
/** A plan is not a write. The backend must lock/CAS the input and commit the whole transition atomically. */
|
|
103
|
+
export const claim = (input, leaseToken, dbNow, operationResponseBudgetMillis) => Result.gen(function* () {
|
|
104
|
+
const row = yield* validateSnapshot(input);
|
|
105
|
+
yield* validateTime(dbNow);
|
|
106
|
+
if (!Schema.is(LeaseToken)(leaseToken) ||
|
|
107
|
+
!Schema.is(EpochMillis)(operationResponseBudgetMillis)) {
|
|
108
|
+
return yield* Result.fail(invalid("invalid-command"));
|
|
109
|
+
}
|
|
110
|
+
if (!(row.state === "Pending" || row.state === "RetryScheduled") ||
|
|
111
|
+
row.availableAt > dbNow ||
|
|
112
|
+
row.policy.leaseDurationMillis - row.policy.attemptTimeoutMillis <
|
|
113
|
+
operationResponseBudgetMillis) {
|
|
114
|
+
return yield* Result.fail(invalid("not-eligible"));
|
|
115
|
+
}
|
|
116
|
+
const leaseExpiresAt = yield* addTimestamp(dbNow, row.policy.leaseDurationMillis);
|
|
117
|
+
const lifecycleVersion = yield* increment(row.lifecycleVersion);
|
|
118
|
+
return {
|
|
119
|
+
...row,
|
|
120
|
+
state: "Active",
|
|
121
|
+
leaseToken,
|
|
122
|
+
leaseExpiresAt,
|
|
123
|
+
lifecycleVersion,
|
|
124
|
+
updatedAt: dbNow
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
export const ownershipOf = (row) => row.state === "Active" && row.leaseToken !== null && row.leaseExpiresAt !== null
|
|
128
|
+
? Result.succeed({
|
|
129
|
+
jobId: row.jobId,
|
|
130
|
+
leaseToken: row.leaseToken,
|
|
131
|
+
leaseExpiresAt: row.leaseExpiresAt,
|
|
132
|
+
lifecycleVersion: row.lifecycleVersion
|
|
133
|
+
})
|
|
134
|
+
: Result.fail(invalid("ownership-lost"));
|
|
135
|
+
export const release = (input, expected, dbNow, phase) => Result.gen(function* () {
|
|
136
|
+
const row = yield* validateSnapshot(input);
|
|
137
|
+
const ownership = yield* Result.mapError(decodeOwnership(expected), () => invalid("invalid-command"));
|
|
138
|
+
yield* validateTime(dbNow);
|
|
139
|
+
if (phase !== "BeforeExecution") {
|
|
140
|
+
return yield* Result.fail(invalid("execution-started"));
|
|
141
|
+
}
|
|
142
|
+
if (!isOwned(row, ownership, dbNow)) {
|
|
143
|
+
return yield* Result.fail(invalid("ownership-lost"));
|
|
144
|
+
}
|
|
145
|
+
const lifecycleVersion = yield* increment(row.lifecycleVersion);
|
|
146
|
+
return {
|
|
147
|
+
...row,
|
|
148
|
+
state: "Pending",
|
|
149
|
+
availableAt: dbNow,
|
|
150
|
+
updatedAt: dbNow,
|
|
151
|
+
lifecycleVersion,
|
|
152
|
+
leaseToken: null,
|
|
153
|
+
leaseExpiresAt: null
|
|
154
|
+
};
|
|
155
|
+
});
|
|
156
|
+
export const finalize = (input, expected, command, dbNow) => Result.gen(function* () {
|
|
157
|
+
const row = yield* validateSnapshot(input);
|
|
158
|
+
const ownership = yield* Result.mapError(decodeOwnership(expected), () => invalid("invalid-command"));
|
|
159
|
+
const finalization = yield* Result.mapError(decodeFinalization(command), () => invalid("invalid-command"));
|
|
160
|
+
yield* validateTime(dbNow);
|
|
161
|
+
if (!isOwned(row, ownership, dbNow)) {
|
|
162
|
+
return yield* Result.fail(invalid("ownership-lost"));
|
|
163
|
+
}
|
|
164
|
+
const lifecycleVersion = yield* increment(row.lifecycleVersion);
|
|
165
|
+
const attemptsMade = yield* increment(row.attemptsMade);
|
|
166
|
+
const nextAvailableAt = finalization._tag === "Retry"
|
|
167
|
+
? yield* addTimestamp(dbNow, row.policy.retrySchedule.delayMillis)
|
|
168
|
+
: row.availableAt;
|
|
169
|
+
const state = finalization._tag === "Complete"
|
|
170
|
+
? "Completed"
|
|
171
|
+
: finalization._tag === "Isolate"
|
|
172
|
+
? "Isolated"
|
|
173
|
+
: finalization._tag === "Dead" ||
|
|
174
|
+
attemptsMade >= row.policy.maxAttempts ||
|
|
175
|
+
(finalization.notAfter !== undefined &&
|
|
176
|
+
nextAvailableAt >= finalization.notAfter)
|
|
177
|
+
? "Dead"
|
|
178
|
+
: "RetryScheduled";
|
|
179
|
+
return {
|
|
180
|
+
...row,
|
|
181
|
+
state,
|
|
182
|
+
attemptsMade,
|
|
183
|
+
lifecycleVersion,
|
|
184
|
+
availableAt: nextAvailableAt,
|
|
185
|
+
updatedAt: dbNow,
|
|
186
|
+
completedAt: state === "Completed" || state === "Dead" ? dbNow : null,
|
|
187
|
+
lastFailureCode: finalization._tag === "Complete" ? null : finalization.code,
|
|
188
|
+
leaseToken: null,
|
|
189
|
+
leaseExpiresAt: null
|
|
190
|
+
};
|
|
191
|
+
});
|
|
192
|
+
export const recoverExpired = (input, dbNow) => Result.gen(function* () {
|
|
193
|
+
const row = yield* validateSnapshot(input);
|
|
194
|
+
yield* validateTime(dbNow);
|
|
195
|
+
if (row.state !== "Active" ||
|
|
196
|
+
row.leaseExpiresAt === null ||
|
|
197
|
+
row.leaseExpiresAt > dbNow) {
|
|
198
|
+
return yield* Result.fail(invalid("not-eligible"));
|
|
199
|
+
}
|
|
200
|
+
const stalledCount = yield* increment(row.stalledCount);
|
|
201
|
+
const lifecycleVersion = yield* increment(row.lifecycleVersion);
|
|
202
|
+
const dead = stalledCount > row.policy.maxStalledCount;
|
|
203
|
+
return {
|
|
204
|
+
...row,
|
|
205
|
+
state: dead ? "Dead" : "Pending",
|
|
206
|
+
stalledCount,
|
|
207
|
+
lifecycleVersion,
|
|
208
|
+
updatedAt: dbNow,
|
|
209
|
+
completedAt: dead ? dbNow : null,
|
|
210
|
+
lastFailureCode: dead ? "stall_limit_exceeded" : null,
|
|
211
|
+
leaseToken: null,
|
|
212
|
+
leaseExpiresAt: null
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
/** Only explicit validated single failures are known. Cause/defect/timeout classification is worker-owned. */
|
|
216
|
+
export const finalizationFromFailure = (input) => Result.map(Result.mapError(Schema.decodeUnknownResult(JobFailure, { onExcessProperty: "error" })(input), () => invalid("invalid-command")), (failure) => (failure._tag === "OutcomeUnknown" ? null : failure));
|
|
217
|
+
/** Pure eligibility only; domain reference coordination and atomic deletion remain app/backend obligations. */
|
|
218
|
+
export const cleanupEligible = (row, dbNow) => Result.gen(function* () {
|
|
219
|
+
const stored = yield* validateSnapshot(row);
|
|
220
|
+
yield* validateTime(dbNow);
|
|
221
|
+
if ((stored.state !== "Completed" && stored.state !== "Dead") ||
|
|
222
|
+
stored.completedAt === null) {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
const retention = stored.state === "Completed"
|
|
226
|
+
? stored.policy.completedRetention
|
|
227
|
+
: stored.policy.deadRetention;
|
|
228
|
+
if (retention._tag === "Forever") {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
const expiresAt = yield* addTimestamp(stored.completedAt, retention.millis);
|
|
232
|
+
return expiresAt <= dbNow;
|
|
233
|
+
});
|
|
234
|
+
//# sourceMappingURL=JobLifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JobLifecycle.js","sourceRoot":"","sources":["../src/JobLifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE/E,iEAAiE;AACjE,MAAM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,GAAG,KAAK,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,MAAM,CAAC,CAAA;IAC3E,OAAO,SAAS,IAAI,KAAK,CAAA;AAC3B,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Schema } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* Marks an application-owned, already-protected JSON representation. Requires an
|
|
4
|
+
* own fingerprint in the encoded value. This neither proves protection nor seals
|
|
5
|
+
* or opens data. Encryption and stable fingerprint keys remain application-owned.
|
|
6
|
+
* The schema may describe any JSON fingerprint; no envelope shape or crypto key
|
|
7
|
+
* manager is imposed. Unsupported protected mappings fail when the codec runs.
|
|
8
|
+
*/
|
|
9
|
+
declare const protectedPayload: <S extends Schema.Top>(schema: S) => S["Rebuild"];
|
|
10
|
+
export { protectedPayload as protected };
|
|
11
|
+
declare module "effect/Schema" {
|
|
12
|
+
namespace Annotations {
|
|
13
|
+
interface Annotations {
|
|
14
|
+
readonly effectJobsProtectedPayload?: true | undefined;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=JobPayload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JobPayload.d.ts","sourceRoot":"","sources":["../src/JobPayload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEpC;;;;;;GAMG;AACH,QAAA,MAAM,gBAAgB,GAAI,CAAC,SAAS,MAAM,CAAC,GAAG,UAAU,CAAC,KAAG,CAAC,CAAC,SAAS,CAChB,CAAA;AAEvD,OAAO,EAAE,gBAAgB,IAAI,SAAS,EAAE,CAAA;AAExC,OAAO,QAAQ,eAAe,CAAC;IAC7B,UAAU,WAAW,CAAC;QACpB,UAAU,WAAW;YACnB,QAAQ,CAAC,0BAA0B,CAAC,EAAE,IAAI,GAAG,SAAS,CAAA;SACvD;KACF;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marks an application-owned, already-protected JSON representation. Requires an
|
|
3
|
+
* own fingerprint in the encoded value. This neither proves protection nor seals
|
|
4
|
+
* or opens data. Encryption and stable fingerprint keys remain application-owned.
|
|
5
|
+
* The schema may describe any JSON fingerprint; no envelope shape or crypto key
|
|
6
|
+
* manager is imposed. Unsupported protected mappings fail when the codec runs.
|
|
7
|
+
*/
|
|
8
|
+
const protectedPayload = (schema) => schema.annotate({ effectJobsProtectedPayload: true });
|
|
9
|
+
export { protectedPayload as protected };
|
|
10
|
+
//# sourceMappingURL=JobPayload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JobPayload.js","sourceRoot":"","sources":["../src/JobPayload.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG,CAAuB,MAAS,EAAgB,EAAE,CACzE,MAAM,CAAC,QAAQ,CAAC,EAAE,0BAA0B,EAAE,IAAI,EAAE,CAAC,CAAA;AAEvD,OAAO,EAAE,gBAAgB,IAAI,SAAS,EAAE,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { JobPayloadEncoder, JobPayloadDecoder } from "./JobContract.js";
|
|
2
|
+
/**
|
|
3
|
+
* Encodes the validated wire representation, not the decoded domain object.
|
|
4
|
+
* Structs, arrays, absent optional keys and unions are supported. Domain
|
|
5
|
+
* transforms must have a JSON encoded side; transforms across protected markers,
|
|
6
|
+
* recursive/custom shapes, records and tuples fail with invalid-schema.
|
|
7
|
+
* Each returned buffer is owned independently by this execution. Receivers must
|
|
8
|
+
* copy buffers before retaining them; readonly properties do not freeze bytes.
|
|
9
|
+
*/
|
|
10
|
+
export declare const encodeJobPayload: JobPayloadEncoder;
|
|
11
|
+
/** Validates canonical format, bounds, schema and semantic projection before
|
|
12
|
+
* invoking domain decoding. Consistent projection bytes are not authenticity. */
|
|
13
|
+
export declare const decodeJobPayload: JobPayloadDecoder;
|
|
14
|
+
//# sourceMappingURL=JobPayloadCodec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JobPayloadCodec.d.ts","sourceRoot":"","sources":["../src/JobPayloadCodec.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAElB,MAAM,kBAAkB,CAAA;AAUzB;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,iBAiC7B,CAAA;AAyCF;iFACiF;AACjF,eAAO,MAAM,gBAAgB,EAAE,iBAgD7B,CAAA"}
|