better-effect 0.12.0 → 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 (101) hide show
  1. package/README.md +599 -30
  2. package/dist/adapters/iti.d.mts +2 -3
  3. package/dist/adapters/iti.d.mts.map +1 -1
  4. package/dist/adapters/iti.mjs +2 -2
  5. package/dist/bun.d.mts +95 -0
  6. package/dist/bun.d.mts.map +1 -0
  7. package/dist/bun.mjs +177 -0
  8. package/dist/bun.mjs.map +1 -0
  9. package/dist/{context-BUEf1qjL.mjs → context-DSGSqcJj.mjs} +14 -3
  10. package/dist/context-DSGSqcJj.mjs.map +1 -0
  11. package/dist/current-request-Bc1YHL0w.mjs +21 -0
  12. package/dist/current-request-Bc1YHL0w.mjs.map +1 -0
  13. package/dist/current-request-Dm-QQ3Xr.d.mts +22 -0
  14. package/dist/current-request-Dm-QQ3Xr.d.mts.map +1 -0
  15. package/dist/{effect-CK4YZaX0.mjs → effect-W0IQXY8P.mjs} +21 -2
  16. package/dist/effect-W0IQXY8P.mjs.map +1 -0
  17. package/dist/{errors-BKcsQ0ip.d.mts → errors-CpHMzPiP.d.mts} +6 -2
  18. package/dist/errors-CpHMzPiP.d.mts.map +1 -0
  19. package/dist/hono.d.mts +65 -27
  20. package/dist/hono.d.mts.map +1 -1
  21. package/dist/hono.mjs +177 -53
  22. package/dist/hono.mjs.map +1 -1
  23. package/dist/{index-CX6iAoCB.d.mts → index-3Bkl-sxS.d.mts} +7 -2
  24. package/dist/{index-CX6iAoCB.d.mts.map → index-3Bkl-sxS.d.mts.map} +1 -1
  25. package/dist/{index-B1nH4luq.d.mts → index-C2ed9Ilq.d.mts} +32 -21
  26. package/dist/index-C2ed9Ilq.d.mts.map +1 -0
  27. package/dist/{index-GYJ4qm9K.d.mts → index-ClNndn2-.d.mts} +93 -62
  28. package/dist/index-ClNndn2-.d.mts.map +1 -0
  29. package/dist/{index-BMdU_Z72.d.mts → index-Cy1VsU-u.d.mts} +2 -3
  30. package/dist/index-Cy1VsU-u.d.mts.map +1 -0
  31. package/dist/index.d.mts +6 -7
  32. package/dist/index.mjs +8 -8
  33. package/dist/{internal-identity-CbXoZIfw.mjs → internal-identity-BuHBtP0k.mjs} +2 -2
  34. package/dist/{internal-identity-CbXoZIfw.mjs.map → internal-identity-BuHBtP0k.mjs.map} +1 -1
  35. package/dist/layer-2kjHVv4N.mjs +343 -0
  36. package/dist/layer-2kjHVv4N.mjs.map +1 -0
  37. package/dist/{outcome-CB43bnFW.d.mts → layer-C2OaqTmB.d.mts} +683 -138
  38. package/dist/layer-C2OaqTmB.d.mts.map +1 -0
  39. package/dist/next.d.mts +192 -0
  40. package/dist/next.d.mts.map +1 -0
  41. package/dist/next.mjs +185 -0
  42. package/dist/next.mjs.map +1 -0
  43. package/dist/{node-context-DWsCUBRa.d.mts → node-context-1YEjrU9g.d.mts} +2 -2
  44. package/dist/{node-context-DWsCUBRa.d.mts.map → node-context-1YEjrU9g.d.mts.map} +1 -1
  45. package/dist/{node-context-lggRF4bR.mjs → node-context-g3bCcY9t.mjs} +2 -2
  46. package/dist/{node-context-lggRF4bR.mjs.map → node-context-g3bCcY9t.mjs.map} +1 -1
  47. package/dist/node.d.mts +11 -6
  48. package/dist/node.d.mts.map +1 -1
  49. package/dist/node.mjs +156 -10
  50. package/dist/node.mjs.map +1 -1
  51. package/dist/opentelemetry.d.mts +112 -0
  52. package/dist/opentelemetry.d.mts.map +1 -0
  53. package/dist/opentelemetry.mjs +871 -0
  54. package/dist/opentelemetry.mjs.map +1 -0
  55. package/dist/{registration-drnZk0SY.mjs → registration-Bwe2GbVu.mjs} +8 -2
  56. package/dist/registration-Bwe2GbVu.mjs.map +1 -0
  57. package/dist/runtime/explicit.d.mts +2 -2
  58. package/dist/runtime/explicit.mjs +1 -1
  59. package/dist/runtime/node.d.mts +3 -3
  60. package/dist/runtime/node.mjs +2 -2
  61. package/dist/runtime-qpcVwaz_.mjs +1680 -0
  62. package/dist/runtime-qpcVwaz_.mjs.map +1 -0
  63. package/dist/service-CO9VJQYa.mjs +74 -0
  64. package/dist/service-CO9VJQYa.mjs.map +1 -0
  65. package/dist/signal-5Rg9bUUe.mjs +52 -0
  66. package/dist/signal-5Rg9bUUe.mjs.map +1 -0
  67. package/dist/{standard-services-GBZ32tll.mjs → standard-services-B-iMM_W7.mjs} +39 -19
  68. package/dist/standard-services-B-iMM_W7.mjs.map +1 -0
  69. package/dist/standard-services.d.mts +4 -3
  70. package/dist/standard-services.mjs +3 -2
  71. package/dist/testing.d.mts +25 -6
  72. package/dist/testing.d.mts.map +1 -1
  73. package/dist/testing.mjs +51 -7
  74. package/dist/testing.mjs.map +1 -1
  75. package/dist/types-BFTqCCcw.d.mts +81 -0
  76. package/dist/types-BFTqCCcw.d.mts.map +1 -0
  77. package/dist/web-effect-B9hp9jIe.mjs +380 -0
  78. package/dist/web-effect-B9hp9jIe.mjs.map +1 -0
  79. package/dist/web.d.mts +56 -0
  80. package/dist/web.d.mts.map +1 -0
  81. package/dist/web.mjs +2 -0
  82. package/package.json +36 -11
  83. package/dist/context-BUEf1qjL.mjs.map +0 -1
  84. package/dist/effect-CK4YZaX0.mjs.map +0 -1
  85. package/dist/errors-BKcsQ0ip.d.mts.map +0 -1
  86. package/dist/index-B1nH4luq.d.mts.map +0 -1
  87. package/dist/index-BMdU_Z72.d.mts.map +0 -1
  88. package/dist/index-GYJ4qm9K.d.mts.map +0 -1
  89. package/dist/index-heuaRmXR.d.mts +0 -374
  90. package/dist/index-heuaRmXR.d.mts.map +0 -1
  91. package/dist/layer-D56fRdLt.mjs +0 -269
  92. package/dist/layer-D56fRdLt.mjs.map +0 -1
  93. package/dist/outcome-CB43bnFW.d.mts.map +0 -1
  94. package/dist/program-metadata-DhQCCirO.mjs +0 -260
  95. package/dist/program-metadata-DhQCCirO.mjs.map +0 -1
  96. package/dist/registration-drnZk0SY.mjs.map +0 -1
  97. package/dist/runtime-CBMrX8Wl.mjs +0 -776
  98. package/dist/runtime-CBMrX8Wl.mjs.map +0 -1
  99. package/dist/signal-D2UTcaaG.mjs +0 -105
  100. package/dist/signal-D2UTcaaG.mjs.map +0 -1
  101. package/dist/standard-services-GBZ32tll.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opentelemetry.mjs","names":["readMonotonicTime","eventName","callSpan","finishSpan","callSpan","boundedDuration"],"sources":["../src/opentelemetry/lifecycle.ts","../src/opentelemetry/shutdown.ts","../src/opentelemetry/index.ts"],"sourcesContent":["import { SpanStatusCode, type AttributeValue, type Context, type Span } from '@opentelemetry/api'\n\nimport type {\n RuntimeLifecycleEndEvent,\n RuntimeLifecycleEventMetadata,\n RuntimeLifecycleReleaseEvent,\n RuntimeLifecycleStartEvent\n} from '../runtime/observer'\n\n/** Controls how lifecycle-only Layer entries are represented in telemetry. */\nexport type LifecycleTelemetryMode = 'off' | 'events' | 'spans'\n\nexport type LifecyclePhase = 'activate' | 'release'\n\ntype AttributeMap = Record<string, AttributeValue>\n\ntype FailureDetails = {\n readonly message?: string\n readonly attributes: AttributeMap\n}\n\nexport type LifecycleTelemetryOptions = {\n readonly mode: LifecycleTelemetryMode\n readonly recordFailures: boolean\n readonly getParentContext: () => Context\n readonly startSpan: (\n name: string,\n attributes: AttributeMap,\n parentContext: Context | undefined\n ) => Span | undefined\n readonly makeAttributes: (\n event: RuntimeLifecycleEventMetadata,\n phase: LifecyclePhase,\n outcome: 'success' | 'failure' | undefined,\n durationMs: number | undefined\n ) => AttributeMap\n readonly getFailureDetails: (cause: unknown) => FailureDetails | undefined\n}\n\ntype LifecycleState = {\n readonly lifecycleId: symbol\n readonly startedAt: number\n readonly parentContext: Context\n starting: boolean\n carrier: Span | undefined\n activationSpan: Span | undefined\n activationEnded: boolean\n activationReported: boolean\n pendingActivationEnd: RuntimeLifecycleEndEvent | undefined\n}\n\nconst readMonotonicTime = (): number => {\n try {\n return performance.now()\n } catch {\n return Date.now()\n }\n}\n\nconst eventName = (phase: LifecyclePhase): string => `better-effect.lifecycle.${phase}`\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters, anti-slop/no-unknown-returns -- Optional tracer methods are an opaque host boundary.\nconst callSpan = (operation: () => unknown): void => {\n try {\n void Promise.resolve(operation()).catch(() => {})\n } catch {\n // Optional tracer boundaries must not affect Runtime control flow.\n }\n}\n\nconst finishSpan = (\n span: Span,\n status: 'success' | 'failure',\n details: FailureDetails | undefined\n): void => {\n callSpan(() =>\n span.setStatus({\n code: status === 'failure' ? SpanStatusCode.ERROR : SpanStatusCode.OK\n })\n )\n\n if (details !== undefined) {\n const message = details.message\n\n if (message !== undefined) {\n callSpan(() => span.recordException(message))\n }\n\n if (Object.keys(details.attributes).length > 0) {\n callSpan(() => span.addEvent('better-effect.failure', details.attributes))\n }\n }\n\n callSpan(() => span.end())\n}\n\ntype FailureCause = Parameters<LifecycleTelemetryOptions['getFailureDetails']>[0]\n\nconst failureCause = (\n event: RuntimeLifecycleEndEvent | RuntimeLifecycleReleaseEvent\n): FailureCause => {\n if (event.error !== undefined) {\n return event.error\n }\n\n return event.outcome.status === 'failure' ? event.outcome.cause : undefined\n}\n\nconst eventStatus = (\n event: RuntimeLifecycleEndEvent | RuntimeLifecycleReleaseEvent\n): 'success' | 'failure' =>\n 'error' in event && event.error !== undefined ? 'failure' : event.outcome.status\n\n/** Internal lifecycle state machine for the OpenTelemetry Runtime observer. */\nexport class LifecycleTelemetry {\n private readonly states = new Map<symbol, LifecycleState>()\n\n private disposed = false\n\n constructor(private readonly options: LifecycleTelemetryOptions) {}\n\n onStart(event: RuntimeLifecycleStartEvent): void {\n if (this.disposed || this.options.mode === 'off' || this.states.has(event.lifecycleId)) {\n return\n }\n\n const state: LifecycleState = {\n lifecycleId: event.lifecycleId,\n startedAt: readMonotonicTime(),\n parentContext: this.options.getParentContext(),\n starting: true,\n carrier: undefined,\n activationSpan: undefined,\n activationEnded: false,\n activationReported: false,\n pendingActivationEnd: undefined\n }\n this.states.set(event.lifecycleId, state)\n\n const span = this.options.startSpan(\n this.options.mode === 'events' ? 'better-effect.lifecycle' : eventName('activate'),\n this.options.makeAttributes(event, 'activate', undefined, undefined),\n state.parentContext\n )\n\n if (!this.states.has(event.lifecycleId)) {\n if (span !== undefined) {\n callSpan(() => span.end())\n }\n\n return\n }\n\n state.starting = false\n\n if (this.options.mode === 'events') {\n state.carrier = span\n\n if (span !== undefined) {\n callSpan(() =>\n span.addEvent(\n eventName('activate'),\n this.options.makeAttributes(event, 'activate', undefined, undefined)\n )\n )\n }\n } else {\n state.activationSpan = span\n }\n\n const pendingEnd = state.pendingActivationEnd\n\n if (pendingEnd !== undefined) {\n state.pendingActivationEnd = undefined\n this.onEnd(pendingEnd)\n }\n }\n\n onEnd(event: RuntimeLifecycleEndEvent): void {\n if (this.options.mode === 'off') {\n return\n }\n\n const state = this.states.get(event.lifecycleId)\n\n if (state === undefined || state.activationReported) {\n return\n }\n\n const durationMs = Math.max(0, readMonotonicTime() - state.startedAt)\n const status = eventStatus(event)\n\n if (this.options.mode === 'events') {\n const span = state.carrier\n\n if (span === undefined) {\n if (state.starting) {\n state.pendingActivationEnd = event\n return\n }\n\n state.activationReported = true\n\n if (status === 'failure') {\n this.states.delete(event.lifecycleId)\n }\n\n return\n }\n\n state.activationReported = true\n state.activationEnded = true\n\n if (status === 'failure') {\n this.states.delete(event.lifecycleId)\n }\n\n callSpan(() =>\n span.addEvent(\n eventName('activate'),\n this.options.makeAttributes(event, 'activate', status, durationMs)\n )\n )\n\n if (status === 'failure' && this.options.recordFailures) {\n const details = this.options.getFailureDetails(failureCause(event))\n\n if (details !== undefined) {\n finishDetails(span, details)\n }\n }\n\n if (status === 'failure') {\n callSpan(() => span.setStatus({ code: SpanStatusCode.ERROR }))\n callSpan(() => span.end())\n }\n\n return\n }\n\n const span = state.activationSpan\n\n if (span === undefined) {\n if (state.starting) {\n state.pendingActivationEnd = event\n return\n }\n\n state.activationReported = true\n\n if (status === 'failure') {\n this.states.delete(event.lifecycleId)\n }\n\n return\n }\n\n state.activationReported = true\n\n if (status === 'failure') {\n this.states.delete(event.lifecycleId)\n }\n\n state.activationEnded = true\n finishSpan(\n span,\n status,\n status === 'failure' && this.options.recordFailures\n ? this.options.getFailureDetails(failureCause(event))\n : undefined\n )\n }\n\n onRelease(event: RuntimeLifecycleReleaseEvent): void {\n if (this.options.mode === 'off') {\n return\n }\n\n const state = this.states.get(event.lifecycleId)\n\n if (state === undefined) {\n return\n }\n\n this.states.delete(event.lifecycleId)\n const status = eventStatus(event)\n const attributes = this.options.makeAttributes(event, 'release', status, undefined)\n const details =\n status === 'failure' && this.options.recordFailures\n ? this.options.getFailureDetails(failureCause(event))\n : undefined\n\n if (this.options.mode === 'events') {\n if (state.carrier === undefined) {\n return\n }\n\n callSpan(() => state.carrier!.addEvent(eventName('release'), attributes))\n\n if (details !== undefined) {\n finishDetails(state.carrier, details)\n }\n\n finishSpan(state.carrier, status, undefined)\n return\n }\n\n const span = this.options.startSpan(eventName('release'), attributes, state.parentContext)\n\n if (span !== undefined) {\n finishSpan(span, status, details)\n }\n }\n\n dispose(): void {\n if (this.disposed) {\n return\n }\n\n this.disposed = true\n const pending = [...this.states.values()]\n this.states.clear()\n\n for (const state of pending) {\n if (state.carrier !== undefined) {\n callSpan(() => state.carrier!.end())\n }\n\n if (state.activationSpan !== undefined && !state.activationEnded) {\n callSpan(() => state.activationSpan!.end())\n }\n }\n }\n}\n\nconst finishDetails = (span: Span, details: FailureDetails): void => {\n const message = details.message\n\n if (message !== undefined) {\n callSpan(() => span.recordException(message))\n }\n\n if (Object.keys(details.attributes).length > 0) {\n callSpan(() => span.addEvent('better-effect.failure', details.attributes))\n }\n}\n","import {\n SpanStatusCode,\n trace,\n type AttributeValue,\n type Context,\n type Span\n} from '@opentelemetry/api'\n\nimport type { RuntimeShutdownEvent } from '../runtime/observer'\nimport type { RuntimeShutdownReason } from '../runtime/outcome'\n\n/** Controls how Runtime shutdown phases are represented in telemetry. */\nexport type ShutdownTelemetryMode = 'off' | 'events' | 'spans'\n\nexport type ShutdownPhase = 'requested' | 'quiesce' | 'drain' | 'abort' | 'release' | 'complete'\n\ntype AttributeMap = Record<string, AttributeValue>\n\ntype FailureDetails = {\n readonly message?: string\n readonly attributes: AttributeMap\n}\n\nexport type ShutdownTelemetryOptions = {\n readonly mode: ShutdownTelemetryMode\n readonly recordFailures: boolean\n readonly rootContext: Context\n readonly startSpan: (\n name: string,\n attributes: AttributeMap,\n parentContext: Context | undefined\n ) => Span | undefined\n readonly makeAttributes: (\n event: RuntimeShutdownEvent,\n phase: ShutdownPhase,\n durationMs: number | undefined\n ) => AttributeMap\n readonly getFailureDetails: (cause: unknown) => FailureDetails | undefined\n}\n\ntype ShutdownState = {\n readonly reason: RuntimeShutdownReason\n starting: boolean\n span: Span | undefined\n readonly phaseSpans: Map<ShutdownPhase, Span>\n readonly phaseStartedAt: Map<ShutdownPhase, number>\n readonly pendingPhaseEnds: Map<ShutdownPhase, RuntimeShutdownEvent>\n readonly pendingEvents: RuntimeShutdownEvent[]\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters, anti-slop/no-unknown-returns -- Optional tracer methods are an opaque host boundary.\nconst callSpan = (operation: () => unknown): void => {\n try {\n void Promise.resolve(operation()).catch(() => {})\n } catch {\n // Optional tracer boundaries must not affect Runtime control flow.\n }\n}\n\nconst readMonotonicTime = (): number => {\n try {\n return performance.now()\n } catch {\n return Date.now()\n }\n}\n\nconst boundedDuration = (value: number | undefined): number | undefined =>\n value !== undefined && Number.isFinite(value) && value >= 0\n ? Math.min(value, 2 ** 31 - 1)\n : undefined\n\nconst phaseOf = (phase: RuntimeShutdownEvent['phase']): ShutdownPhase => {\n switch (phase) {\n case 'shutdown-requested':\n return 'requested'\n case 'quiesce-start':\n case 'quiesce-end':\n return 'quiesce'\n case 'drain-start':\n case 'drain-end':\n return 'drain'\n case 'abort-active':\n return 'abort'\n case 'release-start':\n case 'release-end':\n return 'release'\n case 'shutdown-complete':\n case 'shutdown-failure':\n return 'complete'\n }\n}\n\nconst eventName = (phase: ShutdownPhase): string => `better-effect.shutdown.${phase}`\n\nconst isStart = (phase: RuntimeShutdownEvent['phase']): boolean =>\n phase === 'quiesce-start' || phase === 'drain-start' || phase === 'release-start'\n\nconst isEnd = (phase: RuntimeShutdownEvent['phase']): boolean =>\n phase === 'quiesce-end' || phase === 'drain-end' || phase === 'release-end'\n\nconst isTerminal = (phase: RuntimeShutdownEvent['phase']): boolean =>\n phase === 'shutdown-complete' || phase === 'shutdown-failure'\n\nconst finishSpan = (\n span: Span,\n status: 'success' | 'failure',\n details: FailureDetails | undefined\n): void => {\n callSpan(() =>\n span.setStatus({\n code: status === 'failure' ? SpanStatusCode.ERROR : SpanStatusCode.OK\n })\n )\n\n if (details !== undefined) {\n const message = details.message\n\n if (message !== undefined) {\n callSpan(() => span.recordException(message))\n }\n\n if (Object.keys(details.attributes).length > 0) {\n callSpan(() => span.addEvent('better-effect.failure', details.attributes))\n }\n }\n\n callSpan(() => span.end())\n}\n\n/** Internal shutdown state machine for the OpenTelemetry Runtime observer. */\nexport class ShutdownTelemetry {\n private readonly states = new Map<RuntimeShutdownReason, ShutdownState>()\n\n private disposed = false\n\n constructor(private readonly options: ShutdownTelemetryOptions) {}\n\n onEvent(event: RuntimeShutdownEvent): void {\n if (this.disposed || this.options.mode === 'off') {\n return\n }\n\n if (event.phase === 'shutdown-requested') {\n this.start(event)\n return\n }\n\n const state = this.states.get(event.reason)\n\n if (state === undefined) {\n return\n }\n\n if (state.span === undefined && state.starting) {\n state.pendingEvents.push(event)\n return\n }\n\n if (state.span === undefined && isTerminal(event.phase)) {\n this.states.delete(event.reason)\n state.pendingEvents.length = 0\n return\n }\n\n if (state.span !== undefined) {\n this.process(state, event)\n }\n }\n\n private start(event: RuntimeShutdownEvent): void {\n if (this.states.has(event.reason)) {\n return\n }\n\n const state: ShutdownState = {\n reason: event.reason,\n starting: true,\n span: undefined,\n phaseSpans: new Map(),\n phaseStartedAt: new Map(),\n pendingPhaseEnds: new Map(),\n pendingEvents: []\n }\n this.states.set(event.reason, state)\n\n const span = this.options.startSpan(\n 'better-effect.shutdown',\n this.options.makeAttributes(event, 'requested', undefined),\n this.options.rootContext\n )\n\n if (!this.states.has(event.reason)) {\n if (span !== undefined) {\n callSpan(() => span.end())\n }\n\n return\n }\n\n state.starting = false\n state.span = span\n\n if (span !== undefined) {\n this.addEvent(state, event)\n }\n\n const pendingEvents = state.pendingEvents.splice(0)\n\n for (const pendingEvent of pendingEvents) {\n this.process(state, pendingEvent)\n }\n }\n\n private process(state: ShutdownState, event: RuntimeShutdownEvent): void {\n const phase = phaseOf(event.phase)\n\n if (isStart(event.phase)) {\n this.startPhase(state, event, phase)\n return\n }\n\n if (isEnd(event.phase)) {\n if (!state.phaseStartedAt.has(phase)) {\n return\n }\n\n if (this.options.mode === 'spans' && !state.phaseSpans.has(phase)) {\n state.pendingPhaseEnds.set(phase, event)\n return\n }\n\n this.finishPhase(state, event, phase)\n return\n }\n\n if (event.phase === 'abort-active') {\n if (state.phaseStartedAt.has('abort')) {\n return\n }\n\n state.phaseStartedAt.set('abort', readMonotonicTime())\n\n if (this.options.mode === 'events') {\n this.addEvent(state, event)\n state.phaseStartedAt.delete('abort')\n } else {\n const span = this.startPhaseSpan(state, event, 'abort')\n\n if (span !== undefined) {\n state.phaseStartedAt.delete('abort')\n finishSpan(span, 'success', undefined)\n }\n }\n\n return\n }\n\n if (isTerminal(event.phase)) {\n this.finish(state, event)\n }\n }\n\n private startPhase(\n state: ShutdownState,\n event: RuntimeShutdownEvent,\n phase: ShutdownPhase\n ): void {\n if (state.phaseStartedAt.has(phase)) {\n return\n }\n\n state.phaseStartedAt.set(phase, readMonotonicTime())\n\n if (this.options.mode === 'events') {\n this.addEvent(state, event)\n return\n }\n\n const span = this.startPhaseSpan(state, event, phase)\n\n if (!this.states.has(state.reason)) {\n if (span !== undefined) {\n callSpan(() => span.end())\n }\n\n return\n }\n\n if (span !== undefined) {\n state.phaseSpans.set(phase, span)\n const pendingEnd = state.pendingPhaseEnds.get(phase)\n\n if (pendingEnd !== undefined) {\n state.pendingPhaseEnds.delete(phase)\n this.finishPhase(state, pendingEnd, phase)\n }\n }\n }\n\n private startPhaseSpan(\n state: ShutdownState,\n event: RuntimeShutdownEvent,\n phase: ShutdownPhase\n ): Span | undefined {\n let parent = this.options.rootContext\n\n if (state.span !== undefined) {\n try {\n parent = trace.setSpan(this.options.rootContext, state.span)\n } catch {\n parent = this.options.rootContext\n }\n }\n\n return this.options.startSpan(\n eventName(phase),\n this.options.makeAttributes(event, phase, undefined),\n parent\n )\n }\n\n private addEvent(\n state: ShutdownState,\n event: RuntimeShutdownEvent,\n durationMsOverride?: number\n ): void {\n const span = state.span\n\n if (span === undefined) {\n return\n }\n\n const phase = phaseOf(event.phase)\n const startedAt = state.phaseStartedAt.get(phase)\n const durationMs =\n durationMsOverride ??\n (startedAt === undefined ? undefined : Math.max(0, readMonotonicTime() - startedAt))\n callSpan(() =>\n span.addEvent(eventName(phase), this.options.makeAttributes(event, phase, durationMs))\n )\n }\n\n private finishPhase(\n state: ShutdownState,\n event: RuntimeShutdownEvent,\n phase: ShutdownPhase\n ): void {\n const span = state.phaseSpans.get(phase)\n const startedAt = state.phaseStartedAt.get(phase)\n const durationMs =\n startedAt === undefined ? event.durationMs : Math.max(0, readMonotonicTime() - startedAt)\n state.phaseSpans.delete(phase)\n state.phaseStartedAt.delete(phase)\n state.pendingPhaseEnds.delete(phase)\n\n if (this.options.mode === 'events') {\n this.addEvent(state, event, durationMs)\n return\n }\n\n if (span !== undefined) {\n callSpan(() =>\n span.setAttribute('better_effect.duration_ms', boundedDuration(durationMs) ?? 0)\n )\n finishSpan(span, 'success', undefined)\n }\n }\n\n private finish(state: ShutdownState, event: RuntimeShutdownEvent): void {\n if (this.states.get(state.reason) !== state) {\n return\n }\n\n // Claim the Runtime shutdown before invoking tracer code.\n this.states.delete(state.reason)\n const status = event.phase === 'shutdown-failure' ? 'failure' : 'success'\n const details =\n status === 'failure' && this.options.recordFailures\n ? this.options.getFailureDetails(event.error)\n : undefined\n\n for (const span of state.phaseSpans.values()) {\n callSpan(() => span.end())\n }\n state.phaseSpans.clear()\n state.phaseStartedAt.clear()\n state.pendingPhaseEnds.clear()\n state.pendingEvents.length = 0\n\n if (state.span === undefined) {\n return\n }\n\n this.addEvent(state, event)\n finishSpan(state.span, status, details)\n }\n\n dispose(): void {\n if (this.disposed) {\n return\n }\n\n this.disposed = true\n const pending = [...this.states.values()]\n this.states.clear()\n\n for (const state of pending) {\n for (const span of state.phaseSpans.values()) {\n callSpan(() => span.end())\n }\n\n if (state.span !== undefined) {\n callSpan(() => state.span!.end())\n }\n }\n }\n}\n","import {\n context,\n ROOT_CONTEXT,\n SpanStatusCode,\n trace,\n type AttributeValue,\n type Context,\n type Span,\n type Tracer,\n type TracerProvider\n} from '@opentelemetry/api'\n\nimport type {\n RuntimeExecutionAttributes,\n RuntimeExecutionEndEvent,\n RuntimeExecutionStartEvent,\n RuntimeLifecycleEndEvent,\n RuntimeLifecycleEventMetadata,\n RuntimeLifecycleReleaseEvent,\n RuntimeLifecycleStartEvent,\n RuntimeObserver,\n RuntimeResourceReleaseEvent,\n RuntimeShutdownEvent,\n RuntimeServiceAcquireEvent,\n RuntimeServiceResolveEvent\n} from '../runtime/observer'\n\nimport { LifecycleTelemetry, type LifecyclePhase, type LifecycleTelemetryMode } from './lifecycle'\nimport { ShutdownTelemetry, type ShutdownPhase, type ShutdownTelemetryMode } from './shutdown'\n\nexport type { LifecycleTelemetryMode } from './lifecycle'\nexport type { ShutdownTelemetryMode } from './shutdown'\n\n/** Controls how Service lifecycle events are represented in telemetry. */\nexport type ServiceTelemetryMode = 'off' | 'events' | 'spans'\n\n/** Attribute values accepted by the OpenTelemetry adapter. */\nexport type OpenTelemetryAttributes = Readonly<Record<string, AttributeValue>>\n\n/** A deliberately small, already-sanitized failure representation. */\nexport type OpenTelemetryFailure =\n | string\n | {\n readonly message?: string\n readonly attributes?: OpenTelemetryAttributes\n }\n\n/** Select safe execution attributes explicitly before they reach a span. */\nexport type OpenTelemetryExecutionAttributesSanitizer = (\n attributes: RuntimeExecutionAttributes\n) => OpenTelemetryAttributes | undefined\n\n/** Select safe failure details explicitly before they reach a span. */\nexport type OpenTelemetryFailureSanitizer = (cause: unknown) => OpenTelemetryFailure | undefined\n\ntype OpenTelemetryRuntimeObserverBaseOptions = {\n /** Use an existing tracer. The adapter never registers a global provider. */\n readonly tracer?: Tracer\n /** Resolve a tracer from an existing provider without registering it globally. */\n readonly provider?: TracerProvider\n /** Tracer name used only when `provider` is supplied. */\n readonly tracerName?: string\n /** Optional instrumentation version used only when `provider` is supplied. */\n readonly tracerVersion?: string\n /** Service resolution policy. Defaults to `off`. */\n readonly serviceResolution?: ServiceTelemetryMode\n /** Lifecycle-only Layer entry policy. Defaults to `off`. */\n readonly lifecycle?: LifecycleTelemetryMode\n /** Runtime shutdown policy. Defaults to `off`. */\n readonly shutdown?: ShutdownTelemetryMode\n /** Record explicitly sanitized failure details in addition to setting status. */\n readonly recordFailures?: boolean\n /** Explicitly sanitize arbitrary execution attributes. */\n readonly sanitizeExecutionAttributes?: OpenTelemetryExecutionAttributesSanitizer\n /** Copy only these execution attribute keys, dropping unsupported values. */\n readonly executionAttributeAllowlist?: readonly string[]\n /** Explicitly sanitize a failure before recording it. */\n readonly sanitizeFailure?: OpenTelemetryFailureSanitizer\n /** Maximum length for attribute keys and string values. Defaults to 256. */\n readonly maxAttributeLength?: number\n /** Maximum number of copied execution or failure attributes. Defaults to 32. */\n readonly maxAttributeCount?: number\n /** Maximum number of Service tags retained in a resolution path. Defaults to 16. */\n readonly maxResolutionPathLength?: number\n}\n\n/** Configuration for an observer backed by an existing OpenTelemetry tracer/provider. */\nexport type OpenTelemetryRuntimeObserverOptions =\n | (OpenTelemetryRuntimeObserverBaseOptions & {\n readonly tracer: Tracer\n readonly provider?: never\n })\n | (OpenTelemetryRuntimeObserverBaseOptions & {\n readonly provider: TracerProvider\n readonly tracer?: never\n })\n\nconst DEFAULT_TRACER_NAME = 'better-effect'\nconst DEFAULT_EXECUTION_SPAN_NAME = 'better-effect.execution'\nconst DEFAULT_SERVICE_SPAN_NAME = 'better-effect.service'\nconst DEFAULT_MAX_ATTRIBUTE_LENGTH = 256\nconst DEFAULT_MAX_ATTRIBUTE_COUNT = 32\nconst DEFAULT_MAX_RESOLUTION_PATH_LENGTH = 16\nconst MAX_ATTRIBUTE_LENGTH = 4096\nconst MAX_ATTRIBUTE_COUNT = 128\nconst MAX_RESOLUTION_PATH_LENGTH = 128\nconst MAX_ARRAY_LENGTH = 16\n\nconst EXECUTION_ID_ATTRIBUTE = 'better_effect.execution_id'\nconst PROGRAM_NAME_ATTRIBUTE = 'better_effect.program_name'\nconst OUTCOME_ATTRIBUTE = 'better_effect.outcome'\nconst SERVICE_TAG_ATTRIBUTE = 'better_effect.service_tag'\nconst RESOLUTION_PATH_ATTRIBUTE = 'better_effect.resolution_path'\nconst RESOLUTION_PATH_TRUNCATED_ATTRIBUTE = 'better_effect.resolution_path_truncated'\nconst LIBRARY_ATTRIBUTE = 'better_effect.library'\nconst LIFECYCLE_NAME_ATTRIBUTE = 'better_effect.lifecycle_name'\nconst LIFECYCLE_PHASE_ATTRIBUTE = 'better_effect.lifecycle_phase'\nconst SHUTDOWN_PHASE_ATTRIBUTE = 'better_effect.shutdown_phase'\nconst SHUTDOWN_REASON_ATTRIBUTE = 'better_effect.shutdown_reason'\nconst SHUTDOWN_SIGNAL_ATTRIBUTE = 'better_effect.shutdown_signal'\nconst DURATION_ATTRIBUTE = 'better_effect.duration_ms'\nconst FAILURE_EVENT_NAME = 'better-effect.failure'\n\ntype AttributeMap = Record<string, AttributeValue>\n\ntype Limits = {\n readonly maxAttributeLength: number\n readonly maxAttributeCount: number\n readonly maxResolutionPathLength: number\n}\n\ntype FailureDetails = {\n message?: string\n readonly attributes: AttributeMap\n}\n\ntype ExecutionSpan = {\n readonly executionId: string\n span?: Span\n executionContext?: Context\n pendingEnd?: RuntimeExecutionEndEvent\n ended: boolean\n}\n\ntype StartedExecutionSpan = ExecutionSpan & {\n readonly span: Span\n}\n\ntype ActiveExecutionSpan = StartedExecutionSpan & {\n readonly executionContext: Context\n}\n\ntype ServiceEvent =\n | RuntimeServiceResolveEvent\n | RuntimeServiceAcquireEvent\n | RuntimeResourceReleaseEvent\n\ntype ServiceEventStatus = 'success' | 'failure'\n\ntype ExecutionEventStatus = 'success' | 'failure'\n\nconst serviceEventStatus = (event: ServiceEvent): ServiceEventStatus =>\n 'error' in event && event.error !== undefined ? 'failure' : event.outcome.status\n\nconst executionEventStatus = (event: RuntimeExecutionEndEvent): ExecutionEventStatus =>\n event.cleanupFailure !== undefined ? 'failure' : event.outcome.status\n\nconst isStartedExecutionSpan = (execution: ExecutionSpan): execution is StartedExecutionSpan =>\n execution.span !== undefined\n\nconst isActiveExecutionSpan = (execution: ExecutionSpan): execution is ActiveExecutionSpan =>\n isStartedExecutionSpan(execution) && execution.executionContext !== undefined\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Validate JavaScript callers at the optional adapter boundary.\nconst isTelemetryMode = (value: unknown): value is ServiceTelemetryMode =>\n value === 'off' || value === 'events' || value === 'spans'\n\nconst boundedDuration = (value: number | undefined): number | undefined =>\n value !== undefined && Number.isFinite(value) && value >= 0\n ? Math.min(value, 2 ** 31 - 1)\n : undefined\n\nconst addOutcomeAttribute = (\n attributes: AttributeMap,\n outcome: 'success' | 'failure' | undefined,\n limit: number\n): void => {\n if (outcome !== undefined) {\n addAttribute(attributes, OUTCOME_ATTRIBUTE, outcome, limit)\n }\n}\n\nconst addDurationAttribute = (\n attributes: AttributeMap,\n durationMs: number | undefined,\n limit: number\n): void => {\n const duration = boundedDuration(durationMs)\n\n if (duration !== undefined) {\n addAttribute(attributes, DURATION_ATTRIBUTE, duration, limit)\n }\n}\n\nconst makeLifecycleAttributes = (\n event: RuntimeLifecycleEventMetadata,\n phase: LifecyclePhase,\n outcome: 'success' | 'failure' | undefined,\n durationMs: number | undefined,\n limits: Limits\n): AttributeMap => {\n const attributes: AttributeMap = {}\n const name = boundedNonEmptyString(event.name, limits.maxAttributeLength)\n\n if (name !== undefined) {\n addAttribute(attributes, LIFECYCLE_NAME_ATTRIBUTE, name, limits.maxAttributeCount)\n }\n\n addAttribute(attributes, LIFECYCLE_PHASE_ATTRIBUTE, phase, limits.maxAttributeCount)\n addOutcomeAttribute(attributes, outcome, limits.maxAttributeCount)\n addDurationAttribute(attributes, durationMs, limits.maxAttributeCount)\n\n // oxlint-disable-next-line anti-slop/no-known-value-widening -- Return the private validated OTel attribute owner.\n return attributes\n}\n\nconst makeShutdownAttributes = (\n event: RuntimeShutdownEvent,\n phase: ShutdownPhase,\n durationMs: number | undefined,\n limits: Limits\n): AttributeMap => {\n const attributes: AttributeMap = {}\n const reason = event.reason\n\n addAttribute(attributes, SHUTDOWN_PHASE_ATTRIBUTE, phase, limits.maxAttributeCount)\n addAttribute(attributes, SHUTDOWN_REASON_ATTRIBUTE, reason.kind, limits.maxAttributeCount)\n\n if (reason.signal === 'SIGINT' || reason.signal === 'SIGTERM') {\n addAttribute(attributes, SHUTDOWN_SIGNAL_ATTRIBUTE, reason.signal, limits.maxAttributeCount)\n }\n\n if (event.activeExecutions !== undefined && Number.isSafeInteger(event.activeExecutions)) {\n addAttribute(\n attributes,\n 'better_effect.active_executions',\n Math.max(0, event.activeExecutions),\n limits.maxAttributeCount\n )\n }\n\n addDurationAttribute(attributes, durationMs ?? event.durationMs, limits.maxAttributeCount)\n\n if (event.phase === 'shutdown-complete') {\n addOutcomeAttribute(attributes, 'success', limits.maxAttributeCount)\n } else if (event.phase === 'shutdown-failure') {\n addOutcomeAttribute(attributes, 'failure', limits.maxAttributeCount)\n }\n\n // oxlint-disable-next-line anti-slop/no-known-value-widening -- Return the private validated OTel attribute owner.\n return attributes\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters, anti-slop/no-unsafe-dictionary-type -- This private guard validates untrusted values before scalar validation.\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- Validate the external value before reading it.\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- OTel is an optional runtime peer and must be checked defensively.\nconst isSpan = (value: unknown): value is Span =>\n isRecord(value) &&\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- OTel is an optional runtime peer and must be checked defensively.\n typeof value.end === 'function'\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- OTel is an optional runtime peer and must be checked defensively.\nconst isTracer = (value: unknown): value is Tracer =>\n isRecord(value) &&\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- OTel is an optional runtime peer and must be checked defensively.\n typeof value.startSpan === 'function'\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Sanitizers and observer events are external diagnostic boundaries.\nconst boundedString = (value: unknown, limit: number): string | undefined =>\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- Only primitive strings are copied into OTel attributes.\n typeof value === 'string' ? value.slice(0, limit) : undefined\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Event names and Service tags are validated at this boundary.\nconst boundedNonEmptyString = (value: unknown, limit: number): string | undefined => {\n const text = boundedString(value, limit)\n return text === undefined || text.length === 0 ? undefined : text\n}\n\nconst normalizeLimit = (\n value: number | undefined,\n fallback: number,\n maximum: number,\n name: string\n): number => {\n if (value === undefined) {\n return fallback\n }\n\n if (!Number.isSafeInteger(value) || value < 1 || value > maximum) {\n throw new RangeError(`${name} must be an integer between 1 and ${maximum}`)\n }\n\n return value\n}\n\nconst normalizeLimits = (options: OpenTelemetryRuntimeObserverBaseOptions): Limits => ({\n maxAttributeLength: normalizeLimit(\n options.maxAttributeLength,\n DEFAULT_MAX_ATTRIBUTE_LENGTH,\n MAX_ATTRIBUTE_LENGTH,\n 'maxAttributeLength'\n ),\n maxAttributeCount: normalizeLimit(\n options.maxAttributeCount,\n DEFAULT_MAX_ATTRIBUTE_COUNT,\n MAX_ATTRIBUTE_COUNT,\n 'maxAttributeCount'\n ),\n maxResolutionPathLength: normalizeLimit(\n options.maxResolutionPathLength,\n DEFAULT_MAX_RESOLUTION_PATH_LENGTH,\n MAX_RESOLUTION_PATH_LENGTH,\n 'maxResolutionPathLength'\n )\n})\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Normalize callback output before it reaches the OTel API.\nconst normalizeStringArray = (values: readonly unknown[], limit: number): string[] | undefined => {\n const normalized: string[] = []\n const length = Math.min(values.length, MAX_ARRAY_LENGTH)\n\n for (let index = 0; index < length; index += 1) {\n const value = values[index]\n\n if (value === undefined || value === null) {\n continue\n }\n\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- Accept only OTel string-array values.\n if (typeof value !== 'string') {\n return undefined\n }\n\n normalized.push(value.slice(0, limit))\n }\n\n return normalized\n}\n\nconst normalizeNumberArray = (values: readonly unknown[]): number[] | undefined => {\n const normalized: number[] = []\n const length = Math.min(values.length, MAX_ARRAY_LENGTH)\n normalized.length = length\n\n for (let index = 0; index < length; index += 1) {\n if (!(index in values)) {\n continue\n }\n\n const value = values[index]\n\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- Accept only finite OTel number-array values.\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n return undefined\n }\n\n normalized[index] = value\n }\n\n return normalized\n}\n\nconst normalizeBooleanArray = (values: readonly unknown[]): boolean[] | undefined => {\n const normalized: boolean[] = []\n const length = Math.min(values.length, MAX_ARRAY_LENGTH)\n normalized.length = length\n\n for (let index = 0; index < length; index += 1) {\n if (!(index in values)) {\n continue\n }\n\n const value = values[index]\n\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- Accept only OTel boolean-array values.\n if (typeof value !== 'boolean') {\n return undefined\n }\n\n normalized[index] = value\n }\n\n return normalized\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Normalize explicit sanitizer and allowlist output.\nconst normalizeAttributeValue = (\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Normalize explicit sanitizer and allowlist output.\n value: unknown,\n maxAttributeLength: number\n): AttributeValue | undefined => {\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- Copy only OTel scalar strings.\n if (typeof value === 'string') {\n return value.slice(0, maxAttributeLength)\n }\n\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- Copy only finite OTel scalar numbers.\n if (typeof value === 'number') {\n return Number.isFinite(value) ? value : undefined\n }\n\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- Copy only OTel scalar booleans.\n if (typeof value === 'boolean') {\n return value\n }\n\n if (!Array.isArray(value) || value.length === 0) {\n return undefined\n }\n\n return (\n normalizeStringArray(value, maxAttributeLength) ??\n normalizeNumberArray(value) ??\n normalizeBooleanArray(value)\n )\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters, anti-slop/no-known-value-widening -- Validate sanitizer output into the private OTel attribute owner.\nconst normalizeAttributes = (value: unknown, limits: Limits): AttributeMap => {\n const result: AttributeMap = {}\n let inspected = 0\n let normalizedCount = 0\n\n if (!isRecord(value)) {\n // oxlint-disable-next-line anti-slop/no-known-value-widening -- Return the private validated OTel attribute owner.\n return result\n }\n\n for (const key in value) {\n if (inspected >= limits.maxAttributeCount) {\n break\n }\n\n inspected += 1\n\n if (!Object.prototype.propertyIsEnumerable.call(value, key)) {\n continue\n }\n\n if (key.length === 0 || key.length > limits.maxAttributeLength) {\n continue\n }\n\n let normalized: AttributeValue | undefined\n\n try {\n normalized = normalizeAttributeValue(value[key], limits.maxAttributeLength)\n } catch {\n continue\n }\n\n if (normalized !== undefined) {\n result[key] = normalized\n normalizedCount += 1\n\n if (normalizedCount >= limits.maxAttributeCount) {\n break\n }\n }\n }\n\n // oxlint-disable-next-line anti-slop/no-known-value-widening -- Return the private validated OTel attribute owner.\n return result\n}\n\nconst selectAllowlistedAttributes = (\n source: RuntimeExecutionAttributes | undefined,\n allowlist: readonly string[] | undefined,\n limits: Limits\n): AttributeMap => {\n if (source === undefined || allowlist === undefined) {\n return {}\n }\n\n // oxlint-disable-next-line anti-slop/no-unsafe-dictionary-type -- Values are parsed immediately by normalizeAttributes.\n const selected: Record<string, unknown> = {}\n const length = Math.min(allowlist.length, limits.maxAttributeCount)\n let selectedCount = 0\n\n for (let index = 0; index < length; index += 1) {\n const key = allowlist[index]\n\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- Reject malformed JavaScript allowlist entries before reading source attributes.\n if (typeof key !== 'string' || key.length === 0 || key.length > limits.maxAttributeLength) {\n continue\n }\n\n try {\n if (!(key in selected)) {\n selectedCount += 1\n }\n\n selected[key] = source[key]\n } catch {\n // A hostile getter is an unusable optional attribute, not a Runtime failure.\n }\n\n if (selectedCount >= limits.maxAttributeCount) {\n break\n }\n }\n\n return normalizeAttributes(selected, limits)\n}\n\nconst makeExecutionAttributes = (\n event: RuntimeExecutionStartEvent,\n options: OpenTelemetryRuntimeObserverBaseOptions,\n limits: Limits\n): AttributeMap => {\n const result = selectAllowlistedAttributes(\n event.attributes,\n options.executionAttributeAllowlist,\n limits\n )\n\n if (event.attributes !== undefined && options.sanitizeExecutionAttributes !== undefined) {\n try {\n const sanitized = options.sanitizeExecutionAttributes(event.attributes)\n ignoreRejection(sanitized)\n Object.assign(result, normalizeAttributes(sanitized, limits))\n } catch {\n // Sanitizers are optional diagnostics and cannot affect execution telemetry.\n }\n }\n\n // oxlint-disable-next-line anti-slop/no-known-value-widening -- Return the private validated OTel attribute owner.\n return result\n}\n\nconst makeFailureDetails = (\n cause: unknown,\n sanitizer: OpenTelemetryFailureSanitizer | undefined,\n limits: Limits\n): FailureDetails | undefined => {\n if (sanitizer === undefined) {\n return undefined\n }\n\n let sanitized: OpenTelemetryFailure | undefined\n\n try {\n sanitized = sanitizer(cause)\n ignoreRejection(sanitized)\n } catch {\n return undefined\n }\n\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- A sanitizer may explicitly return a safe string message.\n if (typeof sanitized === 'string') {\n return {\n message: sanitized.slice(0, limits.maxAttributeLength),\n attributes: {}\n }\n }\n\n if (!isRecord(sanitized)) {\n return undefined\n }\n\n let message: string | undefined\n let attributes: unknown\n\n try {\n message = boundedString(sanitized.message, limits.maxAttributeLength)\n attributes = sanitized.attributes\n } catch {\n return undefined\n }\n\n let normalizedAttributes: AttributeMap\n\n try {\n normalizedAttributes = normalizeAttributes(attributes, limits)\n } catch {\n return undefined\n }\n\n const details: FailureDetails = {\n attributes: normalizedAttributes\n }\n\n if (message !== undefined) {\n details.message = message\n }\n\n return details\n}\n\nconst mergeAdditionalAttributes = (\n target: AttributeMap,\n additional: AttributeMap,\n limit: number\n): void => {\n for (const [key, value] of Object.entries(additional)) {\n if (Object.keys(target).length >= limit) {\n break\n }\n\n if (!(key in target)) {\n target[key] = value\n }\n }\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Suppress rejected thenables from optional tracer and sanitizer boundaries.\nconst ignoreRejection = (value: unknown): void => {\n try {\n void Promise.resolve(value).catch(() => {})\n } catch {\n // A malformed thenable is still outside Runtime control flow.\n }\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-returns -- Optional OTel methods are typed void but hostile implementations may return thenables.\nconst callSpan = (operation: () => unknown): void => {\n try {\n ignoreRejection(operation())\n } catch {\n // A tracer is an optional boundary and must never affect Runtime control flow.\n }\n}\n\nconst addFailureDetails = (span: Span, details: FailureDetails): void => {\n const message = details.message\n\n if (message !== undefined) {\n callSpan(() => span.recordException(message))\n }\n\n if (Object.keys(details.attributes).length > 0) {\n callSpan(() => span.addEvent(FAILURE_EVENT_NAME, details.attributes))\n }\n}\n\nconst addAttribute = (\n target: AttributeMap,\n key: string,\n value: AttributeValue,\n limit: number\n): void => {\n if (key in target || Object.keys(target).length < limit) {\n target[key] = value\n }\n}\n\nconst makeExecutionSpanAttributes = (\n event: RuntimeExecutionStartEvent,\n options: OpenTelemetryRuntimeObserverBaseOptions,\n limits: Limits\n) => {\n const attributes: AttributeMap = {}\n const executionId = boundedNonEmptyString(event.executionId, limits.maxAttributeLength)\n const name = boundedNonEmptyString(event.name, limits.maxAttributeLength)\n\n if (executionId !== undefined) {\n addAttribute(attributes, EXECUTION_ID_ATTRIBUTE, executionId, limits.maxAttributeCount)\n }\n\n if (name !== undefined) {\n addAttribute(attributes, PROGRAM_NAME_ATTRIBUTE, name, limits.maxAttributeCount)\n }\n\n addAttribute(attributes, LIBRARY_ATTRIBUTE, 'better-effect', limits.maxAttributeCount)\n mergeAdditionalAttributes(\n attributes,\n makeExecutionAttributes(event, options, limits),\n limits.maxAttributeCount\n )\n\n return attributes\n}\n\nconst makeResolutionPathAttributes = (\n path: readonly { readonly serviceTag: string }[],\n limits: Limits\n): AttributeMap => {\n const tags: string[] = []\n\n for (const service of path.slice(0, limits.maxResolutionPathLength)) {\n const tag = boundedNonEmptyString(service.serviceTag, limits.maxAttributeLength)\n\n if (tag !== undefined) {\n tags.push(tag)\n }\n }\n\n // oxlint-disable-next-line anti-slop/no-known-value-widening -- This map owns validated Service path attributes.\n const result: AttributeMap = {}\n\n if (tags.length > 0) {\n result[RESOLUTION_PATH_ATTRIBUTE] = tags\n }\n\n if (path.length > limits.maxResolutionPathLength) {\n result[RESOLUTION_PATH_TRUNCATED_ATTRIBUTE] = true\n }\n\n // oxlint-disable-next-line anti-slop/no-known-value-widening -- Return the private validated Service path attribute owner.\n return result\n}\n\nconst makeServiceEventAttributes = (\n event: ServiceEvent,\n limits: Limits,\n executionId: string | undefined\n): AttributeMap => {\n const serviceTag = boundedNonEmptyString(event.service.serviceTag, limits.maxAttributeLength)\n // oxlint-disable-next-line anti-slop/no-known-value-widening -- This map owns validated Service event attributes.\n const attributes: AttributeMap = {}\n\n if (serviceTag !== undefined) {\n addAttribute(attributes, SERVICE_TAG_ATTRIBUTE, serviceTag, limits.maxAttributeCount)\n }\n\n addAttribute(attributes, OUTCOME_ATTRIBUTE, serviceEventStatus(event), limits.maxAttributeCount)\n\n if ('resolutionPath' in event) {\n mergeAdditionalAttributes(\n attributes,\n makeResolutionPathAttributes(event.resolutionPath, limits),\n limits.maxAttributeCount\n )\n }\n\n if (executionId !== undefined) {\n addAttribute(attributes, EXECUTION_ID_ATTRIBUTE, executionId, limits.maxAttributeCount)\n }\n\n // oxlint-disable-next-line anti-slop/no-known-value-widening -- Return the private validated Service event attribute owner.\n return attributes\n}\n\nconst readActiveContext = (): Context | undefined => {\n try {\n return context.active()\n } catch {\n return undefined\n }\n}\n\nconst setSpanInContext = (parent: Context, span: Span): Context | undefined => {\n try {\n return trace.setSpan(parent, span)\n } catch {\n return undefined\n }\n}\n\nconst resolveTracer = (options: OpenTelemetryRuntimeObserverOptions): Tracer => {\n const hasTracer = options.tracer !== undefined\n const hasProvider = options.provider !== undefined\n\n if (hasTracer === hasProvider) {\n throw new TypeError('OpenTelemetryRuntimeObserver requires exactly one tracer or provider')\n }\n\n if (hasTracer) {\n if (!isTracer(options.tracer)) {\n throw new TypeError('OpenTelemetryRuntimeObserver requires a tracer with startSpan')\n }\n\n return options.tracer\n }\n\n if (hasProvider) {\n const tracerName = options.tracerName ?? DEFAULT_TRACER_NAME\n const tracer = options.provider.getTracer(tracerName, options.tracerVersion)\n\n if (!isTracer(tracer)) {\n throw new TypeError('OpenTelemetry provider did not return a tracer with startSpan')\n }\n\n return tracer\n }\n\n throw new TypeError('OpenTelemetryRuntimeObserver requires an existing tracer or provider')\n}\n\n/**\n * Best-effort RuntimeObserver adapter for an existing OpenTelemetry tracer.\n *\n * The adapter never installs a global provider, SDK, context manager, or\n * exporter. All observer hooks are synchronous and isolate tracer failures.\n */\nexport class OpenTelemetryRuntimeObserver implements RuntimeObserver {\n private readonly tracer: Tracer\n\n private readonly options: OpenTelemetryRuntimeObserverBaseOptions\n\n private readonly limits: Limits\n\n private readonly executionSpans = new Map<string, ExecutionSpan>()\n\n private readonly serviceResolution: ServiceTelemetryMode\n\n private readonly lifecycleTelemetry: LifecycleTelemetry\n\n private readonly shutdownTelemetry: ShutdownTelemetry\n\n private readonly recordFailures: boolean\n\n private disposed = false\n\n constructor(options: OpenTelemetryRuntimeObserverOptions) {\n this.tracer = resolveTracer(options)\n this.options = options\n this.limits = normalizeLimits(options)\n this.serviceResolution = options.serviceResolution ?? 'off'\n this.recordFailures = options.recordFailures === true\n\n if (!isTelemetryMode(this.serviceResolution)) {\n throw new TypeError('serviceResolution must be off, events, or spans')\n }\n\n const lifecycle = options.lifecycle ?? 'off'\n\n if (!isTelemetryMode(lifecycle)) {\n throw new TypeError('lifecycle must be off, events, or spans')\n }\n\n const shutdown = options.shutdown ?? 'off'\n\n if (!isTelemetryMode(shutdown)) {\n throw new TypeError('shutdown must be off, events, or spans')\n }\n\n this.lifecycleTelemetry = new LifecycleTelemetry({\n mode: lifecycle,\n recordFailures: this.recordFailures,\n getParentContext: () => readActiveContext() ?? ROOT_CONTEXT,\n startSpan: this.startSpan.bind(this),\n makeAttributes: (event, phase, outcome, durationMs) =>\n makeLifecycleAttributes(event, phase, outcome, durationMs, this.limits),\n getFailureDetails: (cause) =>\n makeFailureDetails(cause, this.options.sanitizeFailure, this.limits)\n })\n this.shutdownTelemetry = new ShutdownTelemetry({\n mode: shutdown,\n recordFailures: this.recordFailures,\n rootContext: ROOT_CONTEXT,\n startSpan: this.startSpan.bind(this),\n makeAttributes: (event, phase, durationMs) =>\n makeShutdownAttributes(event, phase, durationMs, this.limits),\n getFailureDetails: (cause) =>\n makeFailureDetails(cause, this.options.sanitizeFailure, this.limits)\n })\n }\n\n static make(options: OpenTelemetryRuntimeObserverOptions): OpenTelemetryRuntimeObserver {\n return new OpenTelemetryRuntimeObserver(options)\n }\n\n readonly onExecutionStart = (event: RuntimeExecutionStartEvent): void => {\n this.safely(() => this.startExecution(event))\n }\n\n readonly onExecutionEnd = (event: RuntimeExecutionEndEvent): void => {\n this.safely(() => this.endExecution(event))\n }\n\n readonly onServiceResolve = (event: RuntimeServiceResolveEvent): void => {\n this.safely(() => this.observeService('better-effect.service.resolve', event))\n }\n\n readonly onServiceAcquire = (event: RuntimeServiceAcquireEvent): void => {\n this.safely(() => this.observeService('better-effect.service.acquire', event))\n }\n\n readonly onResourceRelease = (event: RuntimeResourceReleaseEvent): void => {\n this.safely(() => this.observeService('better-effect.service.release', event))\n }\n\n readonly onLifecycleStart = (event: RuntimeLifecycleStartEvent): void => {\n this.safely(() => this.lifecycleTelemetry.onStart(event))\n }\n\n readonly onLifecycleEnd = (event: RuntimeLifecycleEndEvent): void => {\n this.safely(() => this.lifecycleTelemetry.onEnd(event))\n }\n\n readonly onLifecycleRelease = (event: RuntimeLifecycleReleaseEvent): void => {\n this.safely(() => this.lifecycleTelemetry.onRelease(event))\n }\n\n readonly onShutdown = (event: RuntimeShutdownEvent): void => {\n this.safely(() => this.shutdownTelemetry.onEvent(event))\n }\n\n /** End any spans whose malformed or missing end event left them pending. */\n dispose(): void {\n if (this.disposed) {\n return\n }\n\n this.disposed = true\n const pending = [...this.executionSpans.values()]\n\n for (const execution of pending) {\n const span = execution.span\n\n if (span === undefined) {\n // An in-flight start can publish its span after this reentrant disposal returns.\n continue\n }\n\n this.endExecutionSpan(execution, span)\n }\n\n this.lifecycleTelemetry.dispose()\n this.shutdownTelemetry.dispose()\n }\n\n [Symbol.dispose](): void {\n this.dispose()\n }\n\n async [Symbol.asyncDispose](): Promise<void> {\n this.dispose()\n }\n\n private safely(operation: () => void): void {\n if (this.disposed) {\n return\n }\n\n try {\n operation()\n } catch {\n // Keep malformed events and tracer implementations outside Runtime results.\n }\n }\n\n private startSpan(\n name: string,\n attributes: AttributeMap,\n parentContext: Context | undefined\n ): Span | undefined {\n try {\n const span =\n parentContext === undefined\n ? this.tracer.startSpan(name, { attributes })\n : this.tracer.startSpan(name, { attributes }, parentContext)\n\n if (!isSpan(span)) {\n ignoreRejection(span)\n return undefined\n }\n\n return span\n } catch {\n return undefined\n }\n }\n\n private ownsExecutionSpan(execution: ExecutionSpan, span: Span): boolean {\n return this.executionSpans.get(execution.executionId) === execution && execution.span === span\n }\n\n private claimExecutionSpan(execution: ExecutionSpan, span: Span | undefined): boolean {\n if (this.executionSpans.get(execution.executionId) !== execution || execution.span !== span) {\n return false\n }\n\n this.executionSpans.delete(execution.executionId)\n return true\n }\n\n private endExecutionSpan(execution: ExecutionSpan, span: Span): void {\n if (this.claimExecutionSpan(execution, span)) {\n callSpan(() => span.end())\n }\n }\n\n private finishPendingExecution(execution: ExecutionSpan): void {\n if (execution.pendingEnd !== undefined && isActiveExecutionSpan(execution)) {\n this.finishExecution(execution, execution.pendingEnd)\n }\n }\n\n private startExecution(event: RuntimeExecutionStartEvent): void {\n if (this.executionSpans.has(event.executionId)) {\n return\n }\n\n // Reserve the ID before calling user tracer code: startSpan may synchronously re-enter this observer.\n const execution: ExecutionSpan = { executionId: event.executionId, ended: false }\n this.executionSpans.set(event.executionId, execution)\n const parentContext = readActiveContext() ?? ROOT_CONTEXT\n let span: Span | undefined\n\n try {\n span = this.startSpan(\n boundedNonEmptyString(event.name, this.limits.maxAttributeLength) ??\n DEFAULT_EXECUTION_SPAN_NAME,\n makeExecutionSpanAttributes(event, this.options, this.limits),\n parentContext\n )\n } catch {\n this.claimExecutionSpan(execution, undefined)\n return\n }\n\n if (span === undefined) {\n this.claimExecutionSpan(execution, undefined)\n return\n }\n\n execution.span = span\n\n if (this.disposed) {\n this.endExecutionSpan(execution, span)\n return\n }\n\n if (!this.ownsExecutionSpan(execution, span)) {\n return\n }\n\n const executionContext = setSpanInContext(parentContext, span)\n\n if (executionContext === undefined) {\n const pendingEnd = execution.pendingEnd\n\n if (pendingEnd !== undefined && isStartedExecutionSpan(execution)) {\n this.finishExecution(execution, pendingEnd)\n } else {\n this.endExecutionSpan(execution, span)\n }\n\n return\n }\n\n execution.executionContext = executionContext\n this.finishPendingExecution(execution)\n }\n\n private endExecution(event: RuntimeExecutionEndEvent): void {\n const execution = this.executionSpans.get(event.executionId)\n\n if (execution === undefined || execution.ended) {\n return\n }\n\n execution.ended = true\n\n if (!isActiveExecutionSpan(execution)) {\n execution.pendingEnd = event\n return\n }\n\n this.finishExecution(execution, event)\n }\n\n private finishExecution(execution: StartedExecutionSpan, event: RuntimeExecutionEndEvent): void {\n // Claim map ownership before invoking tracer callbacks so reentrant end or dispose calls cannot\n // finalize this exact span again.\n const span = execution.span\n\n if (!this.claimExecutionSpan(execution, span)) {\n return\n }\n\n try {\n const status = executionEventStatus(event)\n callSpan(() => span.setAttribute(OUTCOME_ATTRIBUTE, status))\n callSpan(() =>\n span.setStatus({\n code: status === 'failure' ? SpanStatusCode.ERROR : SpanStatusCode.OK\n })\n )\n\n if (status === 'failure' && this.recordFailures) {\n const cause =\n event.outcome.status === 'failure' ? event.outcome.cause : event.cleanupFailure\n const details = makeFailureDetails(cause, this.options.sanitizeFailure, this.limits)\n\n if (details !== undefined) {\n addFailureDetails(span, details)\n }\n }\n } finally {\n callSpan(() => span.end())\n }\n }\n\n private findCorrelatedExecution(event: ServiceEvent): ActiveExecutionSpan | undefined {\n if (event.executionId === undefined) {\n return undefined\n }\n\n const execution = this.executionSpans.get(event.executionId)\n return execution !== undefined && isActiveExecutionSpan(execution) ? execution : undefined\n }\n\n private observeService(name: string, event: ServiceEvent): void {\n if (this.serviceResolution === 'off') {\n return\n }\n\n const execution = this.findCorrelatedExecution(event)\n const executionId = execution === undefined ? undefined : this.findExecutionId(execution)\n const attributes = makeServiceEventAttributes(event, this.limits, executionId)\n let failureCause: unknown\n\n if ('error' in event && event.error !== undefined) {\n failureCause = event.error\n } else if (event.outcome.status === 'failure') {\n failureCause = event.outcome.cause\n }\n\n const details =\n serviceEventStatus(event) === 'failure' && this.recordFailures\n ? makeFailureDetails(failureCause, this.options.sanitizeFailure, this.limits)\n : undefined\n\n if (details?.attributes !== undefined) {\n mergeAdditionalAttributes(attributes, details.attributes, this.limits.maxAttributeCount)\n }\n\n if (execution !== undefined) {\n this.observeCorrelatedService(name, event, execution, attributes, details)\n return\n }\n\n this.observeStandaloneService(name, event, attributes, details)\n }\n\n private findExecutionId(execution: ExecutionSpan): string | undefined {\n return boundedNonEmptyString(execution.executionId, this.limits.maxAttributeLength)\n }\n\n private observeCorrelatedService(\n name: string,\n event: ServiceEvent,\n execution: ActiveExecutionSpan,\n attributes: AttributeMap,\n details: FailureDetails | undefined\n ): void {\n if (this.serviceResolution === 'events') {\n callSpan(() => execution.span.addEvent(name, attributes))\n\n if (details !== undefined) {\n addFailureDetails(execution.span, details)\n }\n\n return\n }\n\n const span = this.startSpan(name, attributes, execution.executionContext)\n\n if (span === undefined) {\n return\n }\n\n this.finishServiceSpan(span, event, details)\n }\n\n private observeStandaloneService(\n name: string,\n event: ServiceEvent,\n attributes: AttributeMap,\n details: FailureDetails | undefined\n ): void {\n const span = this.startSpan(\n this.serviceResolution === 'events' ? DEFAULT_SERVICE_SPAN_NAME : name,\n attributes,\n ROOT_CONTEXT\n )\n\n if (span === undefined) {\n return\n }\n\n if (this.serviceResolution === 'events') {\n callSpan(() => span.addEvent(name, attributes))\n }\n\n this.finishServiceSpan(span, event, details)\n }\n\n private finishServiceSpan(\n span: Span,\n event: ServiceEvent,\n details: FailureDetails | undefined\n ): void {\n callSpan(() =>\n span.setStatus({\n code: serviceEventStatus(event) === 'failure' ? SpanStatusCode.ERROR : SpanStatusCode.OK\n })\n )\n\n if (details !== undefined) {\n addFailureDetails(span, details)\n }\n\n callSpan(() => span.end())\n }\n}\n"],"mappings":";;AAmDA,MAAMA,4BAAkC;CACtC,IAAI;EACF,OAAO,YAAY,IAAI;CACzB,QAAQ;EACN,OAAO,KAAK,IAAI;CAClB;AACF;AAEA,MAAMC,eAAa,UAAkC,2BAA2B;AAGhF,MAAMC,cAAY,cAAmC;CACnD,IAAI;EACF,QAAa,QAAQ,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;CAClD,QAAQ,CAER;AACF;AAEA,MAAMC,gBACJ,MACA,QACA,YACS;CACT,iBACE,KAAK,UAAU,EACb,MAAM,WAAW,YAAY,eAAe,QAAQ,eAAe,GACrE,CAAC,CACH;CAEA,IAAI,YAAY,KAAA,GAAW;EACzB,MAAM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,CACH;EAEA,IAAI,YAAY,KAAA,GACd,kBAAkB,MAAM,OAAO;EAGjC,eAAe,KAAK,IAAI,CAAC;CAC3B;AACF"}
@@ -170,13 +170,19 @@ const normalizeLayerRegistration = (registration) => {
170
170
  const registrationTag = registration.serviceTag;
171
171
  const acquire = registration.acquire;
172
172
  const serviceTag = validateRegistrationTag(service, registrationTag);
173
- return Object.freeze({
173
+ if (registration.quiesce === void 0) return Object.freeze({
174
174
  service,
175
175
  serviceTag,
176
176
  acquire
177
177
  });
178
+ return Object.freeze({
179
+ service,
180
+ serviceTag,
181
+ acquire,
182
+ quiesce: registration.quiesce
183
+ });
178
184
  };
179
185
  //#endregion
180
186
  export { LayerGeneratorYieldError as a, CircularDependencyError as c, ServiceRuntimeNotConfiguredError as d, captureServiceTag as f, LayerDisposeError as i, ServiceAcquisitionError as l, validateServiceTag as m, normalizeLayerRegistration as n, LayerRegistrationError as o, registerServiceTag as p, DuplicateServiceError as r, ServiceTagCollisionError as s, captureLayerRegistrationTag as t, ServiceNotFoundError as u };
181
187
 
182
- //# sourceMappingURL=registration-drnZk0SY.mjs.map
188
+ //# sourceMappingURL=registration-Bwe2GbVu.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registration-Bwe2GbVu.mjs","names":[],"sources":["../src/service/tag.ts","../src/service/errors.ts","../src/layer/errors.ts","../src/layer/registration.ts"],"sourcesContent":["const serviceTags = new WeakMap<object, string>()\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- This boundary validates untrusted JavaScript token values.\nconst isObjectLike = (value: unknown): value is object => value !== null && Object(value) === value\n\n// oxlint-disable-next-line anti-slop/no-object-parameters -- Tokens are validated object-like owners at this internal boundary.\nconst lockServiceTag = (token: object, tag: string): void => {\n const descriptor = Object.getOwnPropertyDescriptor(token, 'serviceTag')\n\n if (descriptor?.configurable === false) {\n if ('value' in descriptor && descriptor.value === tag && descriptor.writable === false) {\n return\n }\n\n if ('value' in descriptor && descriptor.value === tag && descriptor.writable === true) {\n Object.defineProperty(token, 'serviceTag', { writable: false })\n return\n }\n\n throw new TypeError('Service tags must be immutable')\n }\n\n Object.defineProperty(token, 'serviceTag', {\n value: tag,\n writable: false,\n enumerable: descriptor?.enumerable ?? true,\n configurable: false\n })\n}\n\n/** Validate the runtime form of a Service tag without coercing it. */\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Validate the public JavaScript declaration boundary.\nexport const validateServiceTag = (tag: unknown): string => {\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- Reject boxed and object tag aliases instead of coercing them.\n if (typeof tag !== 'string' || tag.length === 0) {\n throw new TypeError('Service tags must be non-empty primitive strings')\n }\n\n return tag\n}\n\n/** Record a declaration tag and make the public static property immutable. */\n// oxlint-disable-next-line anti-slop/no-object-parameters -- The declaration owner is always a class constructor.\nexport const registerServiceTag = (token: object, tag: string): void => {\n const canonicalTag = validateServiceTag(tag)\n const existing = serviceTags.get(token)\n\n if (existing !== undefined) {\n if (existing !== canonicalTag) {\n throw new TypeError('A Service tag cannot be changed after declaration')\n }\n\n return\n }\n\n lockServiceTag(token, canonicalTag)\n serviceTags.set(token, canonicalTag)\n}\n\n/** Capture a token's logical tag once so later mutable aliases cannot drift. */\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Validate unchecked Service tokens at each runtime boundary.\nexport const captureServiceTag = (token: unknown): string => {\n if (!isObjectLike(token)) {\n throw new TypeError('Service tokens must be objects or functions')\n }\n\n const known = serviceTags.get(token)\n\n if (known !== undefined) {\n return known\n }\n\n let prototype = Object.getPrototypeOf(token)\n\n while (isObjectLike(prototype)) {\n const inherited = serviceTags.get(prototype)\n\n if (inherited !== undefined) {\n lockServiceTag(token, inherited)\n serviceTags.set(token, inherited)\n\n return inherited\n }\n\n prototype = Object.getPrototypeOf(prototype)\n }\n\n // SAFETY: The object-like check above limits this assertion to a token-shaped object; the value is validated immediately below.\n const tag = validateServiceTag((token as { readonly serviceTag?: unknown }).serviceTag)\n lockServiceTag(token, tag)\n serviceTags.set(token, tag)\n\n return tag\n}\n","import { captureServiceTag } from './tag'\nimport type { AnyServiceToken } from './types'\n\nconst formatResolutionPath = (path: readonly AnyServiceToken[]): string =>\n path.map((service) => captureServiceTag(service)).join(' → ')\n\n/** Thrown when a Service is accessed without an active runtime resolver. */\nexport class ServiceRuntimeNotConfiguredError extends Error {\n constructor() {\n super('No ServiceResolver is available in the current runtime context')\n\n this.name = 'ServiceRuntimeNotConfiguredError'\n }\n}\n\n/** Thrown when a runtime has no provider for the requested Service tag. */\nexport class ServiceNotFoundError extends Error {\n constructor(readonly service: AnyServiceToken) {\n super(`Service \"${captureServiceTag(service)}\" was not provided`)\n\n this.name = 'ServiceNotFoundError'\n }\n}\n\n/** Thrown when resolving a Service re-enters a Service already in its path. */\nexport class CircularDependencyError extends Error {\n readonly path: readonly AnyServiceToken[]\n\n constructor(path: readonly AnyServiceToken[]) {\n const normalizedPath = Object.freeze([...path])\n\n super(`Circular Service dependency detected:\\n${formatResolutionPath(normalizedPath)}`)\n\n this.name = 'CircularDependencyError'\n this.path = normalizedPath\n }\n}\n\n/** Thrown when a registered Service provider fails during lazy acquisition. */\nexport class ServiceAcquisitionError extends Error {\n override readonly cause: unknown\n\n constructor(\n readonly service: AnyServiceToken,\n resolutionPath: readonly AnyServiceToken[],\n cause: unknown\n ) {\n const normalizedPath = Object.freeze([...resolutionPath])\n\n super(\n `Failed to acquire Service \"${captureServiceTag(service)}\"` +\n (normalizedPath.length > 0\n ? ` while resolving: ${formatResolutionPath(normalizedPath)}`\n : '')\n )\n\n this.name = 'ServiceAcquisitionError'\n this.cause = cause\n this.resolutionPath = normalizedPath\n }\n\n readonly resolutionPath: readonly AnyServiceToken[]\n}\n","import { captureServiceTag } from '../service/tag'\nimport type { AnyServiceToken } from '../service'\nimport type { ScopeOutcome } from '../scope'\n\ntype LayerCause = Extract<ScopeOutcome, { readonly status: 'failure' }>['cause']\n\n/** Thrown when a Layer registers the same Service tag more than once. */\nexport class DuplicateServiceError extends Error {\n constructor(readonly service: AnyServiceToken) {\n super(`Duplicate service tag \"${captureServiceTag(service)}\"`)\n\n this.name = 'DuplicateServiceError'\n }\n}\n\n/** Thrown when one Service tag is associated with incompatible constructors. */\nexport class ServiceTagCollisionError extends Error {\n constructor(\n readonly existing: AnyServiceToken,\n readonly incoming: AnyServiceToken\n ) {\n super(\n `Service tag \"${captureServiceTag(incoming)}\" is already associated with \"${existing.name}\" ` +\n `and cannot be associated with \"${incoming.name}\"`\n )\n\n this.name = 'ServiceTagCollisionError'\n }\n}\n\n/** Thrown when a backend fails while registering a Layer provider. */\nexport class LayerRegistrationError extends Error {\n constructor(\n readonly service: AnyServiceToken | undefined,\n readonly registrationCause: LayerCause,\n readonly cleanupCause?: LayerCause\n ) {\n super(\n service\n ? `Failed to register service \"${captureServiceTag(service)}\"`\n : 'Failed to build Layer',\n {\n cause: registrationCause\n }\n )\n\n this.name = 'LayerRegistrationError'\n }\n}\n\n/** Thrown when one or more Layer-owned resources fail during disposal. */\nexport class LayerDisposeError extends Error {\n constructor(readonly causes: readonly unknown[]) {\n super(`Failed to dispose Layer (${causes.length} error${causes.length === 1 ? '' : 's'})`)\n\n this.name = 'LayerDisposeError'\n }\n}\n\n/** Thrown when a Layer generator yields a value other than a Service requirement. */\nexport class LayerGeneratorYieldError extends Error {\n constructor(readonly service: AnyServiceToken) {\n super(`Layer.gen(\"${captureServiceTag(service)}\") yielded an unsupported value`)\n\n this.name = 'LayerGeneratorYieldError'\n }\n}\n","import { captureServiceTag, validateServiceTag } from '../service/tag'\n\nimport type { LayerRegistration } from './types'\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Validate unchecked registrations at the adapter boundary.\nconst validateRegistrationTag = (service: unknown, registrationTag: unknown): string => {\n const tokenTag = captureServiceTag(service)\n\n if (registrationTag === undefined) {\n return tokenTag\n }\n\n const canonicalTag = validateServiceTag(registrationTag)\n\n if (canonicalTag !== tokenTag) {\n throw new TypeError('Layer registration tag does not match its Service token')\n }\n\n return canonicalTag\n}\n\n/** Capture and validate the logical identity carried by a backend registration. */\nexport const captureLayerRegistrationTag = (registration: LayerRegistration): string => {\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- Reject forged registrations before reading their fields.\n if (typeof registration !== 'object' || registration === null) {\n throw new TypeError('Layer registrations must be objects')\n }\n\n return validateRegistrationTag(registration.service, registration.serviceTag)\n}\n\n/** Detach a registration from mutable caller-owned objects at the backend boundary. */\nexport const normalizeLayerRegistration = (registration: LayerRegistration): LayerRegistration => {\n const service = registration.service\n const registrationTag = registration.serviceTag\n const acquire = registration.acquire\n const serviceTag = validateRegistrationTag(service, registrationTag)\n\n if (registration.quiesce === undefined) {\n return Object.freeze({\n service,\n serviceTag,\n acquire\n })\n }\n\n return Object.freeze({\n service,\n serviceTag,\n acquire,\n quiesce: registration.quiesce\n })\n}\n"],"mappings":";AAAA,MAAM,8BAAc,IAAI,QAAwB;AAGhD,MAAM,gBAAgB,UAAoC,UAAU,QAAQ,OAAO,KAAK,MAAM;AAG9F,MAAM,kBAAkB,OAAe,QAAsB;CAC3D,MAAM,aAAa,OAAO,yBAAyB,OAAO,YAAY;CAEtE,IAAI,YAAY,iBAAiB,OAAO;EACtC,IAAI,WAAW,cAAc,WAAW,UAAU,OAAO,WAAW,aAAa,OAC/E;EAGF,IAAI,WAAW,cAAc,WAAW,UAAU,OAAO,WAAW,aAAa,MAAM;GACrF,OAAO,eAAe,OAAO,cAAc,EAAE,UAAU,MAAM,CAAC;GAC9D;EACF;EAEA,MAAM,IAAI,UAAU,gCAAgC;CACtD;CAEA,OAAO,eAAe,OAAO,cAAc;EACzC,OAAO;EACP,UAAU;EACV,YAAY,YAAY,cAAc;EACtC,cAAc;CAChB,CAAC;AACH;;AAIA,MAAa,sBAAsB,QAAyB;CAE1D,IAAI,OAAO,QAAQ,YAAY,IAAI,WAAW,GAC5C,MAAM,IAAI,UAAU,kDAAkD;CAGxE,OAAO;AACT;;AAIA,MAAa,sBAAsB,OAAe,QAAsB;CACtE,M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;EAC7C,MAAM,cAAc,kBAAkB,OAAO,EAAE,gCAAgC;EAD5D,KAAA,UAAA;EAGnB,KAAK,OAAO;CACd;AACF;;;AC7DA,MAAM,2BAA2B,SAAkB,oBAAqC;CACtF,MAAM,WAAW,kBAAkB,OAAO;CAE1C,IAAI,oBAAoB,KAAA,GACtB,OAAO;CAGT,MAAM,eAAe,mBAAmB,eAAe;CAEvD,IAAI,iBAAiB,UACnB,MAAM,IAAI,UAAU,yDAAyD;CAG/E,OAAO;AACT;;AAGA,MAAa,+BAA+B,iBAA4C;CAEtF,IAAI,OAAO,iBAAiB,YAAY,iBAAiB,MACvD,MAAM,IAAI,UAAU,qCAAqC;CAG3D,OAAO,wBAAwB,aAAa,SAAS,aAAa,UAAU;AAC9E;;AAGA,MAAa,8BAA8B,iBAAuD;CAChG,MAAM,UAAU,aAAa;CAC7B,MAAM,kBAAkB,aAAa;CACrC,MAAM,UAAU,aAAa;CAC7B,MAAM,aAAa,wBAAwB,SAAS,eAAe;CAEnE,IAAI,aAAa,YAAY,KAAA,GAC3B,OAAO,OAAO,OAAO;EACnB;EACA;EACA;CACF,CAAC;CAGH,OAAO,OAAO,OAAO;EACnB;EACA;EACA;EACA,SAAS,aAAa;CACxB,CAAC;AACH"}
@@ -1,5 +1,5 @@
1
- import { c as RuntimeContextStorage, s as RuntimeContext } from "../index-heuaRmXR.mjs";
2
- import { n as RuntimeContextOverlapError, t as RuntimeContextNotConfiguredError } from "../errors-BKcsQ0ip.mjs";
1
+ import { c as RuntimeContext, l as RuntimeContextStorage } from "../layer-C2OaqTmB.mjs";
2
+ import { n as RuntimeContextOverlapError, t as RuntimeContextNotConfiguredError } from "../errors-CpHMzPiP.mjs";
3
3
  //#region src/runtime/explicit.d.ts
4
4
  /**
5
5
  * RuntimeContextStorage for hosts without transparent async context support.
@@ -1,4 +1,4 @@
1
- import { a as getRuntimeContextLineage, c as isRuntimeContextFrameCarrierInstalled, g as RuntimeContextOverlapError, h as RuntimeContextNotConfiguredError, m as withActiveRuntimeContextStorage, o as inheritRuntimeContextLineage, p as setRuntimeContextLineage, r as currentRuntimeContextFrame, s as isDerivedRuntimeContext } from "../context-BUEf1qjL.mjs";
1
+ import { a as getRuntimeContextLineage, c as isRuntimeContextFrameCarrierInstalled, g as RuntimeContextOverlapError, h as RuntimeContextNotConfiguredError, m as withActiveRuntimeContextStorage, o as inheritRuntimeContextLineage, p as setRuntimeContextLineage, r as currentRuntimeContextFrame, s as isDerivedRuntimeContext } from "../context-DSGSqcJj.mjs";
2
2
  import { t as isPromiseLike } from "../runtime-CDcCF5cb.mjs";
3
3
  //#region src/runtime/explicit.ts
4
4
  let fallbackRootLease = false;
@@ -1,4 +1,4 @@
1
- import { c as RuntimeContextStorage, s as RuntimeContext } from "../index-heuaRmXR.mjs";
2
- import { t as RuntimeContextNotConfiguredError } from "../errors-BKcsQ0ip.mjs";
3
- import { n as nodeRuntimeContextStorage, t as NodeRuntimeContextStorage } from "../node-context-DWsCUBRa.mjs";
1
+ import { c as RuntimeContext, l as RuntimeContextStorage } from "../layer-C2OaqTmB.mjs";
2
+ import { t as RuntimeContextNotConfiguredError } from "../errors-CpHMzPiP.mjs";
3
+ import { n as nodeRuntimeContextStorage, t as NodeRuntimeContextStorage } from "../node-context-1YEjrU9g.mjs";
4
4
  export { NodeRuntimeContextStorage, type RuntimeContext, RuntimeContextNotConfiguredError, type RuntimeContextStorage, nodeRuntimeContextStorage };
@@ -1,3 +1,3 @@
1
- import { h as RuntimeContextNotConfiguredError } from "../context-BUEf1qjL.mjs";
2
- import { n as nodeRuntimeContextStorage, t as NodeRuntimeContextStorage } from "../node-context-lggRF4bR.mjs";
1
+ import { h as RuntimeContextNotConfiguredError } from "../context-DSGSqcJj.mjs";
2
+ import { n as nodeRuntimeContextStorage, t as NodeRuntimeContextStorage } from "../node-context-g3bCcY9t.mjs";
3
3
  export { NodeRuntimeContextStorage, RuntimeContextNotConfiguredError, nodeRuntimeContextStorage };