@yielded/agent-storage-cloudflare 0.1.0-beta.173 → 0.1.0-beta.174

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.
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { r as ownedState } from "./owned-state-BHzUi0eb.mjs";
2
+ import { r as ownedState } from "./owned-state-DcFh0YNo.mjs";
3
3
  import { SqlMemoryLimits, SqlStorageOwner, memoryStoreLayerWithFailpoints } from "@yielded/agent/sql-memory-store";
4
4
  import { Effect, Layer, Schema } from "effect";
5
5
  import * as SqlClientService from "effect/sql/SqlClient";
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { DoStorageConfig } from "./DoStorageConfig.mjs";
3
3
  import { DoStorageFailpoint } from "./DoStorageFailpoint.mjs";
4
- import { i as initializeDoJournal } from "./do-journal-_MdLGTd3.mjs";
4
+ import { i as initializeDoJournal } from "./do-journal-ZMAzzENZ.mjs";
5
5
  import { BrowserCrypto } from "@effect/platform-browser";
6
6
  import { SqlLifecycleSource } from "@yielded/agent-storage-sql/sql-lifecycle-publication";
7
7
  import { makeSqlMessageDeliveryStore } from "@yielded/agent-storage-sql/sql-message-delivery-store";
@@ -12,10 +12,7 @@ import { Effect } from "effect";
12
12
  * The handles stay injected: this package never imports `cloudflare:workers`, so the harness
13
13
  * that owns a `DurableObjectState` supplies the thunk.
14
14
  */
15
- const evictionFailpointHandler = (options) => (location) => options.isArmed(location).pipe(Effect.flatMap((armed) => armed ? Effect.sync(() => {
16
- options.evict(location);
17
- throw new Error(`Durable Object eviction did not interrupt execution at ${location}.`);
18
- }) : Effect.void));
15
+ const evictionFailpointHandler = (options) => (location) => options.isArmed(location).pipe(Effect.flatMap((armed) => armed ? Effect.sync(() => options.evict(location)).pipe(Effect.andThen(Effect.die(/* @__PURE__ */ new Error(`Durable Object eviction did not interrupt execution at ${location}.`)))) : Effect.void));
19
16
  //#endregion
20
17
  export { evictionFailpointHandler };
21
18
 
@@ -1 +1 @@
1
- {"version":3,"file":"DoStorageFailpointTesting.mjs","names":[],"sources":["../src/DoStorageFailpointTesting.ts"],"sourcesContent":["import { Effect } from \"effect\";\n\nimport type { DoStorageFailpointLocation } from \"./DoStorageError.ts\";\nimport type { DoStorageFailpointHandler } from \"./DoStorageFailpoint.ts\";\n\n/**\n * The DC-specific eviction failpoint mode: instead of failing typed, an armed hit evicts the\n * Durable Object through an injected `evict` thunk — in production-shaped harnesses that thunk\n * is `() => ctx.abort()`, the platform's real failure mode. `ctx.abort()` never returns (it\n * throws while destroying the in-memory instance and every in-flight implicit or explicit\n * storage transaction rolls back), so an armed hit ends the current Attempt exactly like an\n * unannounced platform eviction; DO storage — the only correctness-critical state — survives\n * for the next incarnation, which the persisted alarm wakes without any incoming request.\n *\n * The handles stay injected: this package never imports `cloudflare:workers`, so the harness\n * that owns a `DurableObjectState` supplies the thunk.\n */\nexport const evictionFailpointHandler =\n (options: {\n readonly isArmed: (location: DoStorageFailpointLocation) => Effect.Effect<boolean>;\n /** Kills the incarnation — e.g. `() => ctx.abort()`. Typed `void` because the platform\n * declares `abort` as returning, but it throws while destroying the instance. */\n readonly evict: (location: DoStorageFailpointLocation) => void;\n }): DoStorageFailpointHandler =>\n (location) =>\n options.isArmed(location).pipe(\n Effect.flatMap((armed) =>\n armed\n ? // `ctx.abort()` throws while destroying the instance; that throw surfaces as a\n // defect in the (already dying) incarnation. The defensive throw below keeps the\n // guarantee — nothing after an armed hit may observe in-memory state — even if a\n // harness supplies an evict thunk that returns.\n Effect.sync((): never => {\n options.evict(location);\n throw new Error(\n `Durable Object eviction did not interrupt execution at ${location}.`,\n );\n })\n : Effect.void,\n ),\n );\n"],"mappings":";;;;;;;;;;;;;;AAiBA,MAAa,4BACV,aAMA,aACC,QAAQ,QAAQ,QAAQ,CAAC,CAAC,KACxB,OAAO,SAAS,UACd,QAKI,OAAO,WAAkB;CACvB,QAAQ,MAAM,QAAQ;CACtB,MAAM,IAAI,MACR,0DAA0D,SAAS,EACrE;AACF,CAAC,IACD,OAAO,IACb,CACF"}
1
+ {"version":3,"file":"DoStorageFailpointTesting.mjs","names":[],"sources":["../src/DoStorageFailpointTesting.ts"],"sourcesContent":["import { Effect } from \"effect\";\n\nimport type { DoStorageFailpointLocation } from \"./DoStorageError.ts\";\nimport type { DoStorageFailpointHandler } from \"./DoStorageFailpoint.ts\";\n\n/**\n * The DC-specific eviction failpoint mode: instead of failing typed, an armed hit evicts the\n * Durable Object through an injected `evict` thunk — in production-shaped harnesses that thunk\n * is `() => ctx.abort()`, the platform's real failure mode. `ctx.abort()` never returns (it\n * throws while destroying the in-memory instance and every in-flight implicit or explicit\n * storage transaction rolls back), so an armed hit ends the current Attempt exactly like an\n * unannounced platform eviction; DO storage — the only correctness-critical state — survives\n * for the next incarnation, which the persisted alarm wakes without any incoming request.\n *\n * The handles stay injected: this package never imports `cloudflare:workers`, so the harness\n * that owns a `DurableObjectState` supplies the thunk.\n */\nexport const evictionFailpointHandler =\n (options: {\n readonly isArmed: (location: DoStorageFailpointLocation) => Effect.Effect<boolean>;\n /** Kills the incarnation — e.g. `() => ctx.abort()`. Typed `void` because the platform\n * declares `abort` as returning, but it throws while destroying the instance. */\n readonly evict: (location: DoStorageFailpointLocation) => void;\n }): DoStorageFailpointHandler =>\n (location) =>\n options.isArmed(location).pipe(\n Effect.flatMap((armed) =>\n armed\n ? // `ctx.abort()` throws while destroying the instance; that throw surfaces as a\n // defect in the (already dying) incarnation. The defensive defect below keeps the\n // guarantee — nothing after an armed hit may observe in-memory state — even if a\n // harness supplies an evict thunk that returns.\n Effect.sync(() => options.evict(location)).pipe(\n Effect.andThen(\n Effect.die(\n // oxlint-disable-next-line effect/no-native-error -- A returning native eviction callback violates the host contract and must remain a defect.\n new Error(`Durable Object eviction did not interrupt execution at ${location}.`),\n ),\n ),\n )\n : Effect.void,\n ),\n );\n"],"mappings":";;;;;;;;;;;;;;AAiBA,MAAa,4BACV,aAMA,aACC,QAAQ,QAAQ,QAAQ,CAAC,CAAC,KACxB,OAAO,SAAS,UACd,QAKI,OAAO,WAAW,QAAQ,MAAM,QAAQ,CAAC,CAAC,CAAC,KACzC,OAAO,QACL,OAAO,oBAEL,IAAI,MAAM,0DAA0D,SAAS,EAAE,CACjF,CACF,CACF,IACA,OAAO,IACb,CACF"}
@@ -2,16 +2,16 @@ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { DoStorageConfig } from "./DoStorageConfig.mjs";
3
3
  import { DoStorageFailpoint } from "./DoStorageFailpoint.mjs";
4
4
  import { DoLedgerError, DoStorageCorruptionError, DoStorageError } from "./DoStorageError.mjs";
5
- import { n as ownedRows } from "./owned-state-BHzUi0eb.mjs";
6
- import { i as initializeDoJournal, r as decodeRows } from "./do-journal-_MdLGTd3.mjs";
7
- import { l as prepareCanonicalAppend, o as storageConfigLayer, s as storageFailpointLayer } from "./DoThreadStore-CtyahRTW.mjs";
5
+ import { n as ownedRows } from "./owned-state-DcFh0YNo.mjs";
6
+ import { i as initializeDoJournal, r as decodeRows } from "./do-journal-ZMAzzENZ.mjs";
7
+ import { l as prepareCanonicalAppend, o as storageConfigLayer, s as storageFailpointLayer } from "./DoThreadStore-DyzOZDXK.mjs";
8
8
  import { BrowserCrypto } from "@effect/platform-browser";
9
9
  import { Cause, Clock, Context, Crypto, DateTime, Effect, Layer, Option, Schema, Stream } from "effect";
10
10
  import * as SqlClientService from "effect/sql/SqlClient";
11
11
  import { definitionJson, makeCanonicalStorage, recordBatchId, runKey } from "@yielded/agent-storage-sql/sql-canonical-storage";
12
12
  import { SqlStorageProgress } from "@yielded/agent-storage-sql/sql-storage-progress";
13
13
  import { canonicalRecordJson } from "@yielded/agent-storage-sql/sql-thread-archive-range";
14
- import { ApprovalDecision, CanonicalSequence, DefinitionDigests, Digest, PersistedJson, RecordEnvelope, SettlementOutcome, WorkerAdmission } from "@yielded/agent/records";
14
+ import { ApprovalDecision, CanonicalSequence, DefinitionDigests, Digest, PersistedJson, RecordEnvelope, RecordId, SettlementOutcome, WorkerAdmission } from "@yielded/agent/records";
15
15
  import { AppendConflict, ThreadNotMaterialized, ThreadStoreDiagnostic, ThreadStoreError, makeTransferFactCheck } from "@yielded/agent/thread-store";
16
16
  import { SqliteClient } from "@effect/sql-sqlite-do";
17
17
  import { StorageOwner } from "@yielded/agent/run-storage";
@@ -55,7 +55,7 @@ var SubmissionRow = class extends Schema.Class("SubmissionRow")({
55
55
  receipt_id: BoundedIdentifier,
56
56
  state: SubmissionState,
57
57
  settled_outcome: Schema.NullOr(SettlementOutcome),
58
- settled_record_id: Schema.NullOr(BoundedIdentifier),
58
+ settled_record_id: Schema.NullOr(BoundedIdentifier.pipe(Schema.decodeTo(RecordId))),
59
59
  finalized_at: Schema.NullOr(BoundedTimestamp),
60
60
  created_at: BoundedTimestamp,
61
61
  ready_at: Schema.NullOr(BoundedTimestamp),
@@ -354,11 +354,14 @@ const makeServices = Effect.fnUntraced(function* () {
354
354
  }));
355
355
  if (row.parent_submission_id === null !== (row.parent_tool_call_id === null)) return yield* corruptionFailure(operation, "effect_agent_submissions", row.submission_id, "A parent linkage must record both the parent Submission and the parent Tool Call.");
356
356
  const admission = yield* decodeAdmissionFact(row).pipe(Effect.mapError(decodeFailure));
357
+ const settledAt = row.finalized_at === null ? void 0 : yield* decodeUtcInstant(row.finalized_at).pipe(Effect.mapError(decodeFailure));
357
358
  const readyAt = row.ready_at === null ? void 0 : yield* decodeUtcInstant(row.ready_at).pipe(Effect.mapError(decodeFailure));
358
359
  const snapshot = yield* decodeSubmissionSnapshotType({
359
360
  ...admission,
360
361
  state: row.state,
361
362
  ...row.settled_outcome === null ? {} : { settledOutcome: row.settled_outcome },
363
+ ...settledAt === void 0 ? {} : { settledAt },
364
+ ...row.settled_record_id === null ? {} : { settledRecordId: row.settled_record_id },
362
365
  ...readyAt === void 0 ? {} : { readyAt }
363
366
  }).pipe(Effect.mapError(decodeFailure));
364
367
  submissions.set(row, snapshot);