roboto.domain.triggers.namespace#

Module Contents#

roboto.domain.triggers.namespace.CHANGED_ROOT = 'changed'#

the metadata fields an update event put, keyed by field name.

Type:

Delta root

roboto.domain.triggers.namespace.ENVELOPE_ROOT = 'envelope'#

its id, source, subject, type, time, and org, plus the payload as published under data. Reserved: no event type may expose it as an entity root.

Type:

Namespace root served from the platform event’s own envelope

class roboto.domain.triggers.namespace.EventNamespace(event, source, *, trigger=None, _records=None)#

Resolves dotted variable paths against a platform event.

The one namespace with three consumers: condition evaluation (whole records via record()), target template substitution (single paths via resolve(), satisfying the VariableResolver protocol), and idempotency projections. Entity-backed roots hydrate through the NamespaceSource at most once each and are cached for the namespace’s lifetime — including None results. The envelope, changed, tag and schedule roots are served from the event itself and never touch the source; trigger is served from the bound trigger (see bound_to()) and is otherwise absent.

envelope carries the event’s own fields plus the payload under envelope.data. The payload is fixed when the event is published, while an entity root reads that entity as it stands at evaluation time: on a file.uploaded event, envelope.data.file_version is the version that fired the trigger and file.version is the version the file is on when the condition runs. That payload field is optional on file.uploaded, file.ingested and file.metadata_updated, and resolves to None on events published before the payload carried it; only session.file_added always carries it.

Payload values are rendered as JSON, so a timestamp under envelope.data is an ISO-8601 string while envelope.time and schedule.scheduled_for are datetime objects. Conditions compare the two forms alike; a template substitutes each in its own spelling (2026-08-27T09:00:00Z against 2026-08-27 09:00:00+00:00).

Parameters:
bound_to(trigger)#

A view of this namespace for one trigger, in which trigger.* resolves.

One namespace is shared across every trigger evaluated for an event so each entity hydrates once; the trigger being evaluated is per-trigger state, so it lives on a view rather than on the shared object. The view delegates every other root to the same hydration cache – reading dataset.name through it and through the parent costs one fetch in total.

Parameters:

trigger (roboto.domain.triggers.record.TriggerRecord) – The trigger whose templates and condition are being evaluated.

Return type:

EventNamespace

get(path)#

Return the value at dotted path (e.g. dataset.metadata.vehicle_id), or None.

The first path segment names the root; the rest walk nested mappings. Any missing segment yields None.

Parameters:

path (str)

Return type:

Any

record(root)#

Return the whole record for namespace root, hydrating it at most once.

Parameters:

root (str) – Namespace root to fetch. envelope yields the event’s own fields, with the payload fixed at publish time under data; changed yields the changeset’s put fields; tag yields {"added": [...], "removed": [...]}; schedule and trigger yield the firing schedule and the bound trigger; any other root delegates to the cached NamespaceSource.

Returns:

The record as a mapping, or None when the source cannot resolve the root.

Return type:

Optional[Mapping[str, Any]]

resolve(name)#

Return the string form of the value at name for template substitution, or None.

Parameters:

name (str)

Return type:

Optional[str]

class roboto.domain.triggers.namespace.NamespaceSource#

Bases: Protocol

Lazily hydrates entity-backed namespace roots for an event.

record_for_root(root, event)#

Load the entity for namespace root as a JSON-able mapping.

Parameters:
  • root (str) – The namespace root to hydrate ("dataset", "file", "invocation", "event", …). Never a delta or reserved root: the namespace serves envelope, trigger, schedule, changed and tag itself.

  • event (roboto.domain.platform_events.PlatformEvent) – The event whose subject identifies the entity to load.

Returns:

The entity as a mapping, or None when event cannot resolve it (no such root for this event type, or the entity was deleted between emit and evaluation).

Return type:

Optional[Mapping[str, Any]]

roboto.domain.triggers.namespace.TAG_ROOT = 'tag'#

the tags an event added and removed.

Type:

Delta root

roboto.domain.triggers.namespace.TRIGGER_ROOT = 'trigger'#

Namespace root describing the trigger being evaluated. Reserved for the consumer; no event type may expose it as an entity root.