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 viaresolve(), satisfying theVariableResolverprotocol), and idempotency projections. Entity-backed roots hydrate through theNamespaceSourceat most once each and are cached for the namespace’s lifetime — includingNoneresults. Theenvelope,changed,tagandscheduleroots are served from the event itself and never touch the source;triggeris served from the bound trigger (seebound_to()) and is otherwise absent.envelopecarries the event’s own fields plus the payload underenvelope.data. The payload is fixed when the event is published, while an entity root reads that entity as it stands at evaluation time: on afile.uploadedevent,envelope.data.file_versionis the version that fired the trigger andfile.versionis the version the file is on when the condition runs. That payload field is optional onfile.uploaded,file.ingestedandfile.metadata_updated, and resolves toNoneon events published before the payload carried it; onlysession.file_addedalways carries it.Payload values are rendered as JSON, so a timestamp under
envelope.datais an ISO-8601 string whileenvelope.timeandschedule.scheduled_foraredatetimeobjects. Conditions compare the two forms alike; a template substitutes each in its own spelling (2026-08-27T09:00:00Zagainst2026-08-27 09:00:00+00:00).- Parameters:
source (NamespaceSource)
trigger (Optional[roboto.domain.triggers.record.TriggerRecord])
_records (Optional[dict[str, Optional[Mapping[str, Any]]]])
- 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.namethrough 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:
- get(path)#
Return the value at dotted
path(e.g.dataset.metadata.vehicle_id), orNone.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.
envelopeyields the event’s own fields, with the payload fixed at publish time underdata;changedyields the changeset’s put fields;tagyields{"added": [...], "removed": [...]};scheduleandtriggeryield the firing schedule and the bound trigger; any other root delegates to the cachedNamespaceSource.- Returns:
The record as a mapping, or
Nonewhen the source cannot resolve the root.- Return type:
Optional[Mapping[str, Any]]
- resolve(name)#
Return the string form of the value at
namefor template substitution, orNone.- Parameters:
name (str)
- Return type:
Optional[str]
- class roboto.domain.triggers.namespace.NamespaceSource#
Bases:
ProtocolLazily hydrates entity-backed namespace roots for an event.
- record_for_root(root, event)#
Load the entity for namespace
rootas a JSON-able mapping.- Parameters:
root (str) – The namespace root to hydrate (
"dataset","file","invocation","event", …). Never a delta or reserved root: the namespace servesenvelope,trigger,schedule,changedandtagitself.event (roboto.domain.platform_events.PlatformEvent) – The event whose subject identifies the entity to load.
- Returns:
The entity as a mapping, or
Nonewheneventcannot 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.