roboto.query.filters
Filter controls as a user built them, in a form that survives being saved.
A SavedFilters records what someone expressed in a filter UI — which field, which operator, which values — rather than the query that expression compiles to. Saved Views hold this, and rebuild an executable query from it on load.
Why this exists rather than a QuerySpecification. A query cannot be stored faithfully today, because Comparator has no way to say “the last 7 days”, “between these two dates”, or “any of these three”. Those get flattened at translation time — a relative window resolves to fixed instants, a range becomes two comparisons, a multi-select becomes an OR group — and the flattening has no inverse. A View storing the translated query would show the week it was saved, forever, presented as though it were live.
FilterOnlyComparator lists exactly what Comparator cannot express. Members leave it as Comparator grows to cover them; when it is empty, a saved filter is expressible as a plain QuerySpecification.
On the per-variant comparator lists below. They state what a filter control offers for a field type, which is narrower than what the query language accepts for the same field: a date filter presents <, > and BETWEEN where a query supports all six ordering and equality operators, and a boolean filter presents EQUALS alone.
Module Contents
BooleanFilter
Bases: _FilterBase
True or false, or unset.
Parameters
data AnyAttributes
BooleanFilter.comparator
BooleanFilter.type
BooleanFilter.values
DateFilter
Bases: _FilterBase
Instants and ranges. Values are ISO 8601 strings.
The only variant offering relative windows, which is where the fidelity problem this whole model exists for actually bites.
Parameters
data AnyAttributes
DateFilter.comparator
comparator Literal[roboto.DateFilter.type
DateFilter.values
EnumFilter
Bases: _FilterBase
Equality against a closed set of options.
Parameters
data AnyAttributes
EnumFilter.comparator
EnumFilter.type
EnumFilter.values
FILTER_VARIANTS
Every filter variant, keyed by its type discriminant.
Filter
One filter row. type selects the variant, and with it the operators on offer.
FilterMatchMode
FilterOnlyComparator
Bases: roboto.compat.StrEnum
Operators a saved filter needs that Comparator cannot express.
Every member is a gap in the query language, and this enum is the list of them. It is the complement of Comparator, never a superset: a member here that Comparator can express is a stale entry.
Members are removed one at a time as Comparator grows to cover them. The wire values do not change when that happens, so filters saved beforehand keep parsing.
Attributes
FilterOnlyComparator.Between
An inclusive range. Translates to GTE and LTE, which loses the fact that the author expressed one range rather than two independent bounds.
FilterOnlyComparator.Last24Hours
FilterOnlyComparator.Last30Days
FilterOnlyComparator.Last3Hours
FilterOnlyComparator.Last7Days
FilterOnlyComparator.Last8Hours
FilterOnlyComparator.Last90Days
FilterOnlyComparator.ThisMonth
Relative windows, resolved against “now” when the filter runs.
These are the members that matter. The others cost fidelity; these cost correctness — a resolved window is wrong the day after it is saved, and nothing about the stored value says so.
FilterOnlyComparator.Today
IDENTITY_OPERATORS_BY_TYPE
Which operators each principal type contributes, and the only statement of that pairing.
Exhaustive over RobotoPrincipalType rather than listing the types an audit column happens to hold today, so a new platform principal type is filterable as soon as it exists instead of being silently unaddressable. A test pins that.
IDENTITY_PRESET_COMPARATORS
The IS_ANY_<TYPE> half. Valueless: the comparator alone carries the predicate.
IDENTITY_TYPES_BY_COMPARATOR
The principal type each identity operator addresses. Derived from the pairing above.
IdentityComparator
Bases: roboto.compat.StrEnum
Operators over a principal-valued field, where the operator names a principal type.
An audit column such as created_by stores a fully-qualified principal — user:<user_id>, device:<device_id>@<org_id>, invocation:<invocation_id> — so “created by a user” is a question about the type prefix and “created by this user” a question about the whole value. Putting the type in the operator is what lets a filter UI offer the matching directory to pick from, instead of asking for a hand-typed prefix.
Each type contributes two operators (see IDENTITY_OPERATORS_BY_TYPE): a value-bearing IS_<TYPE> and a valueless IS_ANY_<TYPE>.
Separate from FilterOnlyComparator because these are not gaps in the query language. Both halves are expressible as a query today — IS_<TYPE> as EQUALS against each picked principal, IS_ANY_<TYPE> as LIKE '<type>:%' — so they are never removed. They are a filter-control affordance, and they outlive the gap enum.
Attributes
IdentityComparator.IsAnyDevice
IdentityComparator.IsAnyIntegration
IdentityComparator.IsAnyInvocation
IdentityComparator.IsAnyOrg
IdentityComparator.IsAnyUser
IdentityComparator.IsDevice
IdentityComparator.IsIntegration
IdentityComparator.IsInvocation
IdentityComparator.IsOrg
IdentityComparator.IsUser
IdentityFilter
Bases: _FilterBase
A principal-valued field, filtered by principal type.
Audit columns (created_by, modified_by) hold a fully-qualified principal string, so the operator names the type (IdentityComparator) and any values it takes are principals of that type — an IS_USER filter carrying a device: value is rejected, since it records an intent the picker cannot express and a query cannot satisfy.
Values are labeled options rather than bare strings: a principal id is not a name a reader can place, so the directory’s display name is captured alongside it at pick time.
Has no presence axis. Every write path stamps an audit principal, so the column is never null and a null check would be an operator that always answers the same way.
Parameters
data AnyAttributes
IdentityFilter.comparator
IdentityFilter.type
IdentityFilter.values
IdentityOperators
Bases: NamedTuple
The operator pair one principal type contributes to an identity field’s menu.
Attributes
LabeledOption
Bases: pydantic.BaseModel
One option as it was picked: the value a query is built from, plus what the picker showed.
Both halves are stored because the label cannot be recovered later. An opaque value — user:usr_01J..., a tag id — renders as itself, and resolving it on load would mean a directory lookup per chip, against an org that whoever opens a shared View may not be able to read. Only value ever reaches a query.
Parameters
data AnyAttributes
LabeledOption.label
What the picker displayed when the author chose this option. Display only, never queried.
LabeledOption.model_config
model_config #Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
LabeledOption.value
What the query is built from. A fully-qualified principal, for an identity filter.
METRIC_FIELD_PATTERN
METRIC_FIELD_PREFIX
Prefix distinguishing a user-defined metric from an ordinary numeric property.
Metric filters store the prefixed form so that field means the same thing here as it does in a Condition, and translating a filter into a query copies the field across rather than special-casing it.
MetricField
A metric’s dot-delimited path, carrying its metric. prefix.
MetricFilter
Bases: _FilterBase
Ordering and equality over a user-defined metric.
Numeric in every respect except that field is a metric path. Kept a distinct variant so a client restoring a View knows to reopen the metric picker rather than the property form, which it cannot infer from the field name alone.
Carries the presence pair like any other scalar type. A session may simply have no such metric recorded, and the session query path answers that directly — it maps IS_NULL to a NOT EXISTS over the metrics table.
Parameters
data AnyAttributes
MetricFilter.comparator
comparator Literal[roboto.MetricFilter.type
MetricFilter.unit
The metric’s unit, copied from its definition when the filter was built.
Denormalized for display: the filter chip renders it beside the value (“path_deviation > 1.5 m”) without looking the definition up. None when the definition declares no unit.
Being a copy, it goes stale if the definition’s unit later changes: a saved View renders the unit the filter was built with, not the current one.
MetricFilter.values
NumericFilter
Bases: _FilterBase
Ordering and equality over a numeric property.
Parameters
data AnyAttributes
NumericFilter.comparator
comparator Literal[roboto.NumericFilter.type
NumericFilter.values
PRESENCE_COMPARATORS
Null checks. Valueless: the comparator alone carries the question.
PRESET_COMPARATORS
Relative windows. Valueless: the comparator alone carries the range.
SavedFilters
Bases: pydantic.BaseModel
A complete set of filter controls, as saved.
Parameters
data AnyAttributes
SavedFilters.match_mode
Whether the rows are combined with AND or OR.
Deliberately a single flag rather than a nested boolean expression. A Condition can express arbitrary nesting, but a filter UI cannot build one legibly, so this records the shape the UI actually offers.
SavedFilters.model_config
model_config #Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
SetFilter
Bases: _FilterBase
Membership in a collection-valued field, such as tags.
Has no presence axis: an empty collection is not the same as an absent one, and the UI offers no null check here.
Parameters
data AnyAttributes
SetFilter.comparator
comparator Literal[roboto.SetFilter.type
SetFilter.values
StringFilter
Bases: _FilterBase
Text matching.
Parameters
data AnyAttributes
StringFilter.comparator
comparator Literal[roboto.StringFilter.type
StringFilter.values
comparators_by_type()
The operators each filter type offers, as wire values.
Derived from the models rather than restated, so it cannot fall out of step with what they actually accept. Two callers: anything building a filter that needs to know what is valid for a field type, and the drift check against the filter UI’s own copy of this vocabulary — there is no code generation between the two, so a test compares them.
Return type