# `Spectre.GAM.Domain.Event`
[🔗](https://github.com/elchemista/spectre/blob/0.4.0/lib/spectre/gam/domain/event.ex#L1)

Canonical envelope and decoder for facts stored in a Domain ledger.

This module is deliberately smaller than the semantics that consume an
event. It owns the wire grammar shared by writers, live projections and the
independent auditor: exact keys, event identity bindings and acquisition
time. It does not decide whether an event is authorized or whether its
transition is valid; those are governed-act semantics.

Keeping the durable grammar here gives both replay paths the same strict
boundary while allowing them to fold the decoded event independently.

# `t`

```elixir
@type t() :: %Spectre.GAM.Domain.Event{
  batch_id: String.t() | nil,
  batch_index: non_neg_integer() | nil,
  data: map(),
  identity: String.t(),
  recorded_at: non_neg_integer() | nil,
  revision: pos_integer() | nil,
  type: String.t()
}
```

# `decode`

```elixir
@spec decode(map()) :: {:ok, t()} | {:error, term()}
```

Decodes and validates an event envelope without ledger metadata.

# `decode_entry`

```elixir
@spec decode_entry(Spectre.GAM.Ledger.Entry.t()) :: {:ok, t()} | {:error, term()}
```

Decodes an Entry payload and binds its trusted ledger metadata.

# `definition_revised`

```elixir
@spec definition_revised(Spectre.GAM.Act.t(), Spectre.GAM.Definition.t()) ::
  {:ok, map()} | {:error, term()}
```

Encodes a governed Definition revision; publishing data alone does not activate it.

# `dispatch_cancelled`

```elixir
@spec dispatch_cancelled(
  Spectre.GAM.Act.t(),
  Spectre.GAM.Act.t() | Spectre.GAM.Duty.t() | Spectre.GAM.Mandate.t(),
  atom()
) :: {:ok, map()} | {:error, term()}
```

Encodes the causal cancellation of a pending dispatch, not cancellation of an already-attempted effect.

# `dispatch_ready`

```elixir
@spec dispatch_ready(Spectre.GAM.Act.t()) :: map()
```

Encodes readiness for a committed world Act; creating this map does not mint a Grant.

# `duty_disposed`

```elixir
@spec duty_disposed(Spectre.GAM.Act.t(), term()) :: {:ok, map()} | {:error, term()}
```

Links disposal of the exact causal opening to its disposition Act; the fold verifies the closing route.

# `envelope`

```elixir
@spec envelope(String.t(), String.t(), map()) :: map()
```

Builds the exact plain-map envelope persisted as an Entry payload.

# `host_profile_revised`

```elixir
@spec host_profile_revised(
  Spectre.GAM.Act.t(),
  String.t(),
  Spectre.GAM.HostProfile.t()
) ::
  {:ok, map()} | {:error, term()}
```

Links a HostProfile revision to its predecessor and governance Act, without proving deployment isolation.

# `mandate_restricted`

```elixir
@spec mandate_restricted(Spectre.GAM.Act.t(), String.t(), Spectre.GAM.Mandate.t()) ::
  {:ok, map()} | {:error, term()}
```

Links a subtractive Mandate successor to its predecessor and governance Act.

# `mandate_revoked`

```elixir
@spec mandate_revoked(Spectre.GAM.Act.t(), String.t()) ::
  {:ok, map()} | {:error, term()}
```

Binds revocation to the governance Act's effective time without changing past Acts or observations.

# `metadata`

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

Returns ledger metadata from an event decoded with `decode_entry/1`.

# `meter`

```elixir
@spec meter(:reserve | :settle | :release | :suspend, Spectre.GAM.Act.t()) ::
  {:ok, map()} | {:error, term()}
```

Encodes the Act's exact reservation movement; the fold verifies the permitted accounting transition.

# `meter_devolved`

```elixir
@spec meter_devolved(Spectre.GAM.Act.t(), String.t(), map()) ::
  {:ok, map()} | {:error, term()}
```

Encodes return of child allocation; ancestry and available quantity remain fold checks.

# `meter_duty_resolved`

```elixir
@spec meter_duty_resolved(
  Spectre.GAM.Act.t(),
  Spectre.GAM.Act.t(),
  Spectre.GAM.Duty.t(),
  :settle | :release,
  map()
) :: {:ok, map()} | {:error, term()}
```

Binds a Meter resolution to its cause, open Duty and disposition Act; does not authorize disposal.

# `meter_recontained`

```elixir
@spec meter_recontained(Spectre.GAM.Act.t(), Spectre.GAM.Outcome.t(), map(), map()) ::
  {:ok, map()} | {:error, term()}
```

Encodes recontainment and its deficit after Evidence contradicts a no-effect Outcome.

# `principal_registered`

```elixir
@spec principal_registered(Spectre.GAM.Act.t(), Spectre.GAM.Principal.t()) ::
  {:ok, map()} | {:error, term()}
```

Encodes Principal registration under an Act, not authentication or a new Mandate.

# `record`

```elixir
@spec record(
  atom(),
  struct()
) :: {:ok, map()} | {:error, term()}
```

Builds a canonical envelope for a typed Domain record.

# `scope_opened`

```elixir
@spec scope_opened(Spectre.GAM.Scope.Opening.t()) :: {:ok, map()} | {:error, term()}
```

Encodes a validated Scope opening; parent authority and promise semantics remain governed checks.

# `surface_revised`

```elixir
@spec surface_revised(Spectre.GAM.Act.t(), String.t(), Spectre.GAM.Surface.t()) ::
  {:ok, map()} | {:error, term()}
```

Links a Surface successor and its exact predecessor to the governance Act.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
