niceeval 0.13.4-canary.48 → 0.14.0

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.
Files changed (108) hide show
  1. package/INDEX.md +3 -3
  2. package/dist/experiment/host/operations.cjs +58 -0
  3. package/dist/experiment/host/operations.cjs.map +1 -1
  4. package/dist/inspection/overview.cjs +20 -9
  5. package/dist/inspection/overview.cjs.map +1 -1
  6. package/dist/inspection/overview.d.cts +5 -0
  7. package/dist/inspection/overview.d.mts +5 -0
  8. package/dist/inspection/overview.d.ts +5 -0
  9. package/dist/inspection/protocol.d.cts +238 -0
  10. package/dist/inspection/protocol.d.mts +238 -0
  11. package/dist/inspection/protocol.d.ts +238 -0
  12. package/dist/inspection/public.mjs +43 -19
  13. package/dist/inspection/results.cjs +11 -10
  14. package/dist/inspection/results.cjs.map +1 -1
  15. package/dist/inspection/results.d.cts +34 -0
  16. package/dist/inspection/results.d.mts +34 -0
  17. package/dist/inspection/results.d.ts +34 -0
  18. package/dist/record/attachment/protocol.cjs +10 -5
  19. package/dist/record/attachment/protocol.cjs.map +1 -1
  20. package/dist/record/attachment/protocol.d.cts +4 -0
  21. package/dist/record/attachment/protocol.d.mts +4 -0
  22. package/dist/record/attachment/protocol.d.ts +4 -0
  23. package/dist/record/family/source-receipt/index.cjs +16 -3
  24. package/dist/record/family/source-receipt/index.cjs.map +1 -1
  25. package/dist/record/family/source-receipt/index.d.cts +1 -0
  26. package/dist/record/family/source-receipt/index.d.mts +1 -0
  27. package/dist/record/family/source-receipt/index.d.ts +1 -0
  28. package/dist/record/family/source-receipt/index.js +2 -0
  29. package/dist/record/host/sqlite-host.cjs +3 -0
  30. package/dist/record/host/sqlite-host.cjs.map +1 -1
  31. package/dist/record/host/types.cjs.map +1 -1
  32. package/dist/record/host/types.d.cts +3 -1
  33. package/dist/record/host/types.d.mts +3 -1
  34. package/dist/record/host/types.d.ts +3 -1
  35. package/dist/record/sqlite/storage.cjs +11 -8
  36. package/dist/record/sqlite/storage.cjs.map +1 -1
  37. package/dist/record/writer/current-attachment.cjs +18 -13
  38. package/dist/record/writer/current-attachment.cjs.map +1 -1
  39. package/dist/record/writer/errors.cjs +6 -1
  40. package/dist/record/writer/errors.cjs.map +1 -1
  41. package/dist/record/writer/errors.d.cts +7 -1
  42. package/dist/record/writer/errors.d.mts +7 -1
  43. package/dist/record/writer/errors.d.ts +7 -1
  44. package/dist/runner/adoption.cjs +1 -1
  45. package/dist/runner/adoption.cjs.map +1 -1
  46. package/dist/runner/reuse-plan.cjs +1 -1
  47. package/dist/runner/reuse-plan.cjs.map +1 -1
  48. package/dist/runner/source-receipts/support.cjs +2 -1
  49. package/dist/runner/source-receipts/support.cjs.map +1 -1
  50. package/dist/runner/source-receipts/support.d.cts +1 -1
  51. package/dist/runner/source-receipts/support.d.mts +1 -1
  52. package/dist/runner/source-receipts/support.d.ts +1 -1
  53. package/dist/show/contribution.cjs +11 -2
  54. package/dist/show/contribution.cjs.map +1 -1
  55. package/dist/show/contribution.d.cts +7 -0
  56. package/dist/show/contribution.d.mts +7 -0
  57. package/dist/show/contribution.d.ts +7 -0
  58. package/dist/show/model.cjs +1 -0
  59. package/dist/show/model.cjs.map +1 -1
  60. package/dist/show/model.d.cts +2 -0
  61. package/dist/show/model.d.mts +2 -0
  62. package/dist/show/model.d.ts +2 -0
  63. package/dist/show/render.cjs +149 -81
  64. package/dist/show/render.cjs.map +1 -1
  65. package/dist/show/render.d.cts +3 -1
  66. package/dist/show/render.d.mts +3 -1
  67. package/dist/show/render.d.ts +3 -1
  68. package/dist/view/app-dist/.vite/manifest.json +18 -18
  69. package/dist/view/app-dist/assets/{AttemptDialog-DKEWcS7m.js → AttemptDialog-76dX1VQq.js} +1 -1
  70. package/dist/view/app-dist/assets/{AttemptRoute-DUs5kic4.js → AttemptRoute-DRHVh2JA.js} +1 -1
  71. package/dist/view/app-dist/assets/{ResultsPage-VlExJ6F0.js → ResultsPage-9CSI8dvZ.js} +2 -2
  72. package/dist/view/app-dist/assets/{RunPage-B9Bagswz.js → RunPage-BUF0REv7.js} +1 -1
  73. package/dist/view/app-dist/assets/{TableContentView-ZL9elUsA.js → TableContentView-_Sbg5wDr.js} +1 -1
  74. package/dist/view/app-dist/assets/index-BGr_6pGY.js +19 -0
  75. package/dist/view/app-dist/assets/{quality-cost-scatter-BqIAORD4.js → quality-cost-scatter-B5wDa_F1.js} +1 -1
  76. package/dist/view/app-dist/assets/useSuspenseQuery-D3W8Uy33.js +1 -0
  77. package/dist/view/app-dist/index.html +1 -1
  78. package/dist/view/function-runtime.mjs +68 -29
  79. package/docs-site/zh/examples/ai-agent-application.mdx +1 -1
  80. package/docs-site/zh/examples/index.mdx +1 -3
  81. package/docs-site/zh/explanation/evals.mdx +1 -1
  82. package/docs-site/zh/explanation/experiment.mdx +3 -1
  83. package/docs-site/zh/explanation/overview.mdx +6 -4
  84. package/docs-site/zh/explanation/record.mdx +9 -5
  85. package/docs-site/zh/explanation/runner.mdx +3 -3
  86. package/docs-site/zh/index.mdx +4 -8
  87. package/docs-site/zh/introduction.mdx +2 -2
  88. package/docs-site/zh/reference/cli.mdx +8 -7
  89. package/docs-site/zh/troubleshooting/debug-sandbox.mdx +5 -5
  90. package/docs-site/zh/troubleshooting/debugging.mdx +8 -8
  91. package/docs-site/zh/troubleshooting/recover-after-kill.mdx +35 -55
  92. package/docs-site/zh/tutorials/accept-results.mdx +4 -4
  93. package/docs-site/zh/tutorials/agent-onboarding.mdx +2 -2
  94. package/docs-site/zh/tutorials/authoring.mdx +1 -1
  95. package/docs-site/zh/tutorials/compare-runs.mdx +3 -3
  96. package/docs-site/zh/tutorials/concurrency.mdx +6 -6
  97. package/docs-site/zh/tutorials/connect-your-agent.mdx +2 -2
  98. package/docs-site/zh/tutorials/docker-in-docker.mdx +1 -1
  99. package/docs-site/zh/tutorials/experiments.mdx +1 -1
  100. package/docs-site/zh/tutorials/install-custom-sandbox-agent.mdx +1 -1
  101. package/docs-site/zh/tutorials/quickstart.mdx +2 -2
  102. package/docs-site/zh/tutorials/reporters.mdx +3 -3
  103. package/docs-site/zh/tutorials/sandbox-agent.mdx +2 -2
  104. package/docs-site/zh/tutorials/sandbox-reuse.mdx +3 -3
  105. package/docs-site/zh/tutorials/viewing-results.mdx +10 -11
  106. package/package.json +1 -1
  107. package/dist/view/app-dist/assets/index-C1E4NkG0.js +0 -19
  108. package/dist/view/app-dist/assets/useSuspenseQuery-BlFuYKyI.js +0 -1
@@ -33,10 +33,15 @@ function closureFailed() {
33
33
  (0, errors_ts_1.recordAttachmentIssue)("record-attachment-closure-mismatch", ["value"]),
34
34
  ]);
35
35
  }
36
- function encodeFailed() {
36
+ function encodeFailed(family, schemaIssues = []) {
37
37
  return (0, errors_ts_3.recordAttachmentEncodeError)((0, errors_ts_1.recordAttachmentPayloadInvalid)([
38
- (0, errors_ts_1.recordAttachmentIssue)("record-attachment-schema-invalid", ["value"]),
39
- ]));
38
+ ...(schemaIssues.length === 0
39
+ ? [(0, errors_ts_1.recordAttachmentIssue)("record-attachment-schema-invalid", ["value"])]
40
+ : schemaIssues.map((issue) => (0, errors_ts_1.recordAttachmentIssue)("record-attachment-schema-invalid", ["value", ...issue.path.map((segment) => typeof segment === "number" ? String(segment) : String(segment))]))),
41
+ ]), family, schemaIssues.map((issue) => Object.freeze({
42
+ path: Object.freeze(issue.path.map((segment) => typeof segment === "number" ? segment : String(segment))),
43
+ message: issue.message,
44
+ })));
40
45
  }
41
46
  function makeBuilder(sources) {
42
47
  const content = (kind, stream) => {
@@ -139,13 +144,13 @@ function prepareCurrentRecordAttachment(input) {
139
144
  catch: callbackFailed,
140
145
  });
141
146
  if (effect_1.Result.isFailure(encoded))
142
- return yield* effect_1.Effect.fail(encodeFailed());
147
+ return yield* effect_1.Effect.fail(encodeFailed(input.definition.family, encoded.failure.schemaIssues ?? []));
143
148
  const inspected = yield* effect_1.Effect.try({
144
149
  try: () => (0, protocol_ts_1.inspectRecordAttachmentOpaqueClosure)(input.definition, value),
145
150
  catch: callbackFailed,
146
151
  });
147
152
  if (effect_1.Result.isFailure(inspected))
148
- return yield* effect_1.Effect.fail(encodeFailed());
153
+ return yield* effect_1.Effect.fail(encodeFailed(input.definition.family));
149
154
  const contentEntries = inspected.success.filter(({ value }) => (0, content_ts_1.isRecordContentHandle)(value));
150
155
  if (contentEntries.length > exports.RECORD_ATTACHMENT_MAXIMUM_CONTENTS) {
151
156
  return yield* effect_1.Effect.fail(new errors_ts_2.RecordResourceLimitExceeded({
@@ -197,7 +202,7 @@ function prepareCurrentRecordAttachment(input) {
197
202
  }
198
203
  const referenceValue = (0, canonical_ts_1.canonicalizeRecordJson)(wire.value, jsonLimits);
199
204
  if (effect_1.Result.isFailure(referenceValue))
200
- return yield* effect_1.Effect.fail(encodeFailed());
205
+ return yield* effect_1.Effect.fail(encodeFailed(input.definition.family));
201
206
  replacements.set(entry.value, Object.freeze({
202
207
  "$niceeval.record.reference": Object.freeze({
203
208
  owner: wire.owner,
@@ -222,10 +227,10 @@ function prepareCurrentRecordAttachment(input) {
222
227
  });
223
228
  const canonical = (0, canonical_ts_1.canonicalizeRecordJson)(replaced, jsonLimits);
224
229
  if (effect_1.Result.isFailure(canonical))
225
- return yield* effect_1.Effect.fail(encodeFailed());
230
+ return yield* effect_1.Effect.fail(encodeFailed(input.definition.family));
226
231
  const payloadBytes = (0, limits_ts_1.encodeRecordJsonUtf8)(canonical.success);
227
232
  if (payloadBytes.byteLength > limits_ts_1.RECORD_JSON_MAXIMUM_BYTES)
228
- return yield* effect_1.Effect.fail(encodeFailed());
233
+ return yield* effect_1.Effect.fail(encodeFailed(input.definition.family));
229
234
  const orderedReferences = [...referenceIdentities.values()].sort((left, right) => `${left.owner}\u0000${left.family}`.localeCompare(`${right.owner}\u0000${right.family}`));
230
235
  return Object.freeze({
231
236
  payloadBytes,
@@ -253,13 +258,13 @@ function prepareStreamingRecordAttachment(input) {
253
258
  catch: callbackFailed,
254
259
  });
255
260
  if (effect_1.Result.isFailure(encoded))
256
- return yield* effect_1.Effect.fail(encodeFailed());
261
+ return yield* effect_1.Effect.fail(encodeFailed(input.definition.family, encoded.failure.schemaIssues ?? []));
257
262
  const inspected = yield* effect_1.Effect.try({
258
263
  try: () => (0, protocol_ts_1.inspectRecordAttachmentOpaqueClosure)(input.definition, value),
259
264
  catch: callbackFailed,
260
265
  });
261
266
  if (effect_1.Result.isFailure(inspected))
262
- return yield* effect_1.Effect.fail(encodeFailed());
267
+ return yield* effect_1.Effect.fail(encodeFailed(input.definition.family));
263
268
  const contentEntries = inspected.success.filter(({ value }) => (0, content_ts_1.isRecordContentHandle)(value));
264
269
  const replacements = new Map();
265
270
  const contents = [];
@@ -294,7 +299,7 @@ function prepareStreamingRecordAttachment(input) {
294
299
  return yield* effect_1.Effect.fail(closureFailed());
295
300
  const referenceValue = (0, canonical_ts_1.canonicalizeRecordJson)(wire.value, jsonLimits);
296
301
  if (effect_1.Result.isFailure(referenceValue))
297
- return yield* effect_1.Effect.fail(encodeFailed());
302
+ return yield* effect_1.Effect.fail(encodeFailed(input.definition.family));
298
303
  replacements.set(entry.value, Object.freeze({
299
304
  "$niceeval.record.reference": Object.freeze({
300
305
  owner: wire.owner,
@@ -319,10 +324,10 @@ function prepareStreamingRecordAttachment(input) {
319
324
  });
320
325
  const canonical = (0, canonical_ts_1.canonicalizeRecordJson)(replaced, jsonLimits);
321
326
  if (effect_1.Result.isFailure(canonical))
322
- return yield* effect_1.Effect.fail(encodeFailed());
327
+ return yield* effect_1.Effect.fail(encodeFailed(input.definition.family));
323
328
  const payloadBytes = (0, limits_ts_1.encodeRecordJsonUtf8)(canonical.success);
324
329
  if (payloadBytes.byteLength > limits_ts_1.RECORD_JSON_MAXIMUM_BYTES)
325
- return yield* effect_1.Effect.fail(encodeFailed());
330
+ return yield* effect_1.Effect.fail(encodeFailed(input.definition.family));
326
331
  const orderedReferences = [...referenceIdentities.values()].sort((left, right) => `${left.owner}\u0000${left.family}`.localeCompare(`${right.owner}\u0000${right.family}`));
327
332
  return Object.freeze({
328
333
  payloadBytes,
@@ -1 +1 @@
1
- {"version":3,"file":"current-attachment.js","sourceRoot":"","sources":["current-attachment.ts"],"names":[],"mappings":";;;AAiNA,wEAyHC;AAKD,4EAuGC;AAtbD,mCAAwD;AACxD,2DAAoZ;AACpZ,yDAAkL;AAClL,uDAAiI;AACjI,6DAAqF;AACrF,4DAA8D;AAG9D,qDAAoE;AACpE,2CAA+F;AAE/F,2CAA8E;AAC9E,MAAM,mBAAmB,GAAkB,MAAM,CAAC,wCAAwC,CAAC,CAAC;AAiF/E,QAAA,kCAAkC,GAAG,MAAM,CAAC;AAC5C,QAAA,uCAAuC,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAC3D,QAAA,6CAA6C,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAC/E,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7B,gBAAgB,EAAE,qCAAyB;IAC3C,YAAY,EAAE,EAAE;IAChB,YAAY,EAAE,MAAM;IACpB,iBAAiB,EAAE,KAAK;IACxB,iBAAiB,EAAE,MAAM;IACzB,mBAAmB,EAAE,KAAK;IAC1B,sBAAsB,EAAE,OAAO;CAClC,CAAC,CAAC;AACH,SAAS,cAAc,CAAC,KAAc;IAClC,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,mCAAmC,EAAE,KAAK,EAAE,CAAC,CAAC;AAC/E,CAAC;AACD,SAAS,aAAa;IAClB,OAAO,IAAA,0CAA8B,EAAC;QAClC,IAAA,iCAAqB,EAAC,oCAAoC,EAAE,CAAC,OAAO,CAAC,CAAC;KACzE,CAAC,CAAC;AACP,CAAC;AACD,SAAS,YAAY;IACjB,OAAO,IAAA,uCAA2B,EAAC,IAAA,0CAA8B,EAAC;QAC9D,IAAA,iCAAqB,EAAC,kCAAkC,EAAE,CAAC,OAAO,CAAC,CAAC;KACvE,CAAC,CAAC,CAAC;AACR,CAAC;AACD,SAAS,WAAW,CAAC,OAA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mentCurrent, inspectRecordAttachmentOpaqueClosure, isRecordAttachmentDefinition, isRecordAttachmentReference, mintRecordAttachmentReference, recordAttachmentReferenceDefinition, recordAttachmentReferenceWire, resolveRecordAttachmentDefinition, RecordAttachmentReference, type RecordAttachmentReferenceTarget, type RecordAttachmentDefinition, } from \"../attachment/protocol.ts\";\nimport { isRecordContentHandle, mintRecordContentHandle, type RecordBytesContentHandle, type RecordContentHandle, type RecordTextContentHandle, } from \"../attachment/content.ts\";\nimport { recordAttachmentClosureInvalid, recordAttachmentIssue, recordAttachmentPayloadInvalid, } from \"../attachment/errors.ts\";\nimport { canonicalizeRecordJson, type RecordJson } from \"../definition/canonical.ts\";\nimport { RecordBlobKeySchema } from \"../codec/identifiers.ts\";\nimport type { RecordBlobKey, Sha256Digest } from \"../model/identifiers.ts\";\nimport type { RecordAttachmentOwner } from \"../model/core.ts\";\nimport { RecordResourceLimitExceeded } from \"../platform/errors.ts\";\nimport { recordAttachmentEncodeError, type RecordAttachmentCallbackFailed } from \"./errors.ts\";\nimport type { RecordWriteError } from \"./types.ts\";\nimport { RECORD_JSON_MAXIMUM_BYTES, encodeRecordJsonUtf8 } from \"./limits.ts\";\nconst contentEffectTypeId: unique symbol = Symbol(\"@niceeval/record/AttachedContentEffect\");\nexport type AttachedRecordContent<Handle, E, R> = Handle & {\n readonly [contentEffectTypeId]: () => {\n readonly error: E;\n readonly requirements: R;\n };\n};\ntype PreviousAttachmentTraversalDepth = readonly [\n never,\n 0,\n 1,\n 2,\n 3,\n 4,\n 5,\n 6,\n 7\n];\ntype PreviousDepth<Depth extends number> = Depth extends keyof PreviousAttachmentTraversalDepth ? PreviousAttachmentTraversalDepth[Depth] : never;\nexport type AttachedContentError<Value, Depth extends number = 7> = Depth extends 0 ? never : Value extends {\n readonly [contentEffectTypeId]: () => {\n readonly error: infer E;\n };\n} ? E : Value extends readonly (infer Item)[] ? AttachedContentError<Item, PreviousDepth<Depth>> : Value extends object ? Exclude<{\n [Key in keyof Value]: AttachedContentError<Value[Key], PreviousDepth<Depth>>;\n}[keyof Value], undefined> : never;\nexport type AttachedContentRequirements<Value, Depth extends number = 7> = Depth extends 0 ? never : Value extends {\n readonly [contentEffectTypeId]: () => {\n readonly requirements: infer R;\n };\n} ? R : Value extends readonly (infer Item)[] ? AttachedContentRequirements<Item, PreviousDepth<Depth>> : Value extends object ? Exclude<{\n [Key in keyof Value]: AttachedContentRequirements<Value[Key], PreviousDepth<Depth>>;\n}[keyof Value], undefined> : never;\ntype AnyDefinition = RecordAttachmentDefinition<RecordAttachmentOwner, string, Schema.Top>;\nexport interface RecordAttachmentSessionBuilder {\n readonly content: {\n readonly text: (text: string) => AttachedRecordContent<RecordTextContentHandle, never, never>;\n readonly bytes: (bytes: Uint8Array) => AttachedRecordContent<RecordBytesContentHandle, never, never>;\n readonly stream: <E, R>(stream: Stream.Stream<Uint8Array, E, R>) => AttachedRecordContent<RecordBytesContentHandle, E, R>;\n };\n readonly reference: {\n readonly to: <Definition extends RecordAttachmentReferenceTarget, Value>(definition: Definition, value: Value) => import(\"../attachment/protocol.ts\").RecordAttachmentReference<AnyDefinition, Value>;\n };\n}\ninterface CapturedSource {\n readonly kind: \"text\" | \"bytes\";\n readonly stream: Stream.Stream<Uint8Array, unknown, unknown>;\n}\nexport interface PreparedCurrentAttachment {\n readonly payloadBytes: Uint8Array;\n readonly contents: readonly {\n readonly key: RecordBlobKey;\n readonly sha256: Sha256Digest;\n readonly bytes: Uint8Array;\n }[];\n readonly references: readonly {\n readonly owner: RecordAttachmentOwner;\n readonly family: string;\n }[];\n readonly referenceDefinitions: readonly RecordAttachmentDefinition<RecordAttachmentOwner, string, Schema.Top>[];\n}\n/**\n * SQLite capture keeps the canonical logical payload in memory while leaving\n * every Content source as a one-shot Stream. The Host consumes those Streams\n * outside transactions and persists fixed-size chunks incrementally.\n */\nexport interface PreparedStreamingRecordAttachment<Error = unknown, Requirements = unknown> {\n readonly payloadBytes: Uint8Array;\n readonly contents: readonly {\n readonly key: RecordBlobKey;\n readonly logicalHandle: string;\n readonly kind: \"text\" | \"bytes\";\n readonly maximumBytes: number | undefined;\n readonly stream: Stream.Stream<Uint8Array, Error, Requirements>;\n }[];\n readonly references: readonly {\n readonly owner: RecordAttachmentOwner;\n readonly family: string;\n }[];\n readonly referenceDefinitions: readonly RecordAttachmentDefinition<RecordAttachmentOwner, string, Schema.Top>[];\n}\nexport const RECORD_ATTACHMENT_MAXIMUM_CONTENTS = 100000;\nexport const RECORD_ATTACHMENT_MAXIMUM_CONTENT_BYTES = 64 * 1024 * 1024;\nexport const RECORD_ATTACHMENT_MAXIMUM_TOTAL_CONTENT_BYTES = 128 * 1024 * 1024;\nconst jsonLimits = Object.freeze({\n maximumJsonBytes: RECORD_JSON_MAXIMUM_BYTES,\n maximumDepth: 64,\n maximumNodes: 100000,\n maximumObjectKeys: 10000,\n maximumArrayItems: 100000,\n maximumKeyUtf8Bytes: 16384,\n maximumStringUtf8Bytes: 1048576,\n});\nfunction callbackFailed(cause: unknown): RecordAttachmentCallbackFailed {\n return Object.freeze({ code: \"record-attachment-callback-failed\", cause });\n}\nfunction closureFailed(): ReturnType<typeof recordAttachmentClosureInvalid> {\n return recordAttachmentClosureInvalid([\n recordAttachmentIssue(\"record-attachment-closure-mismatch\", [\"value\"]),\n ]);\n}\nfunction encodeFailed() {\n return recordAttachmentEncodeError(recordAttachmentPayloadInvalid([\n recordAttachmentIssue(\"record-attachment-schema-invalid\", [\"value\"]),\n ]));\n}\nfunction makeBuilder(sources: Map<object, CapturedSource>): RecordAttachmentSessionBuilder {\n const content = <E, R>(kind: \"text\" | \"bytes\", stream: Stream.Stream<Uint8Array, E, R>): AttachedRecordContent<RecordContentHandle, E, R> => {\n const handle = mintRecordContentHandle(kind);\n sources.set(handle, Object.freeze({\n kind,\n stream: stream as Stream.Stream<Uint8Array, unknown, unknown>,\n }));\n return handle as AttachedRecordContent<RecordContentHandle, E, R>;\n };\n return Object.freeze({\n content: Object.freeze({\n text: (text: string) => content(\"text\", Stream.succeed(new TextEncoder().encode(text))) as AttachedRecordContent<RecordTextContentHandle, never, never>,\n bytes: (bytes: Uint8Array) => content(\"bytes\", Stream.succeed(new Uint8Array(bytes))) as AttachedRecordContent<RecordBytesContentHandle, never, never>,\n stream: <E, R>(stream: Stream.Stream<Uint8Array, E, R>) => content(\"bytes\", stream) as AttachedRecordContent<RecordBytesContentHandle, E, R>,\n }),\n reference: Object.freeze({\n to: <Definition extends RecordAttachmentReferenceTarget, Value>(definition: Definition, value: Value) => {\n const resolved = resolveRecordAttachmentDefinition(definition);\n if (resolved === undefined) {\n throw new TypeError(\"Record reference requires an exact Attachment definition\");\n }\n return mintRecordAttachmentReference(RecordAttachmentReference.to<AnyDefinition, Value>(resolved), value);\n },\n }),\n });\n}\nfunction contentKey(index: number): RecordBlobKey | undefined {\n const value = `content-${String(index + 1).padStart(6, \"0\")}`;\n const decoded = Schema.decodeUnknownResult(RecordBlobKeySchema)(value);\n return Result.isSuccess(decoded) ? decoded.success : undefined;\n}\nfunction collectContent(stream: Stream.Stream<Uint8Array, unknown, unknown>, maximumBytes: number, family: string): Effect.Effect<Uint8Array, unknown | RecordWriteError, unknown> {\n interface CollectState {\n readonly chunks: Uint8Array[];\n readonly byteLength: number;\n }\n return Stream.runFoldEffect(stream, () => ({ chunks: [], byteLength: 0 } satisfies CollectState), (state: CollectState, chunk): Effect.Effect<CollectState, RecordWriteError> => {\n if (!(chunk instanceof Uint8Array))\n return Effect.fail(closureFailed());\n const observedAtLeast = state.byteLength + chunk.byteLength;\n if (observedAtLeast > maximumBytes) {\n return Effect.fail(new RecordResourceLimitExceeded({\n code: \"record-resource-limit-exceeded\",\n resource: \"file-bytes\",\n maximum: maximumBytes,\n observedAtLeast,\n path: family,\n }));\n }\n return Effect.succeed({\n chunks: [...state.chunks, chunk.slice()],\n byteLength: observedAtLeast,\n });\n }).pipe(Effect.map(({ chunks, byteLength }) => {\n const bytes = new Uint8Array(byteLength);\n let offset = 0;\n for (const chunk of chunks) {\n bytes.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return bytes;\n }));\n}\nfunction replaceOpaque(value: unknown, replacements: ReadonlyMap<object, RecordJson>, active = new WeakSet<object>()): unknown {\n if (typeof value !== \"object\" || value === null)\n return value;\n const replacement = replacements.get(value);\n if (replacement !== undefined)\n return replacement;\n if (active.has(value))\n throw new TypeError(\"Record Attachment value is cyclic\");\n active.add(value);\n try {\n if (Array.isArray(value))\n return value.map((item) => replaceOpaque(item, replacements, active));\n const output: Record<string, unknown> = Object.create(null) as Record<string, unknown>;\n for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(value))) {\n if (!(\"value\" in descriptor) || !descriptor.enumerable)\n throw new TypeError(\"Record Attachment value is not data-only\");\n output[key] = replaceOpaque(descriptor.value, replacements, active);\n }\n return output;\n }\n finally {\n active.delete(value);\n }\n}\n/**\n * Session-only current encoder. It closes every content/reference token before\n * returning physical bytes and never places storage metadata in logical values.\n */\nexport function prepareCurrentRecordAttachment<Definition extends AnyDefinition, Value extends Schema.Schema.Type<Definition[\"schema\"]>>(input: {\n readonly definition: Definition;\n readonly value: Value | ((build: RecordAttachmentSessionBuilder) => Value);\n readonly digest: (bytes: Uint8Array) => Sha256Digest;\n}): Effect.Effect<PreparedCurrentAttachment, RecordWriteError | AttachedContentError<Value>, AttachedContentRequirements<Value>> {\n const sources = new Map<object, CapturedSource>();\n return Effect.gen(function* () {\n const value = yield* Effect.try({\n try: () => typeof input.value === \"function\"\n ? (input.value as (build: RecordAttachmentSessionBuilder) => Value)(makeBuilder(sources))\n : input.value,\n catch: callbackFailed,\n });\n const encoded = yield* Effect.try({\n try: () => encodeRecordAttachmentCurrent(input.definition, value),\n catch: callbackFailed,\n });\n if (Result.isFailure(encoded))\n return yield* Effect.fail(encodeFailed());\n const inspected = yield* Effect.try({\n try: () => inspectRecordAttachmentOpaqueClosure(input.definition, value),\n catch: callbackFailed,\n });\n if (Result.isFailure(inspected))\n return yield* Effect.fail(encodeFailed());\n const contentEntries = inspected.success.filter(({ value }) => isRecordContentHandle(value));\n if (contentEntries.length > RECORD_ATTACHMENT_MAXIMUM_CONTENTS) {\n return yield* Effect.fail(new RecordResourceLimitExceeded({\n code: \"record-resource-limit-exceeded\",\n resource: \"file-bytes\",\n maximum: RECORD_ATTACHMENT_MAXIMUM_CONTENTS,\n observedAtLeast: contentEntries.length,\n path: input.definition.family,\n }));\n }\n const replacements = new Map<object, RecordJson>();\n const contents: PreparedCurrentAttachment[\"contents\"][number][] = [];\n let totalBytes = 0;\n for (let index = 0; index < contentEntries.length; index += 1) {\n const entry = contentEntries[index]!;\n const source = sources.get(entry.value);\n const declaration = entry.metadata as {\n readonly category?: string;\n readonly kind?: \"text\" | \"bytes\";\n readonly maximumBytes?: number;\n };\n if (source === undefined || declaration.category !== \"content\" || declaration.kind !== source.kind) {\n return yield* Effect.fail(closureFailed());\n }\n const maximumBytes = Math.min(declaration.maximumBytes ?? RECORD_ATTACHMENT_MAXIMUM_CONTENT_BYTES, RECORD_ATTACHMENT_MAXIMUM_CONTENT_BYTES);\n const bytes = yield* collectContent(source.stream, maximumBytes, input.definition.family);\n totalBytes += bytes.byteLength;\n if (totalBytes > RECORD_ATTACHMENT_MAXIMUM_TOTAL_CONTENT_BYTES) {\n return yield* Effect.fail(new RecordResourceLimitExceeded({\n code: \"record-resource-limit-exceeded\",\n resource: \"file-bytes\",\n maximum: RECORD_ATTACHMENT_MAXIMUM_TOTAL_CONTENT_BYTES,\n observedAtLeast: totalBytes,\n path: input.definition.family,\n }));\n }\n const key = contentKey(index);\n if (key === undefined)\n return yield* Effect.fail(closureFailed());\n replacements.set(entry.value, Object.freeze({ \"$niceeval.record.content\": key }));\n contents.push(Object.freeze({ key, sha256: input.digest(bytes), bytes }));\n }\n if (sources.size !== contentEntries.length)\n return yield* Effect.fail(closureFailed());\n const referenceIdentities = new Map<string, {\n readonly owner: RecordAttachmentOwner;\n readonly family: string;\n readonly definition: AnyDefinition;\n }>();\n for (const entry of inspected.success) {\n if (!isRecordAttachmentReference(entry.value))\n continue;\n const wire = recordAttachmentReferenceWire(entry.value);\n const referenceDefinition = recordAttachmentReferenceDefinition(entry.value);\n if (wire === undefined || referenceDefinition === undefined) {\n return yield* Effect.fail(closureFailed());\n }\n const referenceValue = canonicalizeRecordJson(wire.value, jsonLimits);\n if (Result.isFailure(referenceValue))\n return yield* Effect.fail(encodeFailed());\n replacements.set(entry.value, Object.freeze({\n \"$niceeval.record.reference\": Object.freeze({\n owner: wire.owner,\n family: wire.family,\n value: referenceValue.success,\n }),\n }));\n const identity = `${wire.owner}\\u0000${wire.family}`;\n const existing = referenceIdentities.get(identity);\n if (existing !== undefined && existing.definition !== referenceDefinition) {\n return yield* Effect.fail(closureFailed());\n }\n referenceIdentities.set(identity, Object.freeze({\n owner: wire.owner,\n family: wire.family,\n definition: referenceDefinition,\n }));\n }\n const replaced = yield* Effect.try({\n try: () => replaceOpaque(encoded.success, replacements),\n catch: callbackFailed,\n });\n const canonical = canonicalizeRecordJson(replaced, jsonLimits);\n if (Result.isFailure(canonical))\n return yield* Effect.fail(encodeFailed());\n const payloadBytes = encodeRecordJsonUtf8(canonical.success);\n if (payloadBytes.byteLength > RECORD_JSON_MAXIMUM_BYTES)\n return yield* Effect.fail(encodeFailed());\n const orderedReferences = [...referenceIdentities.values()].sort((left, right) => `${left.owner}\\u0000${left.family}`.localeCompare(`${right.owner}\\u0000${right.family}`));\n return Object.freeze({\n payloadBytes,\n contents: Object.freeze(contents),\n references: Object.freeze(orderedReferences.map(({ owner, family }) => Object.freeze({ owner, family }))),\n referenceDefinitions: Object.freeze(orderedReferences.map(({ definition }) => definition)),\n });\n }).pipe(Effect.catchDefect((cause) => Effect.fail(callbackFailed(cause)))) as Effect.Effect<PreparedCurrentAttachment, RecordWriteError | AttachedContentError<Value>, AttachedContentRequirements<Value>>;\n}\n/**\n * Prepare one immutable logical snapshot without reading any Content bytes.\n * The builder and Schema encoder run exactly once in the capture fiber.\n */\nexport function prepareStreamingRecordAttachment<Definition extends AnyDefinition, Value extends Schema.Schema.Type<Definition[\"schema\"]>>(input: {\n readonly definition: Definition;\n readonly value: Value | ((build: RecordAttachmentSessionBuilder) => Value);\n}): Effect.Effect<PreparedStreamingRecordAttachment<AttachedContentError<Value>, AttachedContentRequirements<Value>>, RecordWriteError | AttachedContentError<Value>, AttachedContentRequirements<Value>> {\n const sources = new Map<object, CapturedSource>();\n return Effect.gen(function* () {\n const value = yield* Effect.try({\n try: () => typeof input.value === \"function\"\n ? (input.value as (build: RecordAttachmentSessionBuilder) => Value)(makeBuilder(sources))\n : input.value,\n catch: callbackFailed,\n });\n const encoded = yield* Effect.try({\n try: () => encodeRecordAttachmentCurrent(input.definition, value),\n catch: callbackFailed,\n });\n if (Result.isFailure(encoded))\n return yield* Effect.fail(encodeFailed());\n const inspected = yield* Effect.try({\n try: () => inspectRecordAttachmentOpaqueClosure(input.definition, value),\n catch: callbackFailed,\n });\n if (Result.isFailure(inspected))\n return yield* Effect.fail(encodeFailed());\n const contentEntries = inspected.success.filter(({ value }) => isRecordContentHandle(value));\n const replacements = new Map<object, RecordJson>();\n const contents: PreparedStreamingRecordAttachment[\"contents\"][number][] = [];\n for (let index = 0; index < contentEntries.length; index += 1) {\n const entry = contentEntries[index]!;\n const source = sources.get(entry.value);\n const declaration = entry.metadata as {\n readonly category?: string;\n readonly kind?: \"text\" | \"bytes\";\n readonly maximumBytes?: number;\n };\n if (source === undefined || declaration.category !== \"content\" || declaration.kind !== source.kind) {\n return yield* Effect.fail(closureFailed());\n }\n const key = contentKey(index);\n if (key === undefined)\n return yield* Effect.fail(closureFailed());\n replacements.set(entry.value, Object.freeze({ \"$niceeval.record.content\": key }));\n contents.push(Object.freeze({\n key,\n logicalHandle: key,\n kind: source.kind,\n maximumBytes: declaration.maximumBytes,\n stream: source.stream,\n }));\n }\n if (sources.size !== contentEntries.length)\n return yield* Effect.fail(closureFailed());\n const referenceIdentities = new Map<string, {\n readonly owner: RecordAttachmentOwner;\n readonly family: string;\n readonly definition: AnyDefinition;\n }>();\n for (const entry of inspected.success) {\n if (!isRecordAttachmentReference(entry.value))\n continue;\n const wire = recordAttachmentReferenceWire(entry.value);\n const referenceDefinition = recordAttachmentReferenceDefinition(entry.value);\n if (wire === undefined || referenceDefinition === undefined)\n return yield* Effect.fail(closureFailed());\n const referenceValue = canonicalizeRecordJson(wire.value, jsonLimits);\n if (Result.isFailure(referenceValue))\n return yield* Effect.fail(encodeFailed());\n replacements.set(entry.value, Object.freeze({\n \"$niceeval.record.reference\": Object.freeze({\n owner: wire.owner,\n family: wire.family,\n value: referenceValue.success,\n }),\n }));\n const identity = `${wire.owner}\\u0000${wire.family}`;\n const existing = referenceIdentities.get(identity);\n if (existing !== undefined && existing.definition !== referenceDefinition) {\n return yield* Effect.fail(closureFailed());\n }\n referenceIdentities.set(identity, Object.freeze({\n owner: wire.owner,\n family: wire.family,\n definition: referenceDefinition,\n }));\n }\n const replaced = yield* Effect.try({\n try: () => replaceOpaque(encoded.success, replacements),\n catch: callbackFailed,\n });\n const canonical = canonicalizeRecordJson(replaced, jsonLimits);\n if (Result.isFailure(canonical))\n return yield* Effect.fail(encodeFailed());\n const payloadBytes = encodeRecordJsonUtf8(canonical.success);\n if (payloadBytes.byteLength > RECORD_JSON_MAXIMUM_BYTES)\n return yield* Effect.fail(encodeFailed());\n const orderedReferences = [...referenceIdentities.values()].sort((left, right) => `${left.owner}\\u0000${left.family}`.localeCompare(`${right.owner}\\u0000${right.family}`));\n return Object.freeze({\n payloadBytes,\n contents: Object.freeze(contents),\n references: Object.freeze(orderedReferences.map(({ owner, family }) => Object.freeze({ owner, family }))),\n referenceDefinitions: Object.freeze(orderedReferences.map(({ definition }) => definition)),\n });\n }).pipe(Effect.catchDefect((cause) => Effect.fail(callbackFailed(cause)))) as Effect.Effect<PreparedStreamingRecordAttachment<AttachedContentError<Value>, AttachedContentRequirements<Value>>, RecordWriteError | AttachedContentError<Value>, AttachedContentRequirements<Value>>;\n}\n"]}
1
+ {"version":3,"file":"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AttachmentDefinition, isRecordAttachmentReference, mintRecordAttachmentReference, recordAttachmentReferenceDefinition, recordAttachmentReferenceWire, resolveRecordAttachmentDefinition, RecordAttachmentReference, type RecordAttachmentReferenceTarget, type RecordAttachmentDefinition, } from \"../attachment/protocol.ts\";\nimport { isRecordContentHandle, mintRecordContentHandle, type RecordBytesContentHandle, type RecordContentHandle, type RecordTextContentHandle, } from \"../attachment/content.ts\";\nimport { recordAttachmentClosureInvalid, recordAttachmentIssue, recordAttachmentPayloadInvalid, } from \"../attachment/errors.ts\";\nimport { canonicalizeRecordJson, type RecordJson } from \"../definition/canonical.ts\";\nimport { RecordBlobKeySchema } from \"../codec/identifiers.ts\";\nimport type { RecordBlobKey, Sha256Digest } from \"../model/identifiers.ts\";\nimport type { RecordAttachmentOwner } from \"../model/core.ts\";\nimport { RecordResourceLimitExceeded } from \"../platform/errors.ts\";\nimport { recordAttachmentEncodeError, type RecordAttachmentCallbackFailed } from \"./errors.ts\";\nimport type { RecordWriteError } from \"./types.ts\";\nimport { RECORD_JSON_MAXIMUM_BYTES, encodeRecordJsonUtf8 } from \"./limits.ts\";\nconst contentEffectTypeId: unique symbol = Symbol(\"@niceeval/record/AttachedContentEffect\");\nexport type AttachedRecordContent<Handle, E, R> = Handle & {\n readonly [contentEffectTypeId]: () => {\n readonly error: E;\n readonly requirements: R;\n };\n};\ntype PreviousAttachmentTraversalDepth = readonly [\n never,\n 0,\n 1,\n 2,\n 3,\n 4,\n 5,\n 6,\n 7\n];\ntype PreviousDepth<Depth extends number> = Depth extends keyof PreviousAttachmentTraversalDepth ? PreviousAttachmentTraversalDepth[Depth] : never;\nexport type AttachedContentError<Value, Depth extends number = 7> = Depth extends 0 ? never : Value extends {\n readonly [contentEffectTypeId]: () => {\n readonly error: infer E;\n };\n} ? E : Value extends readonly (infer Item)[] ? AttachedContentError<Item, PreviousDepth<Depth>> : Value extends object ? Exclude<{\n [Key in keyof Value]: AttachedContentError<Value[Key], PreviousDepth<Depth>>;\n}[keyof Value], undefined> : never;\nexport type AttachedContentRequirements<Value, Depth extends number = 7> = Depth extends 0 ? never : Value extends {\n readonly [contentEffectTypeId]: () => {\n readonly requirements: infer R;\n };\n} ? R : Value extends readonly (infer Item)[] ? AttachedContentRequirements<Item, PreviousDepth<Depth>> : Value extends object ? Exclude<{\n [Key in keyof Value]: AttachedContentRequirements<Value[Key], PreviousDepth<Depth>>;\n}[keyof Value], undefined> : never;\ntype AnyDefinition = RecordAttachmentDefinition<RecordAttachmentOwner, string, Schema.Top>;\nexport interface RecordAttachmentSessionBuilder {\n readonly content: {\n readonly text: (text: string) => AttachedRecordContent<RecordTextContentHandle, never, never>;\n readonly bytes: (bytes: Uint8Array) => AttachedRecordContent<RecordBytesContentHandle, never, never>;\n readonly stream: <E, R>(stream: Stream.Stream<Uint8Array, E, R>) => AttachedRecordContent<RecordBytesContentHandle, E, R>;\n };\n readonly reference: {\n readonly to: <Definition extends RecordAttachmentReferenceTarget, Value>(definition: Definition, value: Value) => import(\"../attachment/protocol.ts\").RecordAttachmentReference<AnyDefinition, Value>;\n };\n}\ninterface CapturedSource {\n readonly kind: \"text\" | \"bytes\";\n readonly stream: Stream.Stream<Uint8Array, unknown, unknown>;\n}\nexport interface PreparedCurrentAttachment {\n readonly payloadBytes: Uint8Array;\n readonly contents: readonly {\n readonly key: RecordBlobKey;\n readonly sha256: Sha256Digest;\n readonly bytes: Uint8Array;\n }[];\n readonly references: readonly {\n readonly owner: RecordAttachmentOwner;\n readonly family: string;\n }[];\n readonly referenceDefinitions: readonly RecordAttachmentDefinition<RecordAttachmentOwner, string, Schema.Top>[];\n}\n/**\n * SQLite capture keeps the canonical logical payload in memory while leaving\n * every Content source as a one-shot Stream. The Host consumes those Streams\n * outside transactions and persists fixed-size chunks incrementally.\n */\nexport interface PreparedStreamingRecordAttachment<Error = unknown, Requirements = unknown> {\n readonly payloadBytes: Uint8Array;\n readonly contents: readonly {\n readonly key: RecordBlobKey;\n readonly logicalHandle: string;\n readonly kind: \"text\" | \"bytes\";\n readonly maximumBytes: number | undefined;\n readonly stream: Stream.Stream<Uint8Array, Error, Requirements>;\n }[];\n readonly references: readonly {\n readonly owner: RecordAttachmentOwner;\n readonly family: string;\n }[];\n readonly referenceDefinitions: readonly RecordAttachmentDefinition<RecordAttachmentOwner, string, Schema.Top>[];\n}\nexport const RECORD_ATTACHMENT_MAXIMUM_CONTENTS = 100000;\nexport const RECORD_ATTACHMENT_MAXIMUM_CONTENT_BYTES = 64 * 1024 * 1024;\nexport const RECORD_ATTACHMENT_MAXIMUM_TOTAL_CONTENT_BYTES = 128 * 1024 * 1024;\nconst jsonLimits = Object.freeze({\n maximumJsonBytes: RECORD_JSON_MAXIMUM_BYTES,\n maximumDepth: 64,\n maximumNodes: 100000,\n maximumObjectKeys: 10000,\n maximumArrayItems: 100000,\n maximumKeyUtf8Bytes: 16384,\n maximumStringUtf8Bytes: 1048576,\n});\nfunction callbackFailed(cause: unknown): RecordAttachmentCallbackFailed {\n return Object.freeze({ code: \"record-attachment-callback-failed\", cause });\n}\nfunction closureFailed(): ReturnType<typeof recordAttachmentClosureInvalid> {\n return recordAttachmentClosureInvalid([\n recordAttachmentIssue(\"record-attachment-closure-mismatch\", [\"value\"]),\n ]);\n}\nfunction encodeFailed(family: string, schemaIssues: readonly {\n readonly path: ReadonlyArray<PropertyKey>;\n readonly message: string;\n}[] = []) {\n return recordAttachmentEncodeError(recordAttachmentPayloadInvalid([\n ...(schemaIssues.length === 0\n ? [recordAttachmentIssue(\"record-attachment-schema-invalid\", [\"value\"])]\n : schemaIssues.map((issue) => recordAttachmentIssue(\"record-attachment-schema-invalid\", [\"value\", ...issue.path.map((segment) => typeof segment === \"number\" ? String(segment) : String(segment))]))),\n ]), family, schemaIssues.map((issue) => Object.freeze({\n path: Object.freeze(issue.path.map((segment) => typeof segment === \"number\" ? segment : String(segment))),\n message: issue.message,\n })));\n}\nfunction makeBuilder(sources: Map<object, CapturedSource>): RecordAttachmentSessionBuilder {\n const content = <E, R>(kind: \"text\" | \"bytes\", stream: Stream.Stream<Uint8Array, E, R>): AttachedRecordContent<RecordContentHandle, E, R> => {\n const handle = mintRecordContentHandle(kind);\n sources.set(handle, Object.freeze({\n kind,\n stream: stream as Stream.Stream<Uint8Array, unknown, unknown>,\n }));\n return handle as AttachedRecordContent<RecordContentHandle, E, R>;\n };\n return Object.freeze({\n content: Object.freeze({\n text: (text: string) => content(\"text\", Stream.succeed(new TextEncoder().encode(text))) as AttachedRecordContent<RecordTextContentHandle, never, never>,\n bytes: (bytes: Uint8Array) => content(\"bytes\", Stream.succeed(new Uint8Array(bytes))) as AttachedRecordContent<RecordBytesContentHandle, never, never>,\n stream: <E, R>(stream: Stream.Stream<Uint8Array, E, R>) => content(\"bytes\", stream) as AttachedRecordContent<RecordBytesContentHandle, E, R>,\n }),\n reference: Object.freeze({\n to: <Definition extends RecordAttachmentReferenceTarget, Value>(definition: Definition, value: Value) => {\n const resolved = resolveRecordAttachmentDefinition(definition);\n if (resolved === undefined) {\n throw new TypeError(\"Record reference requires an exact Attachment definition\");\n }\n return mintRecordAttachmentReference(RecordAttachmentReference.to<AnyDefinition, Value>(resolved), value);\n },\n }),\n });\n}\nfunction contentKey(index: number): RecordBlobKey | undefined {\n const value = `content-${String(index + 1).padStart(6, \"0\")}`;\n const decoded = Schema.decodeUnknownResult(RecordBlobKeySchema)(value);\n return Result.isSuccess(decoded) ? decoded.success : undefined;\n}\nfunction collectContent(stream: Stream.Stream<Uint8Array, unknown, unknown>, maximumBytes: number, family: string): Effect.Effect<Uint8Array, unknown | RecordWriteError, unknown> {\n interface CollectState {\n readonly chunks: Uint8Array[];\n readonly byteLength: number;\n }\n return Stream.runFoldEffect(stream, () => ({ chunks: [], byteLength: 0 } satisfies CollectState), (state: CollectState, chunk): Effect.Effect<CollectState, RecordWriteError> => {\n if (!(chunk instanceof Uint8Array))\n return Effect.fail(closureFailed());\n const observedAtLeast = state.byteLength + chunk.byteLength;\n if (observedAtLeast > maximumBytes) {\n return Effect.fail(new RecordResourceLimitExceeded({\n code: \"record-resource-limit-exceeded\",\n resource: \"file-bytes\",\n maximum: maximumBytes,\n observedAtLeast,\n path: family,\n }));\n }\n return Effect.succeed({\n chunks: [...state.chunks, chunk.slice()],\n byteLength: observedAtLeast,\n });\n }).pipe(Effect.map(({ chunks, byteLength }) => {\n const bytes = new Uint8Array(byteLength);\n let offset = 0;\n for (const chunk of chunks) {\n bytes.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return bytes;\n }));\n}\nfunction replaceOpaque(value: unknown, replacements: ReadonlyMap<object, RecordJson>, active = new WeakSet<object>()): unknown {\n if (typeof value !== \"object\" || value === null)\n return value;\n const replacement = replacements.get(value);\n if (replacement !== undefined)\n return replacement;\n if (active.has(value))\n throw new TypeError(\"Record Attachment value is cyclic\");\n active.add(value);\n try {\n if (Array.isArray(value))\n return value.map((item) => replaceOpaque(item, replacements, active));\n const output: Record<string, unknown> = Object.create(null) as Record<string, unknown>;\n for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(value))) {\n if (!(\"value\" in descriptor) || !descriptor.enumerable)\n throw new TypeError(\"Record Attachment value is not data-only\");\n output[key] = replaceOpaque(descriptor.value, replacements, active);\n }\n return output;\n }\n finally {\n active.delete(value);\n }\n}\n/**\n * Session-only current encoder. It closes every content/reference token before\n * returning physical bytes and never places storage metadata in logical values.\n */\nexport function prepareCurrentRecordAttachment<Definition extends AnyDefinition, Value extends Schema.Schema.Type<Definition[\"schema\"]>>(input: {\n readonly definition: Definition;\n readonly value: Value | ((build: RecordAttachmentSessionBuilder) => Value);\n readonly digest: (bytes: Uint8Array) => Sha256Digest;\n}): Effect.Effect<PreparedCurrentAttachment, RecordWriteError | AttachedContentError<Value>, AttachedContentRequirements<Value>> {\n const sources = new Map<object, CapturedSource>();\n return Effect.gen(function* () {\n const value = yield* Effect.try({\n try: () => typeof input.value === \"function\"\n ? (input.value as (build: RecordAttachmentSessionBuilder) => Value)(makeBuilder(sources))\n : input.value,\n catch: callbackFailed,\n });\n const encoded = yield* Effect.try({\n try: () => encodeRecordAttachmentCurrent(input.definition, value),\n catch: callbackFailed,\n });\n if (Result.isFailure(encoded))\n return yield* Effect.fail(encodeFailed(input.definition.family, encoded.failure.schemaIssues ?? []));\n const inspected = yield* Effect.try({\n try: () => inspectRecordAttachmentOpaqueClosure(input.definition, value),\n catch: callbackFailed,\n });\n if (Result.isFailure(inspected))\n return yield* Effect.fail(encodeFailed(input.definition.family));\n const contentEntries = inspected.success.filter(({ value }) => isRecordContentHandle(value));\n if (contentEntries.length > RECORD_ATTACHMENT_MAXIMUM_CONTENTS) {\n return yield* Effect.fail(new RecordResourceLimitExceeded({\n code: \"record-resource-limit-exceeded\",\n resource: \"file-bytes\",\n maximum: RECORD_ATTACHMENT_MAXIMUM_CONTENTS,\n observedAtLeast: contentEntries.length,\n path: input.definition.family,\n }));\n }\n const replacements = new Map<object, RecordJson>();\n const contents: PreparedCurrentAttachment[\"contents\"][number][] = [];\n let totalBytes = 0;\n for (let index = 0; index < contentEntries.length; index += 1) {\n const entry = contentEntries[index]!;\n const source = sources.get(entry.value);\n const declaration = entry.metadata as {\n readonly category?: string;\n readonly kind?: \"text\" | \"bytes\";\n readonly maximumBytes?: number;\n };\n if (source === undefined || declaration.category !== \"content\" || declaration.kind !== source.kind) {\n return yield* Effect.fail(closureFailed());\n }\n const maximumBytes = Math.min(declaration.maximumBytes ?? RECORD_ATTACHMENT_MAXIMUM_CONTENT_BYTES, RECORD_ATTACHMENT_MAXIMUM_CONTENT_BYTES);\n const bytes = yield* collectContent(source.stream, maximumBytes, input.definition.family);\n totalBytes += bytes.byteLength;\n if (totalBytes > RECORD_ATTACHMENT_MAXIMUM_TOTAL_CONTENT_BYTES) {\n return yield* Effect.fail(new RecordResourceLimitExceeded({\n code: \"record-resource-limit-exceeded\",\n resource: \"file-bytes\",\n maximum: RECORD_ATTACHMENT_MAXIMUM_TOTAL_CONTENT_BYTES,\n observedAtLeast: totalBytes,\n path: input.definition.family,\n }));\n }\n const key = contentKey(index);\n if (key === undefined)\n return yield* Effect.fail(closureFailed());\n replacements.set(entry.value, Object.freeze({ \"$niceeval.record.content\": key }));\n contents.push(Object.freeze({ key, sha256: input.digest(bytes), bytes }));\n }\n if (sources.size !== contentEntries.length)\n return yield* Effect.fail(closureFailed());\n const referenceIdentities = new Map<string, {\n readonly owner: RecordAttachmentOwner;\n readonly family: string;\n readonly definition: AnyDefinition;\n }>();\n for (const entry of inspected.success) {\n if (!isRecordAttachmentReference(entry.value))\n continue;\n const wire = recordAttachmentReferenceWire(entry.value);\n const referenceDefinition = recordAttachmentReferenceDefinition(entry.value);\n if (wire === undefined || referenceDefinition === undefined) {\n return yield* Effect.fail(closureFailed());\n }\n const referenceValue = canonicalizeRecordJson(wire.value, jsonLimits);\n if (Result.isFailure(referenceValue))\n return yield* Effect.fail(encodeFailed(input.definition.family));\n replacements.set(entry.value, Object.freeze({\n \"$niceeval.record.reference\": Object.freeze({\n owner: wire.owner,\n family: wire.family,\n value: referenceValue.success,\n }),\n }));\n const identity = `${wire.owner}\\u0000${wire.family}`;\n const existing = referenceIdentities.get(identity);\n if (existing !== undefined && existing.definition !== referenceDefinition) {\n return yield* Effect.fail(closureFailed());\n }\n referenceIdentities.set(identity, Object.freeze({\n owner: wire.owner,\n family: wire.family,\n definition: referenceDefinition,\n }));\n }\n const replaced = yield* Effect.try({\n try: () => replaceOpaque(encoded.success, replacements),\n catch: callbackFailed,\n });\n const canonical = canonicalizeRecordJson(replaced, jsonLimits);\n if (Result.isFailure(canonical))\n return yield* Effect.fail(encodeFailed(input.definition.family));\n const payloadBytes = encodeRecordJsonUtf8(canonical.success);\n if (payloadBytes.byteLength > RECORD_JSON_MAXIMUM_BYTES)\n return yield* Effect.fail(encodeFailed(input.definition.family));\n const orderedReferences = [...referenceIdentities.values()].sort((left, right) => `${left.owner}\\u0000${left.family}`.localeCompare(`${right.owner}\\u0000${right.family}`));\n return Object.freeze({\n payloadBytes,\n contents: Object.freeze(contents),\n references: Object.freeze(orderedReferences.map(({ owner, family }) => Object.freeze({ owner, family }))),\n referenceDefinitions: Object.freeze(orderedReferences.map(({ definition }) => definition)),\n });\n }).pipe(Effect.catchDefect((cause) => Effect.fail(callbackFailed(cause)))) as Effect.Effect<PreparedCurrentAttachment, RecordWriteError | AttachedContentError<Value>, AttachedContentRequirements<Value>>;\n}\n/**\n * Prepare one immutable logical snapshot without reading any Content bytes.\n * The builder and Schema encoder run exactly once in the capture fiber.\n */\nexport function prepareStreamingRecordAttachment<Definition extends AnyDefinition, Value extends Schema.Schema.Type<Definition[\"schema\"]>>(input: {\n readonly definition: Definition;\n readonly value: Value | ((build: RecordAttachmentSessionBuilder) => Value);\n}): Effect.Effect<PreparedStreamingRecordAttachment<AttachedContentError<Value>, AttachedContentRequirements<Value>>, RecordWriteError | AttachedContentError<Value>, AttachedContentRequirements<Value>> {\n const sources = new Map<object, CapturedSource>();\n return Effect.gen(function* () {\n const value = yield* Effect.try({\n try: () => typeof input.value === \"function\"\n ? (input.value as (build: RecordAttachmentSessionBuilder) => Value)(makeBuilder(sources))\n : input.value,\n catch: callbackFailed,\n });\n const encoded = yield* Effect.try({\n try: () => encodeRecordAttachmentCurrent(input.definition, value),\n catch: callbackFailed,\n });\n if (Result.isFailure(encoded))\n return yield* Effect.fail(encodeFailed(input.definition.family, encoded.failure.schemaIssues ?? []));\n const inspected = yield* Effect.try({\n try: () => inspectRecordAttachmentOpaqueClosure(input.definition, value),\n catch: callbackFailed,\n });\n if (Result.isFailure(inspected))\n return yield* Effect.fail(encodeFailed(input.definition.family));\n const contentEntries = inspected.success.filter(({ value }) => isRecordContentHandle(value));\n const replacements = new Map<object, RecordJson>();\n const contents: PreparedStreamingRecordAttachment[\"contents\"][number][] = [];\n for (let index = 0; index < contentEntries.length; index += 1) {\n const entry = contentEntries[index]!;\n const source = sources.get(entry.value);\n const declaration = entry.metadata as {\n readonly category?: string;\n readonly kind?: \"text\" | \"bytes\";\n readonly maximumBytes?: number;\n };\n if (source === undefined || declaration.category !== \"content\" || declaration.kind !== source.kind) {\n return yield* Effect.fail(closureFailed());\n }\n const key = contentKey(index);\n if (key === undefined)\n return yield* Effect.fail(closureFailed());\n replacements.set(entry.value, Object.freeze({ \"$niceeval.record.content\": key }));\n contents.push(Object.freeze({\n key,\n logicalHandle: key,\n kind: source.kind,\n maximumBytes: declaration.maximumBytes,\n stream: source.stream,\n }));\n }\n if (sources.size !== contentEntries.length)\n return yield* Effect.fail(closureFailed());\n const referenceIdentities = new Map<string, {\n readonly owner: RecordAttachmentOwner;\n readonly family: string;\n readonly definition: AnyDefinition;\n }>();\n for (const entry of inspected.success) {\n if (!isRecordAttachmentReference(entry.value))\n continue;\n const wire = recordAttachmentReferenceWire(entry.value);\n const referenceDefinition = recordAttachmentReferenceDefinition(entry.value);\n if (wire === undefined || referenceDefinition === undefined)\n return yield* Effect.fail(closureFailed());\n const referenceValue = canonicalizeRecordJson(wire.value, jsonLimits);\n if (Result.isFailure(referenceValue))\n return yield* Effect.fail(encodeFailed(input.definition.family));\n replacements.set(entry.value, Object.freeze({\n \"$niceeval.record.reference\": Object.freeze({\n owner: wire.owner,\n family: wire.family,\n value: referenceValue.success,\n }),\n }));\n const identity = `${wire.owner}\\u0000${wire.family}`;\n const existing = referenceIdentities.get(identity);\n if (existing !== undefined && existing.definition !== referenceDefinition) {\n return yield* Effect.fail(closureFailed());\n }\n referenceIdentities.set(identity, Object.freeze({\n owner: wire.owner,\n family: wire.family,\n definition: referenceDefinition,\n }));\n }\n const replaced = yield* Effect.try({\n try: () => replaceOpaque(encoded.success, replacements),\n catch: callbackFailed,\n });\n const canonical = canonicalizeRecordJson(replaced, jsonLimits);\n if (Result.isFailure(canonical))\n return yield* Effect.fail(encodeFailed(input.definition.family));\n const payloadBytes = encodeRecordJsonUtf8(canonical.success);\n if (payloadBytes.byteLength > RECORD_JSON_MAXIMUM_BYTES)\n return yield* Effect.fail(encodeFailed(input.definition.family));\n const orderedReferences = [...referenceIdentities.values()].sort((left, right) => `${left.owner}\\u0000${left.family}`.localeCompare(`${right.owner}\\u0000${right.family}`));\n return Object.freeze({\n payloadBytes,\n contents: Object.freeze(contents),\n references: Object.freeze(orderedReferences.map(({ owner, family }) => Object.freeze({ owner, family }))),\n referenceDefinitions: Object.freeze(orderedReferences.map(({ definition }) => definition)),\n });\n }).pipe(Effect.catchDefect((cause) => Effect.fail(callbackFailed(cause)))) as Effect.Effect<PreparedStreamingRecordAttachment<AttachedContentError<Value>, AttachedContentRequirements<Value>>, RecordWriteError | AttachedContentError<Value>, AttachedContentRequirements<Value>>;\n}\n"]}
@@ -53,10 +53,15 @@ function recordCollectionNotClosed(family) {
53
53
  function recordDraftStateError(input) {
54
54
  return Object.freeze({ ...input });
55
55
  }
56
- function recordAttachmentEncodeError(source) {
56
+ function recordAttachmentEncodeError(source, family, schemaIssues = []) {
57
57
  return Object.freeze({
58
58
  code: "record-attachment-encode-error",
59
+ family,
59
60
  issues: source.issues,
61
+ schemaIssues: Object.freeze(schemaIssues.map((issue) => Object.freeze({
62
+ path: Object.freeze([...issue.path]),
63
+ message: issue.message,
64
+ }))),
60
65
  });
61
66
  }
62
67
  function recordOwnerDefinitionMismatch(input) {
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["errors.ts"],"names":[],"mappings":";;AA8EA,gDAEC;AACD,8DAEC;AACD,4DAEC;AACD,0DAEC;AACD,8EAEC;AACD,gEAEC;AACD,8DAEC;AACD,sDAMC;AACD,kEAKC;AACD,sEAKC;AACD,oDAKC;AA/DD,MAAM,YAAY,GAAuB,MAAM,CAAC,MAAM,CAAC;IACnD,IAAI,EAAE,sBAAsB;CAC/B,CAAC,CAAC;AACH,MAAM,mBAAmB,GAA8B,MAAM,CAAC,MAAM,CAAC;IACjE,IAAI,EAAE,8BAA8B;CACvC,CAAC,CAAC;AACH,MAAM,kBAAkB,GAA6B,MAAM,CAAC,MAAM,CAAC;IAC/D,IAAI,EAAE,6BAA6B;CACtC,CAAC,CAAC;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KAGpC;IACG,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,wBAAwB,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import type { NonEmptyRecordAttachmentIssues, RecordAttachmentPayloadInvalid, } from \"../attachment/errors.ts\";\n/** A scoped write session or a draft escaped after its owning Scope closed. */\nexport interface RecordWriterClosed {\n readonly code: \"record-writer-closed\";\n}\n/** A copied or otherwise non-issued write-session capability was invoked. */\nexport interface RecordWriteSessionInvalid {\n readonly code: \"record-write-session-invalid\";\n}\n/** One scoped Run session can reserve exactly one new Run directory. */\nexport interface RecordRunAlreadyCreated {\n readonly code: \"record-run-already-created\";\n}\n/** A copied or otherwise non-issued draft capability was supplied internally. */\nexport interface RecordDraftHandleInvalid {\n readonly code: \"record-draft-handle-invalid\";\n}\nexport type RecordDraftOperation = \"record\" | \"create-attempt\" | \"reference\" | \"publish\";\nexport type RecordDraftLifecycleState = \"open\" | \"publishing\" | \"published\" | \"failed\";\n/** A draft was consumed, is publishing, or a concurrent write already failed. */\nexport interface RecordDraftStateError {\n readonly code: \"record-draft-state-invalid\" | \"record-draft-write-failed\";\n readonly operation: RecordDraftOperation;\n readonly state: RecordDraftLifecycleState;\n}\n/** Schema encoding failed before an Attachment could become durable bytes. */\nexport interface RecordAttachmentEncodeError {\n readonly code: \"record-attachment-encode-error\";\n readonly issues: NonEmptyRecordAttachmentIssues;\n}\n/** A synchronous session builder callback threw before any physical write. */\nexport interface RecordAttachmentCallbackFailed {\n readonly code: \"record-attachment-callback-failed\";\n readonly cause: unknown;\n}\n/** A writer was paired with a definition for the other owner kind. */\nexport interface RecordOwnerDefinitionMismatch {\n readonly code: \"record-owner-definition-mismatch\";\n readonly expected: \"run\" | \"attempt\";\n readonly actual: \"run\" | \"attempt\";\n}\n/** A create-once owner/family already has a reserved write. */\nexport interface RecordAlreadyWritten {\n readonly code: \"record-already-written\";\n readonly owner: \"run\" | \"attempt\";\n readonly family: string;\n}\n/** A forged value or an ordinary Record definition was supplied to collection start. */\nexport interface RecordCollectionDefinitionInvalid {\n readonly code: \"record-collection-definition-invalid\";\n}\n/** A forged value or an ordinary Record write command was supplied to append. */\nexport interface RecordAppendCommandInvalid {\n readonly code: \"record-append-command-invalid\";\n}\n/** Attempt completion cannot invent a collection's domain completion state. */\nexport interface RecordCollectionNotClosed {\n readonly code: \"record-collection-not-closed\";\n readonly family: string;\n}\nconst writerClosed: RecordWriterClosed = Object.freeze({\n code: \"record-writer-closed\",\n});\nconst writeSessionInvalid: RecordWriteSessionInvalid = Object.freeze({\n code: \"record-write-session-invalid\",\n});\nconst draftHandleInvalid: RecordDraftHandleInvalid = Object.freeze({\n code: \"record-draft-handle-invalid\",\n});\nconst runAlreadyCreated: RecordRunAlreadyCreated = Object.freeze({\n code: \"record-run-already-created\",\n});\nconst collectionDefinitionInvalid: RecordCollectionDefinitionInvalid = Object.freeze({\n code: \"record-collection-definition-invalid\",\n});\nconst appendCommandInvalid: RecordAppendCommandInvalid = Object.freeze({\n code: \"record-append-command-invalid\",\n});\nexport function recordWriterClosed(): RecordWriterClosed {\n return writerClosed;\n}\nexport function recordWriteSessionInvalid(): RecordWriteSessionInvalid {\n return writeSessionInvalid;\n}\nexport function recordDraftHandleInvalid(): RecordDraftHandleInvalid {\n return draftHandleInvalid;\n}\nexport function recordRunAlreadyCreated(): RecordRunAlreadyCreated {\n return runAlreadyCreated;\n}\nexport function recordCollectionDefinitionInvalid(): RecordCollectionDefinitionInvalid {\n return collectionDefinitionInvalid;\n}\nexport function recordAppendCommandInvalid(): RecordAppendCommandInvalid {\n return appendCommandInvalid;\n}\nexport function recordCollectionNotClosed(family: string): RecordCollectionNotClosed {\n return Object.freeze({ code: \"record-collection-not-closed\", family });\n}\nexport function recordDraftStateError(input: {\n readonly code: RecordDraftStateError[\"code\"];\n readonly operation: RecordDraftOperation;\n readonly state: RecordDraftLifecycleState;\n}): RecordDraftStateError {\n return Object.freeze({ ...input });\n}\nexport function recordAttachmentEncodeError(source: RecordAttachmentPayloadInvalid): RecordAttachmentEncodeError {\n return Object.freeze({\n code: \"record-attachment-encode-error\",\n issues: source.issues,\n });\n}\nexport function recordOwnerDefinitionMismatch(input: {\n readonly expected: \"run\" | \"attempt\";\n readonly actual: \"run\" | \"attempt\";\n}): RecordOwnerDefinitionMismatch {\n return Object.freeze({ code: \"record-owner-definition-mismatch\", ...input });\n}\nexport function recordAlreadyWritten(input: {\n readonly owner: \"run\" | \"attempt\";\n readonly family: string;\n}): RecordAlreadyWritten {\n return Object.freeze({ code: \"record-already-written\", ...input });\n}\n"]}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["errors.ts"],"names":[],"mappings":";;AAoFA,gDAEC;AACD,8DAEC;AACD,4DAEC;AACD,0DAEC;AACD,8EAEC;AACD,gEAEC;AACD,8DAEC;AACD,sDAMC;AACD,kEAUC;AACD,sEAKC;AACD,oDAKC;AApED,MAAM,YAAY,GAAuB,MAAM,CAAC,MAAM,CAAC;IACnD,IAAI,EAAE,sBAAsB;CAC/B,CAAC,CAAC;AACH,MAAM,mBAAmB,GAA8B,MAAM,CAAC,MAAM,CAAC;IACjE,IAAI,EAAE,8BAA8B;CACvC,CAAC,CAAC;AACH,MAAM,kBAAkB,GAA6B,MAAM,CAAC,MAAM,CAAC;IAC/D,IAAI,EAAE,6BAA6B;CACtC,CAAC,CAAC;AACH,MAAM,iBAAiB,GAA4B,MAAM,CAAC,MAAM,CAAC;IAC7D,IAAI,EAAE,4BAA4B;CACrC,CAAC,CAAC;AACH,MAAM,2BAA2B,GAAsC,MAAM,CAAC,MAAM,CAAC;IACjF,IAAI,EAAE,sCAAsC;CAC/C,CAAC,CAAC;AACH,MAAM,oBAAoB,GAA+B,MAAM,CAAC,MAAM,CAAC;IACnE,IAAI,EAAE,+BAA+B;CACxC,CAAC,CAAC;AACH,SAAgB,kBAAkB;IAC9B,OAAO,YAAY,CAAC;AACxB,CAAC;AACD,SAAgB,yBAAyB;IACrC,OAAO,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E,GAAG,KAAK,EAAE,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import type { NonEmptyRecordAttachmentIssues, RecordAttachmentPayloadInvalid, } from \"../attachment/errors.ts\";\n/** A scoped write session or a draft escaped after its owning Scope closed. */\nexport interface RecordWriterClosed {\n readonly code: \"record-writer-closed\";\n}\n/** A copied or otherwise non-issued write-session capability was invoked. */\nexport interface RecordWriteSessionInvalid {\n readonly code: \"record-write-session-invalid\";\n}\n/** One scoped Run session can reserve exactly one new Run directory. */\nexport interface RecordRunAlreadyCreated {\n readonly code: \"record-run-already-created\";\n}\n/** A copied or otherwise non-issued draft capability was supplied internally. */\nexport interface RecordDraftHandleInvalid {\n readonly code: \"record-draft-handle-invalid\";\n}\nexport type RecordDraftOperation = \"record\" | \"create-attempt\" | \"reference\" | \"publish\";\nexport type RecordDraftLifecycleState = \"open\" | \"publishing\" | \"published\" | \"failed\";\n/** A draft was consumed, is publishing, or a concurrent write already failed. */\nexport interface RecordDraftStateError {\n readonly code: \"record-draft-state-invalid\" | \"record-draft-write-failed\";\n readonly operation: RecordDraftOperation;\n readonly state: RecordDraftLifecycleState;\n}\n/** Schema encoding failed before an Attachment could become durable bytes. */\nexport interface RecordAttachmentEncodeError {\n readonly code: \"record-attachment-encode-error\";\n readonly family: string;\n readonly issues: NonEmptyRecordAttachmentIssues;\n readonly schemaIssues: readonly RecordAttachmentSchemaIssue[];\n}\nexport interface RecordAttachmentSchemaIssue {\n readonly path: readonly (string | number)[];\n readonly message: string;\n}\n/** A synchronous session builder callback threw before any physical write. */\nexport interface RecordAttachmentCallbackFailed {\n readonly code: \"record-attachment-callback-failed\";\n readonly cause: unknown;\n}\n/** A writer was paired with a definition for the other owner kind. */\nexport interface RecordOwnerDefinitionMismatch {\n readonly code: \"record-owner-definition-mismatch\";\n readonly expected: \"run\" | \"attempt\";\n readonly actual: \"run\" | \"attempt\";\n}\n/** A create-once owner/family already has a reserved write. */\nexport interface RecordAlreadyWritten {\n readonly code: \"record-already-written\";\n readonly owner: \"run\" | \"attempt\";\n readonly family: string;\n}\n/** A forged value or an ordinary Record definition was supplied to collection start. */\nexport interface RecordCollectionDefinitionInvalid {\n readonly code: \"record-collection-definition-invalid\";\n}\n/** A forged value or an ordinary Record write command was supplied to append. */\nexport interface RecordAppendCommandInvalid {\n readonly code: \"record-append-command-invalid\";\n}\n/** Attempt completion cannot invent a collection's domain completion state. */\nexport interface RecordCollectionNotClosed {\n readonly code: \"record-collection-not-closed\";\n readonly family: string;\n}\nconst writerClosed: RecordWriterClosed = Object.freeze({\n code: \"record-writer-closed\",\n});\nconst writeSessionInvalid: RecordWriteSessionInvalid = Object.freeze({\n code: \"record-write-session-invalid\",\n});\nconst draftHandleInvalid: RecordDraftHandleInvalid = Object.freeze({\n code: \"record-draft-handle-invalid\",\n});\nconst runAlreadyCreated: RecordRunAlreadyCreated = Object.freeze({\n code: \"record-run-already-created\",\n});\nconst collectionDefinitionInvalid: RecordCollectionDefinitionInvalid = Object.freeze({\n code: \"record-collection-definition-invalid\",\n});\nconst appendCommandInvalid: RecordAppendCommandInvalid = Object.freeze({\n code: \"record-append-command-invalid\",\n});\nexport function recordWriterClosed(): RecordWriterClosed {\n return writerClosed;\n}\nexport function recordWriteSessionInvalid(): RecordWriteSessionInvalid {\n return writeSessionInvalid;\n}\nexport function recordDraftHandleInvalid(): RecordDraftHandleInvalid {\n return draftHandleInvalid;\n}\nexport function recordRunAlreadyCreated(): RecordRunAlreadyCreated {\n return runAlreadyCreated;\n}\nexport function recordCollectionDefinitionInvalid(): RecordCollectionDefinitionInvalid {\n return collectionDefinitionInvalid;\n}\nexport function recordAppendCommandInvalid(): RecordAppendCommandInvalid {\n return appendCommandInvalid;\n}\nexport function recordCollectionNotClosed(family: string): RecordCollectionNotClosed {\n return Object.freeze({ code: \"record-collection-not-closed\", family });\n}\nexport function recordDraftStateError(input: {\n readonly code: RecordDraftStateError[\"code\"];\n readonly operation: RecordDraftOperation;\n readonly state: RecordDraftLifecycleState;\n}): RecordDraftStateError {\n return Object.freeze({ ...input });\n}\nexport function recordAttachmentEncodeError(source: RecordAttachmentPayloadInvalid, family: string, schemaIssues: readonly RecordAttachmentSchemaIssue[] = []): RecordAttachmentEncodeError {\n return Object.freeze({\n code: \"record-attachment-encode-error\",\n family,\n issues: source.issues,\n schemaIssues: Object.freeze(schemaIssues.map((issue) => Object.freeze({\n path: Object.freeze([...issue.path]),\n message: issue.message,\n }))),\n });\n}\nexport function recordOwnerDefinitionMismatch(input: {\n readonly expected: \"run\" | \"attempt\";\n readonly actual: \"run\" | \"attempt\";\n}): RecordOwnerDefinitionMismatch {\n return Object.freeze({ code: \"record-owner-definition-mismatch\", ...input });\n}\nexport function recordAlreadyWritten(input: {\n readonly owner: \"run\" | \"attempt\";\n readonly family: string;\n}): RecordAlreadyWritten {\n return Object.freeze({ code: \"record-already-written\", ...input });\n}\n"]}
@@ -26,7 +26,13 @@ export interface RecordDraftStateError {
26
26
  /** Schema encoding failed before an Attachment could become durable bytes. */
27
27
  export interface RecordAttachmentEncodeError {
28
28
  readonly code: "record-attachment-encode-error";
29
+ readonly family: string;
29
30
  readonly issues: NonEmptyRecordAttachmentIssues;
31
+ readonly schemaIssues: readonly RecordAttachmentSchemaIssue[];
32
+ }
33
+ export interface RecordAttachmentSchemaIssue {
34
+ readonly path: readonly (string | number)[];
35
+ readonly message: string;
30
36
  }
31
37
  /** A synchronous session builder callback threw before any physical write. */
32
38
  export interface RecordAttachmentCallbackFailed {
@@ -70,7 +76,7 @@ export declare function recordDraftStateError(input: {
70
76
  readonly operation: RecordDraftOperation;
71
77
  readonly state: RecordDraftLifecycleState;
72
78
  }): RecordDraftStateError;
73
- export declare function recordAttachmentEncodeError(source: RecordAttachmentPayloadInvalid): RecordAttachmentEncodeError;
79
+ export declare function recordAttachmentEncodeError(source: RecordAttachmentPayloadInvalid, family: string, schemaIssues?: readonly RecordAttachmentSchemaIssue[]): RecordAttachmentEncodeError;
74
80
  export declare function recordOwnerDefinitionMismatch(input: {
75
81
  readonly expected: "run" | "attempt";
76
82
  readonly actual: "run" | "attempt";
@@ -26,7 +26,13 @@ export interface RecordDraftStateError {
26
26
  /** Schema encoding failed before an Attachment could become durable bytes. */
27
27
  export interface RecordAttachmentEncodeError {
28
28
  readonly code: "record-attachment-encode-error";
29
+ readonly family: string;
29
30
  readonly issues: NonEmptyRecordAttachmentIssues;
31
+ readonly schemaIssues: readonly RecordAttachmentSchemaIssue[];
32
+ }
33
+ export interface RecordAttachmentSchemaIssue {
34
+ readonly path: readonly (string | number)[];
35
+ readonly message: string;
30
36
  }
31
37
  /** A synchronous session builder callback threw before any physical write. */
32
38
  export interface RecordAttachmentCallbackFailed {
@@ -70,7 +76,7 @@ export declare function recordDraftStateError(input: {
70
76
  readonly operation: RecordDraftOperation;
71
77
  readonly state: RecordDraftLifecycleState;
72
78
  }): RecordDraftStateError;
73
- export declare function recordAttachmentEncodeError(source: RecordAttachmentPayloadInvalid): RecordAttachmentEncodeError;
79
+ export declare function recordAttachmentEncodeError(source: RecordAttachmentPayloadInvalid, family: string, schemaIssues?: readonly RecordAttachmentSchemaIssue[]): RecordAttachmentEncodeError;
74
80
  export declare function recordOwnerDefinitionMismatch(input: {
75
81
  readonly expected: "run" | "attempt";
76
82
  readonly actual: "run" | "attempt";
@@ -26,7 +26,13 @@ export interface RecordDraftStateError {
26
26
  /** Schema encoding failed before an Attachment could become durable bytes. */
27
27
  export interface RecordAttachmentEncodeError {
28
28
  readonly code: "record-attachment-encode-error";
29
+ readonly family: string;
29
30
  readonly issues: NonEmptyRecordAttachmentIssues;
31
+ readonly schemaIssues: readonly RecordAttachmentSchemaIssue[];
32
+ }
33
+ export interface RecordAttachmentSchemaIssue {
34
+ readonly path: readonly (string | number)[];
35
+ readonly message: string;
30
36
  }
31
37
  /** A synchronous session builder callback threw before any physical write. */
32
38
  export interface RecordAttachmentCallbackFailed {
@@ -70,7 +76,7 @@ export declare function recordDraftStateError(input: {
70
76
  readonly operation: RecordDraftOperation;
71
77
  readonly state: RecordDraftLifecycleState;
72
78
  }): RecordDraftStateError;
73
- export declare function recordAttachmentEncodeError(source: RecordAttachmentPayloadInvalid): RecordAttachmentEncodeError;
79
+ export declare function recordAttachmentEncodeError(source: RecordAttachmentPayloadInvalid, family: string, schemaIssues?: readonly RecordAttachmentSchemaIssue[]): RecordAttachmentEncodeError;
74
80
  export declare function recordOwnerDefinitionMismatch(input: {
75
81
  readonly expected: "run" | "attempt";
76
82
  readonly actual: "run" | "attempt";
@@ -334,7 +334,7 @@ function sourceCoreInvalid(message) {
334
334
  function resolveExplicitAttemptLocator(reader, text) {
335
335
  return effect_1.Effect.gen(function* () {
336
336
  const parsed = yield* parseExplicitAttemptLocator(text);
337
- const selected = yield* reader.selectRuns();
337
+ const selected = yield* reader.selectRuns({ includePublishedActive: true });
338
338
  const resolved = yield* (0, attempt_locator_resolution_ts_1.resolveAttemptLocator)({
339
339
  reader,
340
340
  selection: selected,