@effect-agent/storage-sqlite 0.1.0-beta.84 → 0.1.0-beta.86
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.d.mts +1 -1
- package/dist/SqliteActivityStore.mjs +3 -3
- package/dist/SqliteActivityStore.mjs.map +1 -1
- package/dist/SqliteMessageDeliveryStore.d.mts +1 -1
- package/dist/SqliteMessageDeliveryStore.mjs +3 -3
- package/dist/SqliteMessageDeliveryStore.mjs.map +1 -1
- package/dist/SqliteScheduleStore.d.mts +1 -1
- package/dist/SqliteScheduleStore.mjs +4 -4
- package/dist/SqliteScheduleStore.mjs.map +1 -1
- package/dist/SqliteStorageConfig.d.mts +1 -1
- package/dist/SqliteStorageConfig.mjs +1 -1
- package/dist/SqliteStorageConfig.mjs.map +1 -1
- package/dist/SqliteStorageError.mjs +1 -1
- package/dist/SqliteStorageError.mjs.map +1 -1
- package/dist/SqliteSubmissionLedger.d.mts +1 -1
- package/dist/SqliteSubmissionLedger.mjs +35 -35
- package/dist/SqliteSubmissionLedger.mjs.map +1 -1
- package/dist/SqliteSubscriptionStore.d.mts +1 -1
- package/dist/SqliteSubscriptionStore.mjs +4 -4
- package/dist/SqliteSubscriptionStore.mjs.map +1 -1
- package/dist/SqliteThreadStore.d.mts +2 -2
- package/dist/SqliteThreadStore.mjs +26 -26
- package/dist/SqliteThreadStore.mjs.map +1 -1
- package/dist/{sqlite-journal-D9xFxCw-.mjs → sqlite-journal-CBOQDySe.mjs} +9 -9
- package/dist/sqlite-journal-CBOQDySe.mjs.map +1 -0
- package/package.json +1 -1
- package/src/SqliteActivityStore.ts +4 -4
- package/src/SqliteMessageDeliveryStore.ts +3 -3
- package/src/SqliteScheduleStore.ts +4 -4
- package/src/SqliteStorageConfig.ts +1 -1
- package/src/SqliteStorageError.ts +1 -1
- package/src/SqliteSubmissionLedger.ts +67 -67
- package/src/SqliteSubscriptionStore.ts +4 -8
- package/src/SqliteThreadStore.ts +51 -53
- package/src/internal/sqlite-journal.ts +11 -14
- package/dist/sqlite-journal-D9xFxCw-.mjs.map +0 -1
|
@@ -2,16 +2,16 @@ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
|
2
2
|
import { SqliteStorageConfig } from "./SqliteStorageConfig.mjs";
|
|
3
3
|
import { SqliteLedgerError, SqliteStorageCorruptionError, SqliteStorageError, SqliteWriteContention } from "./SqliteStorageError.mjs";
|
|
4
4
|
import { SqliteStorageFailpoint } from "./SqliteStorageFailpoint.mjs";
|
|
5
|
-
import { a as initializeSqliteJournal, i as decodeRows } from "./sqlite-journal-
|
|
5
|
+
import { a as initializeSqliteJournal, i as decodeRows } from "./sqlite-journal-CBOQDySe.mjs";
|
|
6
6
|
import { storageConfigLayer, storageFailpointLayer } from "./SqliteThreadStore.mjs";
|
|
7
7
|
import { Clock, Context, Crypto, DateTime, Effect, Layer, Option, Schema, Stream } from "effect";
|
|
8
8
|
import * as SqlClientService from "effect/unstable/sql/SqlClient";
|
|
9
|
-
import { EMPTY_TAIL_DIGEST } from "@effect-agent/thread/Digest";
|
|
10
|
-
import { ApprovalDecision, CanonicalSequence, DefinitionDigests, Digest, PersistedJson, ProducerEpoch, RecordEnvelope, SettlementOutcome, WorkerAdmission } from "@effect-agent/thread/Records";
|
|
11
9
|
import { NodeCrypto } from "@effect/platform-node";
|
|
12
10
|
import { SqliteClient } from "@effect/sql-sqlite-node";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
11
|
+
import { EMPTY_TAIL_DIGEST } from "effect-agent/digest";
|
|
12
|
+
import { ApprovalDecision, CanonicalSequence, DefinitionDigests, Digest, PersistedJson, ProducerEpoch, RecordEnvelope, SettlementOutcome, WorkerAdmission } from "effect-agent/records";
|
|
13
|
+
import { InputMessage } from "effect-agent/messaging";
|
|
14
|
+
import { AbortCommand, AbortIntent, AbortIntentRequest, AdmissionAdmitted, AdmissionConflict, AdmissionFence, AdmissionGroup, AdmissionNotAdmitted, AdmissionPolicyError, AdmissionRequest, AdmissionResult, ApprovalConflict, ApprovalDecisionCommand, ApprovalDecisionIntent, AttachChildToReservationRequest, BeginChildBudgetReleaseRequest, ChildAttachmentSnapshot, ChildBudgetReservationRequest, ChildBudgetReservationSnapshot, ChildReservationConflict, ChildReservationStatus, ChildSettledNotification, Claim, ClaimJoiningRequest, ClaimRequest, InputAppliedMarker, JoinSnapshot, JoinedToHost, JoiningClaim, LedgerCapabilities, LedgerError, MarkInputAppliedRequest, MarkJoinedRequest, MarkReadyRequest, MarkUnknownRequest, OwnershipLost, OwnershipRenewal, OwnershipSnapshot, ParentLinkage, QueueSequence, RecoverySnapshot, RecoverySnapshotRequest, ReleaseChildBudgetRequest, ReleaseOwnershipRequest, RenewOwnershipRequest, ReservedChildBudget, ReservedSettlement, RevertJoiningRequest, Settlement, SettlementConflict, SettlementFinalization, SettlementReservation, SettlementReservationSnapshot, SubmissionAdmissionFence, SubmissionLedger, SubmissionLookup, SubmissionLookupByKey, SubmissionSnapshot, SubmissionState, SuspendRequest, SuspensionReason, SuspensionSnapshot, UnknownResolution, UnknownResolutionCommand, UnknownResolutionConflict, UnknownResolutionIntent, settlementFailureFromRecord, submissionAbortRecordId } from "effect-agent/submission-ledger";
|
|
15
15
|
//#region src/SqliteSubmissionLedger.ts
|
|
16
16
|
var SqliteSubmissionLedger_exports = /* @__PURE__ */ __exportAll({
|
|
17
17
|
ledgerLayer: () => ledgerLayer,
|
|
@@ -291,7 +291,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
291
291
|
const ownership = yield* readOwnership(operation, submission.submission_id);
|
|
292
292
|
if (Option.isNone(ownership) || ownership.value.ownership_token !== ownershipToken) {
|
|
293
293
|
const actualEpoch = yield* threadEpoch(operation, submission.thread_id);
|
|
294
|
-
const submissionId = yield* Schema.
|
|
294
|
+
const submissionId = yield* Schema.decodeEffect(SubmissionSnapshot.fields.submissionId)(submission.submission_id).pipe(Effect.mapError(internalFailure(operation)));
|
|
295
295
|
return yield* OwnershipLost.make({
|
|
296
296
|
submissionId,
|
|
297
297
|
actualEpoch
|
|
@@ -486,14 +486,14 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
486
486
|
const capabilities = Effect.succeed(LedgerCapabilities.make({ durability: "durable-node" }));
|
|
487
487
|
const admit = Effect.fn("SqliteSubmissionLedger.admit")(function* (request) {
|
|
488
488
|
const operation = "ledger admit";
|
|
489
|
-
const validated = yield* Schema.
|
|
489
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(AdmissionRequest))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
490
490
|
const inputJson = yield* encodePersistedJsonText(validated.inputPayload).pipe(Effect.mapError(internalFailure(operation)));
|
|
491
491
|
const workerAdmissionJson = validated.workerAdmission === void 0 ? null : yield* Schema.encodeEffect(Schema.fromJsonString(WorkerAdmission))(validated.workerAdmission).pipe(Effect.mapError(internalFailure(operation)));
|
|
492
492
|
if (workerAdmissionJson !== null && new TextEncoder().encode(workerAdmissionJson).byteLength > 16777216) return yield* LedgerError.make({
|
|
493
493
|
operation,
|
|
494
494
|
message: "Worker admission metadata exceeds the stored value bound"
|
|
495
495
|
});
|
|
496
|
-
const messageAdmissionJson = validated.messageAdmission === void 0 ? null : yield* Schema.encodeEffect(Schema.fromJsonString(
|
|
496
|
+
const messageAdmissionJson = validated.messageAdmission === void 0 ? null : yield* Schema.encodeEffect(Schema.fromJsonString(InputMessage))(validated.messageAdmission).pipe(Effect.mapError(internalFailure(operation)));
|
|
497
497
|
if (messageAdmissionJson !== null && new TextEncoder().encode(messageAdmissionJson).byteLength > 16777216) return yield* LedgerError.make({
|
|
498
498
|
operation,
|
|
499
499
|
message: "Message admission metadata exceeds the stored value bound"
|
|
@@ -523,9 +523,9 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
523
523
|
attemptedInputDigest: validated.inputDigest
|
|
524
524
|
});
|
|
525
525
|
const retainedWorkerAdmission = existing[0].worker_admission_json === null ? void 0 : yield* Schema.decodeEffect(Schema.fromJsonString(WorkerAdmission))(existing[0].worker_admission_json).pipe(Effect.mapError(internalFailure(operation)));
|
|
526
|
-
const
|
|
526
|
+
const retainedInputMessage = existing[0].message_admission_json === null ? void 0 : yield* Schema.decodeEffect(Schema.fromJsonString(InputMessage))(existing[0].message_admission_json).pipe(Effect.mapError(internalFailure(operation)));
|
|
527
527
|
const retainedFence = existing[0].admission_fence_json === null ? void 0 : yield* Schema.decodeEffect(Schema.fromJsonString(AdmissionFence))(existing[0].admission_fence_json).pipe(Effect.mapError(internalFailure(operation)));
|
|
528
|
-
if ((existing[0].admission_group ?? void 0) !== validated.admissionGroup || !Schema.toEquivalence(Schema.optional(WorkerAdmission))(retainedWorkerAdmission, validated.workerAdmission) || !Schema.toEquivalence(Schema.optional(
|
|
528
|
+
if ((existing[0].admission_group ?? void 0) !== validated.admissionGroup || !Schema.toEquivalence(Schema.optional(WorkerAdmission))(retainedWorkerAdmission, validated.workerAdmission) || !Schema.toEquivalence(Schema.optional(InputMessage))(retainedInputMessage, validated.messageAdmission) || !Schema.toEquivalence(Schema.optional(AdmissionFence))(retainedFence, validated.admissionFence)) return yield* AdmissionConflict.make({
|
|
529
529
|
threadId: validated.threadId,
|
|
530
530
|
principal: validated.principal,
|
|
531
531
|
idempotencyKey: validated.idempotencyKey,
|
|
@@ -626,7 +626,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
626
626
|
});
|
|
627
627
|
const markReady = Effect.fn("SqliteSubmissionLedger.markReady")(function* (request) {
|
|
628
628
|
const operation = "ledger mark ready";
|
|
629
|
-
const validated = yield* Schema.
|
|
629
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(MarkReadyRequest))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
630
630
|
yield* hitFailpoint("ledger:mark-ready:before", operation);
|
|
631
631
|
yield* inWriteTransaction(operation, Effect.gen(function* () {
|
|
632
632
|
if ((yield* requireSubmission(operation, validated.submissionId)).state !== "admitted") return;
|
|
@@ -641,7 +641,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
641
641
|
});
|
|
642
642
|
const lookup = Effect.fn("SqliteSubmissionLedger.lookup")(function* (request) {
|
|
643
643
|
const operation = "ledger lookup";
|
|
644
|
-
const validated = yield* Schema.
|
|
644
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(SubmissionLookup))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
645
645
|
if (validated._tag === "SubmissionLookupById") {
|
|
646
646
|
const row = yield* readSubmission(operation, validated.submissionId);
|
|
647
647
|
if (Option.isNone(row)) return Option.none();
|
|
@@ -661,7 +661,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
661
661
|
});
|
|
662
662
|
const resolveAdmission = Effect.fn("SqliteSubmissionLedger.resolveAdmission")(function* (request) {
|
|
663
663
|
const operation = "ledger resolve admission";
|
|
664
|
-
const validated = yield* Schema.
|
|
664
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(SubmissionLookupByKey))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
665
665
|
const rows = yield* sql`
|
|
666
666
|
SELECT ${sql.literal(SUBMISSION_COLUMNS)}
|
|
667
667
|
FROM effect_agent_submissions
|
|
@@ -676,7 +676,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
676
676
|
});
|
|
677
677
|
const claim = Effect.fn("SqliteSubmissionLedger.claim")(function* (request) {
|
|
678
678
|
const operation = "ledger claim";
|
|
679
|
-
const validated = yield* Schema.
|
|
679
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ClaimRequest))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
680
680
|
const attemptId = yield* mintIdentifier("attempt", operation);
|
|
681
681
|
const ownershipToken = yield* mintIdentifier("owner", operation);
|
|
682
682
|
yield* hitFailpoint("ledger:claim:before", operation);
|
|
@@ -786,7 +786,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
786
786
|
});
|
|
787
787
|
const renewOwnership = Effect.fn("SqliteSubmissionLedger.renewOwnership")(function* (request) {
|
|
788
788
|
const operation = "ledger renew ownership";
|
|
789
|
-
const validated = yield* Schema.
|
|
789
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(RenewOwnershipRequest))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
790
790
|
yield* hitFailpoint("ledger:renew:before", operation);
|
|
791
791
|
const renewal = yield* inWriteTransaction(operation, Effect.gen(function* () {
|
|
792
792
|
const submission = yield* requireSubmission(operation, validated.submissionId);
|
|
@@ -808,7 +808,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
808
808
|
});
|
|
809
809
|
const releaseOwnership = Effect.fn("SqliteSubmissionLedger.releaseOwnership")(function* (request) {
|
|
810
810
|
const operation = "ledger release ownership";
|
|
811
|
-
const validated = yield* Schema.
|
|
811
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ReleaseOwnershipRequest))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
812
812
|
yield* hitFailpoint("ledger:release:before", operation);
|
|
813
813
|
yield* inWriteTransaction(operation, Effect.gen(function* () {
|
|
814
814
|
const submission = yield* requireSubmission(operation, validated.submissionId);
|
|
@@ -827,7 +827,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
827
827
|
});
|
|
828
828
|
const markInputApplied = Effect.fn("SqliteSubmissionLedger.markInputApplied")(function* (request) {
|
|
829
829
|
const operation = "ledger mark input applied";
|
|
830
|
-
const validated = yield* Schema.
|
|
830
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(MarkInputAppliedRequest))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
831
831
|
yield* hitFailpoint("ledger:mark-input-applied:before", operation);
|
|
832
832
|
yield* inWriteTransaction(operation, Effect.gen(function* () {
|
|
833
833
|
const submission = yield* requireSubmission(operation, validated.submissionId);
|
|
@@ -852,7 +852,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
852
852
|
});
|
|
853
853
|
const reserveSettlement = Effect.fn("SqliteSubmissionLedger.reserveSettlement")(function* (request) {
|
|
854
854
|
const operation = "ledger reserve settlement";
|
|
855
|
-
const validated = yield* Schema.
|
|
855
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(SettlementReservation))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
856
856
|
const recordJson = yield* encodeRecordEnvelopeText(validated.record).pipe(Effect.mapError(internalFailure(operation)));
|
|
857
857
|
yield* hitFailpoint("ledger:reserve-settlement:before", operation);
|
|
858
858
|
const reserved = yield* inWriteTransaction(operation, Effect.gen(function* () {
|
|
@@ -960,7 +960,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
960
960
|
});
|
|
961
961
|
const finalizeSettlement = Effect.fn("SqliteSubmissionLedger.finalizeSettlement")(function* (request) {
|
|
962
962
|
const operation = "ledger finalize settlement";
|
|
963
|
-
const validated = yield* Schema.
|
|
963
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(SettlementFinalization))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
964
964
|
yield* hitFailpoint("ledger:finalize-settlement:before", operation);
|
|
965
965
|
const replayRows = yield* sql`
|
|
966
966
|
SELECT submission.*, reservation.settlement_id, reservation.outcome,
|
|
@@ -1015,7 +1015,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1015
1015
|
});
|
|
1016
1016
|
const requestAbort = Effect.fn("SqliteSubmissionLedger.requestAbort")(function* (request) {
|
|
1017
1017
|
const operation = "ledger request abort";
|
|
1018
|
-
const validated = yield* Schema.
|
|
1018
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(AbortCommand))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
1019
1019
|
yield* hitFailpoint("ledger:request-abort:before", operation);
|
|
1020
1020
|
const intent = yield* inWriteTransaction(operation, Effect.gen(function* () {
|
|
1021
1021
|
const submission = yield* requireSubmission(operation, validated.submissionId);
|
|
@@ -1064,7 +1064,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1064
1064
|
});
|
|
1065
1065
|
const claimJoining = Effect.fn("SqliteSubmissionLedger.claimJoining")(function* (request) {
|
|
1066
1066
|
const operation = "ledger claim joining";
|
|
1067
|
-
const validated = yield* Schema.
|
|
1067
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ClaimJoiningRequest))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
1068
1068
|
yield* hitFailpoint("ledger:claim-joining:before", operation);
|
|
1069
1069
|
const claims = yield* inWriteTransaction(operation, Effect.gen(function* () {
|
|
1070
1070
|
const host = yield* requireSubmission(operation, validated.hostSubmissionId);
|
|
@@ -1106,7 +1106,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1106
1106
|
});
|
|
1107
1107
|
const markJoined = Effect.fn("SqliteSubmissionLedger.markJoined")(function* (request) {
|
|
1108
1108
|
const operation = "ledger mark joined";
|
|
1109
|
-
const validated = yield* Schema.
|
|
1109
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(MarkJoinedRequest))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
1110
1110
|
yield* hitFailpoint("ledger:mark-joined:before", operation);
|
|
1111
1111
|
yield* inWriteTransaction(operation, Effect.gen(function* () {
|
|
1112
1112
|
const submission = yield* requireSubmission(operation, validated.submissionId);
|
|
@@ -1137,7 +1137,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1137
1137
|
});
|
|
1138
1138
|
const revertJoining = Effect.fn("SqliteSubmissionLedger.revertJoining")(function* (request) {
|
|
1139
1139
|
const operation = "ledger revert joining";
|
|
1140
|
-
const validated = yield* Schema.
|
|
1140
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(RevertJoiningRequest))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
1141
1141
|
yield* hitFailpoint("ledger:revert-joining:before", operation);
|
|
1142
1142
|
yield* inWriteTransaction(operation, Effect.gen(function* () {
|
|
1143
1143
|
if ((yield* requireSubmission(operation, validated.submissionId)).state !== "joining") return;
|
|
@@ -1151,7 +1151,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1151
1151
|
});
|
|
1152
1152
|
const suspend = Effect.fn("SqliteSubmissionLedger.suspend")(function* (request) {
|
|
1153
1153
|
const operation = "ledger suspend";
|
|
1154
|
-
const validated = yield* Schema.
|
|
1154
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(SuspendRequest))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
1155
1155
|
const reasonJson = yield* encodeSuspensionReasonText(validated.reason).pipe(Effect.mapError(internalFailure(operation)));
|
|
1156
1156
|
yield* hitFailpoint("ledger:suspend:before", operation);
|
|
1157
1157
|
const outcome = yield* inWriteTransaction(operation, Effect.gen(function* () {
|
|
@@ -1226,7 +1226,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1226
1226
|
});
|
|
1227
1227
|
const recordApprovalDecision = Effect.fn("SqliteSubmissionLedger.recordApprovalDecision")(function* (command) {
|
|
1228
1228
|
const operation = "ledger record approval decision";
|
|
1229
|
-
const validated = yield* Schema.
|
|
1229
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ApprovalDecisionCommand))(command).pipe(Effect.mapError(internalFailure(operation)));
|
|
1230
1230
|
yield* hitFailpoint("ledger:approval-decision:before", operation);
|
|
1231
1231
|
const intent = yield* inWriteTransaction(operation, Effect.gen(function* () {
|
|
1232
1232
|
const submission = yield* requireSubmission(operation, validated.submissionId);
|
|
@@ -1279,7 +1279,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1279
1279
|
});
|
|
1280
1280
|
const markUnknown = Effect.fn("SqliteSubmissionLedger.markUnknown")(function* (request) {
|
|
1281
1281
|
const operation = "ledger mark unknown";
|
|
1282
|
-
const validated = yield* Schema.
|
|
1282
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(MarkUnknownRequest))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
1283
1283
|
yield* hitFailpoint("ledger:mark-unknown:before", operation);
|
|
1284
1284
|
yield* inWriteTransaction(operation, Effect.gen(function* () {
|
|
1285
1285
|
const submission = yield* requireSubmission(operation, validated.submissionId);
|
|
@@ -1312,7 +1312,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1312
1312
|
});
|
|
1313
1313
|
const recordUnknownResolution = Effect.fn("SqliteSubmissionLedger.recordUnknownResolution")(function* (command) {
|
|
1314
1314
|
const operation = "ledger record unknown resolution";
|
|
1315
|
-
const validated = yield* Schema.
|
|
1315
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(UnknownResolutionCommand))(command).pipe(Effect.mapError(internalFailure(operation)));
|
|
1316
1316
|
const resolutionJson = yield* encodeUnknownResolutionText(validated.resolution).pipe(Effect.mapError(internalFailure(operation)));
|
|
1317
1317
|
yield* hitFailpoint("ledger:unknown-resolution:before", operation);
|
|
1318
1318
|
const intent = yield* inWriteTransaction(operation, Effect.gen(function* () {
|
|
@@ -1381,7 +1381,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1381
1381
|
});
|
|
1382
1382
|
const recordChildSettled = Effect.fn("SqliteSubmissionLedger.recordChildSettled")(function* (request) {
|
|
1383
1383
|
const operation = "ledger record child settled";
|
|
1384
|
-
const validated = yield* Schema.
|
|
1384
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ChildSettledNotification))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
1385
1385
|
yield* hitFailpoint("ledger:child-settled:before", operation);
|
|
1386
1386
|
const outcome = yield* inWriteTransaction(operation, Effect.gen(function* () {
|
|
1387
1387
|
const parent = yield* requireSubmission(operation, validated.parentSubmissionId);
|
|
@@ -1415,7 +1415,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1415
1415
|
});
|
|
1416
1416
|
const reserveChildBudget = Effect.fn("SqliteSubmissionLedger.reserveChildBudget")(function* (request) {
|
|
1417
1417
|
const operation = "ledger reserve child budget";
|
|
1418
|
-
const validated = yield* Schema.
|
|
1418
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ChildBudgetReservationRequest))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
1419
1419
|
const allocationJson = yield* encodePersistedJsonText(validated.allocation).pipe(Effect.mapError(internalFailure(operation)));
|
|
1420
1420
|
yield* hitFailpoint("ledger:child-reservation:before", operation);
|
|
1421
1421
|
const reserved = yield* inWriteTransaction(operation, Effect.gen(function* () {
|
|
@@ -1472,7 +1472,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1472
1472
|
});
|
|
1473
1473
|
const attachChildToReservation = Effect.fn("SqliteSubmissionLedger.attachChildToReservation")(function* (request) {
|
|
1474
1474
|
const operation = "ledger attach child to reservation";
|
|
1475
|
-
const validated = yield* Schema.
|
|
1475
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(AttachChildToReservationRequest))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
1476
1476
|
yield* hitFailpoint("ledger:child-attach:before", operation);
|
|
1477
1477
|
const attached = yield* inWriteTransaction(operation, Effect.gen(function* () {
|
|
1478
1478
|
const existing = yield* readChildReservation(operation, validated.reservationId);
|
|
@@ -1514,7 +1514,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1514
1514
|
});
|
|
1515
1515
|
const beginChildBudgetRelease = Effect.fn("SqliteSubmissionLedger.beginChildBudgetRelease")(function* (request) {
|
|
1516
1516
|
const operation = "ledger begin child budget release";
|
|
1517
|
-
const validated = yield* Schema.
|
|
1517
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(BeginChildBudgetReleaseRequest))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
1518
1518
|
const accountingJson = yield* encodePersistedJsonText(validated.accounting).pipe(Effect.mapError(internalFailure(operation)));
|
|
1519
1519
|
yield* hitFailpoint("ledger:child-release-pending:before", operation);
|
|
1520
1520
|
const frozen = yield* inWriteTransaction(operation, Effect.gen(function* () {
|
|
@@ -1550,7 +1550,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1550
1550
|
});
|
|
1551
1551
|
const releaseChildBudget = Effect.fn("SqliteSubmissionLedger.releaseChildBudget")(function* (request) {
|
|
1552
1552
|
const operation = "ledger release child budget";
|
|
1553
|
-
const validated = yield* Schema.
|
|
1553
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ReleaseChildBudgetRequest))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
1554
1554
|
yield* hitFailpoint("ledger:child-release:before", operation);
|
|
1555
1555
|
const released = yield* inWriteTransaction(operation, Effect.gen(function* () {
|
|
1556
1556
|
const existing = yield* readChildReservation(operation, validated.reservationId);
|
|
@@ -1604,7 +1604,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1604
1604
|
const scanNonterminal = Stream.paginate(void 0, scanPage);
|
|
1605
1605
|
const readAbortIntentForSubmission = Effect.fn("SqliteSubmissionLedger.readAbortIntentForSubmission")(function* (request) {
|
|
1606
1606
|
const operation = "ledger read abort intent";
|
|
1607
|
-
const validated = yield* Schema.
|
|
1607
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(AbortIntentRequest))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
1608
1608
|
const recordId = submissionAbortRecordId(validated.submissionId);
|
|
1609
1609
|
const rows = yield* sql`
|
|
1610
1610
|
SELECT
|
|
@@ -1640,7 +1640,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1640
1640
|
});
|
|
1641
1641
|
const loadRecoverySnapshot = Effect.fn("SqliteSubmissionLedger.loadRecoverySnapshot")(function* (request) {
|
|
1642
1642
|
const operation = "ledger load recovery snapshot";
|
|
1643
|
-
const validated = yield* Schema.
|
|
1643
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(RecoverySnapshotRequest))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
1644
1644
|
return yield* journal.withReadTransaction(operation)(Effect.gen(function* () {
|
|
1645
1645
|
const submissionRow = yield* requireSubmission(operation, validated.submissionId);
|
|
1646
1646
|
const submission = yield* decodeSubmissionSnapshot(operation, submissionRow);
|
|
@@ -1661,7 +1661,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1661
1661
|
const reservationRow = yield* readReservation(operation, validated.submissionId);
|
|
1662
1662
|
if (Option.isSome(reservationRow)) {
|
|
1663
1663
|
const record = yield* decodeRecordEnvelopeText(reservationRow.value.record_json).pipe(Effect.mapError((error) => corruptionFailure(operation, "effect_agent_settlement_reservations", validated.submissionId, error.message)));
|
|
1664
|
-
const settlementId = yield* Schema.
|
|
1664
|
+
const settlementId = yield* Schema.decodeEffect(SettlementReservationSnapshot.fields.settlementId)(reservationRow.value.settlement_id).pipe(Effect.mapError(internalFailure(operation)));
|
|
1665
1665
|
reservation = SettlementReservationSnapshot.make({
|
|
1666
1666
|
settlementId,
|
|
1667
1667
|
outcome: reservationRow.value.outcome,
|