RelayMark (relay_mark_elixir v0.6.6)

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

Converts finite historical AST input once; callers retain originals and the identity mapping.

Imports finite historical XML once and records exact identity attribute changes for the existing CRDT owner.

Finite saved publication conversion; optional source must be the same immutable released body.

Imports finite historical source using the same grammar and identity migration. Originals remain caller-owned evidence.

Normalize authored semantics while preserving all block/option IDs and envelope metadata.

Imports CommonMark/directives or the exact relaymark-ast source declaration.

Parses the bounded authored source of an canonical EntityRef atom.

Derives readable Markdown and safe static HTML through one strict preparation.

Projects readable Markdown; this projection is never a second writable body.

Projects a canonical RelayMark document map into its portable manifest.

Renders authored semantics; host hydration and authorization remain outside.

Writes exact source interchange, retaining identities and authored metadata.

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_layer_composition(json)

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

decode_manifest(json)

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

import_document(document, options \\ [])

Converts finite historical AST input once; callers retain originals and the identity mapping.

import_document_snapshot(snapshot, options \\ [])

Imports finite historical XML once and records exact identity attribute changes for the existing CRDT owner.

import_form_publication(publication, options \\ [])

Finite saved publication conversion; optional source must be the same immutable released body.

import_source(source, options \\ [])

Imports finite historical source using the same grammar and identity migration. Originals remain caller-owned evidence.

normalize_document(document)

Normalize authored semantics while preserving all block/option IDs and envelope metadata.

parse_document(source, options \\ [])

Imports CommonMark/directives or the exact relaymark-ast source declaration.

parse_entity_reference_source(source)

@spec parse_entity_reference_source(binary()) :: {:ok, map()} | :error

Parses the bounded authored source of an canonical EntityRef atom.

project_document(document)

Derives readable Markdown and safe static HTML through one strict preparation.

project_document_markdown(document)

Projects readable Markdown; this projection is never a second writable body.

project_manifest(document, diagnostics \\ [])

@spec project_manifest(map(), [map()]) :: map()

Projects a canonical RelayMark document map into its portable manifest.

Hosts should use this function instead of maintaining a parallel manifest projector so newly added portable directives remain consistent everywhere.

render_document(document)

Renders authored semantics; host hydration and authorization remain outside.

serialize_document(document)

Writes exact source interchange, retaining identities and authored metadata.

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_layer_composition(composition)

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

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.