Metakit / @doeixd/metakit/artifact

decodeBundle

function · packages/metakit/src/bundle.ts:1176

function decodeBundle<Shape extends Readonly<Record<string, Schema.Top>>>(
  raw: unknown,
  options: {
    readonly env: Shape
    readonly profile: ReadinessProfile
  },
): Effect.Effect<PortableBundleV1, BundleError>

Read a bundle written by encodeExprBundle or encodeTransitionBundle, applying every check its encoder applies: the size bound counted the same way, the profile, each Match's labels as Expr.match checks them, each slot and write against env ({ state, input, supplied } for a transition), and the fingerprint against the one its content gives.

Fails with ArtifactDecodeError for a malformed or non-canonical bundle or one of another profile, ArtifactLimitError past the limits, and BundleRefusedError with the refusals its encoder would give, or 'fingerprint' where the content does not give the hash it carries.