ExGAM.GovernedAct.Index (ExGAM v0.1.0)

Copy Markdown View Source

Shared access rules for collections in disposable governed state.

Transition modules use these functions so missing-record and duplicate-record errors remain stable as the fold is split by concern. This is not a general repository abstraction: it only reads and updates the in-memory projection rebuilt from the ledger.

Summary

Functions

Requires every reference to exist in a collection, preserving caller error context.

Fetches an Act using the common governed-history error vocabulary.

Fetches an Attempt using the common governed-history error vocabulary.

Fetches a Decision using the common governed-history error vocabulary.

Fetches a Duty by its stable causal identity.

Fetches a Duty by its durable record reference.

Fetches a Mandate using the common governed-history error vocabulary.

Fetches a required value while preserving the caller's record kind.

Restores one canonical record and rejects identity reuse in its target index.

Rejects a duplicate identity in a governed-state collection.

Functions

ensure_present(collection, refs, missing_error)

@spec ensure_present(map(), [String.t()], atom()) :: :ok | {:error, term()}

Requires every reference to exist in a collection, preserving caller error context.

fetch_act(state, ref)

@spec fetch_act(ExGAM.GovernedAct.State.t(), String.t()) ::
  {:ok, ExGAM.Act.t()} | {:error, term()}

Fetches an Act using the common governed-history error vocabulary.

fetch_attempt(state, ref)

@spec fetch_attempt(ExGAM.GovernedAct.State.t(), String.t()) ::
  {:ok, ExGAM.Attempt.t()} | {:error, term()}

Fetches an Attempt using the common governed-history error vocabulary.

fetch_decision(state, ref)

@spec fetch_decision(ExGAM.GovernedAct.State.t(), String.t()) ::
  {:ok, ExGAM.Decision.t()} | {:error, term()}

Fetches a Decision using the common governed-history error vocabulary.

fetch_duty_by_cause(state, cause_key)

@spec fetch_duty_by_cause(ExGAM.GovernedAct.State.t(), term()) ::
  {:ok, ExGAM.Duty.t()} | {:error, term()}

Fetches a Duty by its stable causal identity.

fetch_duty_by_ref(state, duty_ref)

@spec fetch_duty_by_ref(ExGAM.GovernedAct.State.t(), term()) ::
  {:ok, ExGAM.Duty.t()} | {:error, term()}

Fetches a Duty by its durable record reference.

fetch_mandate(state, ref)

@spec fetch_mandate(ExGAM.GovernedAct.State.t(), String.t()) ::
  {:ok, ExGAM.Mandate.t()} | {:error, term()}

Fetches a Mandate using the common governed-history error vocabulary.

fetch_required(collection, key, kind)

@spec fetch_required(map(), term(), atom()) :: {:ok, term()} | {:error, term()}

Fetches a required value while preserving the caller's record kind.

restore_unique(collection, module, identity, canonical, kind)

@spec restore_unique(map(), module(), String.t(), term(), atom()) ::
  {:ok, struct()} | {:error, term()}

Restores one canonical record and rejects identity reuse in its target index.

unique(collection, identity, kind)

@spec unique(map(), term(), atom()) :: :ok | {:error, term()}

Rejects a duplicate identity in a governed-state collection.