Insider.Sentinel.DraftCreation.Receipt (Insider Lab v0.1.0)

Copy Markdown View Source

A canonical local record of one draft-provider attempt.

Created and existing outcomes are provider-reported, not independently verified remote state. An unknown outcome is retained after a deadline because terminating the local callback cannot prove that an external effect did not occur. Exactly-once behavior therefore depends on provider-native idempotency. Standalone validation proves only structure and content identity; callers trust a receipt only after validate_with/2 recomputes it from the request.

Summary

Types

t()

@type t() :: %Insider.Sentinel.DraftCreation.Receipt{
  controls: term(),
  disclosure: term(),
  draft: term(),
  id: term(),
  integrity: term(),
  outcome: term(),
  provider: term(),
  request: term(),
  schema: term(),
  trust: term()
}

Functions

canonical_binary(receipt)

@spec canonical_binary(term()) ::
  {:ok, binary()} | {:error, Insider.Protocol.Error.t()}

decode(value)

@spec decode(term()) :: {:ok, t()} | {:error, Insider.Protocol.Error.t()}

decode_map(wire)

@spec decode_map(term()) :: {:ok, t()} | {:error, Insider.Protocol.Error.t()}

new(request, outcome, draft_reference)

@spec new(term(), binary(), binary() | nil) ::
  {:ok, t()} | {:error, Insider.Protocol.Error.t()}

to_wire_map(receipt)

@spec to_wire_map(t()) :: map()

validate(receipt)

@spec validate(term()) :: {:ok, t()} | {:error, Insider.Protocol.Error.t()}

validate_with(receipt, request)

@spec validate_with(term(), term()) ::
  {:ok, t()} | {:error, Insider.Protocol.Error.t()}

Recomputes the receipt from the exact request and recorded provider outcome.