Spectre.GAM.Duty.Derive.Facts (Spectre v0.4.0)

Copy Markdown View Source

Read-only input prepared for pure Duty derivation.

Governed records stay as their decoded structs. Ledger position and acquisition time stay in Spectre.GAM.Domain.Event.Metadata, where replay put them. This avoids manufacturing a second, map-shaped representation of an Act, Evidence or Outcome merely to attach metadata.

Each governed collection keeps the projection's single keyed representation; derivation traverses those maps directly instead of allocating parallel lists or retaining derived indexes beside their source. This view is disposable and carries no authority: the append-only ledger remains the source of truth and Spectre.GAM.GovernedAct.State remains the complete replay projection.

Summary

Functions

Returns whether a fact was durably available at the given trusted time.

Returns Evidence durably present and not erased at trusted time.

Returns Evidence durably known in the ledger prefix ending at revision.

Builds the minimal indexed view used by the Duty algebra.

Returns metadata when Evidence was recorded after a revision and no later than time.

Looks up trusted ledger metadata for a typed record identity.

Returns whether a fact was durably known at the given ledger revision.

Filters typed records to the ledger prefix ending at revision.

Types

t()

@type t() :: %Spectre.GAM.Duty.Derive.Facts{
  acts: %{optional(String.t()) => Spectre.GAM.Act.t()},
  attempts: %{optional(String.t()) => Spectre.GAM.Attempt.t()},
  availability: {non_neg_integer(), MapSet.t(String.t())} | nil,
  duties: %{optional(term()) => Spectre.GAM.Duty.t()},
  erasures: %{optional(String.t()) => Spectre.GAM.Erasure.t()},
  event_metadata: %{
    optional(String.t()) => Spectre.GAM.Domain.Event.Metadata.t()
  },
  evidence: %{optional(String.t()) => Spectre.GAM.Evidence.t()},
  mandates: %{optional(String.t()) => Spectre.GAM.Mandate.t()},
  outcomes: %{optional(String.t()) => Spectre.GAM.Outcome.t()},
  presentations: %{optional(String.t()) => Spectre.GAM.Presentation.t()},
  scopes: %{optional(String.t()) => Spectre.GAM.Scope.Opening.t()},
  sources: %{optional(atom()) => [term()]}
}

Functions

available_at?(facts, ref, time)

@spec available_at?(t(), String.t(), integer()) :: boolean()

Returns whether a fact was durably available at the given trusted time.

available_evidence(facts, time)

@spec available_evidence(t(), integer()) :: [Spectre.GAM.Evidence.t()]

Returns Evidence durably present and not erased at trusted time.

evidence_through(facts, revision)

@spec evidence_through(t(), non_neg_integer()) :: [Spectre.GAM.Evidence.t()]

Returns Evidence durably known in the ledger prefix ending at revision.

from_state(state)

@spec from_state(Spectre.GAM.GovernedAct.State.t()) :: t()

Builds the minimal indexed view used by the Duty algebra.

later_evidence(facts, evidence, revision, time)

@spec later_evidence(t(), Spectre.GAM.Evidence.t(), non_neg_integer(), integer()) ::
  {:ok, Spectre.GAM.Domain.Event.Metadata.t()} | :error

Returns metadata when Evidence was recorded after a revision and no later than time.

metadata(facts, ref)

@spec metadata(t(), String.t()) ::
  {:ok, Spectre.GAM.Domain.Event.Metadata.t()}
  | {:error, :missing_event_metadata}

Looks up trusted ledger metadata for a typed record identity.

recorded_through?(facts, ref, revision)

@spec recorded_through?(t(), String.t(), non_neg_integer()) :: boolean()

Returns whether a fact was durably known at the given ledger revision.

records_through(facts, records, revision)

@spec records_through(t(), Enumerable.t(), non_neg_integer()) :: [struct()]

Filters typed records to the ledger prefix ending at revision.