@effect-agent/storage-sqlite 0.1.0-beta.83 → 0.1.0-beta.85
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/dist/SqliteActivityStore.mjs +1 -1
- package/dist/SqliteActivityStore.mjs.map +1 -1
- package/dist/SqliteMessageDeliveryStore.mjs +1 -1
- package/dist/SqliteScheduleStore.mjs +2 -2
- package/dist/SqliteScheduleStore.mjs.map +1 -1
- package/dist/SqliteSubmissionLedger.mjs +32 -32
- package/dist/SqliteSubmissionLedger.mjs.map +1 -1
- package/dist/SqliteSubscriptionStore.mjs +2 -2
- package/dist/SqliteSubscriptionStore.mjs.map +1 -1
- package/dist/SqliteThreadStore.mjs +22 -22
- package/dist/SqliteThreadStore.mjs.map +1 -1
- package/dist/{sqlite-journal-D9xFxCw-.mjs → sqlite-journal-B1dejOUb.mjs} +3 -3
- package/dist/{sqlite-journal-D9xFxCw-.mjs.map → sqlite-journal-B1dejOUb.mjs.map} +1 -1
- package/package.json +1 -1
- package/src/SqliteActivityStore.ts +1 -1
- package/src/SqliteScheduleStore.ts +1 -1
- package/src/SqliteSubmissionLedger.ts +61 -61
- package/src/SqliteSubscriptionStore.ts +1 -1
- package/src/SqliteThreadStore.ts +32 -34
- package/src/internal/sqlite-journal.ts +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InputMessage } from "@effect-agent/core/Messaging";
|
|
2
2
|
import { EMPTY_TAIL_DIGEST } from "@effect-agent/thread/Digest";
|
|
3
3
|
import {
|
|
4
4
|
ApprovalDecision,
|
|
@@ -514,9 +514,9 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
514
514
|
if (Option.isNone(ownership) || ownership.value.ownership_token !== ownershipToken) {
|
|
515
515
|
const actualEpoch = yield* threadEpoch(operation, submission.thread_id);
|
|
516
516
|
|
|
517
|
-
const submissionId = yield* Schema.
|
|
518
|
-
|
|
519
|
-
)
|
|
517
|
+
const submissionId = yield* Schema.decodeEffect(SubmissionSnapshot.fields.submissionId)(
|
|
518
|
+
submission.submission_id,
|
|
519
|
+
).pipe(Effect.mapError(internalFailure(operation)));
|
|
520
520
|
|
|
521
521
|
return yield* OwnershipLost.make({ submissionId, actualEpoch });
|
|
522
522
|
}
|
|
@@ -995,9 +995,9 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
995
995
|
function* (request: AdmissionRequest) {
|
|
996
996
|
const operation = "ledger admit";
|
|
997
997
|
|
|
998
|
-
const validated = yield* Schema.
|
|
999
|
-
|
|
1000
|
-
)
|
|
998
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(AdmissionRequest))(request).pipe(
|
|
999
|
+
Effect.mapError(internalFailure(operation)),
|
|
1000
|
+
);
|
|
1001
1001
|
|
|
1002
1002
|
const inputJson = yield* encodePersistedJsonText(validated.inputPayload).pipe(
|
|
1003
1003
|
Effect.mapError(internalFailure(operation)),
|
|
@@ -1023,7 +1023,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1023
1023
|
const messageAdmissionJson =
|
|
1024
1024
|
validated.messageAdmission === undefined
|
|
1025
1025
|
? null
|
|
1026
|
-
: yield* Schema.encodeEffect(Schema.fromJsonString(
|
|
1026
|
+
: yield* Schema.encodeEffect(Schema.fromJsonString(InputMessage))(
|
|
1027
1027
|
validated.messageAdmission,
|
|
1028
1028
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
1029
1029
|
|
|
@@ -1096,10 +1096,10 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1096
1096
|
existing[0].worker_admission_json,
|
|
1097
1097
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
1098
1098
|
|
|
1099
|
-
const
|
|
1099
|
+
const retainedInputMessage =
|
|
1100
1100
|
existing[0].message_admission_json === null
|
|
1101
1101
|
? undefined
|
|
1102
|
-
: yield* Schema.decodeEffect(Schema.fromJsonString(
|
|
1102
|
+
: yield* Schema.decodeEffect(Schema.fromJsonString(InputMessage))(
|
|
1103
1103
|
existing[0].message_admission_json,
|
|
1104
1104
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
1105
1105
|
|
|
@@ -1116,8 +1116,8 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1116
1116
|
retainedWorkerAdmission,
|
|
1117
1117
|
validated.workerAdmission,
|
|
1118
1118
|
) ||
|
|
1119
|
-
!Schema.toEquivalence(Schema.optional(
|
|
1120
|
-
|
|
1119
|
+
!Schema.toEquivalence(Schema.optional(InputMessage))(
|
|
1120
|
+
retainedInputMessage,
|
|
1121
1121
|
validated.messageAdmission,
|
|
1122
1122
|
) ||
|
|
1123
1123
|
!Schema.toEquivalence(Schema.optional(AdmissionFence))(
|
|
@@ -1275,9 +1275,9 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1275
1275
|
)(function* (request: MarkReadyRequest) {
|
|
1276
1276
|
const operation = "ledger mark ready";
|
|
1277
1277
|
|
|
1278
|
-
const validated = yield* Schema.
|
|
1279
|
-
|
|
1280
|
-
)
|
|
1278
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(MarkReadyRequest))(request).pipe(
|
|
1279
|
+
Effect.mapError(internalFailure(operation)),
|
|
1280
|
+
);
|
|
1281
1281
|
|
|
1282
1282
|
yield* hitFailpoint("ledger:mark-ready:before", operation);
|
|
1283
1283
|
yield* inWriteTransaction(
|
|
@@ -1302,9 +1302,9 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1302
1302
|
function* (request: SubmissionLookup) {
|
|
1303
1303
|
const operation = "ledger lookup";
|
|
1304
1304
|
|
|
1305
|
-
const validated = yield* Schema.
|
|
1306
|
-
|
|
1307
|
-
)
|
|
1305
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(SubmissionLookup))(request).pipe(
|
|
1306
|
+
Effect.mapError(internalFailure(operation)),
|
|
1307
|
+
);
|
|
1308
1308
|
|
|
1309
1309
|
if (validated._tag === "SubmissionLookupById") {
|
|
1310
1310
|
const row = yield* readSubmission(operation, validated.submissionId);
|
|
@@ -1350,7 +1350,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1350
1350
|
)(function* (request: SubmissionLookupByKey) {
|
|
1351
1351
|
const operation = "ledger resolve admission";
|
|
1352
1352
|
|
|
1353
|
-
const validated = yield* Schema.
|
|
1353
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(SubmissionLookupByKey))(
|
|
1354
1354
|
request,
|
|
1355
1355
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
1356
1356
|
|
|
@@ -1387,9 +1387,9 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1387
1387
|
function* (request: ClaimRequest) {
|
|
1388
1388
|
const operation = "ledger claim";
|
|
1389
1389
|
|
|
1390
|
-
const validated = yield* Schema.
|
|
1391
|
-
|
|
1392
|
-
)
|
|
1390
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ClaimRequest))(request).pipe(
|
|
1391
|
+
Effect.mapError(internalFailure(operation)),
|
|
1392
|
+
);
|
|
1393
1393
|
|
|
1394
1394
|
const attemptId = yield* mintIdentifier("attempt", operation);
|
|
1395
1395
|
const ownershipToken = yield* mintIdentifier("owner", operation);
|
|
@@ -1563,7 +1563,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1563
1563
|
)(function* (request: RenewOwnershipRequest) {
|
|
1564
1564
|
const operation = "ledger renew ownership";
|
|
1565
1565
|
|
|
1566
|
-
const validated = yield* Schema.
|
|
1566
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(RenewOwnershipRequest))(
|
|
1567
1567
|
request,
|
|
1568
1568
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
1569
1569
|
|
|
@@ -1601,7 +1601,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1601
1601
|
)(function* (request: ReleaseOwnershipRequest) {
|
|
1602
1602
|
const operation = "ledger release ownership";
|
|
1603
1603
|
|
|
1604
|
-
const validated = yield* Schema.
|
|
1604
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ReleaseOwnershipRequest))(
|
|
1605
1605
|
request,
|
|
1606
1606
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
1607
1607
|
|
|
@@ -1633,7 +1633,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1633
1633
|
)(function* (request: MarkInputAppliedRequest) {
|
|
1634
1634
|
const operation = "ledger mark input applied";
|
|
1635
1635
|
|
|
1636
|
-
const validated = yield* Schema.
|
|
1636
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(MarkInputAppliedRequest))(
|
|
1637
1637
|
request,
|
|
1638
1638
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
1639
1639
|
|
|
@@ -1680,7 +1680,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1680
1680
|
)(function* (request: SettlementReservation) {
|
|
1681
1681
|
const operation = "ledger reserve settlement";
|
|
1682
1682
|
|
|
1683
|
-
const validated = yield* Schema.
|
|
1683
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(SettlementReservation))(
|
|
1684
1684
|
request,
|
|
1685
1685
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
1686
1686
|
|
|
@@ -1891,7 +1891,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1891
1891
|
)(function* (request: SettlementFinalization) {
|
|
1892
1892
|
const operation = "ledger finalize settlement";
|
|
1893
1893
|
|
|
1894
|
-
const validated = yield* Schema.
|
|
1894
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(SettlementFinalization))(
|
|
1895
1895
|
request,
|
|
1896
1896
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
1897
1897
|
|
|
@@ -1998,7 +1998,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1998
1998
|
)(function* (request: AbortCommand) {
|
|
1999
1999
|
const operation = "ledger request abort";
|
|
2000
2000
|
|
|
2001
|
-
const validated = yield* Schema.
|
|
2001
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(AbortCommand))(request).pipe(
|
|
2002
2002
|
Effect.mapError(internalFailure(operation)),
|
|
2003
2003
|
);
|
|
2004
2004
|
|
|
@@ -2098,9 +2098,9 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
2098
2098
|
)(function* (request: ClaimJoiningRequest) {
|
|
2099
2099
|
const operation = "ledger claim joining";
|
|
2100
2100
|
|
|
2101
|
-
const validated = yield* Schema.
|
|
2102
|
-
|
|
2103
|
-
)
|
|
2101
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ClaimJoiningRequest))(request).pipe(
|
|
2102
|
+
Effect.mapError(internalFailure(operation)),
|
|
2103
|
+
);
|
|
2104
2104
|
|
|
2105
2105
|
yield* hitFailpoint("ledger:claim-joining:before", operation);
|
|
2106
2106
|
|
|
@@ -2186,9 +2186,9 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
2186
2186
|
)(function* (request: MarkJoinedRequest) {
|
|
2187
2187
|
const operation = "ledger mark joined";
|
|
2188
2188
|
|
|
2189
|
-
const validated = yield* Schema.
|
|
2190
|
-
|
|
2191
|
-
)
|
|
2189
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(MarkJoinedRequest))(request).pipe(
|
|
2190
|
+
Effect.mapError(internalFailure(operation)),
|
|
2191
|
+
);
|
|
2192
2192
|
|
|
2193
2193
|
yield* hitFailpoint("ledger:mark-joined:before", operation);
|
|
2194
2194
|
yield* inWriteTransaction(
|
|
@@ -2246,9 +2246,9 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
2246
2246
|
)(function* (request: RevertJoiningRequest) {
|
|
2247
2247
|
const operation = "ledger revert joining";
|
|
2248
2248
|
|
|
2249
|
-
const validated = yield* Schema.
|
|
2250
|
-
|
|
2251
|
-
)
|
|
2249
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(RevertJoiningRequest))(request).pipe(
|
|
2250
|
+
Effect.mapError(internalFailure(operation)),
|
|
2251
|
+
);
|
|
2252
2252
|
|
|
2253
2253
|
yield* hitFailpoint("ledger:revert-joining:before", operation);
|
|
2254
2254
|
yield* inWriteTransaction(
|
|
@@ -2274,9 +2274,9 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
2274
2274
|
)(function* (request: SuspendRequest) {
|
|
2275
2275
|
const operation = "ledger suspend";
|
|
2276
2276
|
|
|
2277
|
-
const validated = yield* Schema.
|
|
2278
|
-
|
|
2279
|
-
)
|
|
2277
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(SuspendRequest))(request).pipe(
|
|
2278
|
+
Effect.mapError(internalFailure(operation)),
|
|
2279
|
+
);
|
|
2280
2280
|
|
|
2281
2281
|
const reasonJson = yield* encodeSuspensionReasonText(validated.reason).pipe(
|
|
2282
2282
|
Effect.mapError(internalFailure(operation)),
|
|
@@ -2410,7 +2410,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
2410
2410
|
)(function* (command: ApprovalDecisionCommand) {
|
|
2411
2411
|
const operation = "ledger record approval decision";
|
|
2412
2412
|
|
|
2413
|
-
const validated = yield* Schema.
|
|
2413
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ApprovalDecisionCommand))(
|
|
2414
2414
|
command,
|
|
2415
2415
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
2416
2416
|
|
|
@@ -2494,9 +2494,9 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
2494
2494
|
)(function* (request: MarkUnknownRequest) {
|
|
2495
2495
|
const operation = "ledger mark unknown";
|
|
2496
2496
|
|
|
2497
|
-
const validated = yield* Schema.
|
|
2498
|
-
|
|
2499
|
-
)
|
|
2497
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(MarkUnknownRequest))(request).pipe(
|
|
2498
|
+
Effect.mapError(internalFailure(operation)),
|
|
2499
|
+
);
|
|
2500
2500
|
|
|
2501
2501
|
yield* hitFailpoint("ledger:mark-unknown:before", operation);
|
|
2502
2502
|
yield* inWriteTransaction(
|
|
@@ -2561,7 +2561,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
2561
2561
|
)(function* (command: UnknownResolutionCommand) {
|
|
2562
2562
|
const operation = "ledger record unknown resolution";
|
|
2563
2563
|
|
|
2564
|
-
const validated = yield* Schema.
|
|
2564
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(UnknownResolutionCommand))(
|
|
2565
2565
|
command,
|
|
2566
2566
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
2567
2567
|
|
|
@@ -2682,7 +2682,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
2682
2682
|
)(function* (request: ChildSettledNotification) {
|
|
2683
2683
|
const operation = "ledger record child settled";
|
|
2684
2684
|
|
|
2685
|
-
const validated = yield* Schema.
|
|
2685
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ChildSettledNotification))(
|
|
2686
2686
|
request,
|
|
2687
2687
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
2688
2688
|
|
|
@@ -2772,9 +2772,9 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
2772
2772
|
)(function* (request: ChildBudgetReservationRequest) {
|
|
2773
2773
|
const operation = "ledger reserve child budget";
|
|
2774
2774
|
|
|
2775
|
-
const validated = yield* Schema.
|
|
2776
|
-
|
|
2777
|
-
)
|
|
2775
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ChildBudgetReservationRequest))(
|
|
2776
|
+
request,
|
|
2777
|
+
).pipe(Effect.mapError(internalFailure(operation)));
|
|
2778
2778
|
|
|
2779
2779
|
const allocationJson = yield* encodePersistedJsonText(validated.allocation).pipe(
|
|
2780
2780
|
Effect.mapError(internalFailure(operation)),
|
|
@@ -2884,9 +2884,9 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
2884
2884
|
) {
|
|
2885
2885
|
const operation = "ledger attach child to reservation";
|
|
2886
2886
|
|
|
2887
|
-
const validated = yield* Schema.
|
|
2888
|
-
|
|
2889
|
-
)
|
|
2887
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(AttachChildToReservationRequest))(
|
|
2888
|
+
request,
|
|
2889
|
+
).pipe(Effect.mapError(internalFailure(operation)));
|
|
2890
2890
|
|
|
2891
2891
|
yield* hitFailpoint("ledger:child-attach:before", operation);
|
|
2892
2892
|
|
|
@@ -2963,9 +2963,9 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
2963
2963
|
)(function* (request: BeginChildBudgetReleaseRequest) {
|
|
2964
2964
|
const operation = "ledger begin child budget release";
|
|
2965
2965
|
|
|
2966
|
-
const validated = yield* Schema.
|
|
2967
|
-
|
|
2968
|
-
)
|
|
2966
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(BeginChildBudgetReleaseRequest))(
|
|
2967
|
+
request,
|
|
2968
|
+
).pipe(Effect.mapError(internalFailure(operation)));
|
|
2969
2969
|
|
|
2970
2970
|
const accountingJson = yield* encodePersistedJsonText(validated.accounting).pipe(
|
|
2971
2971
|
Effect.mapError(internalFailure(operation)),
|
|
@@ -3040,7 +3040,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
3040
3040
|
)(function* (request: ReleaseChildBudgetRequest) {
|
|
3041
3041
|
const operation = "ledger release child budget";
|
|
3042
3042
|
|
|
3043
|
-
const validated = yield* Schema.
|
|
3043
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ReleaseChildBudgetRequest))(
|
|
3044
3044
|
request,
|
|
3045
3045
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
3046
3046
|
|
|
@@ -3158,9 +3158,9 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
3158
3158
|
)(function* (request) {
|
|
3159
3159
|
const operation = "ledger read abort intent";
|
|
3160
3160
|
|
|
3161
|
-
const validated = yield* Schema.
|
|
3162
|
-
|
|
3163
|
-
)
|
|
3161
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(AbortIntentRequest))(request).pipe(
|
|
3162
|
+
Effect.mapError(internalFailure(operation)),
|
|
3163
|
+
);
|
|
3164
3164
|
|
|
3165
3165
|
const recordId = submissionAbortRecordId(validated.submissionId);
|
|
3166
3166
|
|
|
@@ -3229,7 +3229,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
3229
3229
|
)(function* (request: RecoverySnapshotRequest) {
|
|
3230
3230
|
const operation = "ledger load recovery snapshot";
|
|
3231
3231
|
|
|
3232
|
-
const validated = yield* Schema.
|
|
3232
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(RecoverySnapshotRequest))(
|
|
3233
3233
|
request,
|
|
3234
3234
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
3235
3235
|
|
|
@@ -3278,7 +3278,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
3278
3278
|
),
|
|
3279
3279
|
);
|
|
3280
3280
|
|
|
3281
|
-
const settlementId = yield* Schema.
|
|
3281
|
+
const settlementId = yield* Schema.decodeEffect(
|
|
3282
3282
|
SettlementReservationSnapshot.fields.settlementId,
|
|
3283
3283
|
)(reservationRow.value.settlement_id).pipe(Effect.mapError(internalFailure(operation)));
|
|
3284
3284
|
|
|
@@ -36,7 +36,7 @@ const transactionLayer = Layer.effect(
|
|
|
36
36
|
const makeSubscriptionStore = Effect.fn("SqliteSubscriptionStore.make")(function* (
|
|
37
37
|
owned: SourcePartition,
|
|
38
38
|
) {
|
|
39
|
-
const partition = yield* Schema.
|
|
39
|
+
const partition = yield* Schema.decodeEffect(SourcePartition)(owned).pipe(
|
|
40
40
|
Effect.mapError(() => SubscriptionError.make({ reason: "validation", code: "partition" })),
|
|
41
41
|
);
|
|
42
42
|
|
package/src/SqliteThreadStore.ts
CHANGED
|
@@ -120,9 +120,9 @@ const makeOffset = Effect.fn("SqliteThreadStore.makeOffset")(function* (
|
|
|
120
120
|
threadId: ThreadMaterialization["threadId"],
|
|
121
121
|
sequence: number,
|
|
122
122
|
): Effect.fn.Return<ObservationOffset, ThreadStoreError> {
|
|
123
|
-
return yield* Schema.
|
|
123
|
+
return yield* Schema.decodeEffect(CanonicalSequence)(sequence).pipe(
|
|
124
124
|
Effect.flatMap((validatedSequence) =>
|
|
125
|
-
Schema.
|
|
125
|
+
Schema.decodeEffect(ObservationOffset)(
|
|
126
126
|
`${SQLITE_OFFSET_PREFIX}${encodeURIComponent(threadId)}:${validatedSequence}`,
|
|
127
127
|
),
|
|
128
128
|
),
|
|
@@ -136,7 +136,7 @@ const parseOffset = Effect.fn("SqliteThreadStore.parseOffset")(function* (
|
|
|
136
136
|
): Effect.fn.Return<CanonicalSequence, ThreadStoreError> {
|
|
137
137
|
if (offset === undefined) return ZERO_CANONICAL_SEQUENCE;
|
|
138
138
|
|
|
139
|
-
const text = yield* Schema.
|
|
139
|
+
const text = yield* Schema.decodeEffect(OffsetText)(offset).pipe(
|
|
140
140
|
Effect.mapError((error) => schemaStoreError("decode observation offset", error)),
|
|
141
141
|
);
|
|
142
142
|
|
|
@@ -157,7 +157,7 @@ const parseOffset = Effect.fn("SqliteThreadStore.parseOffset")(function* (
|
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
return yield* Schema.
|
|
160
|
+
return yield* Schema.decodeEffect(CanonicalSequence)(Number(sequenceText)).pipe(
|
|
161
161
|
Effect.mapError((error) => schemaStoreError("decode observation offset", error)),
|
|
162
162
|
);
|
|
163
163
|
});
|
|
@@ -210,13 +210,13 @@ const decodeEnvelope = Effect.fn("SqliteThreadStore.decodeEnvelope")(function* (
|
|
|
210
210
|
),
|
|
211
211
|
);
|
|
212
212
|
|
|
213
|
-
const threadId = yield* Schema.
|
|
213
|
+
const threadId = yield* Schema.decodeEffect(CanonicalRecordEnvelope.fields.threadId)(
|
|
214
214
|
row.thread_id,
|
|
215
215
|
).pipe(Effect.mapError((error) => schemaStoreError("decode thread identity", error)));
|
|
216
216
|
|
|
217
217
|
const offset = yield* makeOffset(threadId, row.sequence);
|
|
218
218
|
|
|
219
|
-
const batchId = yield* Schema.
|
|
219
|
+
const batchId = yield* Schema.decodeEffect(CanonicalRecordEnvelope.fields.batchId)(
|
|
220
220
|
row.batch_id,
|
|
221
221
|
).pipe(Effect.mapError((error) => schemaStoreError("decode batch identity", error)));
|
|
222
222
|
|
|
@@ -270,7 +270,7 @@ const tailDigestAt = Effect.fn("SqliteThreadStore.tailDigestAt")(function* (
|
|
|
270
270
|
});
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
return yield* Schema.
|
|
273
|
+
return yield* Schema.decodeEffect(Digest)(digests[0]).pipe(
|
|
274
274
|
Effect.mapError((error) => schemaStoreError("decode checkpoint digest", error)),
|
|
275
275
|
);
|
|
276
276
|
});
|
|
@@ -511,7 +511,7 @@ const makeServices = Effect.fn("SqliteThreadStore.makeServices")(function* () {
|
|
|
511
511
|
const materialize: ThreadStore["Service"]["materialize"] = Effect.fn(
|
|
512
512
|
"SqliteThreadStore.materialize",
|
|
513
513
|
)(function* (request: ThreadMaterialization) {
|
|
514
|
-
const validated = yield* Schema.
|
|
514
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ThreadMaterialization))(
|
|
515
515
|
request,
|
|
516
516
|
).pipe(Effect.mapError((error) => schemaStoreError("validate materialization", error)));
|
|
517
517
|
|
|
@@ -538,9 +538,9 @@ const makeServices = Effect.fn("SqliteThreadStore.makeServices")(function* () {
|
|
|
538
538
|
const append: ThreadStore["Service"]["append"] = Effect.fn("SqliteThreadStore.append")(function* (
|
|
539
539
|
request: FencedAppendRequest,
|
|
540
540
|
) {
|
|
541
|
-
const validated = yield* Schema.
|
|
542
|
-
|
|
543
|
-
)
|
|
541
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(FencedAppendRequest))(request).pipe(
|
|
542
|
+
Effect.mapError((error) => schemaStoreError("validate canonical append", error)),
|
|
543
|
+
);
|
|
544
544
|
|
|
545
545
|
yield* requireThread(journal, validated.threadId);
|
|
546
546
|
|
|
@@ -559,7 +559,7 @@ const makeServices = Effect.fn("SqliteThreadStore.makeServices")(function* () {
|
|
|
559
559
|
),
|
|
560
560
|
);
|
|
561
561
|
|
|
562
|
-
const rawRequest = yield* Schema.
|
|
562
|
+
const rawRequest = yield* Schema.decodeEffect(RawAppendRequest)({
|
|
563
563
|
threadId: validated.threadId,
|
|
564
564
|
batchId: validated.batch.batchId,
|
|
565
565
|
batchDigest: tailDigest,
|
|
@@ -597,7 +597,7 @@ const makeServices = Effect.fn("SqliteThreadStore.makeServices")(function* () {
|
|
|
597
597
|
return storeError("append canonical batch", error);
|
|
598
598
|
}),
|
|
599
599
|
Effect.flatMap((result) =>
|
|
600
|
-
Schema.
|
|
600
|
+
Schema.decodeEffect(AppendResult)(result).pipe(
|
|
601
601
|
Effect.mapError((error) => schemaStoreError("decode append result", error)),
|
|
602
602
|
),
|
|
603
603
|
),
|
|
@@ -619,7 +619,7 @@ const makeServices = Effect.fn("SqliteThreadStore.makeServices")(function* () {
|
|
|
619
619
|
});
|
|
620
620
|
|
|
621
621
|
const readEffect = Effect.fn("SqliteThreadStore.read")(function* (request: ThreadRead) {
|
|
622
|
-
const validated = yield* Schema.
|
|
622
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ThreadRead))(request).pipe(
|
|
623
623
|
Effect.mapError((error) => schemaStoreError("validate thread read", error)),
|
|
624
624
|
);
|
|
625
625
|
|
|
@@ -641,9 +641,9 @@ const makeServices = Effect.fn("SqliteThreadStore.makeServices")(function* () {
|
|
|
641
641
|
const observeEffect = Effect.fn("SqliteThreadStore.observe")(function* (
|
|
642
642
|
request: ThreadObservation,
|
|
643
643
|
) {
|
|
644
|
-
const validated = yield* Schema.
|
|
645
|
-
|
|
646
|
-
)
|
|
644
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ThreadObservation))(request).pipe(
|
|
645
|
+
Effect.mapError((error) => schemaStoreError("validate thread observation", error)),
|
|
646
|
+
);
|
|
647
647
|
|
|
648
648
|
yield* requireThread(journal, validated.threadId);
|
|
649
649
|
const initialSequence = yield* parseOffset(validated.threadId, validated.afterOffset);
|
|
@@ -678,7 +678,7 @@ const makeServices = Effect.fn("SqliteThreadStore.makeServices")(function* () {
|
|
|
678
678
|
|
|
679
679
|
const exportThread: ThreadStore["Service"]["export"] = Effect.fn("SqliteThreadStore.export")(
|
|
680
680
|
function* (request: ThreadExportRequest) {
|
|
681
|
-
const validated = yield* Schema.
|
|
681
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ThreadExportRequest))(
|
|
682
682
|
request,
|
|
683
683
|
).pipe(Effect.mapError((error) => schemaStoreError("validate thread export", error)));
|
|
684
684
|
|
|
@@ -697,9 +697,9 @@ const makeServices = Effect.fn("SqliteThreadStore.makeServices")(function* () {
|
|
|
697
697
|
});
|
|
698
698
|
}
|
|
699
699
|
|
|
700
|
-
const tailDigest = yield* Schema.
|
|
701
|
-
|
|
702
|
-
)
|
|
700
|
+
const tailDigest = yield* Schema.decodeEffect(Digest)(exported.thread.tail_digest).pipe(
|
|
701
|
+
Effect.mapError((error) => schemaStoreError("decode export tail digest", error)),
|
|
702
|
+
);
|
|
703
703
|
|
|
704
704
|
return ThreadExport.make({
|
|
705
705
|
format: "effect-agent/thread@1",
|
|
@@ -714,13 +714,13 @@ const makeServices = Effect.fn("SqliteThreadStore.makeServices")(function* () {
|
|
|
714
714
|
const inspectTail: ThreadStore["Service"]["inspectTail"] = Effect.fn(
|
|
715
715
|
"SqliteThreadStore.inspectTail",
|
|
716
716
|
)(function* (request: ThreadTailRequest) {
|
|
717
|
-
const validated = yield* Schema.
|
|
718
|
-
|
|
719
|
-
)
|
|
717
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ThreadTailRequest))(request).pipe(
|
|
718
|
+
Effect.mapError((error) => schemaStoreError("validate tail inspection", error)),
|
|
719
|
+
);
|
|
720
720
|
|
|
721
721
|
const thread = yield* requireThread(journal, validated.threadId);
|
|
722
722
|
|
|
723
|
-
const tailDigest = yield* Schema.
|
|
723
|
+
const tailDigest = yield* Schema.decodeEffect(Digest)(thread.tail_digest).pipe(
|
|
724
724
|
Effect.mapError((error) => schemaStoreError("decode tail digest", error)),
|
|
725
725
|
);
|
|
726
726
|
|
|
@@ -734,7 +734,7 @@ const makeServices = Effect.fn("SqliteThreadStore.makeServices")(function* () {
|
|
|
734
734
|
|
|
735
735
|
const saveCheckpoint: ThreadCheckpoints["save"] = Effect.fn("SqliteThreadStore.saveCheckpoint")(
|
|
736
736
|
function* (request: SaveCheckpointRequest) {
|
|
737
|
-
const validated = yield* Schema.
|
|
737
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(SaveCheckpointRequest))(
|
|
738
738
|
request,
|
|
739
739
|
).pipe(Effect.mapError((error) => schemaStoreError("validate checkpoint", error)));
|
|
740
740
|
|
|
@@ -785,7 +785,7 @@ const makeServices = Effect.fn("SqliteThreadStore.makeServices")(function* () {
|
|
|
785
785
|
|
|
786
786
|
const loadCheckpoint: ThreadCheckpoints["load"] = Effect.fn("SqliteThreadStore.loadCheckpoint")(
|
|
787
787
|
function* (request: LoadCheckpointRequest) {
|
|
788
|
-
const validated = yield* Schema.
|
|
788
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(LoadCheckpointRequest))(
|
|
789
789
|
request,
|
|
790
790
|
).pipe(Effect.mapError((error) => schemaStoreError("validate checkpoint lookup", error)));
|
|
791
791
|
|
|
@@ -837,11 +837,9 @@ const makeServices = Effect.fn("SqliteThreadStore.makeServices")(function* () {
|
|
|
837
837
|
const saveRecoveryCheckpoint: ThreadRecoveryCheckpoints["save"] = Effect.fn(
|
|
838
838
|
"SqliteThreadStore.saveRecoveryCheckpoint",
|
|
839
839
|
)(function* (request) {
|
|
840
|
-
const validated = yield* Schema.
|
|
841
|
-
|
|
842
|
-
)
|
|
843
|
-
Effect.mapError((error) => schemaStoreError("validate recovery checkpoint", error)),
|
|
844
|
-
);
|
|
840
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(SaveRecoveryCheckpointRequest))(
|
|
841
|
+
request,
|
|
842
|
+
).pipe(Effect.mapError((error) => schemaStoreError("validate recovery checkpoint", error)));
|
|
845
843
|
|
|
846
844
|
const checkpointJson = yield* encodeCheckpoint(validated.checkpoint);
|
|
847
845
|
|
|
@@ -861,7 +859,7 @@ const makeServices = Effect.fn("SqliteThreadStore.makeServices")(function* () {
|
|
|
861
859
|
const loadRecoveryCheckpoint: ThreadRecoveryCheckpoints["load"] = Effect.fn(
|
|
862
860
|
"SqliteThreadStore.loadRecoveryCheckpoint",
|
|
863
861
|
)(function* (request) {
|
|
864
|
-
const validated = yield* Schema.
|
|
862
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(LoadCheckpointRequest))(
|
|
865
863
|
request,
|
|
866
864
|
).pipe(
|
|
867
865
|
Effect.mapError((error) => schemaStoreError("validate recovery checkpoint lookup", error)),
|
|
@@ -953,7 +951,7 @@ export const storageConfigLayer = (
|
|
|
953
951
|
options: SqliteStorageOptions,
|
|
954
952
|
): Layer.Layer<SqliteStorageConfig, SqliteStorageError> =>
|
|
955
953
|
Layer.effect(SqliteStorageConfig)(
|
|
956
|
-
Schema.
|
|
954
|
+
Schema.decodeEffect(SqliteStorageConfigValue)({
|
|
957
955
|
observationPollInterval: options.observationPollInterval ?? 25,
|
|
958
956
|
busyTimeout: options.busyTimeout ?? 5_000,
|
|
959
957
|
ownershipLeaseDuration:
|
|
@@ -1081,7 +1081,7 @@ export const initializeSqliteJournal = Effect.fn("SqliteJournal.initialize")(fun
|
|
|
1081
1081
|
});
|
|
1082
1082
|
}
|
|
1083
1083
|
|
|
1084
|
-
const firstSequence = yield* Schema.
|
|
1084
|
+
const firstSequence = yield* Schema.decodeEffect(CanonicalSequence)(
|
|
1085
1085
|
thread.tail_sequence + 1,
|
|
1086
1086
|
).pipe(
|
|
1087
1087
|
Effect.mapError((error) =>
|
|
@@ -1093,7 +1093,7 @@ export const initializeSqliteJournal = Effect.fn("SqliteJournal.initialize")(fun
|
|
|
1093
1093
|
),
|
|
1094
1094
|
);
|
|
1095
1095
|
|
|
1096
|
-
const lastSequence = yield* Schema.
|
|
1096
|
+
const lastSequence = yield* Schema.decodeEffect(CanonicalSequence)(
|
|
1097
1097
|
firstSequence + request.records.length - 1,
|
|
1098
1098
|
).pipe(
|
|
1099
1099
|
Effect.mapError((error) =>
|