Public API for hosting a Governed Act Model domain in an OTP application.
Host code wires one explicit
ledger Store into a supervised Domain, an authenticated ingress adapter
supplies a ExGAM.SubmissionContext, and callers durably open a Scope
before proposing a Candidate. propose/3 keeps Admission and execution in
one call without returning the internal Grant through this facade. Internal
modules are callable on the same BEAM; @doc false is not access control.
Deployment isolation and credential protection remain host responsibilities.
Administrative helpers only construct Candidates and submit them through the same kernel. This module exposes no direct ledger append, raw Grant, arbitrary observed-Evidence insertion or post-Genesis root-authority mutation.
Using the API in an application
Start a Domain once for operations that share policy and ledger history. In the outbox walkthrough, a service proposes a note for one destination. Its Mandate specifies which outbox it can write to. Admission records an Act for that exact note, and the host's executor writes it. The walkthrough also shows a refusal and a lost receipt.
The same calls in a payments application take the policy records, adapters and Candidate defined by that host.
{:ok, domain} =
ExGAM.start_domain("domain:payments", store,
ingress: MyApp.Ingress,
constitution: constitution,
genesis: genesis,
principals: principals,
host_profile: host_profile,
surface: surface,
root_mandates: root_mandates,
genesis_verifier: MyApp.GenesisVerifier,
executors: [MyApp.PaymentExecutor],
broker: MyApp.CredentialBroker
)
{:ok, context} = ExGAM.authenticate(domain, scope_ref, request)
{:ok, scope} = ExGAM.open_scope(domain, context, opened_at: now)
{:ok, result} = ExGAM.propose(scope, candidate)A Scope and Domain handle are routing values, not authority. Copying either does not copy a Mandate, reservation or capability.
See ExGAM.GovernedAct for a map of the pure model implementation and its
relationship to the ledger, kernel, projection and audit drivers.
Summary
Functions
Returns immutable Acts visible through an authenticated Scope.
Authenticates through the Domain's fixed ingress and returns a generation-bound context.
Returns the current capability-free authority inventory for an authenticated Scope.
Adds already-durable Evidence to a sealed deliberation context.
Returns governed Evidence declassifications visible through an authenticated Scope.
Removes explicitly authorized labels by producing new immutable Evidence.
Returns an exact governed Definition through a live authenticated Scope.
Delegates a subtractive child Mandate through a normal governance Act.
Returns declared free child Meter balances through a governance Act.
Reads durable dispatch facts for one scoped Act, never inferring cancellation from a missing Attempt.
Disposes a Duty only through the independently authorized governance path.
Returns immutable Duties visible through an authenticated Scope.
Returns causal erasure requests visible through an authenticated Scope.
Returns the verified ledger head represented by the live Domain projection.
Issues a subtractive child Mandate through a normal governance Act.
Returns the locally supervised Domain handle for domain_ref.
Records input through the Domain's declared ingress without invoking a mind.
Durably opens a Scope from an authenticated SubmissionContext.
Opens a finite Work or Vigil Scope through normal governed admission.
Records ingress Evidence and returns its sealed Turn without invoking a Mind.
Stores immutable consent material; this operation does not itself display it.
Proposes a Candidate and completes its permitted execution path.
Records derived/generated Evidence bound to one exact deliberation Turn.
Obtains and records a late world observation through the Domain's fixed observer.
Records a late or independently obtained world Outcome for an Act in this Scope.
Refreshes available durable result facts without calling an executor again.
Registers an immutable Principal through a normal governance Act; it grants no authority.
Requests executor-mediated erasure through a normal governance Act.
Replaces a Mandate with an immutable, strictly narrower successor through a governance Act.
Rebinds a current authenticated context to its exact durable Scope opening.
Revises a declarative Definition through a normal governance Act.
Revises the attested host profile through a normal governance Act.
Revises the governed Surface through a normal governance Act.
Immediately records a forward-only Mandate revocation through a governance Act.
Shows prepared consent material through a normal executor-mediated Act.
Starts one locally supervised Domain using an explicit ledger Store.
Reads the current Surface through the live Scope fence; does not copy Domain history.
Turns authenticated input into durable Evidence and capability-free proposals.
Runs one Turn with explicit, non-authoritative application state.
Returns the governed runtime API version.
Returns the read-only application projection for an authenticated Scope.
Types
@type domain_head() :: %{ domain_ref: domain_ref(), revision: non_neg_integer(), head_digest: String.t() }
@type domain_input() :: ExGAM.Domain.t() | domain_ref()
@type domain_ref() :: String.t()
Functions
@spec acts(ExGAM.Scope.t(), keyword()) :: {:ok, [ExGAM.Act.t()]} | {:error, term()}
Returns immutable Acts visible through an authenticated Scope.
@spec authenticate(domain_input(), String.t(), term(), keyword()) :: {:ok, ExGAM.SubmissionContext.t()} | {:error, term()}
Authenticates through the Domain's fixed ingress and returns a generation-bound context.
@spec authority(ExGAM.Scope.t(), keyword()) :: {:ok, ExGAM.Authority.View.t()} | {:error, term()}
Returns the current capability-free authority inventory for an authenticated Scope.
The result lists Mandates held by the authenticated Principal, their shared state blockers and retained revocation controls. It does not decide whether any particular Candidate is admissible and cannot be used as a Grant.
@spec continue_turn(ExGAM.Scope.t(), ExGAM.Mind.Turn.t(), [String.t()]) :: {:ok, ExGAM.Mind.Turn.t()} | {:error, term()}
Adds already-durable Evidence to a sealed deliberation context.
Rechecks Scope, seal, provenance and availability; no input is observed twice. Required context cannot be silently dropped to fit a smaller Mind window.
@spec declassifications(ExGAM.Scope.t()) :: {:ok, [ExGAM.Declassification.t()]} | {:error, term()}
Returns governed Evidence declassifications visible through an authenticated Scope.
@spec declassify_evidence( ExGAM.Scope.t(), ExGAM.Evidence.t() | map() | keyword(), [term()], map() | keyword(), keyword() ) :: {:ok, ExGAM.Proposal.Result.t()} | {:error, term()}
Removes explicitly authorized labels by producing new immutable Evidence.
@spec definition(ExGAM.Scope.t(), String.t()) :: {:ok, ExGAM.Definition.t()} | {:error, term()}
Returns an exact governed Definition through a live authenticated Scope.
@spec delegate_mandate( ExGAM.Scope.t(), ExGAM.Mandate.t() | map() | keyword(), map() | keyword(), keyword() ) :: {:ok, ExGAM.Proposal.Result.t()} | {:error, term()}
Delegates a subtractive child Mandate through a normal governance Act.
@spec devolve_mandate( ExGAM.Scope.t(), String.t(), map(), map() | keyword(), keyword() ) :: {:ok, ExGAM.Proposal.Result.t()} | {:error, term()}
Returns declared free child Meter balances through a governance Act.
@spec dispatch_status(ExGAM.Scope.t(), String.t()) :: {:ok, %{ mode: ExGAM.GovernedAct.Execution.mode(), terminal: ExGAM.GovernedAct.DispatchState.terminal() | nil, pending?: boolean() }} | {:error, term()}
Reads durable dispatch facts for one scoped Act, never inferring cancellation from a missing Attempt.
@spec dispose_duty( ExGAM.Scope.t(), ExGAM.Duty.Disposition.t() | map() | keyword(), map() | keyword(), keyword() ) :: {:ok, ExGAM.Proposal.Result.t()} | {:error, term()}
Disposes a Duty only through the independently authorized governance path.
@spec duties(ExGAM.Scope.t(), keyword()) :: {:ok, [ExGAM.Duty.t()]} | {:error, term()}
Returns immutable Duties visible through an authenticated Scope.
@spec erasures(ExGAM.Scope.t()) :: {:ok, [ExGAM.Erasure.t()]} | {:error, term()}
Returns causal erasure requests visible through an authenticated Scope.
@spec head(domain_input()) :: {:ok, domain_head()} | {:error, term()}
Returns the verified ledger head represented by the live Domain projection.
@spec issue_mandate( ExGAM.Scope.t(), ExGAM.Mandate.t() | map() | keyword(), map() | keyword(), keyword() ) :: {:ok, ExGAM.Proposal.Result.t()} | {:error, term()}
Issues a subtractive child Mandate through a normal governance Act.
@spec lookup_domain(domain_ref()) :: {:ok, ExGAM.Domain.t()} | {:error, term()}
Returns the locally supervised Domain handle for domain_ref.
@spec observe(ExGAM.Scope.t(), term(), keyword()) :: {:ok, [ExGAM.Evidence.t()]} | {:error, term()}
Records input through the Domain's declared ingress without invoking a mind.
:ingress_opts are passed to that adapter. Supplying an :ingress override
is rejected: call options cannot replace the Domain trust boundary.
@spec open_scope( domain_input(), ExGAM.SubmissionContext.t(), map() | keyword() | ExGAM.Scope.Opening.t() ) :: {:ok, ExGAM.Scope.t()} | {:error, term()}
Durably opens a Scope from an authenticated SubmissionContext.
The context must already have been produced by a trusted ingress adapter. It
is revalidated, bound to the exact Domain and scope reference, fenced by the
currently running host generation and recorded before the handle is returned.
opening_attrs contains only Scope semantics; identity and authentication
fields are forced from the context. :opened_at is required so exact retries
remain byte-identical. Opening a Scope creates no authority or Meter balance.
@spec open_scope( ExGAM.Scope.t(), ExGAM.SubmissionContext.t(), map() | keyword(), map() | keyword(), keyword() ) :: {:ok, ExGAM.Scope.t()} | {:error, term()}
Opens a finite Work or Vigil Scope through normal governed admission.
parent_scope supplies the authenticated proposing context. child_context
must be a current context produced by the same Domain ingress for the new
Scope reference. Its seal is verified separately by the Sequencer and every
durable identity field is forced into the Candidate consequence. The Scope
handle is returned only after the Decision, Act and Opening are durably
recovered from one atomic batch.
@spec open_turn(ExGAM.Scope.t(), term(), keyword()) :: {:ok, ExGAM.Mind.Turn.t()} | {:error, term()}
Records ingress Evidence and returns its sealed Turn without invoking a Mind.
This is the same preparation used by turn/3, exposed for host-controlled handler authoring. It does not submit a Candidate or replace the configured ingress. In particular, routing an input cannot make its contents trusted.
@spec prepare_presentation( ExGAM.Scope.t(), ExGAM.Presentation.t() | map() | keyword(), keyword() ) :: {:ok, ExGAM.Presentation.t()} | {:error, term()}
Stores immutable consent material; this operation does not itself display it.
@spec propose(ExGAM.Scope.t(), ExGAM.Candidate.t() | map() | keyword(), keyword()) :: {:ok, ExGAM.Proposal.Result.t()} | {:error, term()}
Proposes a Candidate and completes its permitted execution path.
The Scope is revalidated against the live Domain and current host generation
on every call. Admission is durably sequenced before ExGAM.Attempt.Runner
receives the internal response. Executor-mediated Acts are routed only to the
executor and broker fixed in Domain configuration; proposal options cannot
replace either implementation or their private options.
The returned ExGAM.Proposal.Result contains the primary durable result
and, for an explicitly refused Candidate, either declared silence or the
result of one fresh governed fallback Candidate. It never contains the
internal Grant or checked-out capability, and fallbacks never recurse.
@spec record_derivation( ExGAM.Scope.t(), ExGAM.Mind.Turn.t(), ExGAM.Evidence.t() | map() | keyword(), keyword() ) :: {:ok, ExGAM.Evidence.t()} | {:error, term()}
Records derived/generated Evidence bound to one exact deliberation Turn.
@spec record_late_observation(ExGAM.Scope.t(), String.t(), term(), keyword()) :: {:ok, %{evidence: [ExGAM.Evidence.t()], outcome: ExGAM.Outcome.t()}} | {:error, term()}
Obtains and records a late world observation through the Domain's fixed observer.
The observer may verify a receipt or query the external system, but it receives no execution capability. A request cannot replace the configured adapter.
@spec record_outcome( ExGAM.Scope.t(), ExGAM.Outcome.t() | map() | keyword(), keyword() ) :: {:ok, ExGAM.Outcome.t()} | {:error, term()}
Records a late or independently obtained world Outcome for an Act in this Scope.
@spec recover_proposal(ExGAM.Scope.t(), ExGAM.Proposal.Result.t()) :: {:ok, ExGAM.Proposal.Result.t()} | {:error, term()}
Refreshes available durable result facts without calling an executor again.
@spec register_principal( ExGAM.Scope.t(), ExGAM.Principal.t() | map() | keyword(), map() | keyword(), keyword() ) :: {:ok, ExGAM.Proposal.Result.t()} | {:error, term()}
Registers an immutable Principal through a normal governance Act; it grants no authority.
@spec request_erasure( ExGAM.Scope.t(), map() | keyword(), map() | keyword(), keyword() ) :: {:ok, ExGAM.Proposal.Result.t()} | {:error, term()}
Requests executor-mediated erasure through a normal governance Act.
@spec restrict_mandate( ExGAM.Scope.t(), String.t(), ExGAM.Mandate.t() | map() | keyword(), map() | keyword(), keyword() ) :: {:ok, ExGAM.Proposal.Result.t()} | {:error, term()}
Replaces a Mandate with an immutable, strictly narrower successor through a governance Act.
@spec resume_scope(domain_input(), ExGAM.SubmissionContext.t()) :: {:ok, ExGAM.Scope.t()} | {:error, term()}
Rebinds a current authenticated context to its exact durable Scope opening.
Authentication and host generation must still match the immutable opening. A changed generation or authentication requires a new Scope, not an implicit rewrite of the old session or its authority.
@spec revise_definition( ExGAM.Scope.t(), ExGAM.Definition.t() | map() | keyword(), map() | keyword(), keyword() ) :: {:ok, ExGAM.Proposal.Result.t()} | {:error, term()}
Revises a declarative Definition through a normal governance Act.
@spec revise_host_profile( ExGAM.Scope.t(), String.t(), ExGAM.HostProfile.t() | map() | keyword(), map() | keyword(), keyword() ) :: {:ok, ExGAM.Proposal.Result.t()} | {:error, term()}
Revises the attested host profile through a normal governance Act.
@spec revise_surface( ExGAM.Scope.t(), String.t(), ExGAM.Surface.t() | map() | keyword(), map() | keyword(), keyword() ) :: {:ok, ExGAM.Proposal.Result.t()} | {:error, term()}
Revises the governed Surface through a normal governance Act.
@spec revoke_mandate( ExGAM.Scope.t(), String.t(), map() | keyword(), keyword() ) :: {:ok, ExGAM.Proposal.Result.t()} | {:error, term()}
Immediately records a forward-only Mandate revocation through a governance Act.
@spec show_presentation( ExGAM.Scope.t(), String.t(), map() | keyword(), keyword() ) :: {:ok, ExGAM.Proposal.Result.t()} | {:error, term()}
Shows prepared consent material through a normal executor-mediated Act.
@spec start_domain(domain_ref(), ExGAM.Ledger.Store.config(), keyword()) :: {:ok, ExGAM.Domain.t()} | {:error, term()}
Starts one locally supervised Domain using an explicit ledger Store.
This is host wiring, not a governance mutation. The Store is never inferred
or created implicitly. Bootstrap records, clock, identifier source,
constitution and Grant secret are forwarded as Domain options and validated
by the Sequencer. :ingress is mandatory and fixes the only adapter reference
accepted in authenticated contexts for that running Domain. :domain_ref,
:store, :name and :registry are reserved so callers cannot silently
replace the identity or uniqueness boundary.
This function starts Domains below ExGAM's Domain supervisor coupled to the
unique Domain registry. For static host supervision, use the existing
ExGAM.Domain.child_spec/1 instead; do not start the same Domain in both trees.
:recovery_policy optionally supplies {module, options} implementing
ExGAM.Domain.Recovery.Policy: an external witness check after verified
recovery, and an optional failure notification for application-owned repair.
:recovery_timeout bounds each callback (default 5 seconds). No policy can
bypass ledger or governed-act validation.
:clock_tolerance_ms bounds wall-clock drift from a boot-local monotonic
anchor (default 60,000 ms). :infinity explicitly disables the fence for
host-managed/virtual clocks. It cannot verify a bad initial clock reading.
@spec surface(ExGAM.Scope.t()) :: {:ok, ExGAM.Surface.t()} | {:error, term()}
Reads the current Surface through the live Scope fence; does not copy Domain history.
@spec turn(ExGAM.Scope.t(), term(), keyword()) :: {:ok, %{ turn: ExGAM.Mind.Turn.t(), evidence: [ExGAM.Evidence.t()], candidates: [ExGAM.Candidate.t()] }} | {:error, term()}
Turns authenticated input into durable Evidence and capability-free proposals.
The mind fixed in Domain configuration receives each Turn. The Domain's
declared ingress first observes the raw
input under the Scope's trusted SubmissionContext; ExGAM verifies the
resulting Evidence binding and commits it before invoking the mind. An
:ingress option is rejected, while :ingress_opts are passed to the fixed
adapter. The mind receives no executor or authority view and returns only
Candidates. Callers may submit those Candidates separately with propose/3.
Optional :context_evidence_refs select additional already-durable Evidence
for deliberation. Labels on the Turn are the conservative union of all
selected Evidence.
@spec turn(ExGAM.Scope.t(), term(), term(), keyword()) :: {:ok, %{ turn: ExGAM.Mind.Turn.t(), evidence: [ExGAM.Evidence.t()], candidates: [ExGAM.Candidate.t()], state: term() }} | {:error, term()}
Runs one Turn with explicit, non-authoritative application state.
This is the explicit-state counterpart of turn/3: the supplied value is
passed only to the optional ExGAM.Mind.deliberate/3 callback and its
successor is returned to the caller. ExGAM neither persists that value nor
treats it as authority, Evidence or a durable execution fact. Minds without
the optional callback use deliberate/2 and return the value unchanged.
Like turn/3, this call records ingress Evidence before deliberation; it is
not a pure function and Mind failure does not roll back those observations.
A stateful Mind must define deliberate/2 and deliberate/3 as separate
functions. A default argument on /3 would generate a misleading /2 that
interprets ordinary Mind options as state; see ExGAM.Mind.
@spec version() :: String.t()
Returns the governed runtime API version.
@spec view(ExGAM.Scope.t()) :: {:ok, ExGAM.Scope.View.t()} | {:error, term()}
Returns the read-only application projection for an authenticated Scope.