RelayMark (relay_mark_elixir v0.5.2)

Copy Markdown View Source

Elixir adapter for RelayMark AST and manifest JSON.

This package intentionally models the portable RelayMark contract. Relay app persistence, authorization, and action execution belong in client projects.

Summary

Functions

Validates a canonical, JSON-keyed RelayMark document map.

Validates and returns a canonical RelayMark document, raising on failure.

Validates a canonical, JSON-keyed RelayMark projection manifest map.

Validates one exact transported Agent Answer document/manifest JSON pair.

Functions

decode_document(json)

@spec decode_document(binary()) :: {:ok, RelayMark.Document.t()} | {:error, term()}

decode_manifest(json)

@spec decode_manifest(binary()) :: {:ok, RelayMark.Manifest.t()} | {:error, term()}

validate_document(document, validation_context \\ %{})

@spec validate_document(map(), map()) :: :ok | {:error, [RelayMark.Diagnostic.t()]}

Validates a canonical, JSON-keyed RelayMark document map.

Structural validation is compiled from the canonical JSON Schema 2020-12 document schema. Semantic validation applies the same directive, evidence, lifecycle, comparison, and identity rules as the reference runtime.

validate_document!(document, validation_context \\ %{})

@spec validate_document!(map(), map()) :: map()

Validates and returns a canonical RelayMark document, raising on failure.

validate_manifest(manifest)

@spec validate_manifest(term()) :: :ok | {:error, [RelayMark.Diagnostic.t()]}

Validates a canonical, JSON-keyed RelayMark projection manifest map.

Structural validation is compiled from the canonical JSON Schema 2020-12 manifest and diagnostic schemas bundled in the package.

validate_transported_agent_answer_pair(document_json, manifest_json, validation_context \\ %{})

@spec validate_transported_agent_answer_pair(binary(), binary(), map()) ::
  {:ok, RelayMark.AgentAnswer.validated_pair()}
  | {:error, [RelayMark.Diagnostic.t()]}

Validates one exact transported Agent Answer document/manifest JSON pair.

Success returns decoded value models plus SHA-256 digests of the exact input bytes. Any semantic or canonical projection mismatch is rejected.