@effect-agent/storage-cloudflare 0.1.0-beta.56 → 0.1.0-beta.58
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/DoMemoryStore.d.mts +2 -2
- package/dist/DoMemoryStore.mjs +2 -2
- package/dist/DoMessageDeliveryStore.d.mts +17 -0
- package/dist/DoMessageDeliveryStore.mjs +32 -0
- package/dist/DoMessageDeliveryStore.mjs.map +1 -0
- package/dist/DoScheduleStore.d.mts +1 -1
- package/dist/DoScheduleStore.mjs +2 -2
- package/dist/{DoStorageVersion-DxqcVgDE.d.mts → DoStorageVersion-Pt3jEHdW.d.mts} +2 -2
- package/dist/DoStorageVersion.d.mts +1 -1
- package/dist/DoStorageVersion.mjs +2 -2
- package/dist/DoSubmissionLedger.mjs +45 -9
- package/dist/DoSubmissionLedger.mjs.map +1 -1
- package/dist/DoSubscriptionStore.mjs +1 -1
- package/dist/DoThreadStore.d.mts +1 -1
- package/dist/DoThreadStore.mjs +432 -5
- package/dist/DoThreadStore.mjs.map +1 -0
- package/dist/MemoryProtocol.d.mts +1 -1
- package/dist/MemoryProtocol.mjs +1 -1
- package/dist/PortProtocol.d.mts +1334 -7
- package/dist/{DoThreadStore-CCSgDto6.mjs → do-journal-Brv7xSH5.mjs} +186 -456
- package/dist/do-journal-Brv7xSH5.mjs.map +1 -0
- package/dist/index.d.mts +5 -4
- package/dist/index.mjs +6 -5
- package/dist/{migrations-B-jiT7vx.mjs → migrations-soC86CQA.mjs} +30 -5
- package/dist/migrations-soC86CQA.mjs.map +1 -0
- package/package.json +1 -1
- package/src/DoMessageDeliveryStore.ts +53 -0
- package/src/DoSubmissionLedger.ts +118 -3
- package/src/index.ts +1 -0
- package/src/internal/do-journal.ts +174 -19
- package/src/internal/message-delivery-schema.ts +24 -0
- package/src/internal/migrations.ts +6 -1
- package/dist/DoThreadStore-CCSgDto6.mjs.map +0 -1
- package/dist/migrations-B-jiT7vx.mjs.map +0 -1
package/dist/DoMemoryStore.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MemoryMutationFailpoint } from "@effect-agent/core/MemoryStore";
|
|
2
|
-
import { SqliteClient } from "@effect/sql-sqlite-do";
|
|
3
1
|
import { Layer, Schema } from "effect";
|
|
2
|
+
import { SqliteClient } from "@effect/sql-sqlite-do";
|
|
3
|
+
import { MemoryMutationFailpoint } from "@effect-agent/core/MemoryStore";
|
|
4
4
|
declare namespace DoMemoryStore_d_exports {
|
|
5
5
|
export { DoMemoryStorageLimits, defaultDoMemoryStorageLimits, doMemoryStoreLayer, doMemoryStoreLayerWithFailpoints };
|
|
6
6
|
}
|
package/dist/DoMemoryStore.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { Effect, Layer, Schema } from "effect";
|
|
3
|
+
import { SqliteClient } from "@effect/sql-sqlite-do";
|
|
2
4
|
import { MemoryMutationFailpoint, MemoryStorageError } from "@effect-agent/core/MemoryStore";
|
|
3
5
|
import { SqlMemoryLimits, memoryStoreLayerWithFailpoints } from "@effect-agent/thread/SqlMemoryStore";
|
|
4
|
-
import { SqliteClient } from "@effect/sql-sqlite-do";
|
|
5
|
-
import { Effect, Layer, Schema } from "effect";
|
|
6
6
|
//#region src/DoMemoryStore.ts
|
|
7
7
|
var DoMemoryStore_exports = /* @__PURE__ */ __exportAll({
|
|
8
8
|
DoMemoryStorageLimits: () => DoMemoryStorageLimits,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { a as DoStorageCompatibilityError, o as DoStorageCorruptionError, s as DoStorageError } from "./DoStorageError-UrxrvbnF.mjs";
|
|
2
|
+
import { DoStorageConfig } from "./DoStorageConfig.mjs";
|
|
3
|
+
import { DoStorageFailpoint } from "./DoStorageFailpoint.mjs";
|
|
4
|
+
import { MessageDeliveryError, MessageDeliveryStore, MessageDeliveryStoreLimits } from "@effect-agent/thread/MessageDelivery";
|
|
5
|
+
import { Layer } from "effect";
|
|
6
|
+
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
|
7
|
+
declare namespace DoMessageDeliveryStore_d_exports {
|
|
8
|
+
export { doMessageDeliveryStoreLayer };
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Message obligations in a Thread Object's own SQL storage. The platform must prearm
|
|
12
|
+
* maintenance before insertion and retain its alarm while nextDeadline is present.
|
|
13
|
+
*/
|
|
14
|
+
declare const doMessageDeliveryStoreLayer: (limits?: MessageDeliveryStoreLimits) => Layer.Layer<MessageDeliveryStore, DoStorageCompatibilityError | DoStorageCorruptionError | DoStorageError | MessageDeliveryError, DoStorageConfig | DoStorageFailpoint | SqlClient.SqlClient>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { doMessageDeliveryStoreLayer, DoMessageDeliveryStore_d_exports as t };
|
|
17
|
+
//# sourceMappingURL=DoMessageDeliveryStore.d.mts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { DoStorageConfig } from "./DoStorageConfig.mjs";
|
|
3
|
+
import { DoStorageFailpoint } from "./DoStorageFailpoint.mjs";
|
|
4
|
+
import { a as initializeDoJournal } from "./do-journal-Brv7xSH5.mjs";
|
|
5
|
+
import { MessageDeliveryError, MessageDeliveryStore } from "@effect-agent/thread/MessageDelivery";
|
|
6
|
+
import { SqlMessageDeliveryTransaction, makeSqlMessageDeliveryStore } from "@effect-agent/thread/SqlMessageDeliveryStore";
|
|
7
|
+
import { Effect, Layer } from "effect";
|
|
8
|
+
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
|
9
|
+
//#region src/DoMessageDeliveryStore.ts
|
|
10
|
+
var DoMessageDeliveryStore_exports = /* @__PURE__ */ __exportAll({ doMessageDeliveryStoreLayer: () => doMessageDeliveryStoreLayer });
|
|
11
|
+
const transactions = Layer.effect(SqlMessageDeliveryTransaction, Effect.gen(function* () {
|
|
12
|
+
const sql = yield* SqlClient.SqlClient;
|
|
13
|
+
return SqlMessageDeliveryTransaction.of({ run: (body) => sql.withTransaction(body).pipe(Effect.catchTag("SqlError", () => MessageDeliveryError.make({
|
|
14
|
+
reason: "storage",
|
|
15
|
+
operation: "transaction"
|
|
16
|
+
}))) });
|
|
17
|
+
}));
|
|
18
|
+
/**
|
|
19
|
+
* Message obligations in a Thread Object's own SQL storage. The platform must prearm
|
|
20
|
+
* maintenance before insertion and retain its alarm while nextDeadline is present.
|
|
21
|
+
*/
|
|
22
|
+
const doMessageDeliveryStoreLayer = (limits) => Layer.effect(MessageDeliveryStore, Effect.gen(function* () {
|
|
23
|
+
const sql = yield* SqlClient.SqlClient;
|
|
24
|
+
const config = yield* DoStorageConfig;
|
|
25
|
+
const failpoint = yield* DoStorageFailpoint;
|
|
26
|
+
yield* initializeDoJournal(sql, failpoint.hit, config.maxStoredValueBytes);
|
|
27
|
+
return yield* makeSqlMessageDeliveryStore(limits, { maxStoredValueBytes: config.maxStoredValueBytes });
|
|
28
|
+
})).pipe(Layer.provide(transactions));
|
|
29
|
+
//#endregion
|
|
30
|
+
export { doMessageDeliveryStoreLayer, DoMessageDeliveryStore_exports as t };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=DoMessageDeliveryStore.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DoMessageDeliveryStore.mjs","names":[],"sources":["../src/DoMessageDeliveryStore.ts"],"sourcesContent":["import {\n MessageDeliveryError,\n MessageDeliveryStore,\n type MessageDeliveryStoreLimits,\n} from \"@effect-agent/thread/MessageDelivery\";\nimport {\n makeSqlMessageDeliveryStore,\n SqlMessageDeliveryTransaction,\n} from \"@effect-agent/thread/SqlMessageDeliveryStore\";\nimport { Effect, Layer } from \"effect\";\nimport * as SqlClient from \"effect/unstable/sql/SqlClient\";\n\nimport { DoStorageConfig } from \"./DoStorageConfig.ts\";\nimport { DoStorageFailpoint } from \"./DoStorageFailpoint.ts\";\nimport { initializeDoJournal } from \"./internal/do-journal.ts\";\n\nconst transactions = Layer.effect(\n SqlMessageDeliveryTransaction,\n Effect.gen(function* () {\n const sql = yield* SqlClient.SqlClient;\n\n return SqlMessageDeliveryTransaction.of({\n run: (body) =>\n sql\n .withTransaction(body)\n .pipe(\n Effect.catchTag(\"SqlError\", () =>\n MessageDeliveryError.make({ reason: \"storage\", operation: \"transaction\" }),\n ),\n ),\n });\n }),\n);\n\n/**\n * Message obligations in a Thread Object's own SQL storage. The platform must prearm\n * maintenance before insertion and retain its alarm while nextDeadline is present.\n */\nexport const doMessageDeliveryStoreLayer = (limits?: MessageDeliveryStoreLimits) =>\n Layer.effect(\n MessageDeliveryStore,\n Effect.gen(function* () {\n const sql = yield* SqlClient.SqlClient;\n const config = yield* DoStorageConfig;\n const failpoint = yield* DoStorageFailpoint;\n\n yield* initializeDoJournal(sql, failpoint.hit, config.maxStoredValueBytes);\n\n return yield* makeSqlMessageDeliveryStore(limits, {\n maxStoredValueBytes: config.maxStoredValueBytes,\n });\n }),\n ).pipe(Layer.provide(transactions));\n"],"mappings":";;;;;;;;;;AAgBA,MAAM,eAAe,MAAM,OACzB,+BACA,OAAO,IAAI,aAAa;CACtB,MAAM,MAAM,OAAO,UAAU;CAE7B,OAAO,8BAA8B,GAAG,EACtC,MAAM,SACJ,IACG,gBAAgB,IAAI,CAAC,CACrB,KACC,OAAO,SAAS,kBACd,qBAAqB,KAAK;EAAE,QAAQ;EAAW,WAAW;CAAc,CAAC,CAC3E,CACF,EACN,CAAC;AACH,CAAC,CACH;;;;;AAMA,MAAa,+BAA+B,WAC1C,MAAM,OACJ,sBACA,OAAO,IAAI,aAAa;CACtB,MAAM,MAAM,OAAO,UAAU;CAC7B,MAAM,SAAS,OAAO;CACtB,MAAM,YAAY,OAAO;CAEzB,OAAO,oBAAoB,KAAK,UAAU,KAAK,OAAO,mBAAmB;CAEzE,OAAO,OAAO,4BAA4B,QAAQ,EAChD,qBAAqB,OAAO,oBAC9B,CAAC;AACH,CAAC,CACH,CAAC,CAAC,KAAK,MAAM,QAAQ,YAAY,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context, Effect, Layer } from "effect";
|
|
2
|
-
import { ScheduleFailpointError, ScheduleStorageError, ScheduleStore } from "@effect-agent/thread/Schedule";
|
|
3
2
|
import * as SqlClientService from "effect/unstable/sql/SqlClient";
|
|
3
|
+
import { ScheduleFailpointError, ScheduleStorageError, ScheduleStore } from "@effect-agent/thread/Schedule";
|
|
4
4
|
declare namespace DoScheduleStore_d_exports {
|
|
5
5
|
export { DoScheduleAlarmControl, DoScheduleAlarmReplacement, DoScheduleReplaceAlarm, DoScheduleTransaction, scheduleStoreLayer };
|
|
6
6
|
}
|
package/dist/DoScheduleStore.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
2
|
import { Context, Effect, Layer, Result, Schema } from "effect";
|
|
3
|
+
import * as SqlClientService from "effect/unstable/sql/SqlClient";
|
|
4
|
+
import { upgradeV2Schedules } from "@effect-agent/thread/SqlStorageV2Upgrade";
|
|
3
5
|
import { ScheduleCapacityError, ScheduleChange, ScheduleConflict, ScheduleDueCursor, ScheduleFailpoint, ScheduleId, ScheduleInstant, ScheduleKey, ScheduleNotFound, ScheduleOwner, SchedulePageRequest, ScheduleRecord, ScheduleStorageError, ScheduleStore, defaultSchedulingLimits } from "@effect-agent/thread/Schedule";
|
|
4
6
|
import { applyScheduleChange, scheduleDeadline, scheduleUsesCapacity } from "@effect-agent/thread/ScheduleTransition";
|
|
5
|
-
import { upgradeV2Schedules } from "@effect-agent/thread/SqlStorageV2Upgrade";
|
|
6
|
-
import * as SqlClientService from "effect/unstable/sql/SqlClient";
|
|
7
7
|
//#region src/DoScheduleStore.ts
|
|
8
8
|
var DoScheduleStore_exports = /* @__PURE__ */ __exportAll({
|
|
9
9
|
DoScheduleAlarmControl: () => DoScheduleAlarmControl,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SqliteMigrator } from "@effect/sql-sqlite-do";
|
|
2
2
|
//#region src/internal/migrations.d.ts
|
|
3
3
|
/** The current storage version recorded in `effect_agent_meta`. */
|
|
4
|
-
declare const CurrentDoStorageVersion =
|
|
4
|
+
declare const CurrentDoStorageVersion = 4;
|
|
5
5
|
declare namespace DoStorageVersion_d_exports {
|
|
6
6
|
export { CurrentDoStorageVersion };
|
|
7
7
|
}
|
|
8
8
|
//#endregion
|
|
9
9
|
export { CurrentDoStorageVersion as n, DoStorageVersion_d_exports as t };
|
|
10
|
-
//# sourceMappingURL=DoStorageVersion-
|
|
10
|
+
//# sourceMappingURL=DoStorageVersion-Pt3jEHdW.d.mts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as CurrentDoStorageVersion } from "./DoStorageVersion-
|
|
1
|
+
import { n as CurrentDoStorageVersion } from "./DoStorageVersion-Pt3jEHdW.mjs";
|
|
2
2
|
export { CurrentDoStorageVersion };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { t as CurrentDoStorageVersion } from "./migrations-
|
|
2
|
+
import { t as CurrentDoStorageVersion } from "./migrations-soC86CQA.mjs";
|
|
3
3
|
//#region src/DoStorageVersion.ts
|
|
4
|
-
var DoStorageVersion_exports = /* @__PURE__ */ __exportAll({ CurrentDoStorageVersion: () =>
|
|
4
|
+
var DoStorageVersion_exports = /* @__PURE__ */ __exportAll({ CurrentDoStorageVersion: () => 4 });
|
|
5
5
|
//#endregion
|
|
6
6
|
export { CurrentDoStorageVersion, DoStorageVersion_exports as t };
|
|
7
7
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
2
|
import { DoStorageConfig } from "./DoStorageConfig.mjs";
|
|
3
|
-
import { DoLedgerError, DoStorageCorruptionError, DoStorageError } from "./DoStorageError.mjs";
|
|
4
3
|
import { DoStorageFailpoint } from "./DoStorageFailpoint.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { DoLedgerError, DoStorageCorruptionError, DoStorageError } from "./DoStorageError.mjs";
|
|
5
|
+
import { a as initializeDoJournal, i as decodeRows } from "./do-journal-Brv7xSH5.mjs";
|
|
6
|
+
import { storageConfigLayer, storageFailpointLayer } from "./DoThreadStore.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 { ApprovalDecision, CanonicalSequence, DefinitionDigests, Digest, PersistedJson, ProducerEpoch, RecordEnvelope, SettlementOutcome } from "@effect-agent/thread/Records";
|
|
9
|
+
import { ApprovalDecision, CanonicalSequence, DefinitionDigests, Digest, PersistedJson, ProducerEpoch, RecordEnvelope, SettlementOutcome, WorkerAdmission } from "@effect-agent/thread/Records";
|
|
10
|
+
import { SqliteClient } from "@effect/sql-sqlite-do";
|
|
11
|
+
import { MessageAdmission } from "@effect-agent/core/Messaging";
|
|
10
12
|
import { EMPTY_TAIL_DIGEST } from "@effect-agent/thread/Digest";
|
|
11
13
|
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/thread/SubmissionLedger";
|
|
12
14
|
import { BrowserCrypto } from "@effect/platform-browser";
|
|
@@ -56,7 +58,9 @@ var SubmissionRow = class extends Schema.Class("SubmissionRow")({
|
|
|
56
58
|
parent_submission_id: Schema.NullOr(BoundedIdentifier),
|
|
57
59
|
parent_tool_call_id: Schema.NullOr(BoundedIdentifier),
|
|
58
60
|
admission_group: Schema.NullOr(AdmissionGroup),
|
|
59
|
-
admission_fence_json: Schema.NullOr(BoundedStoredText)
|
|
61
|
+
admission_fence_json: Schema.NullOr(BoundedStoredText),
|
|
62
|
+
worker_admission_json: Schema.NullOr(BoundedStoredText),
|
|
63
|
+
message_admission_json: Schema.NullOr(BoundedStoredText)
|
|
60
64
|
}) {};
|
|
61
65
|
var ChildReservationRow = class extends Schema.Class("ChildReservationRow")({
|
|
62
66
|
reservation_id: BoundedIdentifier,
|
|
@@ -154,7 +158,9 @@ const SUBMISSION_COLUMNS = `
|
|
|
154
158
|
parent_submission_id,
|
|
155
159
|
parent_tool_call_id,
|
|
156
160
|
admission_group,
|
|
157
|
-
admission_fence_json
|
|
161
|
+
admission_fence_json,
|
|
162
|
+
worker_admission_json,
|
|
163
|
+
message_admission_json
|
|
158
164
|
`;
|
|
159
165
|
const CHILD_RESERVATION_COLUMNS = `
|
|
160
166
|
reservation_id,
|
|
@@ -319,6 +325,8 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
319
325
|
state: row.state,
|
|
320
326
|
createdAt: row.created_at,
|
|
321
327
|
...row.admission_group === null ? {} : { admissionGroup: row.admission_group },
|
|
328
|
+
...row.worker_admission_json === null ? {} : { workerAdmission: yield* parseStoredJsonText(row.worker_admission_json).pipe(Effect.mapError(internalFailure(operation))) },
|
|
329
|
+
...row.message_admission_json === null ? {} : { messageAdmission: yield* parseStoredJsonText(row.message_admission_json).pipe(Effect.mapError(internalFailure(operation))) },
|
|
322
330
|
...row.admission_fence_json === null ? {} : { admissionFence: yield* parseStoredJsonText(row.admission_fence_json).pipe(Effect.mapError(internalFailure(operation))) },
|
|
323
331
|
...row.settled_outcome === null ? {} : { settledOutcome: row.settled_outcome },
|
|
324
332
|
...row.ready_at === null ? {} : { readyAt: row.ready_at },
|
|
@@ -517,6 +525,16 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
517
525
|
const validated = yield* Schema.decodeUnknownEffect(Schema.toType(AdmissionRequest))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
518
526
|
const inputJson = yield* encodePersistedJsonText(validated.inputPayload).pipe(Effect.mapError(internalFailure(operation)));
|
|
519
527
|
yield* journal.checkValueBound(operation, inputJson).pipe(Effect.mapError(internalFailure(operation)));
|
|
528
|
+
const workerAdmissionJson = validated.workerAdmission === void 0 ? null : yield* Schema.encodeEffect(Schema.fromJsonString(WorkerAdmission))(validated.workerAdmission).pipe(Effect.mapError(internalFailure(operation)));
|
|
529
|
+
if (workerAdmissionJson !== null && new TextEncoder().encode(workerAdmissionJson).byteLength > config.maxStoredValueBytes) return yield* LedgerError.make({
|
|
530
|
+
operation,
|
|
531
|
+
message: "Worker admission metadata exceeds the stored value bound"
|
|
532
|
+
});
|
|
533
|
+
const messageAdmissionJson = validated.messageAdmission === void 0 ? null : yield* Schema.encodeEffect(Schema.fromJsonString(MessageAdmission))(validated.messageAdmission).pipe(Effect.mapError(internalFailure(operation)));
|
|
534
|
+
if (messageAdmissionJson !== null && new TextEncoder().encode(messageAdmissionJson).byteLength > config.maxStoredValueBytes) return yield* LedgerError.make({
|
|
535
|
+
operation,
|
|
536
|
+
message: "Message admission metadata exceeds the stored value bound"
|
|
537
|
+
});
|
|
520
538
|
const agentDigestsJson = yield* encodeDefinitionDigestsText(validated.agentDigests).pipe(Effect.mapError(internalFailure(operation)));
|
|
521
539
|
const mintedSubmissionId = `${yield* mintUuid(operation)}:${validated.threadId}`;
|
|
522
540
|
if (mintedSubmissionId.length > MAX_IDENTIFIER_LENGTH) return yield* LedgerError.make({
|
|
@@ -545,8 +563,10 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
545
563
|
existingInputDigest: existing[0].input_digest,
|
|
546
564
|
attemptedInputDigest: validated.inputDigest
|
|
547
565
|
});
|
|
566
|
+
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)));
|
|
567
|
+
const retainedMessageAdmission = existing[0].message_admission_json === null ? void 0 : yield* Schema.decodeEffect(Schema.fromJsonString(MessageAdmission))(existing[0].message_admission_json).pipe(Effect.mapError(internalFailure(operation)));
|
|
548
568
|
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)));
|
|
549
|
-
if ((existing[0].admission_group ?? void 0) !== validated.admissionGroup || !Schema.toEquivalence(Schema.optional(AdmissionFence))(retainedFence, validated.admissionFence)) return yield* AdmissionConflict.make({
|
|
569
|
+
if ((existing[0].admission_group ?? void 0) !== validated.admissionGroup || !Schema.toEquivalence(Schema.optional(WorkerAdmission))(retainedWorkerAdmission, validated.workerAdmission) || !Schema.toEquivalence(Schema.optional(MessageAdmission))(retainedMessageAdmission, validated.messageAdmission) || !Schema.toEquivalence(Schema.optional(AdmissionFence))(retainedFence, validated.admissionFence)) return yield* AdmissionConflict.make({
|
|
550
570
|
threadId: validated.threadId,
|
|
551
571
|
principal: validated.principal,
|
|
552
572
|
idempotencyKey: validated.idempotencyKey,
|
|
@@ -561,6 +581,18 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
561
581
|
replayed: true
|
|
562
582
|
}).pipe(Effect.mapError(internalFailure(operation)));
|
|
563
583
|
}
|
|
584
|
+
const firstRows = yield* sql`
|
|
585
|
+
SELECT worker_admission_json FROM effect_agent_submissions
|
|
586
|
+
WHERE thread_id=${validated.threadId} ORDER BY queue_sequence LIMIT 1
|
|
587
|
+
`.pipe(Effect.mapError(sqlFailure(operation)));
|
|
588
|
+
const first = yield* Schema.decodeUnknownEffect(Schema.Array(Schema.Struct({ worker_admission_json: Schema.NullOr(BoundedStoredText) })))(firstRows).pipe(Effect.mapError(internalFailure(operation)));
|
|
589
|
+
if (first[0] !== void 0) {
|
|
590
|
+
const previous = first[0].worker_admission_json === null ? void 0 : yield* Schema.decodeEffect(Schema.fromJsonString(WorkerAdmission))(first[0].worker_admission_json).pipe(Effect.mapError(internalFailure(operation)));
|
|
591
|
+
if (!Schema.toEquivalence(Schema.optional(WorkerAdmission.fields.origin))(previous?.origin, validated.workerAdmission?.origin)) return yield* AdmissionPolicyError.make({
|
|
592
|
+
reason: "refused",
|
|
593
|
+
code: "worker-origin-conflict"
|
|
594
|
+
});
|
|
595
|
+
}
|
|
564
596
|
yield* admissionFence.check(validated);
|
|
565
597
|
if (validated.admissionGroup !== void 0) {
|
|
566
598
|
if ((yield* sql`
|
|
@@ -597,7 +629,9 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
597
629
|
parent_submission_id,
|
|
598
630
|
parent_tool_call_id,
|
|
599
631
|
admission_group,
|
|
600
|
-
admission_fence_json
|
|
632
|
+
admission_fence_json,
|
|
633
|
+
worker_admission_json,
|
|
634
|
+
message_admission_json
|
|
601
635
|
) VALUES (
|
|
602
636
|
${mintedSubmissionId},
|
|
603
637
|
${validated.threadId},
|
|
@@ -615,7 +649,9 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
615
649
|
${validated.parentLinkage?.parentSubmissionId ?? null},
|
|
616
650
|
${validated.parentLinkage?.parentToolCallId ?? null},
|
|
617
651
|
${validated.admissionGroup ?? null},
|
|
618
|
-
${validated.admissionFence === void 0 ? null : JSON.stringify(validated.admissionFence)}
|
|
652
|
+
${validated.admissionFence === void 0 ? null : JSON.stringify(validated.admissionFence)},
|
|
653
|
+
${workerAdmissionJson},
|
|
654
|
+
${messageAdmissionJson}
|
|
619
655
|
)
|
|
620
656
|
`.pipe(Effect.mapError(sqlFailure(operation)));
|
|
621
657
|
return yield* decodeAdmissionResult({
|