---
sidebar:
  hidden: true
title: roboto.domain.triggers.namespace
---
## Module Contents

- [ENVELOPE_ROOT](/docs/reference/python-sdk/roboto/domain/platform_events/catalog#roboto.domain.platform_events.catalog.ENVELOPE_ROOT) (data): `ENVELOPE_ROOT = 'envelope'`. Root of the trigger condition and template fields that read the platform event itself.

- [TRIGGER_ROOT](/docs/reference/python-sdk/roboto/domain/platform_events/catalog#roboto.domain.platform_events.catalog.TRIGGER_ROOT) (data): `TRIGGER_ROOT = 'trigger'`. Root of the trigger condition and template fields that read the trigger being evaluated.

### CHANGED_ROOT

```python
roboto.domain.triggers.namespace.CHANGED_ROOT = 'changed'
```

`from roboto.domain.triggers.namespace import CHANGED_ROOT`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/namespace.py#L19-L19)

Root of the trigger condition and template fields that read the metadata fields a metadata update set.

The fields are keyed by field name, with their new values.

### EventNamespace

```python
class roboto.domain.triggers.namespace.EventNamespace(
    event: roboto.domain.platform_events.PlatformEvent,
    source: NamespaceSource,
    *,
    trigger: Optional[roboto.domain.triggers.record.TriggerRecord] = None,
    _records: Optional[dict[str, Optional[Mapping[str, Any]]]] = None,
)
```

`from roboto.domain.triggers import EventNamespace`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/namespace.py#L87-L235)

Namespace of the values a trigger's condition and target templates read for one platform event, by dotted path.

Roboto builds one for each platform event it evaluates triggers on, and [`platform_event_sample()`](/docs/reference/python-sdk/roboto/domain/triggers/samples#roboto.domain.triggers.samples.platform_event_sample) builds one over sample records. A path such as `dataset.metadata.vehicle_id` starts with a root, which names a record, and continues through that record's nested mappings. A condition reads whole records with `record`, and a template reads single paths with `resolve`, which makes the namespace a [`VariableResolver`](/docs/reference/python-sdk/roboto/templating/substitution#roboto.templating.substitution.VariableResolver). The roots:

- `envelope`: the event's own fields, with its payload under `data`.
- `changed`: the metadata fields a metadata update set, with their new values. Empty for other events.
- `tag`: `{"added": [...], "removed": [...]}`, the tags the event added and removed.
- `schedule`: on a schedule firing, `scheduled_for`, plus `cron` on a namespace bound to a schedule trigger. `None` on other events.
- `trigger`: the trigger being evaluated, on a namespace from `bound_to`, and `None` otherwise.
- Any other root, such as `dataset` or `file`: the entity's record, fetched from `source` the first time it is read and kept for the namespace's lifetime, including a `None` result.

The payload is fixed when the event is published, while an entity root reads the entity as it stands when the trigger evaluates the event. On a [`FileUploaded`](/docs/reference/python-sdk/roboto/domain/platform_events/events#roboto.domain.platform_events.events.PlatformEventType.FileUploaded) platform event, `envelope.data.file_version` ([`file_version`](/docs/reference/python-sdk/roboto/domain/platform_events/events#roboto.domain.platform_events.events.FileUploadedPayload.file_version)) is the version that fired the trigger and `file.version` is the file's version when the condition runs.

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.datetime` objects. A condition compares either form as an instant. A template substitutes each in its own form: `2026-08-27T09:00:00Z` for the string, `2026-08-27 09:00:00+00:00` for the datetime.

**Parameters**

- **event** (`roboto.domain.platform_events.PlatformEvent`): Platform event whose values the namespace serves.
- **source** (`NamespaceSource`): Loader of the entity roots' records. The namespace calls it at most once per root.
- **trigger** (`Optional[roboto.domain.triggers.record.TriggerRecord]`): Trigger being evaluated, which the `trigger` root reads. `None` leaves that root `None`. Prefer `bound_to`, which shares the fetched records with the namespace it is called on.
- **`_records`** (`Optional[dict[str, Optional[Mapping[str, Any]]]]`)

#### EventNamespace.bound_to()

```python
def bound_to(trigger: roboto.domain.triggers.record.TriggerRecord) -> EventNamespace
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/namespace.py#L137-L146)

Return a namespace for the same event in which the `trigger` root reads `trigger`.

The returned namespace shares this one's fetched records: reading `dataset.name` through both fetches the dataset once. Binding every trigger subscribed to an event from one namespace fetches each entity once.

**Parameters**

- **trigger** (`roboto.domain.triggers.record.TriggerRecord`): Trigger whose condition and targets are being evaluated.

**Returns**

- `EventNamespace`

#### EventNamespace.get()

```python
def get(path: str) -> Any
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/namespace.py#L178-L191)

Return the value at a dotted path such as `dataset.metadata.vehicle_id`, or `None` if it is missing.

**Parameters**

- **path** (`str`): Root, optionally followed by keys of nested mappings, joined by dots. A root alone returns its whole record.

**Returns**

- `Any`

#### EventNamespace.record()

```python
def record(root: str) -> Optional[Mapping[str, Any]]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/namespace.py#L148-L176)

Return the record `root` names, fetching an entity's record from the source at most once.

**Parameters**

- **root** (`str`): Root to read, such as `"envelope"`, `"changed"` or `"dataset"`. The class docstring lists what each root holds.

**Returns**

- `Optional[Mapping[str, Any]]`: The record, or `None` when the root does not resolve: the source has no record for it, a `schedule` root on an event that is not a schedule firing, or a `trigger` root on a namespace not from `bound_to`.

#### EventNamespace.resolve()

```python
def resolve(name: str) -> Optional[str]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/namespace.py#L193-L200)

Return the value at dotted path `name` as a string, for a `{{name}}` template placeholder.

**Parameters**

- **name** (`str`)

**Returns**

- `Optional[str]`: `str()` of the value, or `None` if the path does not resolve.

### NamespaceSource

```python
class roboto.domain.triggers.namespace.NamespaceSource
```

`from roboto.domain.triggers import NamespaceSource`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/namespace.py#L64-L84)

Bases: `Protocol`

Loader of the entity records a platform event's roots name, such as `dataset` and `file`.

`EventNamespace` calls it the first time a condition or template reads such a root. Roboto supplies one that reads Roboto's records, and [`SampleNamespaceSource`](/docs/reference/python-sdk/roboto/domain/triggers/samples#roboto.domain.triggers.samples.SampleNamespaceSource) serves sample records.

#### NamespaceSource.record_for_root()

```python
def record_for_root(
    root: str,
    event: roboto.domain.platform_events.PlatformEvent,
) -> Optional[Mapping[str, Any]]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/namespace.py#L71-L84)

Load the record of the entity `root` names for `event`, as a mapping of JSON-compatible values.

**Parameters**

- **root** (`str`): Root to load, such as `"dataset"`, `"file"`, `"invocation"` or `"event"`. Never `envelope`, `trigger`, `schedule`, `changed` or `tag`, which `EventNamespace` reads from the event or the trigger itself.
- **event** (`roboto.domain.platform_events.PlatformEvent`): Platform event whose payload identifies the entity.

**Returns**

- `Optional[Mapping[str, Any]]`: The entity's record, or `None` when the event type has no such root or the entity was deleted between the event and its evaluation.

### TAG_ROOT

```python
roboto.domain.triggers.namespace.TAG_ROOT = 'tag'
```

`from roboto.domain.triggers.namespace import TAG_ROOT`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/namespace.py#L25-L25)

Root of the trigger condition and template fields that read the tags a platform event added and removed.

The tags are given as `{"added": [...], "removed": [...]}`. Both lists are empty for an event that changed no tags.

### session_event_root()

```python
def roboto.domain.triggers.namespace.session_event_root(
    record: roboto.experimental.events.EventRecord,
) -> dict[str, Any]
```

`from roboto.domain.triggers import session_event_root`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/namespace.py#L39-L60)

Build the `event` root a trigger reads when an event is created on a session.

Roboto calls this when a trigger's condition or target templates read the `event` root of a [`SessionEventCreated`](/docs/reference/python-sdk/roboto/domain/platform_events/events#roboto.domain.platform_events.events.PlatformEventType.SessionEventCreated) platform event. [`platform_event_sample()`](/docs/reference/python-sdk/roboto/domain/triggers/samples#roboto.domain.triggers.samples.platform_event_sample) builds that platform event's sample through it, so most code never calls it. The root holds the event's record, plus the names and IDs of the topics the event is about as `topic_names` and `topic_ids`. A condition walks only nested mappings, so it cannot read into the record's `topics` list; the two flat lists let `event.topic_names CONTAINS "/imu"` match an event about `/imu`. Both are empty for an event about all of its session's data.

**Parameters**

- **record** (`roboto.experimental.events.EventRecord`): Record of the event, a `roboto.experimental.events.EventRecord`.

**Returns**

- `dict[str, Any]`: The root, as a dictionary of JSON-compatible values.
