@systemfsoftware/agent-storage-cloudflare 0.0.0-bootstrap.0 → 0.1.0-beta.192
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/LICENSE +21 -0
- package/dist/DoMemoryStore-AaGtt8CZ.d.mts +29 -0
- package/dist/DoMemoryStore-DVun329p.mjs +67 -0
- package/dist/DoMemoryStore-DVun329p.mjs.map +1 -0
- package/dist/DoMemoryStore.d.mts +2 -0
- package/dist/DoMemoryStore.mjs +1 -0
- package/dist/DoMessageDeliveryStore-BvB6OPI1.mjs +34 -0
- package/dist/DoMessageDeliveryStore-BvB6OPI1.mjs.map +1 -0
- package/dist/DoMessageDeliveryStore-Cb-DNN5s.d.mts +16 -0
- package/dist/DoMessageDeliveryStore.d.mts +2 -0
- package/dist/DoMessageDeliveryStore.mjs +1 -0
- package/dist/DoScheduleStore-BiTgDvX1.d.mts +36 -0
- package/dist/DoScheduleStore-C7GkSReF.mjs +167 -0
- package/dist/DoScheduleStore-C7GkSReF.mjs.map +1 -0
- package/dist/DoScheduleStore.d.mts +2 -0
- package/dist/DoScheduleStore.mjs +1 -0
- package/dist/DoStorageConfig-BqezsbD6.mjs +43 -0
- package/dist/DoStorageConfig-BqezsbD6.mjs.map +1 -0
- package/dist/DoStorageConfig-CuB6ZOtX.d.mts +36 -0
- package/dist/DoStorageConfig.d.mts +2 -0
- package/dist/DoStorageConfig.mjs +1 -0
- package/dist/DoStorageError-C-F5Z_FZ.d.mts +82 -0
- package/dist/DoStorageError-DSQzuCb0.mjs +138 -0
- package/dist/DoStorageError-DSQzuCb0.mjs.map +1 -0
- package/dist/DoStorageError.d.mts +2 -0
- package/dist/DoStorageError.mjs +1 -0
- package/dist/DoStorageFailpoint-C7zLUULu.d.mts +19 -0
- package/dist/DoStorageFailpoint-WO3B_DQl.mjs +20 -0
- package/dist/DoStorageFailpoint-WO3B_DQl.mjs.map +1 -0
- package/dist/DoStorageFailpoint.d.mts +2 -0
- package/dist/DoStorageFailpoint.mjs +1 -0
- package/dist/DoStorageFailpointTesting.d.mts +21 -0
- package/dist/DoStorageFailpointTesting.mjs +18 -0
- package/dist/DoStorageFailpointTesting.mjs.map +1 -0
- package/dist/DoStorageVersion-BrolfBDS.mjs +7 -0
- package/dist/DoStorageVersion-BrolfBDS.mjs.map +1 -0
- package/dist/DoStorageVersion-D7CIxFc_.d.mts +8 -0
- package/dist/DoStorageVersion.d.mts +3 -0
- package/dist/DoStorageVersion.mjs +2 -0
- package/dist/DoSubmissionLedger-Oq5OstxL.mjs +1878 -0
- package/dist/DoSubmissionLedger-Oq5OstxL.mjs.map +1 -0
- package/dist/DoSubmissionLedger-tLjwidUn.d.mts +25 -0
- package/dist/DoSubmissionLedger.d.mts +2 -0
- package/dist/DoSubmissionLedger.mjs +1 -0
- package/dist/DoSubscriptionStore-BMJiFxt3.mjs +185 -0
- package/dist/DoSubscriptionStore-BMJiFxt3.mjs.map +1 -0
- package/dist/DoSubscriptionStore-zx6nfbbh.d.mts +25 -0
- package/dist/DoSubscriptionStore.d.mts +2 -0
- package/dist/DoSubscriptionStore.mjs +1 -0
- package/dist/DoThreadStore-2zTSfui-.d.mts +81 -0
- package/dist/DoThreadStore-CeYHcRR9.mjs +411 -0
- package/dist/DoThreadStore-CeYHcRR9.mjs.map +1 -0
- package/dist/DoThreadStore.d.mts +2 -0
- package/dist/DoThreadStore.mjs +5 -0
- package/dist/MemoryProtocol-CtCFYe4s.mjs +221 -0
- package/dist/MemoryProtocol-CtCFYe4s.mjs.map +1 -0
- package/dist/MemoryProtocol-DXV77CcJ.d.mts +38160 -0
- package/dist/MemoryProtocol.d.mts +2 -0
- package/dist/MemoryProtocol.mjs +1 -0
- package/dist/PortProtocol-4xvMyCgP.mjs +322 -0
- package/dist/PortProtocol-4xvMyCgP.mjs.map +1 -0
- package/dist/PortProtocol-DXuguAgD.d.mts +966 -0
- package/dist/PortProtocol.d.mts +2 -0
- package/dist/PortProtocol.mjs +1 -0
- package/dist/PortRouting-B9302ouX.mjs +683 -0
- package/dist/PortRouting-B9302ouX.mjs.map +1 -0
- package/dist/PortRouting-DsoI6soW.d.mts +105 -0
- package/dist/PortRouting.d.mts +2 -0
- package/dist/PortRouting.mjs +1 -0
- package/dist/do-journal-nPNEAjV5.mjs +769 -0
- package/dist/do-journal-nPNEAjV5.mjs.map +1 -0
- package/dist/index.d.mts +14 -0
- package/dist/index.mjs +14 -0
- package/dist/migrations-BRTvj8Ue.mjs +233 -0
- package/dist/migrations-BRTvj8Ue.mjs.map +1 -0
- package/dist/owned-state-DrOD9s0c.mjs +157 -0
- package/dist/owned-state-DrOD9s0c.mjs.map +1 -0
- package/dist/rolldown-runtime-D3KUYPsf.mjs +12 -0
- package/package.json +104 -5
- package/src/DoMemoryStore.ts +71 -0
- package/src/DoMessageDeliveryStore.ts +46 -0
- package/src/DoScheduleStore.ts +276 -0
- package/src/DoStorageConfig.ts +45 -0
- package/src/DoStorageError.ts +146 -0
- package/src/DoStorageFailpoint.ts +25 -0
- package/src/DoStorageFailpointTesting.ts +42 -0
- package/src/DoStorageVersion.ts +2 -0
- package/src/DoSubmissionLedger.ts +3980 -0
- package/src/DoSubscriptionStore.ts +331 -0
- package/src/DoThreadStore.ts +602 -0
- package/src/MemoryProtocol.ts +357 -0
- package/src/PortProtocol.ts +626 -0
- package/src/PortRouting.ts +1888 -0
- package/src/index.ts +13 -0
- package/src/internal/canonical-append.ts +15 -0
- package/src/internal/do-journal.ts +1449 -0
- package/src/internal/migrations.ts +395 -0
- package/src/internal/owned-state.ts +300 -0
- package/src/internal/prompt-checkpoint.ts +170 -0
- package/src/internal/storage-span.ts +54 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Daniel van der Merwe
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as SqliteClient from "@effect/sql-sqlite-do/SqliteClient";
|
|
2
|
+
import { MemoryMutationFailpoint } from "@systemfsoftware/agent/memory-store";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
declare namespace DoMemoryStore_d_exports {
|
|
6
|
+
export { DoMemoryStorageLimits, defaultDoMemoryStorageLimits, doMemoryStoreLayer, doMemoryStoreLayerWithFailpoints };
|
|
7
|
+
}
|
|
8
|
+
declare const DoMemoryStorageLimits_base: Schema.Class<DoMemoryStorageLimits, Schema.Struct<{
|
|
9
|
+
readonly maxRowBytes: Schema.Int;
|
|
10
|
+
readonly maxStorageBytes: Schema.Int;
|
|
11
|
+
readonly maxDocuments: Schema.Int;
|
|
12
|
+
readonly maxReceipts: Schema.Int;
|
|
13
|
+
readonly reservedWithdrawalBytes: Schema.optional<Schema.Natural>;
|
|
14
|
+
readonly reservedWithdrawalReceipts: Schema.optional<Schema.Natural>;
|
|
15
|
+
}>, {}>;
|
|
16
|
+
declare class DoMemoryStorageLimits extends DoMemoryStorageLimits_base {}
|
|
17
|
+
declare const defaultDoMemoryStorageLimits: DoMemoryStorageLimits;
|
|
18
|
+
/**
|
|
19
|
+
* Local memory only, without Thread tables. Pass the full storage handle: sql-only
|
|
20
|
+
* handles cannot provide atomic receipts and revisions. Services over the same storage
|
|
21
|
+
* share a transaction gate and bounded, write-through document and receipt views.
|
|
22
|
+
* Byte limits conservatively count encoded rows, not SQLite page/index overhead.
|
|
23
|
+
* Optional withdrawal reserves default to zero and stay within hard byte/receipt limits.
|
|
24
|
+
* Ordinary Put cannot consume them. Deploy exclusively upgraded writers before relying
|
|
25
|
+
* on reserves; the SQL accounting migration preserves older writers and their receipts.
|
|
26
|
+
*/
|
|
27
|
+
declare const doMemoryStoreLayerWithFailpoints: (storage: NonNullable<SqliteClient.SqliteClientConfig['storage']>, limits?: DoMemoryStorageLimits) => Layer.Layer<import("@systemfsoftware/agent/memory-store").MemoryReader | import("@systemfsoftware/agent/memory-store").MemoryWriter | import("@systemfsoftware/agent/sql-memory-store").SqlMemoryBatchWriter, import("@systemfsoftware/agent/sql-memory-store").SqliteMemoryInitializationError, MemoryMutationFailpoint>;
|
|
28
|
+
declare const doMemoryStoreLayer: (storage: NonNullable<SqliteClient.SqliteClientConfig['storage']>, limits?: DoMemoryStorageLimits) => Layer.Layer<import("@systemfsoftware/agent/memory-store").MemoryReader | import("@systemfsoftware/agent/memory-store").MemoryWriter | import("@systemfsoftware/agent/sql-memory-store").SqlMemoryBatchWriter, import("@systemfsoftware/agent/sql-memory-store").SqliteMemoryInitializationError, never>;
|
|
29
|
+
export { doMemoryStoreLayerWithFailpoints as a, doMemoryStoreLayer as i, DoMemoryStore_d_exports as n, defaultDoMemoryStorageLimits as r, DoMemoryStorageLimits as t };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D3KUYPsf.mjs";
|
|
2
|
+
import * as SqliteClient from "@effect/sql-sqlite-do/SqliteClient";
|
|
3
|
+
import { MemoryMutationFailpoint, MemoryStorageError } from "@systemfsoftware/agent/memory-store";
|
|
4
|
+
import { SqlMemoryLimits, SqlStorageOwner, memoryStoreLayerWithFailpoints } from "@systemfsoftware/agent/sql-memory-store";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Layer from "effect/Layer";
|
|
7
|
+
import * as Schema from "effect/Schema";
|
|
8
|
+
import * as SqlClientService from "effect/sql/SqlClient";
|
|
9
|
+
import { r as ownedState } from "./owned-state-DrOD9s0c.mjs";
|
|
10
|
+
// src/DoMemoryStore.ts
|
|
11
|
+
var DoMemoryStore_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
+
DoMemoryStorageLimits: () => DoMemoryStorageLimits,
|
|
13
|
+
defaultDoMemoryStorageLimits: () => defaultDoMemoryStorageLimits,
|
|
14
|
+
doMemoryStoreLayer: () => doMemoryStoreLayer,
|
|
15
|
+
doMemoryStoreLayerWithFailpoints: () => doMemoryStoreLayerWithFailpoints
|
|
16
|
+
});
|
|
17
|
+
var DoMemoryStorageLimits = class extends Schema.Class("@effect-agent/storage-cloudflare/DoMemoryStorageLimits")({
|
|
18
|
+
maxRowBytes: Schema.Int.check(Schema.isBetween({
|
|
19
|
+
minimum: 1,
|
|
20
|
+
maximum: 19e5
|
|
21
|
+
})),
|
|
22
|
+
maxStorageBytes: Schema.Int.check(Schema.isBetween({
|
|
23
|
+
minimum: 1,
|
|
24
|
+
maximum: 536870912
|
|
25
|
+
})),
|
|
26
|
+
maxDocuments: Schema.Int.check(Schema.isBetween({
|
|
27
|
+
minimum: 1,
|
|
28
|
+
maximum: 1e5
|
|
29
|
+
})),
|
|
30
|
+
maxReceipts: Schema.Int.check(Schema.isBetween({
|
|
31
|
+
minimum: 1,
|
|
32
|
+
maximum: 1e6
|
|
33
|
+
})),
|
|
34
|
+
reservedWithdrawalBytes: Schema.optional(Schema.Natural),
|
|
35
|
+
reservedWithdrawalReceipts: Schema.optional(Schema.Natural)
|
|
36
|
+
}) {};
|
|
37
|
+
const defaultDoMemoryStorageLimits = DoMemoryStorageLimits.make({
|
|
38
|
+
maxRowBytes: 19e5,
|
|
39
|
+
maxStorageBytes: 536870912,
|
|
40
|
+
maxDocuments: 1e4,
|
|
41
|
+
maxReceipts: 1e5
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* Local memory only, without Thread tables. Pass the full storage handle: sql-only
|
|
45
|
+
* handles cannot provide atomic receipts and revisions. Services over the same storage
|
|
46
|
+
* share a transaction gate and bounded, write-through document and receipt views.
|
|
47
|
+
* Byte limits conservatively count encoded rows, not SQLite page/index overhead.
|
|
48
|
+
* Optional withdrawal reserves default to zero and stay within hard byte/receipt limits.
|
|
49
|
+
* Ordinary Put cannot consume them. Deploy exclusively upgraded writers before relying
|
|
50
|
+
* on reserves; the SQL accounting migration preserves older writers and their receipts.
|
|
51
|
+
*/
|
|
52
|
+
const doMemoryStoreLayerWithFailpoints = (storage, limits = defaultDoMemoryStorageLimits) => Layer.unwrap(Effect.gen(function* () {
|
|
53
|
+
const validated = yield* Schema.decodeEffect(DoMemoryStorageLimits)(limits).pipe(Effect.mapError(() => MemoryStorageError.make({
|
|
54
|
+
operation: "memory storage limits",
|
|
55
|
+
reason: "invalid-input"
|
|
56
|
+
})));
|
|
57
|
+
const sql = yield* SqlClientService.SqlClient;
|
|
58
|
+
const owner = yield* ownedState(sql).pipe(Effect.mapError(() => MemoryStorageError.make({
|
|
59
|
+
operation: "open memory owner",
|
|
60
|
+
reason: "unavailable"
|
|
61
|
+
})));
|
|
62
|
+
return memoryStoreLayerWithFailpoints.pipe(Layer.provide(Layer.succeed(SqlMemoryLimits, validated)), Layer.provide(Layer.succeed(SqlStorageOwner, owner)));
|
|
63
|
+
})).pipe(Layer.provide(SqliteClient.layer({ storage })));
|
|
64
|
+
const doMemoryStoreLayer = (storage, limits = defaultDoMemoryStorageLimits) => doMemoryStoreLayerWithFailpoints(storage, limits).pipe(Layer.provide(MemoryMutationFailpoint.layer));
|
|
65
|
+
export { doMemoryStoreLayerWithFailpoints as a, doMemoryStoreLayer as i, DoMemoryStore_exports as n, defaultDoMemoryStorageLimits as r, DoMemoryStorageLimits as t };
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=DoMemoryStore-DVun329p.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DoMemoryStore-DVun329p.mjs","names":[],"sources":["../src/DoMemoryStore.ts"],"sourcesContent":["import * as SqliteClient from '@effect/sql-sqlite-do/SqliteClient'\nimport { MemoryMutationFailpoint, MemoryStorageError } from '@systemfsoftware/agent/memory-store'\nimport {\n memoryStoreLayerWithFailpoints,\n SqlMemoryLimits,\n SqlStorageOwner,\n} from '@systemfsoftware/agent/sql-memory-store'\nimport * as Effect from 'effect/Effect'\nimport * as Layer from 'effect/Layer'\nimport * as Schema from 'effect/Schema'\nimport * as SqlClientService from 'effect/sql/SqlClient'\n\nimport { ownedState } from './internal/owned-state'\n\nexport class DoMemoryStorageLimits extends Schema.Class<DoMemoryStorageLimits>(\n '@effect-agent/storage-cloudflare/DoMemoryStorageLimits',\n)({\n maxRowBytes: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 1_900_000 })),\n maxStorageBytes: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 536_870_912 })),\n maxDocuments: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 100_000 })),\n maxReceipts: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 1_000_000 })),\n reservedWithdrawalBytes: Schema.optional(Schema.Natural),\n reservedWithdrawalReceipts: Schema.optional(Schema.Natural),\n}) {}\n\nexport const defaultDoMemoryStorageLimits = DoMemoryStorageLimits.make({\n maxRowBytes: 1_900_000,\n maxStorageBytes: 536_870_912,\n maxDocuments: 10_000,\n maxReceipts: 100_000,\n})\n\n/**\n * Local memory only, without Thread tables. Pass the full storage handle: sql-only\n * handles cannot provide atomic receipts and revisions. Services over the same storage\n * share a transaction gate and bounded, write-through document and receipt views.\n * Byte limits conservatively count encoded rows, not SQLite page/index overhead.\n * Optional withdrawal reserves default to zero and stay within hard byte/receipt limits.\n * Ordinary Put cannot consume them. Deploy exclusively upgraded writers before relying\n * on reserves; the SQL accounting migration preserves older writers and their receipts.\n */\nexport const doMemoryStoreLayerWithFailpoints = (\n storage: NonNullable<SqliteClient.SqliteClientConfig['storage']>,\n limits: DoMemoryStorageLimits = defaultDoMemoryStorageLimits,\n) =>\n Layer.unwrap(\n Effect.gen(function*() {\n const validated = yield* Schema.decodeEffect(DoMemoryStorageLimits)(limits).pipe(\n Effect.mapError(() => MemoryStorageError.make({ operation: 'memory storage limits', reason: 'invalid-input' })),\n )\n\n const sql = yield* SqlClientService.SqlClient\n\n const owner = yield* ownedState(sql).pipe(\n Effect.mapError(() => MemoryStorageError.make({ operation: 'open memory owner', reason: 'unavailable' })),\n )\n\n return memoryStoreLayerWithFailpoints.pipe(\n Layer.provide(Layer.succeed(SqlMemoryLimits, validated)),\n Layer.provide(Layer.succeed(SqlStorageOwner, owner)),\n )\n }),\n ).pipe(Layer.provide(SqliteClient.layer({ storage })))\n\nexport const doMemoryStoreLayer = (\n storage: NonNullable<SqliteClient.SqliteClientConfig['storage']>,\n limits: DoMemoryStorageLimits = defaultDoMemoryStorageLimits,\n) =>\n doMemoryStoreLayerWithFailpoints(storage, limits).pipe(\n Layer.provide(MemoryMutationFailpoint.layer),\n )\n"],"mappings":";;;;;;;;;;;;;;;;AAcA,IAAa,wBAAb,cAA2C,OAAO,MAChD,wDACF,CAAC,CAAC;CACA,aAAa,OAAO,IAAI,MAAM,OAAO,UAAU;EAAE,SAAS;EAAG,SAAS;CAAU,CAAC,CAAC;CAClF,iBAAiB,OAAO,IAAI,MAAM,OAAO,UAAU;EAAE,SAAS;EAAG,SAAS;CAAY,CAAC,CAAC;CACxF,cAAc,OAAO,IAAI,MAAM,OAAO,UAAU;EAAE,SAAS;EAAG,SAAS;CAAQ,CAAC,CAAC;CACjF,aAAa,OAAO,IAAI,MAAM,OAAO,UAAU;EAAE,SAAS;EAAG,SAAS;CAAU,CAAC,CAAC;CAClF,yBAAyB,OAAO,SAAS,OAAO,OAAO;CACvD,4BAA4B,OAAO,SAAS,OAAO,OAAO;AAC5D,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAa,+BAA+B,sBAAsB,KAAK;CACrE,aAAa;CACb,iBAAiB;CACjB,cAAc;CACd,aAAa;AACf,CAAC;;;;;;;;;;AAWD,MAAa,oCACX,SACA,SAAgC,iCAEhC,MAAM,OACJ,OAAO,IAAI,aAAY;CACrB,MAAM,YAAY,OAAO,OAAO,aAAa,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC,KAC1E,OAAO,eAAe,mBAAmB,KAAK;EAAE,WAAW;EAAyB,QAAQ;CAAgB,CAAC,CAAC,CAChH;CAEA,MAAM,MAAM,OAAO,iBAAiB;CAEpC,MAAM,QAAQ,OAAO,WAAW,GAAG,CAAC,CAAC,KACnC,OAAO,eAAe,mBAAmB,KAAK;EAAE,WAAW;EAAqB,QAAQ;CAAc,CAAC,CAAC,CAC1G;CAEA,OAAO,+BAA+B,KACpC,MAAM,QAAQ,MAAM,QAAQ,iBAAiB,SAAS,CAAC,GACvD,MAAM,QAAQ,MAAM,QAAQ,iBAAiB,KAAK,CAAC,CACrD;AACF,CAAC,CACH,CAAC,CAAC,KAAK,MAAM,QAAQ,aAAa,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEvD,MAAa,sBACX,SACA,SAAgC,iCAEhC,iCAAiC,SAAS,MAAM,CAAC,CAAC,KAChD,MAAM,QAAQ,wBAAwB,KAAK,CAC7C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as doMemoryStoreLayerWithFailpoints, i as doMemoryStoreLayer, r as defaultDoMemoryStorageLimits, t as DoMemoryStorageLimits } from "./DoMemoryStore-AaGtt8CZ.mjs";
|
|
2
|
+
export { DoMemoryStorageLimits, defaultDoMemoryStorageLimits, doMemoryStoreLayer, doMemoryStoreLayerWithFailpoints };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as DoMemoryStorageLimits, r as defaultDoMemoryStorageLimits, i as doMemoryStoreLayer, a as doMemoryStoreLayerWithFailpoints } from "./DoMemoryStore-DVun329p.mjs";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D3KUYPsf.mjs";
|
|
2
|
+
import * as BrowserCrypto from "@effect/platform-browser/BrowserCrypto";
|
|
3
|
+
import { SqlLifecycleSource } from "@systemfsoftware/agent-storage-sql/sql-lifecycle-publication";
|
|
4
|
+
import { makeSqlMessageDeliveryStore, registerCanonicalMessageWriter } from "@systemfsoftware/agent-storage-sql/sql-message-delivery-store";
|
|
5
|
+
import { MessageDeliveryStore } from "@systemfsoftware/agent/message-delivery";
|
|
6
|
+
import { SqlStorageOwner } from "@systemfsoftware/agent/sql-storage-owner";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Layer from "effect/Layer";
|
|
9
|
+
import * as SqlClient from "effect/sql/SqlClient";
|
|
10
|
+
import { n as DoStorageConfig } from "./DoStorageConfig-BqezsbD6.mjs";
|
|
11
|
+
import { t as DoStorageFailpoint } from "./DoStorageFailpoint-WO3B_DQl.mjs";
|
|
12
|
+
import { r as initializeDoJournal } from "./do-journal-nPNEAjV5.mjs";
|
|
13
|
+
// src/DoMessageDeliveryStore.ts
|
|
14
|
+
var DoMessageDeliveryStore_exports = /* @__PURE__ */ __exportAll({ doMessageDeliveryStoreLayer: () => doMessageDeliveryStoreLayer });
|
|
15
|
+
/**
|
|
16
|
+
* Message obligations paired with the Thread Object's physical storage owner. Canonical
|
|
17
|
+
* publication uses this configured writer inside the source transaction. The platform must
|
|
18
|
+
* retain delivery maintenance with that transaction and while nextDeadline is present.
|
|
19
|
+
*/
|
|
20
|
+
const doMessageDeliveryStoreLayer = (limits) => Layer.effect(MessageDeliveryStore, Effect.gen(function* () {
|
|
21
|
+
const sql = yield* SqlClient.SqlClient;
|
|
22
|
+
const config = yield* DoStorageConfig;
|
|
23
|
+
const failpoint = yield* DoStorageFailpoint;
|
|
24
|
+
const journal = yield* initializeDoJournal(sql, failpoint.hit, config.maxStoredValueBytes);
|
|
25
|
+
const store = yield* makeSqlMessageDeliveryStore(journal.state.owner, limits, { maxStoredValueBytes: config.maxStoredValueBytes }).pipe(Effect.provideService(SqlStorageOwner, journal.owner), Effect.provideService(SqlLifecycleSource, {
|
|
26
|
+
beforeRetain: (threadId) => journal.flushCanonical(threadId),
|
|
27
|
+
beforePending: journal.flushPublications()
|
|
28
|
+
}));
|
|
29
|
+
yield* registerCanonicalMessageWriter(journal.state.owner, store);
|
|
30
|
+
return store;
|
|
31
|
+
})).pipe(Layer.provide(BrowserCrypto.layer));
|
|
32
|
+
export { doMessageDeliveryStoreLayer as n, DoMessageDeliveryStore_exports as t };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=DoMessageDeliveryStore-BvB6OPI1.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DoMessageDeliveryStore-BvB6OPI1.mjs","names":[],"sources":["../src/DoMessageDeliveryStore.ts"],"sourcesContent":["import * as BrowserCrypto from '@effect/platform-browser/BrowserCrypto'\nimport { SqlLifecycleSource } from '@systemfsoftware/agent-storage-sql/sql-lifecycle-publication'\nimport {\n makeSqlMessageDeliveryStore,\n registerCanonicalMessageWriter,\n} from '@systemfsoftware/agent-storage-sql/sql-message-delivery-store'\nimport { MessageDeliveryStore, type MessageDeliveryStoreLimits } from '@systemfsoftware/agent/message-delivery'\nimport { SqlStorageOwner } from '@systemfsoftware/agent/sql-storage-owner'\nimport * as Effect from 'effect/Effect'\nimport * as Layer from 'effect/Layer'\nimport * as SqlClient from 'effect/sql/SqlClient'\n\nimport { DoStorageConfig } from './DoStorageConfig'\nimport { DoStorageFailpoint } from './DoStorageFailpoint'\nimport { initializeDoJournal } from './internal/do-journal'\n\n/**\n * Message obligations paired with the Thread Object's physical storage owner. Canonical\n * publication uses this configured writer inside the source transaction. The platform must\n * retain delivery maintenance with that transaction and 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 const journal = yield* initializeDoJournal(sql, failpoint.hit, config.maxStoredValueBytes)\n\n const store = yield* makeSqlMessageDeliveryStore(journal.state.owner, limits, {\n maxStoredValueBytes: config.maxStoredValueBytes,\n }).pipe(\n Effect.provideService(SqlStorageOwner, journal.owner),\n Effect.provideService(SqlLifecycleSource, {\n beforeRetain: (threadId) => journal.flushCanonical(threadId),\n beforePending: journal.flushPublications(),\n }),\n )\n\n yield* registerCanonicalMessageWriter(journal.state.owner, store)\n\n return store\n }),\n ).pipe(Layer.provide(BrowserCrypto.layer))\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,MAAa,+BAA+B,WAC1C,MAAM,OACJ,sBACA,OAAO,IAAI,aAAY;CACrB,MAAM,MAAM,OAAO,UAAU;CAC7B,MAAM,SAAS,OAAO;CACtB,MAAM,YAAY,OAAO;CAEzB,MAAM,UAAU,OAAO,oBAAoB,KAAK,UAAU,KAAK,OAAO,mBAAmB;CAEzF,MAAM,QAAQ,OAAO,4BAA4B,QAAQ,MAAM,OAAO,QAAQ,EAC5E,qBAAqB,OAAO,oBAC9B,CAAC,CAAC,CAAC,KACD,OAAO,eAAe,iBAAiB,QAAQ,KAAK,GACpD,OAAO,eAAe,oBAAoB;EACxC,eAAe,aAAa,QAAQ,eAAe,QAAQ;EAC3D,eAAe,QAAQ,kBAAkB;CAC3C,CAAC,CACH;CAEA,OAAO,+BAA+B,QAAQ,MAAM,OAAO,KAAK;CAEhE,OAAO;AACT,CAAC,CACH,CAAC,CAAC,KAAK,MAAM,QAAQ,cAAc,KAAK,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { a as DoStorageError, i as DoStorageCorruptionError, r as DoStorageCompatibilityError } from "./DoStorageError-C-F5Z_FZ.mjs";
|
|
2
|
+
import { MessageDeliveryStore, MessageDeliveryStoreLimits } from "@systemfsoftware/agent/message-delivery";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import * as SqlClient from "effect/sql/SqlClient";
|
|
5
|
+
import { n as DoStorageConfig } from "./DoStorageConfig-CuB6ZOtX.mjs";
|
|
6
|
+
import { t as DoStorageFailpoint } from "./DoStorageFailpoint-C7zLUULu.mjs";
|
|
7
|
+
declare namespace DoMessageDeliveryStore_d_exports {
|
|
8
|
+
export { doMessageDeliveryStoreLayer };
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Message obligations paired with the Thread Object's physical storage owner. Canonical
|
|
12
|
+
* publication uses this configured writer inside the source transaction. The platform must
|
|
13
|
+
* retain delivery maintenance with that transaction and while nextDeadline is present.
|
|
14
|
+
*/
|
|
15
|
+
declare const doMessageDeliveryStoreLayer: (limits?: MessageDeliveryStoreLimits) => Layer.Layer<MessageDeliveryStore, DoStorageCompatibilityError | DoStorageCorruptionError | DoStorageError | import("@systemfsoftware/agent/message-delivery").MessageDeliveryError, DoStorageConfig | DoStorageFailpoint | SqlClient.SqlClient>;
|
|
16
|
+
export { doMessageDeliveryStoreLayer as n, DoMessageDeliveryStore_d_exports as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { n as doMessageDeliveryStoreLayer } from "./DoMessageDeliveryStore-BvB6OPI1.mjs";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ScheduleFailpointError, ScheduleStorageError, ScheduleStore } from "@systemfsoftware/agent/schedule";
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
import * as SqlClientService from "effect/sql/SqlClient";
|
|
6
|
+
declare namespace DoScheduleStore_d_exports {
|
|
7
|
+
export { DoScheduleAlarmControl, DoScheduleAlarmReplacement, DoScheduleReplaceAlarm, DoScheduleTransaction, scheduleStoreLayer };
|
|
8
|
+
}
|
|
9
|
+
interface DoScheduleAlarmReplacement {
|
|
10
|
+
readonly deadlineAtMillis: number | null;
|
|
11
|
+
/** Included in every logical alarm payload so equal-time replacement stays distinguishable. */
|
|
12
|
+
readonly generation: number;
|
|
13
|
+
}
|
|
14
|
+
type DoScheduleReplaceAlarm = (replacement: DoScheduleAlarmReplacement) => Effect.Effect<void, ScheduleStorageError>;
|
|
15
|
+
declare const DoScheduleTransaction_base: Context.ServiceClass<DoScheduleTransaction, "@effect-agent/storage-cloudflare/DoScheduleTransaction", {
|
|
16
|
+
readonly run: <A, E, R>(body: (replaceAlarm: DoScheduleReplaceAlarm) => Effect.Effect<A, E, R>) => Effect.Effect<A, E | ScheduleStorageError, R>;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Platform-owned transaction boundary for schedule SQL and logical alarm mutation. The callback
|
|
20
|
+
* and its `replaceAlarm` capability belong to one fiber and must not escape or fork.
|
|
21
|
+
*/
|
|
22
|
+
declare class DoScheduleTransaction extends DoScheduleTransaction_base {}
|
|
23
|
+
declare const DoScheduleAlarmControl_base: Context.ServiceClass<DoScheduleAlarmControl, "@effect-agent/storage-cloudflare/DoScheduleAlarmControl", {
|
|
24
|
+
/** Establish a future recovery wake before cross-Object admission starts. */
|
|
25
|
+
readonly prearm: (deadlineAtMillis: number) => Effect.Effect<void, ScheduleStorageError | ScheduleFailpointError>;
|
|
26
|
+
/** Replace or cancel the wake from the object's authoritative indexed deadline. */
|
|
27
|
+
readonly reconcile: Effect.Effect<void, ScheduleStorageError | ScheduleFailpointError>;
|
|
28
|
+
}>;
|
|
29
|
+
/** Platform driver operations that use the same schedule-state and alarm transaction. */
|
|
30
|
+
declare class DoScheduleAlarmControl extends DoScheduleAlarmControl_base {}
|
|
31
|
+
/**
|
|
32
|
+
* Durable Object SQLite ScheduleStore. Platform code supplies the one transaction owner that
|
|
33
|
+
* combines these SQL mutations with its logical and native alarm lifecycle.
|
|
34
|
+
*/
|
|
35
|
+
declare const scheduleStoreLayer: Layer.Layer<ScheduleStore | DoScheduleAlarmControl, ScheduleStorageError, SqlClientService.SqlClient | DoScheduleTransaction>;
|
|
36
|
+
export { DoScheduleTransaction as a, DoScheduleStore_d_exports as i, DoScheduleAlarmReplacement as n, scheduleStoreLayer as o, DoScheduleReplaceAlarm as r, DoScheduleAlarmControl as t };
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D3KUYPsf.mjs";
|
|
2
|
+
import { SqlScheduleWriteTransaction, makeSqlScheduleStore } from "@systemfsoftware/agent-storage-sql/sql-schedule-store";
|
|
3
|
+
import { ScheduleFailpoint, ScheduleInstant, ScheduleStorageError, ScheduleStore } from "@systemfsoftware/agent/schedule";
|
|
4
|
+
import * as Context from "effect/Context";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Layer from "effect/Layer";
|
|
7
|
+
import * as Schema from "effect/Schema";
|
|
8
|
+
import * as SqlClientService from "effect/sql/SqlClient";
|
|
9
|
+
// src/DoScheduleStore.ts
|
|
10
|
+
var DoScheduleStore_exports = /* @__PURE__ */ __exportAll({
|
|
11
|
+
DoScheduleAlarmControl: () => DoScheduleAlarmControl,
|
|
12
|
+
DoScheduleTransaction: () => DoScheduleTransaction,
|
|
13
|
+
scheduleStoreLayer: () => scheduleStoreLayer
|
|
14
|
+
});
|
|
15
|
+
const CURRENT_SCHEDULE_STORE_VERSION = 3;
|
|
16
|
+
const MAX_STORED_SCHEDULE_LENGTH = 19e5;
|
|
17
|
+
var ScheduleDeadlineRow = class extends Schema.Class("@effect-agent/storage-cloudflare/ScheduleDeadlineRow")({ deadline_at_millis: Schema.NullOr(ScheduleInstant) }) {};
|
|
18
|
+
var ScheduleStoreStateRow = class extends Schema.Class("@effect-agent/storage-cloudflare/ScheduleStoreStateRow")({
|
|
19
|
+
storage_version: Schema.Int.check(Schema.isGreaterThan(0)),
|
|
20
|
+
alarm_generation: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))
|
|
21
|
+
}) {};
|
|
22
|
+
var ScheduleTableNameRow = class extends Schema.Class("@effect-agent/storage-cloudflare/ScheduleTableNameRow")({ name: Schema.String }) {};
|
|
23
|
+
/**
|
|
24
|
+
* Platform-owned transaction boundary for schedule SQL and logical alarm mutation. The callback
|
|
25
|
+
* and its `replaceAlarm` capability belong to one fiber and must not escape or fork.
|
|
26
|
+
*/
|
|
27
|
+
var DoScheduleTransaction = class extends Context.Service()("@effect-agent/storage-cloudflare/DoScheduleTransaction") {};
|
|
28
|
+
/** Platform driver operations that use the same schedule-state and alarm transaction. */
|
|
29
|
+
var DoScheduleAlarmControl = class extends Context.Service()("@effect-agent/storage-cloudflare/DoScheduleAlarmControl") {};
|
|
30
|
+
const unavailable = (operation) => ScheduleStorageError.make({
|
|
31
|
+
operation,
|
|
32
|
+
reason: "unavailable"
|
|
33
|
+
});
|
|
34
|
+
const corrupt = (operation) => ScheduleStorageError.make({
|
|
35
|
+
operation,
|
|
36
|
+
reason: "corrupt"
|
|
37
|
+
});
|
|
38
|
+
const decodeRows = (schema, rows, operation) => Schema.decodeUnknownEffect(schema)(rows).pipe(Effect.mapError(() => corrupt(operation)));
|
|
39
|
+
const decodeBoundary = (schema, value, operation) => Schema.decodeUnknownEffect(schema)(value).pipe(Effect.mapError(() => corrupt(operation)));
|
|
40
|
+
const initializeScheduleStore = Effect.fnUntraced(function* () {
|
|
41
|
+
const sql = yield* SqlClientService.SqlClient;
|
|
42
|
+
const operation = "initialize schedule store";
|
|
43
|
+
const rawTables = yield* sql`
|
|
44
|
+
SELECT name
|
|
45
|
+
FROM sqlite_master
|
|
46
|
+
WHERE type = 'table'
|
|
47
|
+
AND name IN (
|
|
48
|
+
'effect_agent_schedule_store_state',
|
|
49
|
+
'effect_agent_schedules'
|
|
50
|
+
)
|
|
51
|
+
ORDER BY name
|
|
52
|
+
`.pipe(Effect.mapError(() => unavailable(operation)));
|
|
53
|
+
const tables = yield* decodeRows(Schema.Array(ScheduleTableNameRow), rawTables, operation);
|
|
54
|
+
const hasState = tables.some((row) => row.name === "effect_agent_schedule_store_state");
|
|
55
|
+
const hasSchedules = tables.some((row) => row.name === "effect_agent_schedules");
|
|
56
|
+
if (!hasState) {
|
|
57
|
+
if (hasSchedules) return yield* corrupt(operation);
|
|
58
|
+
yield* sql.withTransaction(Effect.gen(function* () {
|
|
59
|
+
yield* sql`
|
|
60
|
+
CREATE TABLE effect_agent_schedule_store_state (
|
|
61
|
+
singleton INTEGER PRIMARY KEY NOT NULL CHECK (singleton = 1),
|
|
62
|
+
storage_version INTEGER NOT NULL,
|
|
63
|
+
alarm_generation INTEGER NOT NULL
|
|
64
|
+
)
|
|
65
|
+
`.withoutTransform;
|
|
66
|
+
yield* sql`
|
|
67
|
+
CREATE TABLE effect_agent_schedules (
|
|
68
|
+
tenant_id TEXT NOT NULL,
|
|
69
|
+
owner_id TEXT NOT NULL,
|
|
70
|
+
schedule_id TEXT NOT NULL,
|
|
71
|
+
deadline_at_millis INTEGER,
|
|
72
|
+
record_json TEXT NOT NULL,
|
|
73
|
+
PRIMARY KEY (tenant_id, owner_id, schedule_id)
|
|
74
|
+
)
|
|
75
|
+
`.withoutTransform;
|
|
76
|
+
yield* sql`
|
|
77
|
+
CREATE INDEX effect_agent_schedules_deadline
|
|
78
|
+
ON effect_agent_schedules (deadline_at_millis, tenant_id, owner_id, schedule_id)
|
|
79
|
+
WHERE deadline_at_millis IS NOT NULL
|
|
80
|
+
`.withoutTransform;
|
|
81
|
+
yield* sql`
|
|
82
|
+
CREATE INDEX effect_agent_schedules_owner_deadline
|
|
83
|
+
ON effect_agent_schedules (tenant_id, owner_id, deadline_at_millis, schedule_id)
|
|
84
|
+
WHERE deadline_at_millis IS NOT NULL
|
|
85
|
+
`.withoutTransform;
|
|
86
|
+
yield* sql`
|
|
87
|
+
INSERT INTO effect_agent_schedule_store_state (
|
|
88
|
+
singleton, storage_version, alarm_generation
|
|
89
|
+
) VALUES (1, ${CURRENT_SCHEDULE_STORE_VERSION}, 0)
|
|
90
|
+
`.withoutTransform;
|
|
91
|
+
})).pipe(Effect.mapError(() => unavailable(operation)));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (!hasSchedules) return yield* corrupt(operation);
|
|
95
|
+
const rawState = yield* sql`
|
|
96
|
+
SELECT storage_version, alarm_generation
|
|
97
|
+
FROM effect_agent_schedule_store_state
|
|
98
|
+
WHERE singleton = 1
|
|
99
|
+
`.pipe(Effect.mapError(() => unavailable(operation)));
|
|
100
|
+
const state = yield* decodeRows(Schema.Array(ScheduleStoreStateRow), rawState, operation);
|
|
101
|
+
if (state.length !== 1 || state[0].storage_version !== CURRENT_SCHEDULE_STORE_VERSION) return yield* corrupt(state.length === 1 ? `${operation}: incompatible storage version ${state[0].storage_version}; expected ${CURRENT_SCHEDULE_STORE_VERSION}` : `${operation}: invalid storage version row`);
|
|
102
|
+
});
|
|
103
|
+
const makeServices = Effect.gen(function* () {
|
|
104
|
+
const sql = yield* SqlClientService.SqlClient;
|
|
105
|
+
const transactions = yield* DoScheduleTransaction;
|
|
106
|
+
const scheduleFailpoint = yield* ScheduleFailpoint;
|
|
107
|
+
yield* initializeScheduleStore();
|
|
108
|
+
const readNextDeadline = Effect.fnUntraced(function* (operation) {
|
|
109
|
+
const rows = yield* sql`
|
|
110
|
+
SELECT MIN(deadline_at_millis) AS deadline_at_millis
|
|
111
|
+
FROM effect_agent_schedules
|
|
112
|
+
WHERE deadline_at_millis IS NOT NULL
|
|
113
|
+
`.pipe(Effect.mapError(() => unavailable(operation)));
|
|
114
|
+
const decoded = yield* decodeRows(Schema.Array(ScheduleDeadlineRow), rows, operation);
|
|
115
|
+
if (decoded.length !== 1) return yield* corrupt(operation);
|
|
116
|
+
return decoded[0].deadline_at_millis;
|
|
117
|
+
});
|
|
118
|
+
const replaceAlarm = Effect.fnUntraced(function* (replace, deadlineAtMillis, operation) {
|
|
119
|
+
const rawState = yield* sql`
|
|
120
|
+
UPDATE effect_agent_schedule_store_state
|
|
121
|
+
SET alarm_generation = alarm_generation + 1
|
|
122
|
+
WHERE singleton = 1
|
|
123
|
+
RETURNING storage_version, alarm_generation
|
|
124
|
+
`.pipe(Effect.mapError(() => unavailable(operation)));
|
|
125
|
+
const state = yield* decodeRows(Schema.Array(ScheduleStoreStateRow), rawState, operation);
|
|
126
|
+
if (state.length !== 1 || state[0].storage_version !== CURRENT_SCHEDULE_STORE_VERSION) return yield* corrupt(operation);
|
|
127
|
+
yield* scheduleFailpoint.hit("schedule:alarm:before");
|
|
128
|
+
yield* replace({
|
|
129
|
+
deadlineAtMillis,
|
|
130
|
+
generation: state[0].alarm_generation
|
|
131
|
+
});
|
|
132
|
+
yield* scheduleFailpoint.hit("schedule:alarm:after");
|
|
133
|
+
});
|
|
134
|
+
const run = (body, operation) => transactions.run((replace) => Effect.gen(function* () {
|
|
135
|
+
const result = yield* body;
|
|
136
|
+
if (result.changed) yield* replaceAlarm(replace, yield* readNextDeadline(operation), operation);
|
|
137
|
+
return result;
|
|
138
|
+
}));
|
|
139
|
+
const prearm = Effect.fnUntraced(function* (deadlineAtMillis) {
|
|
140
|
+
yield* decodeBoundary(ScheduleInstant, deadlineAtMillis, "pre-arm schedule recovery");
|
|
141
|
+
yield* transactions.run((replace) => replaceAlarm(replace, deadlineAtMillis, "pre-arm schedule recovery"));
|
|
142
|
+
yield* scheduleFailpoint.hit("schedule:prearm:after");
|
|
143
|
+
});
|
|
144
|
+
const reconcile = Effect.gen(function* () {
|
|
145
|
+
yield* transactions.run((replace) => Effect.gen(function* () {
|
|
146
|
+
const deadline = yield* readNextDeadline("reconcile schedule alarm");
|
|
147
|
+
yield* replaceAlarm(replace, deadline, "reconcile schedule alarm");
|
|
148
|
+
}));
|
|
149
|
+
yield* scheduleFailpoint.hit("schedule:reconcile:after");
|
|
150
|
+
});
|
|
151
|
+
return Context.make(SqlScheduleWriteTransaction, { run }).pipe(Context.add(DoScheduleAlarmControl, {
|
|
152
|
+
prearm,
|
|
153
|
+
reconcile
|
|
154
|
+
}));
|
|
155
|
+
});
|
|
156
|
+
/**
|
|
157
|
+
* Durable Object SQLite ScheduleStore. Platform code supplies the one transaction owner that
|
|
158
|
+
* combines these SQL mutations with its logical and native alarm lifecycle.
|
|
159
|
+
*/
|
|
160
|
+
const scheduleStoreLayer = Layer.effectContext(Effect.gen(function* () {
|
|
161
|
+
const store = yield* makeSqlScheduleStore(void 0, MAX_STORED_SCHEDULE_LENGTH);
|
|
162
|
+
const alarms = yield* DoScheduleAlarmControl;
|
|
163
|
+
return Context.make(ScheduleStore, store).pipe(Context.add(DoScheduleAlarmControl, alarms));
|
|
164
|
+
})).pipe(Layer.provide(Layer.effectContext(makeServices)));
|
|
165
|
+
export { scheduleStoreLayer as i, DoScheduleStore_exports as n, DoScheduleTransaction as r, DoScheduleAlarmControl as t };
|
|
166
|
+
|
|
167
|
+
//# sourceMappingURL=DoScheduleStore-C7GkSReF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DoScheduleStore-C7GkSReF.mjs","names":[],"sources":["../src/DoScheduleStore.ts"],"sourcesContent":["import {\n makeSqlScheduleStore,\n SqlScheduleWriteTransaction,\n} from '@systemfsoftware/agent-storage-sql/sql-schedule-store'\nimport {\n ScheduleFailpoint,\n type ScheduleFailpointError,\n ScheduleInstant,\n ScheduleStorageError,\n ScheduleStore,\n} from '@systemfsoftware/agent/schedule'\nimport * as Context from 'effect/Context'\nimport * as Effect from 'effect/Effect'\nimport * as Layer from 'effect/Layer'\nimport * as Schema from 'effect/Schema'\nimport * as SqlClientService from 'effect/sql/SqlClient'\n\nconst CURRENT_SCHEDULE_STORE_VERSION = 3\nconst MAX_STORED_SCHEDULE_LENGTH = 1_900_000\n\nclass ScheduleDeadlineRow extends Schema.Class<ScheduleDeadlineRow>(\n '@effect-agent/storage-cloudflare/ScheduleDeadlineRow',\n)({\n deadline_at_millis: Schema.NullOr(ScheduleInstant),\n}) {}\n\nclass ScheduleStoreStateRow extends Schema.Class<ScheduleStoreStateRow>(\n '@effect-agent/storage-cloudflare/ScheduleStoreStateRow',\n)({\n storage_version: Schema.Int.check(Schema.isGreaterThan(0)),\n alarm_generation: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n}) {}\n\nclass ScheduleTableNameRow extends Schema.Class<ScheduleTableNameRow>(\n '@effect-agent/storage-cloudflare/ScheduleTableNameRow',\n)({\n name: Schema.String,\n}) {}\n\nexport interface DoScheduleAlarmReplacement {\n readonly deadlineAtMillis: number | null\n /** Included in every logical alarm payload so equal-time replacement stays distinguishable. */\n readonly generation: number\n}\n\nexport type DoScheduleReplaceAlarm = (\n replacement: DoScheduleAlarmReplacement,\n) => Effect.Effect<void, ScheduleStorageError>\n\n/**\n * Platform-owned transaction boundary for schedule SQL and logical alarm mutation. The callback\n * and its `replaceAlarm` capability belong to one fiber and must not escape or fork.\n */\nexport class DoScheduleTransaction extends Context.Service<\n DoScheduleTransaction,\n {\n readonly run: <A, E, R>(\n body: (replaceAlarm: DoScheduleReplaceAlarm) => Effect.Effect<A, E, R>,\n ) => Effect.Effect<A, E | ScheduleStorageError, R>\n }\n>()('@effect-agent/storage-cloudflare/DoScheduleTransaction') {}\n\n/** Platform driver operations that use the same schedule-state and alarm transaction. */\nexport class DoScheduleAlarmControl extends Context.Service<\n DoScheduleAlarmControl,\n {\n /** Establish a future recovery wake before cross-Object admission starts. */\n readonly prearm: (\n deadlineAtMillis: number,\n ) => Effect.Effect<void, ScheduleStorageError | ScheduleFailpointError>\n /** Replace or cancel the wake from the object's authoritative indexed deadline. */\n readonly reconcile: Effect.Effect<void, ScheduleStorageError | ScheduleFailpointError>\n }\n>()('@effect-agent/storage-cloudflare/DoScheduleAlarmControl') {}\n\nconst unavailable = (operation: string): ScheduleStorageError =>\n ScheduleStorageError.make({ operation, reason: 'unavailable' })\n\nconst corrupt = (operation: string): ScheduleStorageError => ScheduleStorageError.make({ operation, reason: 'corrupt' })\n\nconst decodeRows = <A, I, R>(\n schema: Schema.Codec<A, I, R>,\n rows: ReadonlyArray<unknown>,\n operation: string,\n): Effect.Effect<A, ScheduleStorageError, R> =>\n Schema.decodeUnknownEffect(schema)(rows).pipe(Effect.mapError(() => corrupt(operation)))\n\nconst decodeBoundary = <A, I, R>(\n schema: Schema.Codec<A, I, R>,\n value: unknown,\n operation: string,\n): Effect.Effect<A, ScheduleStorageError, R> =>\n Schema.decodeUnknownEffect(schema)(value).pipe(Effect.mapError(() => corrupt(operation)))\n\nconst initializeScheduleStore = Effect.fnUntraced(function*() {\n const sql = yield* SqlClientService.SqlClient\n const operation = 'initialize schedule store'\n\n const rawTables = yield* sql<Record<string, unknown>>`\n SELECT name\n FROM sqlite_master\n WHERE type = 'table'\n AND name IN (\n 'effect_agent_schedule_store_state',\n 'effect_agent_schedules'\n )\n ORDER BY name\n `.pipe(Effect.mapError(() => unavailable(operation)))\n\n const tables = yield* decodeRows(Schema.Array(ScheduleTableNameRow), rawTables, operation)\n const hasState = tables.some((row) => row.name === 'effect_agent_schedule_store_state')\n const hasSchedules = tables.some((row) => row.name === 'effect_agent_schedules')\n\n if (!hasState) {\n if (hasSchedules) return yield* corrupt(operation)\n yield* sql\n .withTransaction(\n Effect.gen(function*() {\n yield* sql`\n CREATE TABLE effect_agent_schedule_store_state (\n singleton INTEGER PRIMARY KEY NOT NULL CHECK (singleton = 1),\n storage_version INTEGER NOT NULL,\n alarm_generation INTEGER NOT NULL\n )\n `.withoutTransform\n yield* sql`\n CREATE TABLE effect_agent_schedules (\n tenant_id TEXT NOT NULL,\n owner_id TEXT NOT NULL,\n schedule_id TEXT NOT NULL,\n deadline_at_millis INTEGER,\n record_json TEXT NOT NULL,\n PRIMARY KEY (tenant_id, owner_id, schedule_id)\n )\n `.withoutTransform\n yield* sql`\n CREATE INDEX effect_agent_schedules_deadline\n ON effect_agent_schedules (deadline_at_millis, tenant_id, owner_id, schedule_id)\n WHERE deadline_at_millis IS NOT NULL\n `.withoutTransform\n yield* sql`\n CREATE INDEX effect_agent_schedules_owner_deadline\n ON effect_agent_schedules (tenant_id, owner_id, deadline_at_millis, schedule_id)\n WHERE deadline_at_millis IS NOT NULL\n `.withoutTransform\n yield* sql`\n INSERT INTO effect_agent_schedule_store_state (\n singleton, storage_version, alarm_generation\n ) VALUES (1, ${CURRENT_SCHEDULE_STORE_VERSION}, 0)\n `.withoutTransform\n }),\n )\n .pipe(Effect.mapError(() => unavailable(operation)))\n\n return\n }\n\n if (!hasSchedules) return yield* corrupt(operation)\n\n const rawState = yield* sql<Record<string, unknown>>`\n SELECT storage_version, alarm_generation\n FROM effect_agent_schedule_store_state\n WHERE singleton = 1\n `.pipe(Effect.mapError(() => unavailable(operation)))\n\n const state = yield* decodeRows(Schema.Array(ScheduleStoreStateRow), rawState, operation)\n\n if (state.length !== 1 || state[0].storage_version !== CURRENT_SCHEDULE_STORE_VERSION) {\n return yield* corrupt(\n state.length === 1\n ? `${operation}: incompatible storage version ${\n state[0].storage_version\n }; expected ${CURRENT_SCHEDULE_STORE_VERSION}`\n : `${operation}: invalid storage version row`,\n )\n }\n})\n\nconst makeServices = Effect.gen(function*() {\n const sql = yield* SqlClientService.SqlClient\n const transactions = yield* DoScheduleTransaction\n const scheduleFailpoint = yield* ScheduleFailpoint\n\n yield* initializeScheduleStore()\n\n const readNextDeadline = Effect.fnUntraced(function*(\n operation: string,\n ): Effect.fn.Return<number | null, ScheduleStorageError> {\n const rows = yield* sql<Record<string, unknown>>`\n SELECT MIN(deadline_at_millis) AS deadline_at_millis\n FROM effect_agent_schedules\n WHERE deadline_at_millis IS NOT NULL\n `.pipe(Effect.mapError(() => unavailable(operation)))\n\n const decoded = yield* decodeRows(Schema.Array(ScheduleDeadlineRow), rows, operation)\n\n if (decoded.length !== 1) return yield* corrupt(operation)\n\n return decoded[0].deadline_at_millis\n })\n\n const replaceAlarm = Effect.fnUntraced(function*(\n replace: DoScheduleReplaceAlarm,\n deadlineAtMillis: number | null,\n operation: string,\n ) {\n const rawState = yield* sql<Record<string, unknown>>`\n UPDATE effect_agent_schedule_store_state\n SET alarm_generation = alarm_generation + 1\n WHERE singleton = 1\n RETURNING storage_version, alarm_generation\n `.pipe(Effect.mapError(() => unavailable(operation)))\n\n const state = yield* decodeRows(Schema.Array(ScheduleStoreStateRow), rawState, operation)\n\n if (state.length !== 1 || state[0].storage_version !== CURRENT_SCHEDULE_STORE_VERSION) {\n return yield* corrupt(operation)\n }\n yield* scheduleFailpoint.hit('schedule:alarm:before')\n yield* replace({ deadlineAtMillis, generation: state[0].alarm_generation })\n yield* scheduleFailpoint.hit('schedule:alarm:after')\n })\n\n const run: SqlScheduleWriteTransaction['Service']['run'] = (body, operation) =>\n transactions.run((replace) =>\n Effect.gen(function*() {\n const result = yield* body\n\n if (result.changed) {\n yield* replaceAlarm(replace, yield* readNextDeadline(operation), operation)\n }\n\n return result\n })\n )\n\n const prearm = Effect.fnUntraced(function*(\n deadlineAtMillis: number,\n ): Effect.fn.Return<void, ScheduleStorageError | ScheduleFailpointError> {\n yield* decodeBoundary(ScheduleInstant, deadlineAtMillis, 'pre-arm schedule recovery')\n yield* transactions.run((replace) => replaceAlarm(replace, deadlineAtMillis, 'pre-arm schedule recovery'))\n yield* scheduleFailpoint.hit('schedule:prearm:after')\n })\n\n const reconcile = Effect.gen(function*() {\n yield* transactions.run((replace) =>\n Effect.gen(function*() {\n const deadline = yield* readNextDeadline('reconcile schedule alarm')\n\n yield* replaceAlarm(replace, deadline, 'reconcile schedule alarm')\n })\n )\n yield* scheduleFailpoint.hit('schedule:reconcile:after')\n })\n\n return Context.make(SqlScheduleWriteTransaction, { run }).pipe(\n Context.add(DoScheduleAlarmControl, { prearm, reconcile }),\n )\n})\n\n/**\n * Durable Object SQLite ScheduleStore. Platform code supplies the one transaction owner that\n * combines these SQL mutations with its logical and native alarm lifecycle.\n */\nexport const scheduleStoreLayer: Layer.Layer<\n ScheduleStore | DoScheduleAlarmControl,\n ScheduleStorageError,\n SqlClientService.SqlClient | DoScheduleTransaction\n> = Layer.effectContext(\n Effect.gen(function*() {\n const store = yield* makeSqlScheduleStore(undefined, MAX_STORED_SCHEDULE_LENGTH)\n const alarms = yield* DoScheduleAlarmControl\n\n return Context.make(ScheduleStore, store).pipe(Context.add(DoScheduleAlarmControl, alarms))\n }),\n).pipe(Layer.provide(Layer.effectContext(makeServices)))\n"],"mappings":"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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as DoScheduleTransaction, n as DoScheduleAlarmReplacement, o as scheduleStoreLayer, r as DoScheduleReplaceAlarm, t as DoScheduleAlarmControl } from "./DoScheduleStore-BiTgDvX1.mjs";
|
|
2
|
+
export { DoScheduleAlarmControl, DoScheduleAlarmReplacement, DoScheduleReplaceAlarm, DoScheduleTransaction, scheduleStoreLayer };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as DoScheduleAlarmControl, r as DoScheduleTransaction, i as scheduleStoreLayer } from "./DoScheduleStore-C7GkSReF.mjs";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D3KUYPsf.mjs";
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
// src/DoStorageConfig.ts
|
|
5
|
+
var DoStorageConfig_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
DEFAULT_MAX_STORED_VALUE_BYTES: () => DEFAULT_MAX_STORED_VALUE_BYTES,
|
|
7
|
+
DoStorageConfig: () => DoStorageConfig,
|
|
8
|
+
DoStorageConfigValue: () => DoStorageConfigValue
|
|
9
|
+
});
|
|
10
|
+
const ObservationPollInterval = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
11
|
+
/**
|
|
12
|
+
* Default per-value byte bound, kept under the Durable Object platform's 2 MB SQLite value
|
|
13
|
+
* limit with a safety margin. This is the DC analogue of Node's 16 MB `BoundedStoredText`
|
|
14
|
+
* bound: both fail typed before mutating, only the threshold differs (a documented DN/DC
|
|
15
|
+
* behavioral difference; Travel Planner payloads sit orders of magnitude below both).
|
|
16
|
+
*/
|
|
17
|
+
const DEFAULT_MAX_STORED_VALUE_BYTES = 19e5;
|
|
18
|
+
/** The hard schema ceiling for the configurable bound: never at or above the platform limit. */
|
|
19
|
+
const MaxStoredValueBytes = Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(2e6));
|
|
20
|
+
/**
|
|
21
|
+
* Validated construction configuration consumed by the Durable Object storage Layers. The
|
|
22
|
+
* storage identity itself belongs to the SqlClient Layer (built from `ctx.storage`);
|
|
23
|
+
* duplicating it here could silently diverge from the handle actually in use.
|
|
24
|
+
*/
|
|
25
|
+
var DoStorageConfigValue = class extends Schema.Class("@effect-agent/storage-cloudflare/DoStorageConfigValue")({
|
|
26
|
+
observationPollInterval: ObservationPollInterval,
|
|
27
|
+
/**
|
|
28
|
+
* Maximum bytes for any single stored text value (canonical batch/record JSON, admission
|
|
29
|
+
* input payload, checkpoint JSON). Enforced typed BEFORE any write; must stay under the
|
|
30
|
+
* platform's 2 MB per-value limit.
|
|
31
|
+
*/
|
|
32
|
+
maxStoredValueBytes: MaxStoredValueBytes,
|
|
33
|
+
/**
|
|
34
|
+
* Audit stored payload schemas, identities, and batch coverage while opening the store.
|
|
35
|
+
* Per-operation Schema decoding remains enabled; this complete scan is an explicit opt-in.
|
|
36
|
+
*/
|
|
37
|
+
verifyOnOpen: Schema.Boolean
|
|
38
|
+
}) {};
|
|
39
|
+
/** Explicit Durable Object storage configuration authority. */
|
|
40
|
+
var DoStorageConfig = class extends Context.Service()("@effect-agent/storage-cloudflare/DoStorageConfig") {};
|
|
41
|
+
export { DoStorageConfig_exports as i, DoStorageConfig as n, DoStorageConfigValue as r, DEFAULT_MAX_STORED_VALUE_BYTES as t };
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=DoStorageConfig-BqezsbD6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DoStorageConfig-BqezsbD6.mjs","names":[],"sources":["../src/DoStorageConfig.ts"],"sourcesContent":["import * as Context from 'effect/Context'\nimport * as Schema from 'effect/Schema'\n\nconst ObservationPollInterval = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))\n\n/**\n * Default per-value byte bound, kept under the Durable Object platform's 2 MB SQLite value\n * limit with a safety margin. This is the DC analogue of Node's 16 MB `BoundedStoredText`\n * bound: both fail typed before mutating, only the threshold differs (a documented DN/DC\n * behavioral difference; Travel Planner payloads sit orders of magnitude below both).\n */\nexport const DEFAULT_MAX_STORED_VALUE_BYTES = 1_900_000\n\n/** The hard schema ceiling for the configurable bound: never at or above the platform limit. */\nconst MaxStoredValueBytes = Schema.Int.check(\n Schema.isGreaterThan(0),\n Schema.isLessThanOrEqualTo(2_000_000),\n)\n\n/**\n * Validated construction configuration consumed by the Durable Object storage Layers. The\n * storage identity itself belongs to the SqlClient Layer (built from `ctx.storage`);\n * duplicating it here could silently diverge from the handle actually in use.\n */\nexport class DoStorageConfigValue extends Schema.Class<DoStorageConfigValue>(\n '@effect-agent/storage-cloudflare/DoStorageConfigValue',\n)({\n observationPollInterval: ObservationPollInterval,\n /**\n * Maximum bytes for any single stored text value (canonical batch/record JSON, admission\n * input payload, checkpoint JSON). Enforced typed BEFORE any write; must stay under the\n * platform's 2 MB per-value limit.\n */\n maxStoredValueBytes: MaxStoredValueBytes,\n /**\n * Audit stored payload schemas, identities, and batch coverage while opening the store.\n * Per-operation Schema decoding remains enabled; this complete scan is an explicit opt-in.\n */\n verifyOnOpen: Schema.Boolean,\n}) {}\n\n/** Explicit Durable Object storage configuration authority. */\nexport class DoStorageConfig extends Context.Service<DoStorageConfig, DoStorageConfigValue>()(\n '@effect-agent/storage-cloudflare/DoStorageConfig',\n) {}\n"],"mappings":";;;;;;;;;AAGA,MAAM,0BAA0B,OAAO,IAAI,MAAM,OAAO,uBAAuB,CAAC,CAAC;;;;;;;AAQjF,MAAa,iCAAiC;;AAG9C,MAAM,sBAAsB,OAAO,IAAI,MACrC,OAAO,cAAc,CAAC,GACtB,OAAO,oBAAoB,GAAS,CACtC;;;;;;AAOA,IAAa,uBAAb,cAA0C,OAAO,MAC/C,uDACF,CAAC,CAAC;CACA,yBAAyB;;;;;;CAMzB,qBAAqB;;;;;CAKrB,cAAc,OAAO;AACvB,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,kBAAb,cAAqC,QAAQ,QAA+C,CAAC,CAC3F,kDACF,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
declare namespace DoStorageConfig_d_exports {
|
|
4
|
+
export { DEFAULT_MAX_STORED_VALUE_BYTES, DoStorageConfig, DoStorageConfigValue };
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Default per-value byte bound, kept under the Durable Object platform's 2 MB SQLite value
|
|
8
|
+
* limit with a safety margin. This is the DC analogue of Node's 16 MB `BoundedStoredText`
|
|
9
|
+
* bound: both fail typed before mutating, only the threshold differs (a documented DN/DC
|
|
10
|
+
* behavioral difference; Travel Planner payloads sit orders of magnitude below both).
|
|
11
|
+
*/
|
|
12
|
+
declare const DEFAULT_MAX_STORED_VALUE_BYTES = 1900000;
|
|
13
|
+
declare const DoStorageConfigValue_base: Schema.Class<DoStorageConfigValue, Schema.Struct<{
|
|
14
|
+
readonly observationPollInterval: Schema.Int;
|
|
15
|
+
/**
|
|
16
|
+
* Maximum bytes for any single stored text value (canonical batch/record JSON, admission
|
|
17
|
+
* input payload, checkpoint JSON). Enforced typed BEFORE any write; must stay under the
|
|
18
|
+
* platform's 2 MB per-value limit.
|
|
19
|
+
*/
|
|
20
|
+
readonly maxStoredValueBytes: Schema.Int;
|
|
21
|
+
/**
|
|
22
|
+
* Audit stored payload schemas, identities, and batch coverage while opening the store.
|
|
23
|
+
* Per-operation Schema decoding remains enabled; this complete scan is an explicit opt-in.
|
|
24
|
+
*/
|
|
25
|
+
readonly verifyOnOpen: Schema.Boolean;
|
|
26
|
+
}>, {}>;
|
|
27
|
+
/**
|
|
28
|
+
* Validated construction configuration consumed by the Durable Object storage Layers. The
|
|
29
|
+
* storage identity itself belongs to the SqlClient Layer (built from `ctx.storage`);
|
|
30
|
+
* duplicating it here could silently diverge from the handle actually in use.
|
|
31
|
+
*/
|
|
32
|
+
declare class DoStorageConfigValue extends DoStorageConfigValue_base {}
|
|
33
|
+
declare const DoStorageConfig_base: Context.ServiceClass<DoStorageConfig, "@effect-agent/storage-cloudflare/DoStorageConfig", DoStorageConfigValue>;
|
|
34
|
+
/** Explicit Durable Object storage configuration authority. */
|
|
35
|
+
declare class DoStorageConfig extends DoStorageConfig_base {}
|
|
36
|
+
export { DoStorageConfig_d_exports as i, DoStorageConfig as n, DoStorageConfigValue as r, DEFAULT_MAX_STORED_VALUE_BYTES as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as DEFAULT_MAX_STORED_VALUE_BYTES, n as DoStorageConfig, r as DoStorageConfigValue } from "./DoStorageConfig-BqezsbD6.mjs";
|