Rules: CEL, the dialect seam and System One
ptone chose CEL as the rule engine (D4), with friendlier forms and GitHub presets layered on top that compile down to CEL. Later the same day (2026-11-14) he widened it to “one rule engine, two dialects”: CEL first, and a model-backed System One dialect owned by the System One workstream. Triggers owns the seam; System One owns its dialect.
system_one dialect is registered, but no trigger can use it yet: Stage 1 accepts only cel in rule slots.How a trigger rule is evaluated
- Event types (required, 1–16 entries, exact or
prefix.*). A rule cannot match “everything”. Candidates are loaded per (project, source) and filtered by type. - Match rules (optional; since 2026-11-17 an ordered list of 1–8 elements, each
{dialect, expr}, ≤ 4 KiB each, ≤ 16 KiB in total). Elements are evaluated in the author’s order and AND’d, stopping at the first that does not match; the fire records how far it got (matched_through). Each element is compiled at authoring with positioned errors and cached per revision; a single rule is a list of one. Empty means “all events of those types”. CLI: repeatable--where [dialect:]expror--where-file. Built in 3b-1 (ptone/scion#8234, scope ptone/scion#8257); designmixed-rule-arrays-design.md. - Subject rule (optional CEL, ≤ 1 KiB) overrides the source’s subject. Bad output falls back to the event subject.
The CEL environment: event.id, event.type, event.source.kind/id, event.subject, event.occurred_at, event.received_at, event.attributes (flat strings), event.payload (the bounded JSON body), trigger.id/name/project_id; Stage 3 adds event.lists (labels, assignees…). Example GitHub preset output:
event.attributes.command == 'review' && event.attributes.is_pull_request == 'true' && event.attributes.sender_type != 'Bot'
Failures are never turned into “no match”: an evaluation error records the fire as skipped "rule evaluation failed", and each event has a 1 s total CEL budget across its candidate rules.
Types as an indexed SQL prefilter. The Stage 1 design (§7.3) deliberately filters types in Go after the per-source SQL query (at most 50 candidates). The plan relied on RE2 semantics for regex safety; after code review found repeated limit escapes through regex, ptone chose literal-only regex patterns (option A, 2026-11-15). One table row in the Stage 1 design (§7.2) still mentions sender-supplied patterns.System One as a second dialect
System One provides fast, model-backed semantic decisions for message admission and routing, trigger filters and routes, and later features. Its first provider is TypeSafe. For triggers, the seam sets these constraints on any non-CEL dialect (Stage 1 design §7.0a, plan §3.7 amendment):
- Bounded evaluation within the drainer lease.
- Uncertain and failed are distinct errors, and both become
skipped, never a silent match. - No access to endpoint secrets or other material.
- A route decision may only pick from a closed candidate set the rule author declared.
- Side-effect-free, or idempotent on
event_id. - A dialect decision never grants authority: the fire still runs as the recorded principal.
| Shared by CEL, Triggers and System One | System One only |
|---|---|
|
|
Two meanings of “admission”: dialect admission (merged, GoogleCloudPlatform/scion#4945) decides which consumer may use which dialect; System One’s runtime admission is capacity control (semaphores and a token bucket) inside the dialect.
Trigger track of System One: T1 a CEL route slot; T2 semantic trigger filters (ptone/scion#8051, prerequisite P2 ptone/scion#8045); T3 a System One route. Since 2026-11-17, T2 is a system_one element inside the ordered rule list (typically after cheap CEL guards). ptone’s v1 defaults (18:00Z): the per-project instance allow-list is empty everywhere, with explicit opt-in; only users, not agents, may author System One elements. Which project and author may use which instance, and what content may leave the hub, is still design work owned by system-one-mode. Nothing of T1–T3 is built yet.
skipped with the deciding element.