From 599c588b21ef1194bc530cea3dfa8021707ad350 Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 02:10:34 +0200 Subject: [PATCH 01/23] =?UTF-8?q?docs(rfc-0002):=20specify=20the=20query?= =?UTF-8?q?=20DSL=20=E2=80=94=20Branch=20B,=20surface=20=CE=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves the §3 prior decision (distance from OTTL) on the β (pipe-composable) surface, per the audience analysis (primary: Perses dashboard authors; future: MCP agents) — §3.5/§3.6. Advances RFC 0002 drafted → specified. Adds the design (§6): Branch-B predicate grammar over the OTel data model (bare top-level fields, resource./attr. prefixes, bare-identifier severity), first-class OTel-canonical fields (service/trace_id/span_id/ scope) + template primitives, the β pipe surface, and the two-front-ends- one-core model (string DSL for humans + a structured JSON surface for MCP agents, both compiling to one IR → DataFusion LogicalPlan, no SQL leakage). Adds the owned EBNF grammar (§7), 11 greppable RFC0002.x acceptance criteria (§5), the testing strategy (§8), and narrows the open questions (§9) — surface, severity casing, agent-friendliness, and first-class fields now resolved. The RFC 0007 execution layer this DSL targets is already green; this is the user-facing language in front of it. Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 976 +++++++++++++++++------------------- 1 file changed, 470 insertions(+), 506 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index cfd21d6b9..843d12256 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -1,7 +1,7 @@ --- rfc: 0002 -title: Query DSL — prior decision (borrow from OTTL or distance?) and candidate designs -status: drafted +title: Query DSL — the Ourios logs query language (Branch B, surface β) +status: specified author: Jens Holdgaard Pedersen drafting-assistance: Claude created: 2026-04-24 @@ -11,546 +11,510 @@ superseded-by: — # RFC 0002 — Query DSL -> **Status note.** This RFC presents a decision tree, not a finished -> answer. The DSL surface depends on user research we have not done -> yet (§9) and on a prior decision (§3) that has been raised but not -> resolved. The RFC cannot flip to `accepted` until §3 is decided and -> §4–§5 are narrowed to a single branch. Hazard 6 (`CLAUDE.md` §4) — -> no DataFusion leakage — constrains every branch equally. +> **Status note.** The prior decision (§3) is **resolved**: the predicate +> sublanguage takes **Branch B** (distance from OTTL), on the +> **β** (pipe-composable) top-level surface. Decided 2026-06-07 from the +> audience analysis in §3.6 (primary: Perses dashboard authors; future: +> MCP agents). This RFC is now `specified` — §6 gives the design, §7 the +> grammar, §5 the testable acceptance criteria. It advances to `red` → +> `green` as the parser/compiler lands (the RFC 0007 execution layer it +> targets is already green), and to `accepted` after the §9 validation. +> Hazard 6 (`CLAUDE.md` §4.6 — no DataFusion/SQL leakage) constrains the +> whole design. ## 1. Summary -Ourios exposes a logs DSL. The shape of that DSL depends on a prior -decision, which this RFC deliberately does **not** pre-commit: - -- **Branch A** — borrow from OTTL for the predicate sublanguage, - track a pinned spec version, enumerate divergences. -- **Branch B** — actively distance from OTTL; use the OTel *data - model* (unavoidable — it is the ingest contract) but with an - Ourios-native path and predicate syntax designed for query - readability rather than Collector transformation. - -Both branches share the same top-level query surface (one of three -candidates in §5.3), the same template and correctness primitives -(§5.4), and the same compilation target (§5.5 — DataFusion -`LogicalPlan`, no SQL leakage). The difference lives in one layer: -how paths and predicates are written. - -Section 3 lays out the cases for each branch. Section 5 sketches -both designs concretely enough to compare side by side. Section 9 -lists the prior decision as the first open question. +Ourios exposes a logs query DSL that does **not** leak DataFusion/SQL to +users (hazard `CLAUDE.md` §4.6). This RFC specifies it: + +- **Predicate sublanguage — Branch B (distance from OTTL).** An + Ourios-native, query-ergonomic syntax over the OTel *data model* (the + ingest contract): bare top-level fields (`body`, `severity`, + `trace_id`), `resource.` / `attr.` prefixes, bare-identifier severity + (`severity >= error`), first-class template + OTel-canonical primitives. +- **Top-level surface — β (pipe-composable).** A predicate followed by + pipe stages: `… | range(-1h, now) | count by template_id | sort count + desc | limit 10`. Compact, single-line, and embeddable as a YAML scalar + in Perses dashboards. +- **Two front-ends, one core.** The string DSL (for humans, esp. Perses + YAML) and a **structured JSON surface** (for MCP agents + programmatic + clients) parse to the same query IR and compile to the same DataFusion + `LogicalPlan`. Agents emit JSON, not syntax. + +The design rests on `ourios-querier` (RFC 0007), whose execution layer +(predicate pushdown, tenant isolation, `QueryStats`) is already `green`; +this RFC adds the *user-facing language* in front of it. ## 2. Motivation ### 2.1 Why a DSL at all? -`CLAUDE.md` §4 hazard 6 commits Ourios to a DSL that does not leak -DataFusion SQL through to users. The reasons are stability (we want -to evolve the backend without breaking user queries), safety (full -SQL exposes a surface area we cannot audit — arbitrary joins across -tenants, resource-exhausting scans), and *fit* (logs are a narrow -domain; a narrow DSL is more ergonomic than a general one). - -This motivation is branch-agnostic. Whether we borrow from OTTL or -not, we ship a DSL. - -### 2.2 Why the prior decision matters - -"OTTL-inspired" sounds like a free decision — borrow the ergonomics, -skip the parts that do not fit. It is not free. Borrowing OTTL -syntax in a query context makes a promise to OTTL-literate users -that their mental model will transfer. If the promise is kept, the -win is real for that user segment. If the promise is broken — if -OTTL syntax looks the same but behaves differently in a query -context — the surface actively misleads users who would have been -better off learning an unfamiliar DSL from scratch. The decision is -load-bearing enough to deserve its own section. - -## 3. The prior decision: borrow from OTTL, or distance from it? - -Both positions are defensible. This section writes both down -honestly. - -### 3.1 The case for borrowing (Branch A) - -- **Positive transfer for the highest-leverage user segment.** SREs - and platform engineers who write Collector processor pipelines - already think in OTTL paths and predicates. Reusing that mental - model in the query context is zero-onboarding for them. -- **Reduces bikeshed surface.** Adopting a pinned external - specification cuts off a whole class of "why did we pick this - syntax" debates. Decisions are inherited, not re-litigated. -- **Ecosystem alignment.** A project in the OTel orbit that - gratuitously diverges on surface syntax looks politically odd and - costs us contribution mindshare we do not need to spend. -- **OTTL's path grammar is near-minimal.** The OTel data model is - the ingest contract, so we must address it anyway. OTTL's - `resource.attributes["service.name"]` form is verbose, but it is - *correct* about the data model, and any alternative has to answer - the same disambiguation questions. - -### 3.2 The case for distancing (Branch B) - -- **The OTTL-literate population is smaller than "OTLP users."** - The subset of OTLP users who write Collector configs is a - minority. Most developers emit logs via an SDK and never touch - OTTL. The familiarity-transfer argument applies to a narrower - segment than §3.1 implies. -- **OTTL's Collector ergonomics become query verbosity.** - `resource.attributes["service.name"] == "api"` is readable in a - Collector processor config (where record-typing is explicit) and - is unnecessarily loud in a query (where the user is asking a - question about logs, not configuring a pipeline). Branch B can - collapse this to `resource.service.name == "api"` or similar. -- **Shared syntax plus different semantics actively misleads.** A - user who sees OTTL syntax reasonably expects OTTL semantics — - batch mutation, pipeline forwarding. Query semantics are - different. The safer failure mode is unfamiliar syntax than - almost-familiar-but-not-quite syntax. -- **Maintenance burden of tracking an evolving spec.** OTTL's - grammar has had breaking changes in the Collector-contrib - repository. Pinning a version helps, but every time we revisit - the pin we pay a review cost that we avoid if we never opted into - the commitment. -- **Design freedom for the query context.** A distanced DSL can use - bare-identifier severity (`severity >= error`), short prefixes - (`attr.foo`), and other idioms that are tuned for typing speed - and readability in the query context — which is where the DSL - will actually live. - -### 3.3 What the branches have in common - -Whichever branch wins, the following remain unchanged: - -- The OTel *data model* is the schema of log records. We address - attributes, resources, severity, body, timestamps, trace context. - This is the ingest contract, not a design choice. -- The top-level query surface (projection, aggregation, sort, - limit, time ranges) is Ourios-specific and designed against - LogQL/Insights idioms. See §5.3. -- Template primitives (`template_id`, `confidence`, etc.) are - first-class in both branches. See §5.4. -- Compilation target is DataFusion logical plans, with no SQL - leakage. See §5.5. - -### 3.4 Consequences of each branch +`CLAUDE.md` §4.6 commits Ourios to a DSL that does not leak DataFusion SQL. +The reasons are **stability** (evolve the backend without breaking user +queries), **safety** (full SQL exposes cross-tenant joins, unbounded +scans, recursive CTEs we cannot audit), and **fit** (logs are a narrow +domain; a narrow DSL is more ergonomic than a general one). This is +branch-agnostic. + +### 2.2 Why the prior decision mattered + +"OTTL-inspired" was not a free decision. Borrowing OTTL syntax in a query +context promises OTTL-literate users that their mental model transfers; if +the syntax looks the same but behaves differently (OTTL mutates; a query +filters), the surface actively misleads. §3 records how that decision was +made. + +## 3. The prior decision (resolved): distance from OTTL + +Both positions were defensible; §3.1–3.4 keep the honest case for each for +the record. §3.5 records the resolution; §3.6 the reasoning. + +### 3.1 The case for borrowing (Branch A) — not chosen + +- **Positive transfer for Collector-literate SREs.** Engineers who write + Collector/OTTL pipelines reuse that mental model at zero onboarding. +- **Reduces bikeshed surface.** A pinned external spec inherits decisions + rather than re-litigating them. +- **Ecosystem alignment.** Diverging on surface syntax in the OTel orbit + can read as gratuitous. +- **OTTL's path grammar is correct about the data model**, which any + alternative must address anyway. + +### 3.2 The case for distancing (Branch B) — chosen + +- **The OTTL-literate population is a minority of OTLP users** — most emit + logs via an SDK and never touch OTTL. +- **Collector ergonomics become query verbosity.** + `resource.attributes["service.name"] == "api"` is loud in a query. +- **Shared syntax + different semantics misleads.** Unfamiliar syntax is a + safer failure mode than almost-familiar-but-wrong. +- **No evolving external spec to track** (OTTL has had breaking changes). +- **Design freedom** for query-context idioms (`severity >= error`, + `attr.foo`). + +### 3.3 What is shared regardless of branch + +- The OTel **data model** is the schema of log records (the ingest + contract, not a design choice): attributes, resources, severity, body, + timestamps, trace context. +- The **template + correctness primitives** (`template_id`, `confidence`, + `lossy`, `drift`) are first-class (§6.3). +- The **compilation target** is a DataFusion `LogicalPlan`, no SQL leakage + (§6.5). + +### 3.4 Consequences | Dimension | Branch A (borrow) | Branch B (distance) | |---|---|---| | Onboarding for Collector-literate SREs | Near-zero | Mild (new syntax, familiar semantics) | -| Onboarding for SDK users | Same in both (OTel data model) | Same | -| Maintenance cost | Track pinned OTTL version, amend on bumps | Own every syntactic decision | -| Risk of semantic confusion (same-syntax, different-meaning) | Real | Avoided | -| Size of the spec we maintain | Smaller (borrow) | Larger (own) | -| Ecosystem signalling | Aligned with OTel | Independent | -| Design freedom | Constrained by OTTL | Unconstrained within OTel data model | - -### 3.5 Status: unresolved - -This RFC cannot recommend either branch without user research -(§9) and non-author review. Both branches are sketched in §5 in -enough detail for side-by-side comparison. Reviewers: pick one, or -push back on both and propose a third. +| Onboarding for SDK / dashboard users | Same (OTel data model) | Same | +| Maintenance cost | Track pinned OTTL, amend on bumps | Own the grammar | +| Same-syntax/different-meaning confusion | Real | Avoided | +| Spec size | Smaller | Larger (owned) | +| Ecosystem signalling | Aligned with OTel | Independent (in the data model: still aligned) | +| Design freedom | Constrained by OTTL | Free within the OTel data model | + +### 3.5 Resolution + +**Branch B (distance from OTTL), surface β (pipe-composable).** Decided +2026-06-07 by the maintainer, on the audience analysis in §3.6 in lieu of +the formal user research originally gated here (§9 now scopes that +research to the `accepted` gate, not `specified`). + +### 3.6 Why — the two audiences + +The decision turns on two audiences that re-weight §3.1–3.4: + +1. **Primary — Perses dashboard authors (declarative YAML/CRDs).** Queries + live as **string scalars in versioned YAML**. Brevity and low + bracket/quote density win (readable scalars, clean diffs); the audience + thinks in *dashboard* query languages (PromQL/LogQL), not OTTL. Branch + B's flat syntax + the β pipe surface embed cleanly on one line; Branch A + on surface α would be multi-line and bracket-heavy. +2. **Future — MCP agents.** Borrow-but-diverge (Branch A + the §6 + divergence list it required) is the **worst case for LLMs**: strong + public-OTTL priors pull a model toward real-OTTL constructs we do not + support → plausible-but-invalid queries. A small, self-owned grammar + (Branch B) has no priors to fight, is cheaper to embed in an MCP tool + schema, and is enforceable with grammar-constrained decoding. And — + decisively — agents need not generate syntax at all: they target the + **structured surface** (§6.4). + +The one strong case for Branch A (onboarding + signalling for +Collector-literate SREs) lands on the audience that is *not* primary here, +while its costs (semantic-confusion in the overlap zone; an +externally-driven breaking cadence against long-lived dashboards + cached +agent schemas) land squarely on these two. Distancing on *surface syntax* +costs little ecosystem goodwill because we stay faithful to the OTel +**data model** (§3.3) and because bespoke query syntax is the norm (LogQL, +PromQL, CloudWatch Insights all diverge from any transformation language). + +The full audience analysis is the drafting-assistance recommendation that +informed this decision; its three OTel-ecosystem questions (is there an +OTel *query* language to align with? is OTTL the expected *querying* +surface? Perses+OTel query conventions?) are folded into §9. ## 4. Design principles -These rails apply to both branches. - -1. **Familiarity beats cleverness.** A user who reads an Ourios - query for the first time should understand what it does within - 30 seconds, without reading a reference. Rules out - heavily-sigil'd and overly abstract forms. -2. **No DataFusion leakage.** Hazard 6. If a surface form forces us - to say "it's the DataFusion X" to explain it, the form is wrong. -3. **Strict separation of predicate from projection from - aggregation.** A query has a clear *where*, a clear *return*, - and a clear *roll-up*. Users should be able to read these - sections independently. -4. **Template primitives are first-class.** `template_id`, - `template_version`, `drift`, `confidence`, `lossy_flag` are - vocabulary, not pseudo-columns. -5. **Every query has a time range, explicitly or by default.** An - unbounded query is a footgun. Missing a `range` clause implies a - tenant-configurable default window, never an infinite scan. -6. **Compatibility pledges are written, not implied.** If Branch A - wins, "OTTL-compatible predicates" is pinned to a specific spec - version with an enumerated divergence list. If Branch B wins, we - own our grammar explicitly and version it ourselves. "Inspired - by" without a pledge is marketing. - -## 5. Proposed designs (two branches) - -### 5.1 Predicate sublanguage — Branch A (borrow from OTTL) - -Predicate expressions and path access follow **OTTL specification -v1.x** (version to be pinned when this RFC freezes) for: - -- Path syntax into the OTel log record: - `resource.attributes["service.name"]`, `attributes["http.method"]`, - `body`, `severity_number`, `severity_text`, - `instrumentation_scope.name`, `trace_id`, `span_id`, `flags`, - `observed_timestamp`, `timestamp`. -- Boolean operators: `and`, `or`, `not`, grouping with parentheses. -- Comparison operators: `==`, `!=`, `<`, `<=`, `>`, `>=`, `=~` - (regex), `!=~` (regex negation). -- Literal forms: strings, numbers, booleans, nil, duration literals - (`1h`, `30s`), timestamp literals. -- Function calls: a *documented subset* of OTTL's function library: - `IsMatch`, `Contains`, `Len`, `Int`, `Double`, `String`. Mutation - functions (`set`, `delete`, etc.) are excluded — predicates do - not mutate. - -The RFC freezes the accepted subset at acceptance time. Future OTTL -spec versions are not automatically adopted; adoption requires an -amending RFC that enumerates the delta. - -**Worked predicate in Branch A**: - -``` -resource.attributes["service.name"] == "api" - and severity_number >= 17 - and attributes["http.status_code"] == 500 -``` - -**Divergences from OTTL (Branch A only)** — see §6 for the full -enumerated list. - -### 5.2 Predicate sublanguage — Branch B (distance from OTTL) - -An Ourios-native predicate grammar designed for query readability. -Still addresses the OTel data model — attributes, resources, -severity, body, timestamps, trace context — but with a syntax chosen -to minimise noise in the query context. - -- **Path syntax** into the OTel log record: - - Top-level fields are bare identifiers: `body`, `severity`, - `ts`, `trace_id`, `span_id`, `scope`. - - Resource attributes are prefixed with `resource.`: - `resource.service.name`, bracketed form - `resource["service.name"]` when the key contains characters - that are not valid bare identifiers. - - Log-record attributes are prefixed with `attr.`: - `attr.http.status_code`, bracketed form when needed. - - `severity` accepts either a bare severity identifier - (`severity >= error`, mapped to severity numbers by the OTel - severity-text convention) or a numeric form - (`severity >= 17`). -- **Boolean operators**: `and`, `or`, `not`. Aliases `&&`, `||`, - `!` accepted for terseness. -- **Comparison operators**: `==`, `!=`, `<`, `<=`, `>`, `>=`, - `=~`, `!=~`. Same as Branch A. -- **Literal forms**: same as Branch A. -- **Function calls**: a bespoke, named library designed for query - ergonomics. Initial set: `matches(path, regex)`, - `contains(path, substring)`, `len(path)`, `starts_with(path, s)`, - `ends_with(path, s)`. Named to match Rust-ecosystem naming - conventions, not OTTL's. - -**Worked predicate in Branch B** (same semantics as §5.1 example): - -``` -resource.service.name == "api" - and severity >= error - and attr.http.status_code == 500 -``` - -Notice: shorter by roughly a third, identifier-forward where -possible, no forced bracket-quoting for common attributes. - -**Trade-off realised**: Branch B is more readable; Branch A is more -transferable. The choice is exactly the one in §3. - -### 5.3 Top-level query surface — branch-agnostic - -Three candidate surfaces. This decision is separate from §3 — any -of A/B/C can sit on top of either predicate branch. - -#### Candidate α — SQL-ish, clause-structured +1. **Familiarity beats cleverness.** A first-time reader understands a + query within 30 seconds without a reference. No heavy sigils. +2. **No DataFusion/SQL leakage** (hazard §4.6). If explaining a surface + form requires naming a DataFusion type, the form is wrong. +3. **Predicate, then pipeline.** A query is a *predicate* (the `where`) + followed by ordered *stages* (range, aggregate, sort, limit, project). + Each reads independently. +4. **Template + OTel-canonical fields are first-class vocabulary**, not + pseudo-columns: `template_id`, `confidence`, `lossy`, `drift`; + `service`, `trace_id`, `span_id`, `scope` (the primary + correlation/query dimensions per OTel maintainer guidance, §6.2). +5. **Every query has a time range** — explicit `range(...)` or a + tenant-configurable default window. Never an unbounded scan. +6. **One core, two surfaces.** The string DSL and the structured surface + are equivalent front-ends over one IR (§6.4); neither can express a + query the other cannot. +7. **YAML-embeddable.** A query is expressible as a single-line scalar + that survives a YAML round-trip — a first-class constraint for the + Perses audience, not an afterthought. +8. **The grammar is owned and versioned by this RFC** (§7), not "inspired + by" anything. Compatibility pledges are written, not implied. + +## 5. Acceptance criteria + +> `Given/When/Then`, ids greppable from tests (`RFC0002.`, referenced +> verbatim in each test's leading doc comment). These specify the +> parser + compiler that front-ends the (already-green) RFC 0007 execution +> layer. + +- **RFC0002.1 — A Branch-B predicate parses and compiles to a pushdown filter `[§4.6]`** + - **Given** a Branch-B predicate (e.g. `service == "api" and severity >= error`) + - **When** it is parsed and compiled + - **Then** it yields the query IR and a DataFusion `Filter` whose + column predicates match those the RFC 0007 execution layer already + pushes down (`template_id`, `time_unix_nano`, `severity_text`, + `service.name`), and the result is identical to issuing the equivalent + `ourios_querier` structured request. + +- **RFC0002.2 — String DSL and structured surface compile to the same plan `[§6.4]`** + - **Given** a query expressed both as a β string and as the structured + JSON surface + - **When** both are compiled + - **Then** they produce the *same* query IR (and hence the same + `LogicalPlan`) — the one-core/two-surfaces invariant. + +- **RFC0002.3 — No DataFusion/arrow/SQL leakage `[§4.6]`** + - **Given** the public DSL API (parse, compile, error types) + - **When** a query parses, compiles, or fails + - **Then** no `datafusion`/`arrow`/SQL type or message appears in any + public signature or error string (compile- and string-level boundary + test, mirroring RFC0007.3). + +- **RFC0002.4 — A query without an explicit range gets the tenant default window `[§4.5]`** + - **Given** a query with no `range(...)` stage + - **When** it is compiled in a tenant context with a default window W + - **Then** the plan carries a time-column filter equal to W — never an + unbounded scan. + +- **RFC0002.5 — Bare-identifier severity maps by the OTel convention `[§6.1]`** + - **Given** `severity >= error` (and `warn`, `info`, `debug`, `trace`, + `fatal`) + - **When** compiled + - **Then** each maps to the correct OTel severity-number range, case- + insensitively, identically to the numeric form (`severity >= 17`). + +- **RFC0002.6 — First-class OTel-canonical fields resolve correctly `[§6.2]`** + - **Given** `service`, `trace_id`, `span_id`, `scope` used as bare + fields + - **When** compiled + - **Then** each resolves to the RFC 0001 §6.1 column / resource-attribute + it names (`service` → `resource["service.name"]`), with no + string-flattening required of the user. + +- **RFC0002.7 — Parse/serialise round-trip is idempotent** + - **Given** any well-formed query (property-generated) + - **When** parsed → serialised → parsed + - **Then** the second parse equals the first (AST idempotence). + +- **RFC0002.8 — A malformed query yields a specific, leak-free error** + - **Given** a syntactically or semantically invalid query + - **When** parsed/compiled + - **Then** it returns a specific error citing the offending + token/clause and the §7 grammar — never a panic, never a DataFusion + message. + +- **RFC0002.9 — Template primitives compile `[§6.3]`** + - **Given** `template_id == X`, `resolves_to(X)`, `lossy == true`, + `confidence < 0.7` + - **When** compiled + - **Then** each compiles to the documented plan (`resolves_to` expands + to the alias-set membership of RFC 0001 §6.7), without leaking the + underlying representation. + +- **RFC0002.10 — A query is a YAML-safe single-line scalar `[§4.7]`** + - **Given** the canonical serialisation of any well-formed query + - **When** embedded as a YAML scalar and round-tripped through a YAML + parser + - **Then** the recovered string parses to the same query (the Perses- + embedding guarantee). + +- **RFC0002.11 — The structured surface validates against its published schema `[§6.4]`** + - **Given** the structured (MCP) query surface + - **When** a request is validated against the published JSON schema + - **Then** well-formed requests pass and compile; malformed ones are + rejected by the schema before reaching the planner. + +## 6. Design + +### 6.1 Predicate sublanguage (Branch B) + +A predicate is a boolean expression over **paths**, **operators**, and +**literals** against the OTel log data model. + +**Paths.** + +- **Top-level fields** are bare identifiers: `body`, `severity`, `ts` + (event timestamp), `observed_ts`, `trace_id`, `span_id`, `scope` + (instrumentation-scope name), `flags`. +- **Resource attributes**: `resource.` where `` is the OTel + attribute key taken literally including dots (`resource.service.name` → + resource attribute `"service.name"`). Bracketed form + `resource["k8s.pod.name"]` for keys with characters outside the + bare-identifier set. +- **Log-record attributes**: `attr.` (`attr.http.status_code` → + attribute `"http.status_code"`); bracketed `attr["k"]` when needed. +- **Severity**: `severity` compares against a **bare severity name** + (`severity >= error`) — mapped to OTel severity numbers by the + severity-text convention, case-insensitive — or a **numeric** form + (`severity >= 17`). + +**Operators.** Comparison: `==`, `!=`, `<`, `<=`, `>`, `>=`, `=~` +(regex match), `!~` (regex non-match). Boolean: `and`, `or`, `not`, with +terse aliases `&&`, `||`, `!`; grouping with `()`. + +**Literals.** Double-quoted strings (`"api"`), numbers (`500`, `0.7`), +booleans (`true`/`false`), `null`, duration literals (`30s`, `1h`, `1d`, +`1w`), and RFC 3339 timestamps. + +**Functions** (read-only, bespoke names tuned for queries): +`matches(path, regex)`, `contains(path, s)`, `starts_with(path, s)`, +`ends_with(path, s)`, `len(path)`. + +**Worked predicate.** ``` -from logs - where - range ts in [now() - 1h, now()] - aggregate count() by template_id - sort count desc - limit 10 +service == "api" and severity >= error and attr.http.status_code == 500 ``` -Pros: reads like English; clear separation; verbose in a way that -is usually a feature. Cons: drifts from LogQL/Insights idioms. +### 6.2 First-class OTel-canonical fields -#### Candidate β — pipe-composable, LogQL-ish +Per OpenTelemetry maintainer guidance (the primary dimensions a log +backend is judged on), these get **named, bare** surface rather than +hand-written attribute lookups, resolving the last open question of the +prior draft: +| Surface | Resolves to (RFC 0001 §6.1) | +|---|---| +| `service` | `resource["service.name"]` | +| `trace_id`, `span_id` | the dedicated columns (log↔trace correlation) | +| `scope` | `scope_name` | +| `severity` | `severity_number` (via the §6.1 mapping) | + +### 6.3 Template + correctness primitives + +First-class vocabulary (RFC 0001 §6.3/§6.7): + +- `template_id == X` — exact template. +- `resolves_to(X)` — `X` plus its drift aliases (the RFC 0001 §6.7 drift + question); compiles to alias-set membership. +- `confidence` (miner confidence, `< 0.7`), `lossy` (the lossy- + reconstruction flag), `drift` (template drifted across versions). +- `render` (pipe stage, §6.5) reconstructs the original line, honouring + `lossy`. + +### 6.4 Two front-ends, one core + +```mermaid +flowchart LR + A["string DSL (β)
Perses YAML, humans"] --> P[parser] + B["structured surface
JSON, MCP agents + clients"] --> V[schema validate] + P --> IR[query IR] + V --> IR + IR --> C["compiler
(no SQL leakage)"] + C --> LP["DataFusion LogicalPlan
(RFC 0007 execution layer)"] ``` -{} - | range(-1h, now) - | count by template_id - | sort desc - | limit 10 -``` - -Pros: compact, composable, familiar to LogQL users. Cons: sigils -(`{}`, `|`); deeply nested pipes can become unreadable. - -#### Candidate γ — Insights-ish -``` -filter -range 1h -stats count() by template_id -sort count desc -limit 10 -``` +- **String DSL (surface β)** is the human surface (esp. Perses YAML). A + query is a predicate optionally followed by `|`-separated stages: -Pros: familiar to CloudWatch users; minimal sigil density; -verb-per-line. Cons: forces linebreaks in simple queries; less -composable than β. + ``` + service == "api" and severity >= error + | range(-1h, now) + | count by template_id + | sort count desc + | limit 10 + ``` -*Reviewers: surface choice (α/β/γ) and predicate choice (A/B) are -independent. Both decisions feed §9.* + Stages: `range(from, to)` (relative durations or RFC 3339; defaults per + §4.5), `count [by ]` and other aggregations (`sum`, `min`, + `max`, `avg` over a path), `sort [asc|desc]`, `limit `, + `project ` / `render`. The whole query is expressible on one + line (the `|` newlines above are cosmetic) — the §4.7 YAML constraint. -### 5.4 Template and correctness primitives — branch-agnostic +- **Structured surface** is the machine contract (MCP tool schema + + programmatic clients): a JSON predicate tree (`{field, op, value}` with + `and`/`or`/`not` nodes) plus structured stages. It is the formalised + successor to the throwaway `ourios_querier::QueryRequest` and is the + stable surface agents target — no grammar generation required. -Present in both branches. Straw-man forms in Candidate α: +Both parse/validate to the **same query IR** and compile identically +(RFC0002.2). The tenant is **not** expressed in either surface — it is +supplied by the executing context (RFC 0007 §3.7 / RFC0007.5); a query +without a tenant is an API usage error, not a cross-tenant scan. -``` -# Find rows where the miner was not fully confident -where lossy_flag = true +### 6.5 Compilation target -# Find all rows belonging to a template, including drift/aliases -where template_id.resolves_to(X) +Every construct compiles to a DataFusion `LogicalPlan`: -# Find templates that have drifted across versions -aggregate count() by template_id where template.drift = true - -# Reconstruct the original line (honours lossy_flag) -select render(*) from logs where ... +| DSL construct | DataFusion logical node | +|---|---| +| implicit `from logs` | `TableScan` on the tenant's log table | +| predicate / `range` | `Filter` (range → time-column predicate) | +| `count` / aggregations | `Aggregate` | +| `sort` | `Sort` | +| `limit` | `Limit` | +| `project` | `Projection` | +| `render` | custom projection honouring the three-zone reconstruction model | +| `resolves_to(X)` | custom node expanding to alias-set membership | + +All but `render` and `resolves_to` are DataFusion's built-in algebra; +those two are the only Ourios extensions, both surface-independent. + +### 6.6 Stability and versioning + +The grammar (§7) is owned and versioned by this RFC. Additions (new +functions, new first-class fields) are minor versions. Behavioural changes +that could alter a query's result set are major versions, require an +amending RFC + a deprecation window, and — because the Perses/MCP +audiences persist queries (git-versioned dashboards, cached agent schemas) +— ship with a documented migration. There is no external spec to shadow, +so major versions are deliberate, not inherited. + +## 7. Grammar specification (owned by this RFC) + +A compact EBNF; the canonical machine-readable grammar lives beside the +parser and is snapshot-tested (§8). Kept small and regular so it doubles +as a constrained-decoding grammar for the MCP surface (§3.6). + +```ebnf +query = predicate , { "|" , stage } ; +predicate = or_expr ; +or_expr = and_expr , { ("or" | "||") , and_expr } ; +and_expr = unary , { ("and" | "&&") , unary } ; +unary = [ "not" | "!" ] , ( comparison | call | "(" , predicate , ")" ) ; +comparison = path , cmp_op , literal ; +cmp_op = "==" | "!=" | "<" | "<=" | ">" | ">=" | "=~" | "!~" ; +call = ident , "(" , [ arg , { "," , arg } ] , ")" ; +arg = path | literal ; +path = field | "resource" , key_tail | "attr" , key_tail ; +field = "body" | "severity" | "ts" | "observed_ts" | "trace_id" + | "span_id" | "scope" | "flags" | "service" + | "template_id" | "confidence" | "lossy" | "drift" ; +key_tail = ( "." , dotted_key ) | ( "[" , string , "]" ) ; +dotted_key = ident , { "." , ident } ; +stage = "range" , "(" , time , "," , time , ")" + | "count" , [ "by" , field_list ] + | agg_fn , "(" , path , ")" , [ "by" , field_list ] + | "sort" , field , [ "asc" | "desc" ] + | "limit" , integer + | "project" , field_list + | "render" ; +agg_fn = "sum" | "min" | "max" | "avg" ; +literal = string | number | boolean | "null" | duration | timestamp ; +(* lexical: ident, string (dq), number, duration (e.g. 1h/30s/1d/1w), + timestamp (RFC 3339), boolean, severity names error|warn|info|… *) ``` -The `resolves_to` construct answers the drift question in RFC 0001 -§6.7. Equivalent forms exist under β and γ. - -### 5.5 Compilation target — branch-agnostic - -Every construct compiles to a DataFusion **LogicalPlan**: - -| DSL construct | DataFusion logical node | -|----------------------|--------------------------------------------| -| `from logs` | `TableScan` on the tenant's log table | -| `where` / filter | `Filter` | -| `range` | `Filter` with a time-column predicate | -| projection / `select`| `Projection` | -| `aggregate` / `stats`| `Aggregate` | -| `sort` | `Sort` | -| `limit` | `Limit` | -| `render(*)` | Custom `ProjectionExec` that honours the three-zone model | -| `template_id.resolves_to(X)` | Custom logical node that expands to an `IN` over the alias set | - -Most is DataFusion's built-in logical algebra. The two non-trivial -entries — `render` and `resolves_to` — are the only places Ourios -extends DataFusion. Both are branch-agnostic. - -### 5.6 Stability and versioning — branch-dependent - -Branch A: DSL versioning tracks (a) internal changes and (b) OTTL -compatibility bumps. An OTTL spec bump is always a DSL major -version. - -Branch B: DSL versioning tracks only (a). There is no upstream -spec to shadow. Consequently Branch B has fewer unsolicited major -versions but more deliberated ones. - -General rules (both branches): - -- Additions (new functions, new pseudo-columns) are minor versions. -- Behavioural changes that could alter a query's result set are - major versions, require an RFC amending this one, and ship with - a deprecation window. - -## 6. Enumerated divergences from OTTL (applies only if Branch A wins) - -Known deviations from the pinned OTTL spec under Branch A. The list -is exhaustive at RFC freeze; any divergence added later requires an -amending RFC. - -| Divergence | Reason | -|---|---| -| No mutation functions (`set`, `delete`, `keep_keys`, `limit_keys`) | Read-only query context | -| No `Statement` top-level form | Queries are not OTTL statements | -| `where` semantics apply to rows, not Collector batches | Different execution model | -| Ourios-specific paths (`template_id`, `confidence`, etc.) | Not in OTel data model | -| Duration literals accept Ourios forms (`1d`, `1w`) | Log time windows coarser than Collector processing | - -If Branch B wins, this section is deleted and replaced with a -"Grammar specification" appendix owned by this RFC. - -## 7. Testing strategy - -Mapping to `CLAUDE.md` §6.2. - -- **Unit tests** for the parser: every documented syntactic form - has a positive and negative test. -- **Property tests**: generate random well-formed queries, - round-trip through parser → AST → serialised form → parser, - assert idempotence. -- **Compilation tests**: every DSL construct has a golden-file test - of the resulting DataFusion LogicalPlan. -- **End-to-end query tests**: against the corpora from - `docs/benchmarks.md` §1, pin expected query results; any change - is a PR-visible diff. -- **Branch-specific:** - - *Branch A only*: OTTL compatibility tests — the pinned OTTL - predicate corpus is imported; every supported predicate parses - and produces the expected AST; every unsupported predicate - fails with a specific error message linking to §6. - - *Branch B only*: grammar golden-file tests — every syntactic - form is exercised against a committed-to-repo reference - grammar snapshot; deviations are visible in PR diffs. - -## 8. Alternatives considered (to the DSL as a whole) - -These are alternatives that would replace *both* §5.1/§5.2, not -just one branch. - -### 8.1 Pure SQL (DataFusion dialect) - -- **Pros**: zero parser implementation; SQL users immediately - productive; DataFusion's planner already supports it. -- **Cons**: violates hazard 6. Exposes SQL features we cannot - safely permit (cross-tenant joins, unbounded windows, recursive - CTEs) without a sandboxing layer that is its own project. Binds - user-facing surface to DataFusion evolution. -- **Verdict**: rejected as the default. Possible future - advanced-mode escape hatch, gated and sandboxed, under a - separate RFC. - -### 8.2 LogQL clone - -- **Pros**: well-understood logs DSL; Loki migrators - immediately productive. -- **Cons**: LogQL uses label selectors, which are less expressive - than the OTel log record. Adopting LogQL means projecting OTel - attributes into labels, losing structure and lying about the - ingest contract. -- **Verdict**: rejected as the full DSL. Its top-level query shape - survives as Candidate β in §5.3. - -### 8.3 CloudWatch Logs Insights clone - -- **Pros**: familiar to a large AWS population; clear - verb-per-line; explicit aggregation idioms. -- **Cons**: proprietary syntax, no open spec to pin; attribute - model differs from OTel. -- **Verdict**: rejected as the full DSL. Its readability idioms - survive as Candidate γ in §5.3. - -### 8.4 Full-custom DSL - -- **Pros**: maximum fit; no external compatibility constraints. -- **Cons**: highest learning cost for every user regardless of - background. Violates principle §4.1. "Own every decision" with - no upstream pressure. -- **Verdict**: rejected as a green-field approach. Branch B is - *not* full-custom — it borrows the top-level surface from - LogQL/Insights and the data model from OTel; only the predicate - syntax is Ourios-native. Full-custom would replace the query - surface too. - -## 9. Testing the premise (user research) - -This RFC makes claims about what users will find familiar. Those -claims are currently unvalidated. Before acceptance, the RFC -requires at least: - -- A **user persona document** identifying three-to-five archetypes - (e.g. "SRE running a Collector pipeline", "Go developer - debugging their service", "analyst exploring historical - incidents"), with their expected prior DSL exposure. The - Branch A/B decision pivots heavily on the weight of the - Collector-operator segment among these. -- A **readability test** on 10–20 sample queries across: - - each surface candidate (α/β/γ), - - both predicate branches (A/B), - with non-author reviewers scoring them on first-read - comprehensibility and semantic-guess accuracy. -- A **migration feasibility sketch** from LogQL, Insights, and - OTTL transformations into each branch × surface combination. - -Skipping this step and picking on instinct is the path where we -build something elegant that nobody wants to use. - -## 10. Open questions - -*Must be resolved before status flips to `accepted`. The first -question is the prior decision; the rest are downstream.* - -- [ ] **Prior: Branch A (borrow from OTTL) or Branch B (distance - from OTTL)?** Decided by §9 user research + explicit - reviewer vote. -- [ ] Which candidate surface (α, β, γ) wins, and under what - criteria? -- [ ] If Branch A: which OTTL spec version is pinned, and how are - upstream bumps handled operationally? -- [ ] If Branch B: does the bare-identifier severity form - (`severity >= error`) collide with OTel severity-text - casing conventions? -- [ ] Is there a `--sql` advanced-mode escape hatch, and if so, - what are its safety constraints? -- [ ] How are saved queries and dashboards versioned across DSL - major versions? -- [ ] Does the DSL expose custom user functions? If so, where do - they run, and what is the sandboxing story? -- [ ] How does the DSL address the multi-tenant boundary — - implicit in the executing tenant's context, or explicit in - the query? -- [ ] Do we expose `params[N]` positional access, or name - parameters via the template schema? -- [ ] Error messages: how specific can we be about *why* a query - was rejected (e.g. linking to §6 divergence table under - Branch A, or to the grammar appendix under Branch B)? -- [ ] Is there a query cost estimator in-path, so users see "this - will scan 400 GB" before running? -- [ ] Is the DSL rendered identically in the CLI and in the UI, - or does the UI add affordances the spec does not dictate? -- [ ] Is the DSL designed to be **agent-friendly** — callable from - a CLI with stable, machine-parseable output schemas (JSON, - JSONL) suitable for consumption by Claude Code, Cursor, - Grafana's GCX, or comparable agentic tools? This is a UX - layer question that does not change the A/B predicate-branch - decision, but should be answered before §9 user research - because the answer changes who counts as a "user". -- [ ] **First-class query dimensions for OTel-canonical fields.** - RFC 0001 §6.1 stores `service.name` (via - `resource_attributes`), `trace_id` / `span_id`, `scope_name`, - and `attributes` as faithful columns — but the storage spec - stays silent on how the DSL surfaces them. Community - feedback (OpenTelemetry maintainer guidance, May 2026) is - that these are the primary correlation/query dimensions a - log backend is judged on: `service.name` for cross-service - navigation, `trace_id`/`span_id` for log↔trace correlation, - typed `attributes` access without string-flattening. The - DSL should give them ergonomic, *named* surface (e.g. - `service ==`, `trace_id ==`, `attr["k"] ==`) rather than - requiring users to hand-write attribute-map lookups. Decide - the surface here so RFC 0001 doesn't have to retrofit it. - -The DSL is the most user-facing surface in the project. More open -questions here is healthier than fewer. +## 8. Testing strategy + +Mapping to `CLAUDE.md` §6.2 and `docs/verification.md` §3 (red→green +two-loop: `#[ignore]`'d stubs first, implementations second). + +- **Unit tests** — every grammar production has a positive and negative + parse test. +- **Property tests** — generate well-formed queries; assert the §5 + round-trip idempotence (RFC0002.7) and that every generated query is a + YAML-safe single-line scalar (RFC0002.10). +- **Compilation golden tests** — every construct has a golden `LogicalPlan` + (debug-rendered) checked in; the no-leakage boundary (RFC0002.3) is a + compile + string test. +- **Equivalence tests** — string vs structured surface compile to the + same IR (RFC0002.2); a DSL query and the equivalent `ourios_querier` + structured request return identical results + `QueryStats` (RFC0002.1). +- **Grammar snapshot** — the EBNF / parser grammar is committed and + snapshot-tested so changes are PR-visible (Branch B owns its grammar). +- **End-to-end** — against the `docs/benchmarks.md` §1 corpora, pinned + expected results for a query set spanning each construct. + +## 9. Open questions + +*Narrowed by the §3 resolution. Must be resolved before `accepted`.* + +- [ ] **Pre-`accepted` validation.** The §3.6 audience analysis stands in + for instinct, not for evidence: before `accepted`, run a readability + pass on 10–20 sample queries with non-author reviewers, and a + migration sketch from LogQL/Insights into β. (Replaces the prior + §9 user-research gate; not required for `specified`.) +- [ ] **OTel ecosystem alignment** (for the maintainer's OpenTelemetry + AI): is there an OpenTelemetry *query/read* language (distinct from + OTTL) to align with? Is OTTL treated as the expected *querying* + surface (making divergence costly) or is bespoke query syntax the + norm? Any Perses+OTel query conventions presupposing a syntax? +- [ ] `--sql` advanced-mode escape hatch — gated + sandboxed, or never? + (Currently: never; reconsider under a separate RFC.) +- [ ] Custom user functions — out for v1 (sandboxing is its own project). +- [ ] `params[N]` positional access vs named parameters via the template + schema. +- [ ] In-path query cost estimator ("this will scan 400 GB") before run. +- [ ] Pagination / streaming surface for large result sets (mirrors + RFC 0007 §8). + +Resolved by this RFC (were open in the draft): branch (B), top-level +surface (β), severity-text casing (case-insensitive, §6.1), agent- +friendliness (the structured surface, §6.4), and first-class OTel- +canonical fields (§6.2). + +## 10. Alternatives considered + +Alternatives that would replace the whole design, not just one branch. + +- **Pure SQL (DataFusion dialect)** — zero parser cost, but violates + hazard §4.6 (cross-tenant joins, unbounded scans) and binds the user + surface to DataFusion. Rejected as default; possible future gated, + sandboxed escape hatch under a separate RFC. +- **LogQL clone** — label selectors are less expressive than the OTel log + record; adopting them flattens structure and lies about the ingest + contract. Rejected as the full DSL; its top-level shape survives as the + chosen β surface. +- **CloudWatch Insights clone** — proprietary, no open spec; attribute + model differs from OTel. Rejected; its verb-per-line readability is the + γ alternative we did not pick. +- **Branch A (borrow OTTL) on any surface** — see §3; not chosen for the + Perses/MCP audiences. ## 11. References -- OpenTelemetry Transformation Language (OTTL) specification: - https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl - (pin a commit at RFC freeze under Branch A; reference-only under - Branch B). -- LogQL (Grafana Loki): https://grafana.com/docs/loki/latest/query/ -- CloudWatch Logs Insights: - https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html - OpenTelemetry log data model: https://opentelemetry.io/docs/specs/otel/logs/data-model/ - OpenTelemetry severity text conventions: https://opentelemetry.io/docs/specs/otel/logs/data-model/#field-severitytext -- Apache DataFusion logical plan docs. -- `CLAUDE.md` §4 hazard 6; §3.5 and §3.7. -- RFC 0001 (template miner), specifically §6.1, §6.3, §6.7 for the - Ourios-specific pseudo-columns used here. +- OTTL (reference-only under Branch B): + https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl +- LogQL: https://grafana.com/docs/loki/latest/query/ +- CloudWatch Logs Insights: + https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html +- Perses (CNCF dashboards-as-code): https://perses.dev/ +- Apache DataFusion logical-plan documentation. +- RFC 0001 §6.1/§6.3/§6.7 (the columns + template/drift primitives); + RFC 0007 (the execution layer this DSL targets); `CLAUDE.md` §4.6 + (no-leakage hazard), §3.7 (multi-tenancy). +``` + From 27062d0575b42da7c9f8786968115f3901a80ef0 Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 02:28:29 +0200 Subject: [PATCH 02/23] docs(rfc-0002): tighten RFC0002.1 pushdown claim + complete the EBNF MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review fixes: RFC0002.1 no longer claims service.name pushdown (RFC 0005 §3.6 indexes only template_id/time/severity_text) — non-indexed predicates compile to a correct Filter with no pruning claim. The §7 EBNF now defines field_list/sort_key/value/time/integer and a severity_name production, so it derives the documented examples (severity >= error, sort count desc). Label two fenced blocks (MD040) and drop a stray trailing code fence. Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index 843d12256..803707acf 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -185,14 +185,16 @@ surface? Perses+OTel query conventions?) are folded into §9. > parser + compiler that front-ends the (already-green) RFC 0007 execution > layer. -- **RFC0002.1 — A Branch-B predicate parses and compiles to a pushdown filter `[§4.6]`** - - **Given** a Branch-B predicate (e.g. `service == "api" and severity >= error`) +- **RFC0002.1 — A Branch-B predicate parses and compiles to a filter `[§4.6]`** + - **Given** a Branch-B predicate (e.g. `template_id == X and severity >= error`) - **When** it is parsed and compiled - - **Then** it yields the query IR and a DataFusion `Filter` whose - column predicates match those the RFC 0007 execution layer already - pushes down (`template_id`, `time_unix_nano`, `severity_text`, - `service.name`), and the result is identical to issuing the equivalent - `ourios_querier` structured request. + - **Then** it yields the query IR and a DataFusion `Filter`. Predicates + over the RFC 0005 §3.6 indexed columns (`template_id`, + `time_unix_nano`, `severity_text`) push down and prune row groups + identically to the equivalent `ourios_querier` structured request; + predicates over non-indexed fields (`service`, `attr.*`) compile to a + correct `Filter` with no row-group-pruning claim (adding `service.name` + pushdown would be a future RFC 0005 §3.6 amendment). - **RFC0002.2 — String DSL and structured surface compile to the same plan `[§6.4]`** - **Given** a query expressed both as a β string and as the structured @@ -300,7 +302,7 @@ booleans (`true`/`false`), `null`, duration literals (`30s`, `1h`, `1d`, **Worked predicate.** -``` +```text service == "api" and severity >= error and attr.http.status_code == 500 ``` @@ -345,7 +347,7 @@ flowchart LR - **String DSL (surface β)** is the human surface (esp. Perses YAML). A query is a predicate optionally followed by `|`-separated stages: - ``` + ```text service == "api" and severity >= error | range(-1h, now) | count by template_id @@ -410,7 +412,7 @@ predicate = or_expr ; or_expr = and_expr , { ("or" | "||") , and_expr } ; and_expr = unary , { ("and" | "&&") , unary } ; unary = [ "not" | "!" ] , ( comparison | call | "(" , predicate , ")" ) ; -comparison = path , cmp_op , literal ; +comparison = path , cmp_op , value ; cmp_op = "==" | "!=" | "<" | "<=" | ">" | ">=" | "=~" | "!~" ; call = ident , "(" , [ arg , { "," , arg } ] , ")" ; arg = path | literal ; @@ -423,14 +425,22 @@ dotted_key = ident , { "." , ident } ; stage = "range" , "(" , time , "," , time , ")" | "count" , [ "by" , field_list ] | agg_fn , "(" , path , ")" , [ "by" , field_list ] - | "sort" , field , [ "asc" | "desc" ] + | "sort" , sort_key , [ "asc" | "desc" ] | "limit" , integer | "project" , field_list | "render" ; agg_fn = "sum" | "min" | "max" | "avg" ; +field_list = field , { "," , field } ; +sort_key = field | ident ; (* ident = an aggregate output, e.g. count *) +value = literal | severity_name ; literal = string | number | boolean | "null" | duration | timestamp ; -(* lexical: ident, string (dq), number, duration (e.g. 1h/30s/1d/1w), - timestamp (RFC 3339), boolean, severity names error|warn|info|… *) +severity_name = "trace" | "debug" | "info" | "warn" | "error" | "fatal" ; (* case-insensitive *) +time = "now" | [ "-" ] , duration | timestamp ; (* e.g. now , -1h *) +integer = digit , { digit } ; +(* lexical: ident = letter , { letter | digit | "_" } ; + string = '"' , { char } , '"' ; number = integer | float ; + boolean = "true" | "false" ; duration = integer , ( "s"|"m"|"h"|"d"|"w" ) ; + timestamp = RFC 3339 *) ``` ## 8. Testing strategy @@ -516,5 +526,4 @@ Alternatives that would replace the whole design, not just one branch. - RFC 0001 §6.1/§6.3/§6.7 (the columns + template/drift primitives); RFC 0007 (the execution layer this DSL targets); `CLAUDE.md` §4.6 (no-leakage hazard), §3.7 (multi-tenancy). -``` From b52415b8fb755498a363a49098a20432f54402b2 Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 02:41:14 +0200 Subject: [PATCH 03/23] docs(rfc-0002): fix RFC0002.1 severity wording + map ts/observed_ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review pass 2: RFC0002.1 no longer ties severity pushdown to severity_text or to QueryRequest-equivalence (the DSL resolves severity to a severity_number range per §6.2/RFC0002.5 that the current request cannot express) — it now scopes equivalence to template+time and defers severity to RFC 0007 §4.3. §6.2 now maps ts -> time_unix_nano and observed_ts -> observed_time_unix_nano. Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index 803707acf..e583d1d87 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -189,11 +189,14 @@ surface? Perses+OTel query conventions?) are folded into §9. - **Given** a Branch-B predicate (e.g. `template_id == X and severity >= error`) - **When** it is parsed and compiled - **Then** it yields the query IR and a DataFusion `Filter`. Predicates - over the RFC 0005 §3.6 indexed columns (`template_id`, - `time_unix_nano`, `severity_text`) push down and prune row groups - identically to the equivalent `ourios_querier` structured request; - predicates over non-indexed fields (`service`, `attr.*`) compile to a - correct `Filter` with no row-group-pruning claim (adding `service.name` + over RFC 0007 §4.3's pushdown keys (notably `template_id` and + `time_unix_nano`) prune row groups; for the subset the current + `ourios_querier` structured request can express (template + time) the + DSL result is identical to it. Severity is compiled per RFC 0007 §4.3 + (the `severity_number` mapping of §6.2/RFC0002.5, not necessarily the + `severity_text` equality the current request supports), and predicates + over non-indexed fields (`service`, `attr.*`) compile to a correct + `Filter` with no row-group-pruning claim (indexed `service.name` pushdown would be a future RFC 0005 §3.6 amendment). - **RFC0002.2 — String DSL and structured surface compile to the same plan `[§6.4]`** @@ -319,6 +322,8 @@ prior draft: | `trace_id`, `span_id` | the dedicated columns (log↔trace correlation) | | `scope` | `scope_name` | | `severity` | `severity_number` (via the §6.1 mapping) | +| `ts` | `time_unix_nano` (the event timestamp; what `range(...)` filters) | +| `observed_ts` | `observed_time_unix_nano` | ### 6.3 Template + correctness primitives From 1cd9939e76a2c6adcc4d0dd4bdec36a9f70df947 Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 03:00:09 +0200 Subject: [PATCH 04/23] docs(rfc-0002): define id literal format, lossy mapping; defer drift predicate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review pass 3: specify trace_id/span_id literals as lowercase-hex strings (hex-decoded to the byte columns, OTLP/JSON convention); map lossy -> the lossy_flag column explicitly; and defer the bare drift predicate (RFC 0001 6.7 drift is an audit-stream property, not an RFC 0005 data column, so it needs a future audit-stream query path) — the alias query is already served by resolves_to. drift removed from the field list + EBNF. Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index e583d1d87..35cc4e781 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -325,18 +325,30 @@ prior draft: | `ts` | `time_unix_nano` (the event timestamp; what `range(...)` filters) | | `observed_ts` | `observed_time_unix_nano` | +`trace_id` / `span_id` literals are **lowercase-hex strings** (32 and 16 +hex digits respectively), accepted case-insensitively with no separators; +the compiler hex-decodes them to match the stored byte columns — the +OTLP/JSON id convention, consistent with RFC0003.6. + ### 6.3 Template + correctness primitives First-class vocabulary (RFC 0001 §6.3/§6.7): -- `template_id == X` — exact template. +- `template_id == X` — exact template; resolves to the `template_id` column. - `resolves_to(X)` — `X` plus its drift aliases (the RFC 0001 §6.7 drift - question); compiles to alias-set membership. -- `confidence` (miner confidence, `< 0.7`), `lossy` (the lossy- - reconstruction flag), `drift` (template drifted across versions). + question); compiles to alias-set membership over `template_id`. +- `confidence` — miner confidence (e.g. `< 0.7`); the `confidence` column. +- `lossy` — the lossy-reconstruction flag; resolves to the RFC 0001 / + RFC 0005 **`lossy_flag`** column (`lossy == true`). - `render` (pipe stage, §6.5) reconstructs the original line, honouring `lossy`. +The drift *question* is answered by `resolves_to` (alias membership). A +bare `drift` predicate ("has this template drifted?") is **deferred**: +per RFC 0001 §6.7 drift is an audit-stream property, not a column in the +RFC 0005 data files, so it needs an audit-stream query path — a future +capability, not a row predicate in this grammar. + ### 6.4 Two front-ends, one core ```mermaid @@ -424,7 +436,7 @@ arg = path | literal ; path = field | "resource" , key_tail | "attr" , key_tail ; field = "body" | "severity" | "ts" | "observed_ts" | "trace_id" | "span_id" | "scope" | "flags" | "service" - | "template_id" | "confidence" | "lossy" | "drift" ; + | "template_id" | "confidence" | "lossy" ; key_tail = ( "." , dotted_key ) | ( "[" , string , "]" ) ; dotted_key = ident , { "." , ident } ; stage = "range" , "(" , time , "," , time , ")" From 4ef3fd9a3b48c61e7e51243ccf91b59c93dd0625 Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 03:11:54 +0200 Subject: [PATCH 05/23] docs(rfc-0002): drift/hex/severity consistency sweep MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review pass 4 (internal consistency): drop drift from the §3.3 shared list and principle #4 (it is deferred per §6.3; drift-alias is resolves_to); fix the §6.2 hex wording (hex strings parsed case-insensitively, canonical lowercase — was self-contradictory); scope severity_name to a severity RHS in the §7 EBNF (split comparison into severity_cmp | scalar_cmp so `service == error` is not grammatical); cite CLAUDE.md §4.6 in principle #2. Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index 35cc4e781..2f0e4a423 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -98,7 +98,8 @@ the record. §3.5 records the resolution; §3.6 the reasoning. contract, not a design choice): attributes, resources, severity, body, timestamps, trace context. - The **template + correctness primitives** (`template_id`, `confidence`, - `lossy`, `drift`) are first-class (§6.3). + `lossy`; drift-alias membership via `resolves_to`) are first-class + (§6.3). - The **compilation target** is a DataFusion `LogicalPlan`, no SQL leakage (§6.5). @@ -158,13 +159,14 @@ surface? Perses+OTel query conventions?) are folded into §9. 1. **Familiarity beats cleverness.** A first-time reader understands a query within 30 seconds without a reference. No heavy sigils. -2. **No DataFusion/SQL leakage** (hazard §4.6). If explaining a surface +2. **No DataFusion/SQL leakage** (hazard `CLAUDE.md` §4.6). If explaining a surface form requires naming a DataFusion type, the form is wrong. 3. **Predicate, then pipeline.** A query is a *predicate* (the `where`) followed by ordered *stages* (range, aggregate, sort, limit, project). Each reads independently. 4. **Template + OTel-canonical fields are first-class vocabulary**, not - pseudo-columns: `template_id`, `confidence`, `lossy`, `drift`; + pseudo-columns: `template_id`, `confidence`, `lossy` (drift-alias + membership via `resolves_to`); `service`, `trace_id`, `span_id`, `scope` (the primary correlation/query dimensions per OTel maintainer guidance, §6.2). 5. **Every query has a time range** — explicit `range(...)` or a @@ -325,9 +327,10 @@ prior draft: | `ts` | `time_unix_nano` (the event timestamp; what `range(...)` filters) | | `observed_ts` | `observed_time_unix_nano` | -`trace_id` / `span_id` literals are **lowercase-hex strings** (32 and 16 -hex digits respectively), accepted case-insensitively with no separators; -the compiler hex-decodes them to match the stored byte columns — the +`trace_id` / `span_id` literals are **hex strings** (32 and 16 hex digits +respectively, no separators), **parsed case-insensitively** so uppercase +OTLP/JSON ids are accepted; the canonical/serialised form is lowercase. +The compiler hex-decodes them to match the stored byte columns — the OTLP/JSON id convention, consistent with RFC0003.6. ### 6.3 Template + correctness primitives @@ -429,7 +432,9 @@ predicate = or_expr ; or_expr = and_expr , { ("or" | "||") , and_expr } ; and_expr = unary , { ("and" | "&&") , unary } ; unary = [ "not" | "!" ] , ( comparison | call | "(" , predicate , ")" ) ; -comparison = path , cmp_op , value ; +comparison = severity_cmp | scalar_cmp ; +severity_cmp = "severity" , cmp_op , ( severity_name | number ) ; +scalar_cmp = path , cmp_op , literal ; cmp_op = "==" | "!=" | "<" | "<=" | ">" | ">=" | "=~" | "!~" ; call = ident , "(" , [ arg , { "," , arg } ] , ")" ; arg = path | literal ; @@ -449,9 +454,8 @@ stage = "range" , "(" , time , "," , time , ")" agg_fn = "sum" | "min" | "max" | "avg" ; field_list = field , { "," , field } ; sort_key = field | ident ; (* ident = an aggregate output, e.g. count *) -value = literal | severity_name ; literal = string | number | boolean | "null" | duration | timestamp ; -severity_name = "trace" | "debug" | "info" | "warn" | "error" | "fatal" ; (* case-insensitive *) +severity_name = "trace" | "debug" | "info" | "warn" | "error" | "fatal" ; (* case-insensitive; only as a `severity` RHS *) time = "now" | [ "-" ] , duration | timestamp ; (* e.g. now , -1h *) integer = digit , { digit } ; (* lexical: ident = letter , { letter | digit | "_" } ; From 278204a56971bdeb28c87fa541458dfef43ce763 Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 03:17:44 +0200 Subject: [PATCH 06/23] docs(rfc-0002): make severity comparisons grammatically exclusive; qualify citations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review pass 5: scalar_cmp now uses scalar_path (= nonsev_field | resource/ attr), so severity is reachable only via severity_cmp — severity == \"error\" / severity == null are ungrammatical in §7, not just a semantic error (field = nonsev_field | severity is retained for field_list/sort_key). Qualify the two remaining bare hazard citations as CLAUDE.md §4.6 (§10) and CLAUDE.md §3.7 (references). Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index 2f0e4a423..f5ed58b17 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -434,14 +434,16 @@ and_expr = unary , { ("and" | "&&") , unary } ; unary = [ "not" | "!" ] , ( comparison | call | "(" , predicate , ")" ) ; comparison = severity_cmp | scalar_cmp ; severity_cmp = "severity" , cmp_op , ( severity_name | number ) ; -scalar_cmp = path , cmp_op , literal ; +scalar_cmp = scalar_path , cmp_op , literal ; cmp_op = "==" | "!=" | "<" | "<=" | ">" | ">=" | "=~" | "!~" ; call = ident , "(" , [ arg , { "," , arg } ] , ")" ; arg = path | literal ; path = field | "resource" , key_tail | "attr" , key_tail ; -field = "body" | "severity" | "ts" | "observed_ts" | "trace_id" - | "span_id" | "scope" | "flags" | "service" - | "template_id" | "confidence" | "lossy" ; +scalar_path = nonsev_field | "resource" , key_tail | "attr" , key_tail ; +field = nonsev_field | "severity" ; +nonsev_field = "body" | "ts" | "observed_ts" | "trace_id" | "span_id" + | "scope" | "flags" | "service" | "template_id" + | "confidence" | "lossy" ; key_tail = ( "." , dotted_key ) | ( "[" , string , "]" ) ; dotted_key = ident , { "." , ident } ; stage = "range" , "(" , time , "," , time , ")" @@ -518,7 +520,7 @@ canonical fields (§6.2). Alternatives that would replace the whole design, not just one branch. - **Pure SQL (DataFusion dialect)** — zero parser cost, but violates - hazard §4.6 (cross-tenant joins, unbounded scans) and binds the user + hazard `CLAUDE.md` §4.6 (cross-tenant joins, unbounded scans) and binds the user surface to DataFusion. Rejected as default; possible future gated, sandboxed escape hatch under a separate RFC. - **LogQL clone** — label selectors are less expressive than the OTel log @@ -546,5 +548,5 @@ Alternatives that would replace the whole design, not just one branch. - Apache DataFusion logical-plan documentation. - RFC 0001 §6.1/§6.3/§6.7 (the columns + template/drift primitives); RFC 0007 (the execution layer this DSL targets); `CLAUDE.md` §4.6 - (no-leakage hazard), §3.7 (multi-tenancy). + (no-leakage hazard) and `CLAUDE.md` §3.7 (multi-tenancy). From 9f5e7d5bad9bc56498f9935ec310e594facf8b80 Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 10:58:15 +0200 Subject: [PATCH 07/23] =?UTF-8?q?docs(rfc-0002):=20resolvable=20=C2=A74=20?= =?UTF-8?q?citations,=20sort=20synopsis,=20time=20EBNF=20parens?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review pass 6: §4 is a flat principle list (no subsections), so the acceptance-criteria tags now read [CLAUDE.md §4.6] (the no-leakage hazard, RFC0002.1/.3) and [§4 P5]/[§4 P7] (this RFC design principles 5/7, RFC0002.4/.10). The §6.4 sort synopsis now says sort to match the §7 sort_key grammar + the sort count desc example. The time production parenthesises ([ - ] , duration) so the alternation precedence is unambiguous across EBNF dialects (matters for constrained decoding). Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index f5ed58b17..4173fbbdf 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -187,7 +187,7 @@ surface? Perses+OTel query conventions?) are folded into §9. > parser + compiler that front-ends the (already-green) RFC 0007 execution > layer. -- **RFC0002.1 — A Branch-B predicate parses and compiles to a filter `[§4.6]`** +- **RFC0002.1 — A Branch-B predicate parses and compiles to a filter `[CLAUDE.md §4.6]`** - **Given** a Branch-B predicate (e.g. `template_id == X and severity >= error`) - **When** it is parsed and compiled - **Then** it yields the query IR and a DataFusion `Filter`. Predicates @@ -208,14 +208,14 @@ surface? Perses+OTel query conventions?) are folded into §9. - **Then** they produce the *same* query IR (and hence the same `LogicalPlan`) — the one-core/two-surfaces invariant. -- **RFC0002.3 — No DataFusion/arrow/SQL leakage `[§4.6]`** +- **RFC0002.3 — No DataFusion/arrow/SQL leakage `[CLAUDE.md §4.6]`** - **Given** the public DSL API (parse, compile, error types) - **When** a query parses, compiles, or fails - **Then** no `datafusion`/`arrow`/SQL type or message appears in any public signature or error string (compile- and string-level boundary test, mirroring RFC0007.3). -- **RFC0002.4 — A query without an explicit range gets the tenant default window `[§4.5]`** +- **RFC0002.4 — A query without an explicit range gets the tenant default window `[§4 P5]`** - **Given** a query with no `range(...)` stage - **When** it is compiled in a tenant context with a default window W - **Then** the plan carries a time-column filter equal to W — never an @@ -256,7 +256,7 @@ surface? Perses+OTel query conventions?) are folded into §9. to the alias-set membership of RFC 0001 §6.7), without leaking the underlying representation. -- **RFC0002.10 — A query is a YAML-safe single-line scalar `[§4.7]`** +- **RFC0002.10 — A query is a YAML-safe single-line scalar `[§4 P7]`** - **Given** the canonical serialisation of any well-formed query - **When** embedded as a YAML scalar and round-tripped through a YAML parser @@ -377,7 +377,9 @@ flowchart LR Stages: `range(from, to)` (relative durations or RFC 3339; defaults per §4.5), `count [by ]` and other aggregations (`sum`, `min`, - `max`, `avg` over a path), `sort [asc|desc]`, `limit `, + `max`, `avg` over a path), `sort [asc|desc]` + (the §7 `sort_key` — a field or an aggregate output like `count`), + `limit `, `project ` / `render`. The whole query is expressible on one line (the `|` newlines above are cosmetic) — the §4.7 YAML constraint. @@ -458,7 +460,7 @@ field_list = field , { "," , field } ; sort_key = field | ident ; (* ident = an aggregate output, e.g. count *) literal = string | number | boolean | "null" | duration | timestamp ; severity_name = "trace" | "debug" | "info" | "warn" | "error" | "fatal" ; (* case-insensitive; only as a `severity` RHS *) -time = "now" | [ "-" ] , duration | timestamp ; (* e.g. now , -1h *) +time = "now" | ( [ "-" ] , duration ) | timestamp ; (* e.g. now , -1h *) integer = digit , { digit } ; (* lexical: ident = letter , { letter | digit | "_" } ; string = '"' , { char } , '"' ; number = integer | float ; From 987cee844d5a52948b3140fb96fb5a62c7bbf7e0 Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 11:09:26 +0200 Subject: [PATCH 08/23] docs(rfc-0002): fold in OpenTelemetry-AI review (field semantics + severity) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Maintainer-relayed OTel-AI feedback, all spec-grounded: - §6.1 top-level fields now name their canonical OTel data-model targets (Body/SeverityNumber/Timestamp/ObservedTimestamp/TraceId/SpanId/ InstrumentationScope name/TraceFlags) + note structured-body vs attr is not uniform across backends. - Severity comparisons (incl. ordering) are defined on SeverityNumber, not severity_text (OTel comparing-severity guidance); the bare-name->number mapping (trace->1 .. fatal->21) is made explicit and flagged as Ourios's (aligned with the spec ranges, not an OTel-standardised threshold). RFC0002.5 reworded accordingly. - §6.3 marks template_id/confidence/lossy/resolves_to/render as Ourios-specific extensions, not OTel fields. - §9 OTel-alignment question resolved: no standard OTel query/read language; OTTL is a Collector transformation language, not a querying surface; bespoke query syntax is the norm -> Branch B has no ecosystem-divergence cost. Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 51 ++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index 4173fbbdf..69d275d73 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -221,12 +221,15 @@ surface? Perses+OTel query conventions?) are folded into §9. - **Then** the plan carries a time-column filter equal to W — never an unbounded scan. -- **RFC0002.5 — Bare-identifier severity maps by the OTel convention `[§6.1]`** +- **RFC0002.5 — Bare-identifier severity maps to its SeverityNumber `[§6.1]`** - **Given** `severity >= error` (and `warn`, `info`, `debug`, `trace`, `fatal`) - **When** compiled - - **Then** each maps to the correct OTel severity-number range, case- - insensitively, identically to the numeric form (`severity >= 17`). + - **Then** each maps, case-insensitively, to the §6.1 `SeverityNumber` + for that level (`error` → 17, etc.) and compiles identically to the + numeric form (`severity >= 17`). The name→number mapping is the + documented §6.1 one (Ourios's, aligned with the OTel ranges) — not an + OTel-standardised threshold. - **RFC0002.6 — First-class OTel-canonical fields resolve correctly `[§6.2]`** - **Given** `service`, `trace_id`, `span_id`, `scope` used as bare @@ -278,9 +281,13 @@ A predicate is a boolean expression over **paths**, **operators**, and **Paths.** -- **Top-level fields** are bare identifiers: `body`, `severity`, `ts` - (event timestamp), `observed_ts`, `trace_id`, `span_id`, `scope` - (instrumentation-scope name), `flags`. +- **Top-level fields** are bare identifiers mapping to the OTel log + data-model fields: `body` (Body — a free-form string *or* structured + map/array), `severity` (SeverityNumber), `ts` (Timestamp), `observed_ts` + (ObservedTimestamp), `trace_id` (TraceId), `span_id` (SpanId), `scope` + (InstrumentationScope name), `flags` (TraceFlags). (Backend treatment of + structured `body` vs `attr.*` is not uniform across the ecosystem; the + DSL keeps the split explicit rather than flattening.) - **Resource attributes**: `resource.` where `` is the OTel attribute key taken literally including dots (`resource.service.name` → resource attribute `"service.name"`). Bracketed form @@ -289,9 +296,15 @@ A predicate is a boolean expression over **paths**, **operators**, and - **Log-record attributes**: `attr.` (`attr.http.status_code` → attribute `"http.status_code"`); bracketed `attr["k"]` when needed. - **Severity**: `severity` compares against a **bare severity name** - (`severity >= error`) — mapped to OTel severity numbers by the - severity-text convention, case-insensitive — or a **numeric** form - (`severity >= 17`). + (`severity >= error`), case-insensitive, or a **numeric** form + (`severity >= 17`). All severity comparisons — **including ordering** + (`<`/`<=`/`>`/`>=`) — are defined on the OTel **`SeverityNumber`**, + **never** on the free-form `severity_text` (per the OTel *comparing + severity* guidance). Bare names map to the **floor of the matching OTel + `SeverityNumber` range**: `trace`→1, `debug`→5, `info`→9, `warn`→13, + `error`→17, `fatal`→21. The spec standardises the *ranges* and says to + compare on `SeverityNumber`; this name→number mapping is **Ourios's**, + aligned with those ranges, not separately mandated by OTel. **Operators.** Comparison: `==`, `!=`, `<`, `<=`, `>`, `>=`, `=~` (regex match), `!~` (regex non-match). Boolean: `and`, `or`, `not`, with @@ -335,7 +348,9 @@ OTLP/JSON id convention, consistent with RFC0003.6. ### 6.3 Template + correctness primitives -First-class vocabulary (RFC 0001 §6.3/§6.7): +First-class vocabulary — **Ourios-specific** extensions (RFC 0001 +§6.3/§6.7), **not** OpenTelemetry log-data-model fields; they live in the +Ourios schema + query layer alongside the OTel-canonical fields of §6.2: - `template_id == X` — exact template; resolves to the `template_id` column. - `resolves_to(X)` — `X` plus its drift aliases (the RFC 0001 §6.7 drift @@ -498,11 +513,17 @@ two-loop: `#[ignore]`'d stubs first, implementations second). pass on 10–20 sample queries with non-author reviewers, and a migration sketch from LogQL/Insights into β. (Replaces the prior §9 user-research gate; not required for `specified`.) -- [ ] **OTel ecosystem alignment** (for the maintainer's OpenTelemetry - AI): is there an OpenTelemetry *query/read* language (distinct from - OTTL) to align with? Is OTTL treated as the expected *querying* - surface (making divergence costly) or is bespoke query syntax the - norm? Any Perses+OTel query conventions presupposing a syntax? +- [x] ~~**OTel ecosystem alignment**~~ *Resolved (maintainer's + OpenTelemetry AI, 2026-06-07):* OTel defines the logs data model + + API/SDK but **no standard query/read language**; **OTTL is a + Collector *transformation* language, not a querying surface**; the + sources show no canonical OTel read syntax and no Perses-specific + query convention. Bespoke query syntax over the OTel data model is + the norm — there is **nothing to align to beyond the field + semantics**, which §6.1/§6.2 honour (`ts`/`observed_ts`/`trace_id`/ + `span_id`/`flags`/`body`/`scope`/`severity` map to the canonical + data-model fields, and `severity` ordering is on `SeverityNumber`). + Confirms Branch B carries no ecosystem-divergence cost. - [ ] `--sql` advanced-mode escape hatch — gated + sandboxed, or never? (Currently: never; reconsider under a separate RFC.) - [ ] Custom user functions — out for v1 (sandboxing is its own project). From 2752da6b6f8b027f4f39119b32ff1fe29af27575 Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 11:16:01 +0200 Subject: [PATCH 09/23] =?UTF-8?q?docs(rfc-0002):=20pass-7=20nits=20?= =?UTF-8?q?=E2=80=94=20=C2=A74=20P5/P7=20prose=20refs,=20severity=20citati?= =?UTF-8?q?on,=20defer=20len,=20drop=20throwaway?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolvable §4 P5/P7 refs in the §6.4 stage synopsis (were §4.5/§4.7); RFC0002.1 now attributes the severity_number mapping to §6.2/RFC0002.5 (+ RFC 0005 column), not RFC 0007 §4.3 (which is pushdown mechanics); defer scalar len(path) (the grammar admits a call only as a boolean term, so a numeric len > n needs a future scalar-comparison form); call QueryRequest the existing RFC 0007 API rather than throwaway. Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index 69d275d73..80580ac54 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -194,9 +194,10 @@ surface? Perses+OTel query conventions?) are folded into §9. over RFC 0007 §4.3's pushdown keys (notably `template_id` and `time_unix_nano`) prune row groups; for the subset the current `ourios_querier` structured request can express (template + time) the - DSL result is identical to it. Severity is compiled per RFC 0007 §4.3 - (the `severity_number` mapping of §6.2/RFC0002.5, not necessarily the - `severity_text` equality the current request supports), and predicates + DSL result is identical to it. Severity compiles via the §6.2/RFC0002.5 + `severity_number` mapping (the column is RFC 0005's `severity_number`), + not the `severity_text` equality the current request supports, and + predicates over non-indexed fields (`service`, `attr.*`) compile to a correct `Filter` with no row-group-pruning claim (indexed `service.name` pushdown would be a future RFC 0005 §3.6 amendment). @@ -314,9 +315,12 @@ terse aliases `&&`, `||`, `!`; grouping with `()`. booleans (`true`/`false`), `null`, duration literals (`30s`, `1h`, `1d`, `1w`), and RFC 3339 timestamps. -**Functions** (read-only, bespoke names tuned for queries): -`matches(path, regex)`, `contains(path, s)`, `starts_with(path, s)`, -`ends_with(path, s)`, `len(path)`. +**Functions** (read-only, bespoke names tuned for queries) — boolean +predicate terms: `matches(path, regex)`, `contains(path, s)`, +`starts_with(path, s)`, `ends_with(path, s)`. (Scalar-returning functions +such as `len(path)` are **deferred**: the grammar admits a call only as a +boolean term, so a numeric `len(...) > n` would need a scalar-comparison +form — added under a future minor version when a need surfaces.) **Worked predicate.** @@ -391,18 +395,19 @@ flowchart LR ``` Stages: `range(from, to)` (relative durations or RFC 3339; defaults per - §4.5), `count [by ]` and other aggregations (`sum`, `min`, + §4 P5), `count [by ]` and other aggregations (`sum`, `min`, `max`, `avg` over a path), `sort [asc|desc]` (the §7 `sort_key` — a field or an aggregate output like `count`), `limit `, `project ` / `render`. The whole query is expressible on one - line (the `|` newlines above are cosmetic) — the §4.7 YAML constraint. + line (the `|` newlines above are cosmetic) — the §4 P7 YAML constraint. - **Structured surface** is the machine contract (MCP tool schema + programmatic clients): a JSON predicate tree (`{field, op, value}` with - `and`/`or`/`not` nodes) plus structured stages. It is the formalised - successor to the throwaway `ourios_querier::QueryRequest` and is the - stable surface agents target — no grammar generation required. + `and`/`or`/`not` nodes) plus structured stages. It is the formalised, + extended successor to the existing `ourios_querier::QueryRequest` (the + RFC 0007 structured API) and is the stable surface agents target — no + grammar generation required. Both parse/validate to the **same query IR** and compile identically (RFC0002.2). The tenant is **not** expressed in either surface — it is From a84516e23aeccb682db832ddb47dac217fc08221 Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 11:23:34 +0200 Subject: [PATCH 10/23] docs(rfc-0002): describe RFC 0007 as implemented+tested, not green MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review pass 8: RFC 0007 the doc is still specified (its green gate is tied to this DSL per the prove-thesis decision), even though its §5 criteria are all implemented + tested. Reword the three "already green" claims to "implemented and tested (RFC 0007 §5)" so the maturity ladder reads consistently. Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index 80580ac54..23143a1c7 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -18,7 +18,8 @@ superseded-by: — > MCP agents). This RFC is now `specified` — §6 gives the design, §7 the > grammar, §5 the testable acceptance criteria. It advances to `red` → > `green` as the parser/compiler lands (the RFC 0007 execution layer it -> targets is already green), and to `accepted` after the §9 validation. +> targets is already implemented and tested — RFC 0007 §5), and to +> `accepted` after the §9 validation. > Hazard 6 (`CLAUDE.md` §4.6 — no DataFusion/SQL leakage) constrains the > whole design. @@ -42,8 +43,10 @@ users (hazard `CLAUDE.md` §4.6). This RFC specifies it: `LogicalPlan`. Agents emit JSON, not syntax. The design rests on `ourios-querier` (RFC 0007), whose execution layer -(predicate pushdown, tenant isolation, `QueryStats`) is already `green`; -this RFC adds the *user-facing language* in front of it. +(predicate pushdown, tenant isolation, `QueryStats`) is already +implemented and tested (RFC 0007 §5 criteria all live; the RFC itself +stays `specified` pending this DSL); this RFC adds the *user-facing +language* in front of it. ## 2. Motivation @@ -184,8 +187,8 @@ surface? Perses+OTel query conventions?) are folded into §9. > `Given/When/Then`, ids greppable from tests (`RFC0002.`, referenced > verbatim in each test's leading doc comment). These specify the -> parser + compiler that front-ends the (already-green) RFC 0007 execution -> layer. +> parser + compiler that front-ends the (already-implemented, RFC 0007 §5) +> execution layer. - **RFC0002.1 — A Branch-B predicate parses and compiles to a filter `[CLAUDE.md §4.6]`** - **Given** a Branch-B predicate (e.g. `template_id == X and severity >= error`) From a561f4b9b772b918c546e4fa8912e224bd77ad36 Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 11:35:20 +0200 Subject: [PATCH 11/23] docs(rfc-0002): partition-vs-row-group pruning precision; comma-separated field lists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review pass 9: RFC0002.1 now matches RFC 0007 §4.3 pruning split (template_id skips row groups, time_unix_nano prunes partitions + row groups, tenant_id prunes partition directories), not a blanket prune row groups. The §6.4 synopsis shows count by / project (comma-separated, per the §7 field_list). Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index 23143a1c7..be0a4d29b 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -194,10 +194,12 @@ surface? Perses+OTel query conventions?) are folded into §9. - **Given** a Branch-B predicate (e.g. `template_id == X and severity >= error`) - **When** it is parsed and compiled - **Then** it yields the query IR and a DataFusion `Filter`. Predicates - over RFC 0007 §4.3's pushdown keys (notably `template_id` and - `time_unix_nano`) prune row groups; for the subset the current - `ourios_querier` structured request can express (template + time) the - DSL result is identical to it. Severity compiles via the §6.2/RFC0002.5 + over RFC 0007 §4.3's pushdown keys prune the scan per that section's + split — `template_id` skips row groups (B1), `time_unix_nano` prunes + partitions and row groups, `tenant_id` prunes partition directories + (not row groups); for the subset the current `ourios_querier` + structured request can express (template + time) the DSL result is + identical to it. Severity compiles via the §6.2/RFC0002.5 `severity_number` mapping (the column is RFC 0005's `severity_number`), not the `severity_text` equality the current request supports, and predicates @@ -398,11 +400,12 @@ flowchart LR ``` Stages: `range(from, to)` (relative durations or RFC 3339; defaults per - §4 P5), `count [by ]` and other aggregations (`sum`, `min`, + §4 P5), `count [by ]` (comma-separated, per the §7 + `field_list`) and other aggregations (`sum`, `min`, `max`, `avg` over a path), `sort [asc|desc]` (the §7 `sort_key` — a field or an aggregate output like `count`), `limit `, - `project ` / `render`. The whole query is expressible on one + `project ` / `render`. The whole query is expressible on one line (the `|` newlines above are cosmetic) — the §4 P7 YAML constraint. - **Structured surface** is the machine contract (MCP tool schema + From c9398bb1b2ff38355bd75aac1957c736a1a6e35b Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 11:43:43 +0200 Subject: [PATCH 12/23] =?UTF-8?q?docs(rfc-0002):=20body=3DAnyValue,=20stri?= =?UTF-8?q?ng=20escaping,=20structured-surface=20shape,=20standalone=20?= =?UTF-8?q?=C2=A79=20resolution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review pass 10: - §6.1 body is an OTel AnyValue (string/bool/int/double/bytes/array/kvlist), not just string-or-map. - §7 lexical note defines char + backslash escapes (\\" \\ \n \t \r \uXXXX) and notes YAML embedding wraps the query in a single-quoted scalar. - §6.4 spells out the structured surface JSON shape (comparison + boolean nodes, stages array) and that its JSON Schema is published+versioned with the parser (RFC0002.11) and compiles to the same IR (RFC0002.2). - §9 OTel-alignment resolution now stands on its own + cites the §11 authoritative sources (OTTL README, OTel logs spec) rather than an ephemeral AI exchange. Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 55 +++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index be0a4d29b..3d17d615f 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -288,8 +288,9 @@ A predicate is a boolean expression over **paths**, **operators**, and **Paths.** - **Top-level fields** are bare identifiers mapping to the OTel log - data-model fields: `body` (Body — a free-form string *or* structured - map/array), `severity` (SeverityNumber), `ts` (Timestamp), `observed_ts` + data-model fields: `body` (Body — an OTel `AnyValue`: string, bool, int, + double, bytes, array, or kvlist/map), `severity` (SeverityNumber), `ts` + (Timestamp), `observed_ts` (ObservedTimestamp), `trace_id` (TraceId), `span_id` (SpanId), `scope` (InstrumentationScope name), `flags` (TraceFlags). (Backend treatment of structured `body` vs `attr.*` is not uniform across the ecosystem; the @@ -409,11 +410,16 @@ flowchart LR line (the `|` newlines above are cosmetic) — the §4 P7 YAML constraint. - **Structured surface** is the machine contract (MCP tool schema + - programmatic clients): a JSON predicate tree (`{field, op, value}` with - `and`/`or`/`not` nodes) plus structured stages. It is the formalised, - extended successor to the existing `ourios_querier::QueryRequest` (the - RFC 0007 structured API) and is the stable surface agents target — no - grammar generation required. + programmatic clients): a JSON predicate tree — leaf **comparison nodes** + `{ "field": …, "op": …, "value": … }` and **boolean nodes** + `{ "and" | "or" | "not": [ … ] }` — plus an ordered **`stages`** array + mirroring the pipe stages (`range`/`count`/`sort`/`limit`/`project`). + Its **JSON Schema is published and versioned with the parser** (snapshot- + tested like the §7 grammar; RFC0002.11), and it compiles to the same IR + as the string surface (RFC0002.2). It is the formalised, extended + successor to the existing `ourios_querier::QueryRequest` (the RFC 0007 + structured API) and is the stable surface agents target — no grammar + generation required. Both parse/validate to the **same query IR** and compile identically (RFC0002.2). The tenant is **not** expressed in either surface — it is @@ -489,9 +495,15 @@ severity_name = "trace" | "debug" | "info" | "warn" | "error" | "fatal" ; (* ca time = "now" | ( [ "-" ] , duration ) | timestamp ; (* e.g. now , -1h *) integer = digit , { digit } ; (* lexical: ident = letter , { letter | digit | "_" } ; - string = '"' , { char } , '"' ; number = integer | float ; - boolean = "true" | "false" ; duration = integer , ( "s"|"m"|"h"|"d"|"w" ) ; - timestamp = RFC 3339 *) + string = '"' , { char | escape } , '"' ; + char = any Unicode scalar except '"' or '\' ; + escape = '\' , ( '"' | '\' | "n" | "t" | "r" | ( "u" , 4 * hex ) ) ; + number = integer | float ; boolean = "true" | "false" ; + duration = integer , ( "s"|"m"|"h"|"d"|"w" ) ; timestamp = RFC 3339 ; + hex = digit | "a".."f" | "A".."F" + — strings are double-quoted with backslash escapes; YAML embedding + (RFC0002.10) wraps the whole query in a single-quoted YAML scalar so + these double quotes need no YAML-level escaping *) ``` ## 8. Testing strategy @@ -524,17 +536,18 @@ two-loop: `#[ignore]`'d stubs first, implementations second). pass on 10–20 sample queries with non-author reviewers, and a migration sketch from LogQL/Insights into β. (Replaces the prior §9 user-research gate; not required for `specified`.) -- [x] ~~**OTel ecosystem alignment**~~ *Resolved (maintainer's - OpenTelemetry AI, 2026-06-07):* OTel defines the logs data model + - API/SDK but **no standard query/read language**; **OTTL is a - Collector *transformation* language, not a querying surface**; the - sources show no canonical OTel read syntax and no Perses-specific - query convention. Bespoke query syntax over the OTel data model is - the norm — there is **nothing to align to beyond the field - semantics**, which §6.1/§6.2 honour (`ts`/`observed_ts`/`trace_id`/ - `span_id`/`flags`/`body`/`scope`/`severity` map to the canonical - data-model fields, and `severity` ordering is on `SeverityNumber`). - Confirms Branch B carries no ecosystem-divergence cost. +- [x] ~~**OTel ecosystem alignment**~~ *Resolved:* OpenTelemetry defines + the logs data model + API/SDK but **no standard query/read + language**, and **OTTL is a Collector *transformation* language, not + a querying surface** (OTTL README and the OTel logs spec, §11). There + is no canonical OTel read syntax, and no Perses-specific query + convention, to align to. Bespoke query syntax over the OTel data + model is the norm (LogQL, PromQL, CloudWatch Insights), so Branch B + carries no ecosystem-divergence cost — the alignment that matters is + at the **field semantics**, which §6.1/§6.2 honour + (`ts`/`observed_ts`/`trace_id`/`span_id`/`flags`/`body`/`scope`/ + `severity` → canonical data-model fields; `severity` ordering on + `SeverityNumber`). - [ ] `--sql` advanced-mode escape hatch — gated + sandboxed, or never? (Currently: never; reconsider under a separate RFC.) - [ ] Custom user functions — out for v1 (sandboxing is its own project). From 55536217044998015dbee48cee04a095b7f9bdd2 Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 11:49:55 +0200 Subject: [PATCH 13/23] =?UTF-8?q?docs(rfc-0002):=20fix=20RFC0007=20=C2=A73?= =?UTF-8?q?.7=20ref,=20boolean-node=20cardinality,=20define=20float?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review pass 11: tenant context now cites CLAUDE.md §3.7 (enforced per RFC0007.5), not a non-existent RFC 0007 §3.7; the structured surface states boolean-node shapes (and/or take a child array, not is unary per §7); and the §7 lexical note defines float (integer . digit {digit}). Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index 3d17d615f..0ae93de0c 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -412,7 +412,8 @@ flowchart LR - **Structured surface** is the machine contract (MCP tool schema + programmatic clients): a JSON predicate tree — leaf **comparison nodes** `{ "field": …, "op": …, "value": … }` and **boolean nodes** - `{ "and" | "or" | "not": [ … ] }` — plus an ordered **`stages`** array + (`{ "and": [ … ] }` / `{ "or": [ … ] }` with a child array; `{ "not": + }` **unary**, per §7) — plus an ordered **`stages`** array mirroring the pipe stages (`range`/`count`/`sort`/`limit`/`project`). Its **JSON Schema is published and versioned with the parser** (snapshot- tested like the §7 grammar; RFC0002.11), and it compiles to the same IR @@ -423,7 +424,8 @@ flowchart LR Both parse/validate to the **same query IR** and compile identically (RFC0002.2). The tenant is **not** expressed in either surface — it is -supplied by the executing context (RFC 0007 §3.7 / RFC0007.5); a query +supplied by the executing context (`CLAUDE.md` §3.7 multi-tenancy; +enforced per RFC0007.5); a query without a tenant is an API usage error, not a cross-tenant scan. ### 6.5 Compilation target @@ -498,7 +500,8 @@ integer = digit , { digit } ; string = '"' , { char | escape } , '"' ; char = any Unicode scalar except '"' or '\' ; escape = '\' , ( '"' | '\' | "n" | "t" | "r" | ( "u" , 4 * hex ) ) ; - number = integer | float ; boolean = "true" | "false" ; + number = integer | float ; float = integer , "." , digit , { digit } ; + boolean = "true" | "false" ; duration = integer , ( "s"|"m"|"h"|"d"|"w" ) ; timestamp = RFC 3339 ; hex = digit | "a".."f" | "A".."F" — strings are double-quoted with backslash escapes; YAML embedding From 5c08f57978245e6c30bdb24408ef7e87806bf8cf Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 11:54:27 +0200 Subject: [PATCH 14/23] docs(rfc-0002): use a literal template_id in examples (X -> 42) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review pass 12: the §7 grammar allows only literals as comparison RHS / function args, so the bare placeholder X in template_id == X / resolves_to(X) was invalid DSL. template_id is u64, so the examples now use 42 (a numeric literal) across §5/§6.3/§6.5. Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index 0ae93de0c..d7c067ece 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -191,7 +191,7 @@ surface? Perses+OTel query conventions?) are folded into §9. > execution layer. - **RFC0002.1 — A Branch-B predicate parses and compiles to a filter `[CLAUDE.md §4.6]`** - - **Given** a Branch-B predicate (e.g. `template_id == X and severity >= error`) + - **Given** a Branch-B predicate (e.g. `template_id == 42 and severity >= error`) - **When** it is parsed and compiled - **Then** it yields the query IR and a DataFusion `Filter`. Predicates over RFC 0007 §4.3's pushdown keys prune the scan per that section's @@ -258,7 +258,7 @@ surface? Perses+OTel query conventions?) are folded into §9. message. - **RFC0002.9 — Template primitives compile `[§6.3]`** - - **Given** `template_id == X`, `resolves_to(X)`, `lossy == true`, + - **Given** `template_id == 42`, `resolves_to(42)`, `lossy == true`, `confidence < 0.7` - **When** compiled - **Then** each compiles to the documented plan (`resolves_to` expands @@ -362,8 +362,8 @@ First-class vocabulary — **Ourios-specific** extensions (RFC 0001 §6.3/§6.7), **not** OpenTelemetry log-data-model fields; they live in the Ourios schema + query layer alongside the OTel-canonical fields of §6.2: -- `template_id == X` — exact template; resolves to the `template_id` column. -- `resolves_to(X)` — `X` plus its drift aliases (the RFC 0001 §6.7 drift +- `template_id == 42` — exact template; resolves to the `template_id` column. +- `resolves_to(42)` — `X` plus its drift aliases (the RFC 0001 §6.7 drift question); compiles to alias-set membership over `template_id`. - `confidence` — miner confidence (e.g. `< 0.7`); the `confidence` column. - `lossy` — the lossy-reconstruction flag; resolves to the RFC 0001 / @@ -441,7 +441,7 @@ Every construct compiles to a DataFusion `LogicalPlan`: | `limit` | `Limit` | | `project` | `Projection` | | `render` | custom projection honouring the three-zone reconstruction model | -| `resolves_to(X)` | custom node expanding to alias-set membership | +| `resolves_to(42)` | custom node expanding to alias-set membership | All but `render` and `resolves_to` are DataFusion's built-in algebra; those two are the only Ourios extensions, both surface-independent. From 48797864c3b386997068deff7dae1bc09eb50420 Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 12:01:41 +0200 Subject: [PATCH 15/23] docs(rfc-0002): exclude newlines from string char; define structured top-level shape MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review pass 13: §7 char excludes line terminators (literal newline only via the \n escape) so queries stay single-line (§4 P7 / RFC0002.10); §6.4 now defines the structured surfaces canonical top-level object { predicate: , stages: [, …] } with node + stage shapes, so the two surfaces can be implemented compatibly (RFC0002.2/.11). Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index d7c067ece..c52aa640d 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -410,11 +410,14 @@ flowchart LR line (the `|` newlines above are cosmetic) — the §4 P7 YAML constraint. - **Structured surface** is the machine contract (MCP tool schema + - programmatic clients): a JSON predicate tree — leaf **comparison nodes** - `{ "field": …, "op": …, "value": … }` and **boolean nodes** - (`{ "and": [ … ] }` / `{ "or": [ … ] }` with a child array; `{ "not": - }` **unary**, per §7) — plus an ordered **`stages`** array - mirroring the pipe stages (`range`/`count`/`sort`/`limit`/`project`). + programmatic clients): a top-level object + `{ "predicate": , "stages": [ , … ] }` (`stages` optional, + default `[]`). A **``** is either a leaf **comparison node** + `{ "field": …, "op": …, "value": … }` or a **boolean node** + (`{ "and": [ , … ] }` / `{ "or": [ , … ] }` with a child + array; `{ "not": }` **unary**, per §7). Each **``** is a + tagged object mirroring a pipe stage + (`range`/`count`/`sort`/`limit`/`project`). Its **JSON Schema is published and versioned with the parser** (snapshot- tested like the §7 grammar; RFC0002.11), and it compiles to the same IR as the string surface (RFC0002.2). It is the formalised, extended @@ -498,7 +501,9 @@ time = "now" | ( [ "-" ] , duration ) | timestamp ; (* e.g. now , -1h integer = digit , { digit } ; (* lexical: ident = letter , { letter | digit | "_" } ; string = '"' , { char | escape } , '"' ; - char = any Unicode scalar except '"' or '\' ; + char = any Unicode scalar except '"' , '\' , or a line terminator + (a literal newline must be written as the \n escape — queries + are single-line, §4 P7 / RFC0002.10) ; escape = '\' , ( '"' | '\' | "n" | "t" | "r" | ( "u" , 4 * hex ) ) ; number = integer | float ; float = integer , "." , digit , { digit } ; boolean = "true" | "false" ; From 1359f28b4eb409c6c645f898ee317b36c91dfd0b Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 12:12:38 +0200 Subject: [PATCH 16/23] docs(rfc-0002): structured call node + enumerate fn_name in EBNF MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review pass 14: the structured surface gains a call node { call: , args: [...] } so it can represent function predicates (matches/contains/starts_with/ends_with/resolves_to) — preserving string=structured equivalence (RFC0002.2). §7 call now uses an enumerated fn_name (not any ident), so unknown function names are ungrammatical (constrained-decoding-friendly). Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index c52aa640d..947f9425d 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -412,8 +412,10 @@ flowchart LR - **Structured surface** is the machine contract (MCP tool schema + programmatic clients): a top-level object `{ "predicate": , "stages": [ , … ] }` (`stages` optional, - default `[]`). A **``** is either a leaf **comparison node** - `{ "field": …, "op": …, "value": … }` or a **boolean node** + default `[]`). A **``** is a leaf **comparison node** + `{ "field": …, "op": …, "value": … }`, a **call node** + `{ "call": "", "args": [ … ] }` (the §6.1 functions + `resolves_to`, + matching the §7 `fn_name` set), or a **boolean node** (`{ "and": [ , … ] }` / `{ "or": [ , … ] }` with a child array; `{ "not": }` **unary**, per §7). Each **``** is a tagged object mirroring a pipe stage @@ -475,7 +477,9 @@ comparison = severity_cmp | scalar_cmp ; severity_cmp = "severity" , cmp_op , ( severity_name | number ) ; scalar_cmp = scalar_path , cmp_op , literal ; cmp_op = "==" | "!=" | "<" | "<=" | ">" | ">=" | "=~" | "!~" ; -call = ident , "(" , [ arg , { "," , arg } ] , ")" ; +call = fn_name , "(" , [ arg , { "," , arg } ] , ")" ; +fn_name = "matches" | "contains" | "starts_with" | "ends_with" + | "resolves_to" ; arg = path | literal ; path = field | "resource" , key_tail | "attr" , key_tail ; scalar_path = nonsev_field | "resource" , key_tail | "attr" , key_tail ; From 64a3998bd15179b929fee489a8a6182a5d0744d1 Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 12:20:24 +0200 Subject: [PATCH 17/23] docs(rfc-0002): make structured-surface atom encoding explicit + complete stage set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review pass 15: §6.4 now spells out how atoms encode (field = §7 path string, op = §7 cmp_op string, value = JSON primitive with duration/ timestamp as §7 lexical strings, call args likewise) for RFC0002.2/.11, and the structured stage set is the full §7 set (range/count/sum/min/max/avg/sort/limit/project/render), not a partial list. Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index 947f9425d..a3eef41a7 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -412,14 +412,18 @@ flowchart LR - **Structured surface** is the machine contract (MCP tool schema + programmatic clients): a top-level object `{ "predicate": , "stages": [ , … ] }` (`stages` optional, - default `[]`). A **``** is a leaf **comparison node** - `{ "field": …, "op": …, "value": … }`, a **call node** - `{ "call": "", "args": [ … ] }` (the §6.1 functions + `resolves_to`, - matching the §7 `fn_name` set), or a **boolean node** + default `[]`). Atoms encode §7 directly: a **`field`** is a string equal + to a §7 `path` (`"service"`, `"attr.http.status_code"`); an **`op`** is a + §7 `cmp_op` string (`"=="`, `">="`, `"=~"`, …); a **`value`** is a JSON + primitive (string / number / bool / null), with durations and timestamps + carried as their §7 lexical strings (`"1h"`, RFC 3339). A **``** is + a **comparison node** `{ "field": …, "op": …, "value": … }`, a **call + node** `{ "call": "", "args": [ … ] }` (`fn` in the §7 `fn_name` set; + each arg a path-string or a value as above), or a **boolean node** (`{ "and": [ , … ] }` / `{ "or": [ , … ] }` with a child array; `{ "not": }` **unary**, per §7). Each **``** is a - tagged object mirroring a pipe stage - (`range`/`count`/`sort`/`limit`/`project`). + tagged object covering the full §7 stage set — + `range`/`count`/`sum`/`min`/`max`/`avg`/`sort`/`limit`/`project`/`render`. Its **JSON Schema is published and versioned with the parser** (snapshot- tested like the §7 grammar; RFC0002.11), and it compiles to the same IR as the string surface (RFC0002.2). It is the formalised, extended From fd4c4cca3f1200e9d58d4c7a1a4f856b3aaf7b54 Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 12:33:29 +0200 Subject: [PATCH 18/23] docs(rfc-0002): typed function signatures in EBNF + structured surface; internal Filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review pass 16: §7 call is now typed per signature — str_fn(path, string) for matches/contains/starts_with/ends_with, resolves_to(number) — so the grammar matches §6.1/§6.3 and is constrained-decoding-exact (no any-fn/ any-args). §6.4 call-node args follow the same typed signatures. RFC0002.1 now says the DataFusion Filter is an internal compilation artifact, never surfaced through the public API (RFC0002.3). Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index a3eef41a7..75c578c23 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -193,7 +193,9 @@ surface? Perses+OTel query conventions?) are folded into §9. - **RFC0002.1 — A Branch-B predicate parses and compiles to a filter `[CLAUDE.md §4.6]`** - **Given** a Branch-B predicate (e.g. `template_id == 42 and severity >= error`) - **When** it is parsed and compiled - - **Then** it yields the query IR and a DataFusion `Filter`. Predicates + - **Then** it yields the query IR and an **internal** DataFusion + `Filter` (a private compilation artifact — never surfaced through the + public API, RFC0002.3). Predicates over RFC 0007 §4.3's pushdown keys prune the scan per that section's split — `template_id` skips row groups (B1), `time_unix_nano` prunes partitions and row groups, `tenant_id` prunes partition directories @@ -418,8 +420,10 @@ flowchart LR primitive (string / number / bool / null), with durations and timestamps carried as their §7 lexical strings (`"1h"`, RFC 3339). A **``** is a **comparison node** `{ "field": …, "op": …, "value": … }`, a **call - node** `{ "call": "", "args": [ … ] }` (`fn` in the §7 `fn_name` set; - each arg a path-string or a value as above), or a **boolean node** + node** `{ "call": "", "args": [ … ] }` whose `args` follow the §7 + typed signatures — `matches`/`contains`/`starts_with`/`ends_with` take + `[ , ]`, `resolves_to` takes `[ ]`), or a + **boolean node** (`{ "and": [ , … ] }` / `{ "or": [ , … ] }` with a child array; `{ "not": }` **unary**, per §7). Each **``** is a tagged object covering the full §7 stage set — @@ -481,10 +485,9 @@ comparison = severity_cmp | scalar_cmp ; severity_cmp = "severity" , cmp_op , ( severity_name | number ) ; scalar_cmp = scalar_path , cmp_op , literal ; cmp_op = "==" | "!=" | "<" | "<=" | ">" | ">=" | "=~" | "!~" ; -call = fn_name , "(" , [ arg , { "," , arg } ] , ")" ; -fn_name = "matches" | "contains" | "starts_with" | "ends_with" - | "resolves_to" ; -arg = path | literal ; +call = str_fn , "(" , path , "," , string , ")" + | "resolves_to" , "(" , number , ")" ; +str_fn = "matches" | "contains" | "starts_with" | "ends_with" ; path = field | "resource" , key_tail | "attr" , key_tail ; scalar_path = nonsev_field | "resource" , key_tail | "attr" , key_tail ; field = nonsev_field | "severity" ; From cabc8a319a925faa8dff9aaa9498419858256673 Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 12:44:59 +0200 Subject: [PATCH 19/23] docs(rfc-0002): drop stray paren; string functions require a string operand MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review pass 17: removed an orphaned closing paren in the §6.4 call-node sentence; §6.1 now states the string functions (matches/contains/ starts_with/ends_with) require a string operand — a non-string path (severity, numeric/bool attr, lossy, ts) is a compile-time type error (RFC0002.8), not a silent coercion. Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index 75c578c23..8311ddd6a 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -325,10 +325,13 @@ booleans (`true`/`false`), `null`, duration literals (`30s`, `1h`, `1d`, **Functions** (read-only, bespoke names tuned for queries) — boolean predicate terms: `matches(path, regex)`, `contains(path, s)`, -`starts_with(path, s)`, `ends_with(path, s)`. (Scalar-returning functions -such as `len(path)` are **deferred**: the grammar admits a call only as a -boolean term, so a numeric `len(...) > n` would need a scalar-comparison -form — added under a future minor version when a need surfaces.) +`starts_with(path, s)`, `ends_with(path, s)`. They require a **string +operand**: applying one to a non-string path (`severity`, a numeric/bool +attribute, `lossy`, `ts`) is a compile-time type error (RFC0002.8), not a +silent coercion. (Scalar-returning functions such as `len(path)` are +**deferred**: the grammar admits a call only as a boolean term, so a +numeric `len(...) > n` would need a scalar-comparison form — added under a +future minor version when a need surfaces.) **Worked predicate.** @@ -422,7 +425,7 @@ flowchart LR a **comparison node** `{ "field": …, "op": …, "value": … }`, a **call node** `{ "call": "", "args": [ … ] }` whose `args` follow the §7 typed signatures — `matches`/`contains`/`starts_with`/`ends_with` take - `[ , ]`, `resolves_to` takes `[ ]`), or a + `[ , ]`, `resolves_to` takes `[ ]`, or a **boolean node** (`{ "and": [ , … ] }` / `{ "or": [ , … ] }` with a child array; `{ "not": }` **unary**, per §7). Each **``** is a From 1b2a433743359d5716de5011ebc6e28ab1851d0c Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 12:55:22 +0200 Subject: [PATCH 20/23] docs(rfc-0002): range now keyword; structured field needs no DSL path syntax MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review pass 18: §6.4 range synopsis lists the now keyword (the §7 time form), not just durations/RFC3339. The structured surface field is now structured — a bare top-level name string or { resource: key } / { attr: key } — so agents never build or escape DSL path syntax (resource[...]), realising the agents-emit-JSON-not-syntax goal; call-node args use the same structured field. Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index 8311ddd6a..db38e62b4 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -405,7 +405,8 @@ flowchart LR | limit 10 ``` - Stages: `range(from, to)` (relative durations or RFC 3339; defaults per + Stages: `range(from, to)` (each bound a relative duration, the `now` + keyword, or an RFC 3339 timestamp — the §7 `time` form; defaults per §4 P5), `count [by ]` (comma-separated, per the §7 `field_list`) and other aggregations (`sum`, `min`, `max`, `avg` over a path), `sort [asc|desc]` @@ -417,15 +418,19 @@ flowchart LR - **Structured surface** is the machine contract (MCP tool schema + programmatic clients): a top-level object `{ "predicate": , "stages": [ , … ] }` (`stages` optional, - default `[]`). Atoms encode §7 directly: a **`field`** is a string equal - to a §7 `path` (`"service"`, `"attr.http.status_code"`); an **`op`** is a - §7 `cmp_op` string (`"=="`, `">="`, `"=~"`, …); a **`value`** is a JSON + default `[]`). A **`field`** is **structured** (no DSL path syntax for + agents to build or escape): a bare top-level name string (`"service"`, + `"severity"`, `"body"`, `"trace_id"`, …) or an attribute object + `{ "resource": "" }` / `{ "attr": "" }` (`` the raw OTel + attribute key, e.g. `"k8s.pod.name"`). An **`op`** is a §7 `cmp_op` + string (`"=="`, `">="`, `"=~"`, …); a **`value`** is a JSON primitive (string / number / bool / null), with durations and timestamps carried as their §7 lexical strings (`"1h"`, RFC 3339). A **``** is a **comparison node** `{ "field": …, "op": …, "value": … }`, a **call node** `{ "call": "", "args": [ … ] }` whose `args` follow the §7 typed signatures — `matches`/`contains`/`starts_with`/`ends_with` take - `[ , ]`, `resolves_to` takes `[ ]`, or a + `[ , ]` (`` as above), `resolves_to` takes + `[ ]`, or a **boolean node** (`{ "and": [ , … ] }` / `{ "or": [ , … ] }` with a child array; `{ "not": }` **unary**, per §7). Each **``** is a From dd1d5f7ad8032d607aa2a02e28cee75b9cbe7c55 Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 13:13:15 +0200 Subject: [PATCH 21/23] =?UTF-8?q?docs(rfc-0002):=20=C2=A74=20hazard=206=20?= =?UTF-8?q?citations;=20severity=20ord=5Fop;=20match-all=20true;=20single-?= =?UTF-8?q?line=20=CE=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review pass 19 (10 comments): cite the no-leakage hazard as CLAUDE.md §4 hazard 6 (the hazards are a numbered list under §4, no §4.6 heading); severity_cmp uses ord_op (no regex =~/!~ on numeric severity); add a bool_lit predicate atom + structured const node so an unfiltered (match-all true) query is expressible on both surfaces; show the β example in canonical single-line form. Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 45 ++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index db38e62b4..cc6aee77a 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -20,13 +20,13 @@ superseded-by: — > `green` as the parser/compiler lands (the RFC 0007 execution layer it > targets is already implemented and tested — RFC 0007 §5), and to > `accepted` after the §9 validation. -> Hazard 6 (`CLAUDE.md` §4.6 — no DataFusion/SQL leakage) constrains the +> Hazard 6 (`CLAUDE.md` §4 — no DataFusion/SQL leakage) constrains the > whole design. ## 1. Summary Ourios exposes a logs query DSL that does **not** leak DataFusion/SQL to -users (hazard `CLAUDE.md` §4.6). This RFC specifies it: +users (`CLAUDE.md` §4 hazard 6). This RFC specifies it: - **Predicate sublanguage — Branch B (distance from OTTL).** An Ourios-native, query-ergonomic syntax over the OTel *data model* (the @@ -52,7 +52,7 @@ language* in front of it. ### 2.1 Why a DSL at all? -`CLAUDE.md` §4.6 commits Ourios to a DSL that does not leak DataFusion SQL. +`CLAUDE.md` §4 hazard 6 commits Ourios to a DSL that does not leak DataFusion SQL. The reasons are **stability** (evolve the backend without breaking user queries), **safety** (full SQL exposes cross-tenant joins, unbounded scans, recursive CTEs we cannot audit), and **fit** (logs are a narrow @@ -162,7 +162,7 @@ surface? Perses+OTel query conventions?) are folded into §9. 1. **Familiarity beats cleverness.** A first-time reader understands a query within 30 seconds without a reference. No heavy sigils. -2. **No DataFusion/SQL leakage** (hazard `CLAUDE.md` §4.6). If explaining a surface +2. **No DataFusion/SQL leakage** (`CLAUDE.md` §4 hazard 6). If explaining a surface form requires naming a DataFusion type, the form is wrong. 3. **Predicate, then pipeline.** A query is a *predicate* (the `where`) followed by ordered *stages* (range, aggregate, sort, limit, project). @@ -190,7 +190,7 @@ surface? Perses+OTel query conventions?) are folded into §9. > parser + compiler that front-ends the (already-implemented, RFC 0007 §5) > execution layer. -- **RFC0002.1 — A Branch-B predicate parses and compiles to a filter `[CLAUDE.md §4.6]`** +- **RFC0002.1 — A Branch-B predicate parses and compiles to a filter `[CLAUDE.md §4 hazard 6]`** - **Given** a Branch-B predicate (e.g. `template_id == 42 and severity >= error`) - **When** it is parsed and compiled - **Then** it yields the query IR and an **internal** DataFusion @@ -216,7 +216,7 @@ surface? Perses+OTel query conventions?) are folded into §9. - **Then** they produce the *same* query IR (and hence the same `LogicalPlan`) — the one-core/two-surfaces invariant. -- **RFC0002.3 — No DataFusion/arrow/SQL leakage `[CLAUDE.md §4.6]`** +- **RFC0002.3 — No DataFusion/arrow/SQL leakage `[CLAUDE.md §4 hazard 6]`** - **Given** the public DSL API (parse, compile, error types) - **When** a query parses, compiles, or fails - **Then** no `datafusion`/`arrow`/SQL type or message appears in any @@ -285,7 +285,9 @@ surface? Perses+OTel query conventions?) are folded into §9. ### 6.1 Predicate sublanguage (Branch B) A predicate is a boolean expression over **paths**, **operators**, and -**literals** against the OTel log data model. +**literals** against the OTel log data model. The bare literal `true` is +the **match-all** predicate (for queries that filter only by `range`/other +stages); `false` matches nothing. **Paths.** @@ -398,13 +400,12 @@ flowchart LR query is a predicate optionally followed by `|`-separated stages: ```text - service == "api" and severity >= error - | range(-1h, now) - | count by template_id - | sort count desc - | limit 10 + service == "api" and severity >= error | range(-1h, now) | count by template_id | sort count desc | limit 10 ``` + A predicate-only / "no filter" query uses the match-all atom `true`, + e.g. `true | range(-1h, now) | limit 100`. + Stages: `range(from, to)` (each bound a relative duration, the `now` keyword, or an RFC 3339 timestamp — the §7 `time` form; defaults per §4 P5), `count [by ]` (comma-separated, per the §7 @@ -413,7 +414,8 @@ flowchart LR (the §7 `sort_key` — a field or an aggregate output like `count`), `limit `, `project ` / `render`. The whole query is expressible on one - line (the `|` newlines above are cosmetic) — the §4 P7 YAML constraint. + line as shown (whitespace around `|` is optional) — the §4 P7 YAML + constraint. - **Structured surface** is the machine contract (MCP tool schema + programmatic clients): a top-level object @@ -430,8 +432,9 @@ flowchart LR node** `{ "call": "", "args": [ … ] }` whose `args` follow the §7 typed signatures — `matches`/`contains`/`starts_with`/`ends_with` take `[ , ]` (`` as above), `resolves_to` takes - `[ ]`, or a - **boolean node** + `[ ]`, a **constant node** `{ "const": true | false }` (the §7 + `bool_lit` match-all / match-none — `{ "const": true }` is the "no + filter" predicate), or a **boolean node** (`{ "and": [ , … ] }` / `{ "or": [ , … ] }` with a child array; `{ "not": }` **unary**, per §7). Each **``** is a tagged object covering the full §7 stage set — @@ -488,11 +491,13 @@ query = predicate , { "|" , stage } ; predicate = or_expr ; or_expr = and_expr , { ("or" | "||") , and_expr } ; and_expr = unary , { ("and" | "&&") , unary } ; -unary = [ "not" | "!" ] , ( comparison | call | "(" , predicate , ")" ) ; +unary = [ "not" | "!" ] , ( comparison | call | bool_lit | "(" , predicate , ")" ) ; +bool_lit = "true" | "false" ; (* match-all / match-none; a bare `true` = no filter *) comparison = severity_cmp | scalar_cmp ; -severity_cmp = "severity" , cmp_op , ( severity_name | number ) ; +severity_cmp = "severity" , ord_op , ( severity_name | number ) ; scalar_cmp = scalar_path , cmp_op , literal ; -cmp_op = "==" | "!=" | "<" | "<=" | ">" | ">=" | "=~" | "!~" ; +ord_op = "==" | "!=" | "<" | "<=" | ">" | ">=" ; (* no regex — severity is numeric *) +cmp_op = ord_op | "=~" | "!~" ; call = str_fn , "(" , path , "," , string , ")" | "resolves_to" , "(" , number , ")" ; str_fn = "matches" | "contains" | "starts_with" | "ends_with" ; @@ -594,7 +599,7 @@ canonical fields (§6.2). Alternatives that would replace the whole design, not just one branch. - **Pure SQL (DataFusion dialect)** — zero parser cost, but violates - hazard `CLAUDE.md` §4.6 (cross-tenant joins, unbounded scans) and binds the user + `CLAUDE.md` §4 hazard 6 (cross-tenant joins, unbounded scans) and binds the user surface to DataFusion. Rejected as default; possible future gated, sandboxed escape hatch under a separate RFC. - **LogQL clone** — label selectors are less expressive than the OTel log @@ -621,6 +626,6 @@ Alternatives that would replace the whole design, not just one branch. - Perses (CNCF dashboards-as-code): https://perses.dev/ - Apache DataFusion logical-plan documentation. - RFC 0001 §6.1/§6.3/§6.7 (the columns + template/drift primitives); - RFC 0007 (the execution layer this DSL targets); `CLAUDE.md` §4.6 + RFC 0007 (the execution layer this DSL targets); `CLAUDE.md` §4 hazard 6 (no-leakage hazard) and `CLAUDE.md` §3.7 (multi-tenancy). From 8860effd20b2e1511547a1ec626ade400ffe4a92 Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 13:35:37 +0200 Subject: [PATCH 22/23] =?UTF-8?q?docs(rfc-0002):=20full=20status=20ladder;?= =?UTF-8?q?=20define=20digit/letter;=20clarify=20=C2=A711=20citation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review pass 20: status note now names validated then accepted (per the README ladder) after §9 validation, not green→accepted directly; §7 lexical note defines digit + letter (self-contained grammar); the §9 resolution cites the OTTL README + OTel logs spec "linked in §11 References" (not implying the OTel spec has a §11). Co-Authored-By: Claude Opus 4.8 --- docs/rfcs/0002-query-dsl.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index cc6aee77a..7006166e5 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -18,8 +18,9 @@ superseded-by: — > MCP agents). This RFC is now `specified` — §6 gives the design, §7 the > grammar, §5 the testable acceptance criteria. It advances to `red` → > `green` as the parser/compiler lands (the RFC 0007 execution layer it -> targets is already implemented and tested — RFC 0007 §5), and to -> `accepted` after the §9 validation. +> targets is already implemented and tested — RFC 0007 §5); then, per the +> `docs/rfcs/README.md` ladder, `validated` and finally `accepted` (a +> maintainer flip) follow the §9 validation. > Hazard 6 (`CLAUDE.md` §4 — no DataFusion/SQL leakage) constrains the > whole design. @@ -532,6 +533,7 @@ integer = digit , { digit } ; number = integer | float ; float = integer , "." , digit , { digit } ; boolean = "true" | "false" ; duration = integer , ( "s"|"m"|"h"|"d"|"w" ) ; timestamp = RFC 3339 ; + digit = "0".."9" ; letter = "a".."z" | "A".."Z" ; hex = digit | "a".."f" | "A".."F" — strings are double-quoted with backslash escapes; YAML embedding (RFC0002.10) wraps the whole query in a single-quoted YAML scalar so @@ -571,7 +573,8 @@ two-loop: `#[ignore]`'d stubs first, implementations second). - [x] ~~**OTel ecosystem alignment**~~ *Resolved:* OpenTelemetry defines the logs data model + API/SDK but **no standard query/read language**, and **OTTL is a Collector *transformation* language, not - a querying surface** (OTTL README and the OTel logs spec, §11). There + a querying surface** (see the OTTL README and the OTel logs spec + linked in §11 References). There is no canonical OTel read syntax, and no Perses-specific query convention, to align to. Bespoke query syntax over the OTel data model is the norm (LogQL, PromQL, CloudWatch Insights), so Branch B From 5d0be305e24829d960551948c8af2ba7a21daa76 Mon Sep 17 00:00:00 2001 From: Jens Holdgaard Pedersen Date: Sun, 7 Jun 2026 13:46:46 +0200 Subject: [PATCH 23/23] =?UTF-8?q?docs(rfc-0002):=20broaden=20bracket-path?= =?UTF-8?q?=20cases;=20align=20=C2=A75=20doc-comment=20format=20to=20verif?= =?UTF-8?q?ication.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review pass 21: resource[...]/attr[...] now described as needed for any non-bare-identifier key (chars outside the set, digit-leading segment, reserved-word collision), not just out-of-set characters; the §5 preface now cites the docs/verification.md §2.2 doc-comment form (/// Scenario RFC0002. — . + /// See ...). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --- docs/rfcs/0002-query-dsl.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/docs/rfcs/0002-query-dsl.md b/docs/rfcs/0002-query-dsl.md index 7006166e5..e7e3f6b91 100644 --- a/docs/rfcs/0002-query-dsl.md +++ b/docs/rfcs/0002-query-dsl.md @@ -186,9 +186,11 @@ surface? Perses+OTel query conventions?) are folded into §9. ## 5. Acceptance criteria -> `Given/When/Then`, ids greppable from tests (`RFC0002.<n>`, referenced -> verbatim in each test's leading doc comment). These specify the -> parser + compiler that front-ends the (already-implemented, RFC 0007 §5) +> `Given/When/Then`, ids greppable from tests: each test carries the +> `docs/verification.md` §2.2 doc-comment form — +> `/// Scenario RFC0002.<n> — <title>.` plus +> `/// See docs/rfcs/0002-query-dsl.md §5.`. These specify the parser + +> compiler that front-ends the (already-implemented, RFC 0007 §5) > execution layer. - **RFC0002.1 — A Branch-B predicate parses and compiles to a filter `[CLAUDE.md §4 hazard 6]`** @@ -302,11 +304,13 @@ stages); `false` matches nothing. DSL keeps the split explicit rather than flattening.) - **Resource attributes**: `resource.<key>` where `<key>` is the OTel attribute key taken literally including dots (`resource.service.name` → - resource attribute `"service.name"`). Bracketed form - `resource["k8s.pod.name"]` for keys with characters outside the - bare-identifier set. + resource attribute `"service.name"`). Bracketed form `resource["..."]` + for any key not expressible as dotted bare identifiers — characters + outside the bare-identifier set, a segment starting with a digit, or a + reserved-word collision (`resource["k8s.pod.name"]`, `resource["3rd.party"]`). - **Log-record attributes**: `attr.<key>` (`attr.http.status_code` → - attribute `"http.status_code"`); bracketed `attr["k"]` when needed. + attribute `"http.status_code"`); bracketed `attr["..."]` for the same + non-bare-identifier cases. - **Severity**: `severity` compares against a **bare severity name** (`severity >= error`), case-insensitive, or a **numeric** form (`severity >= 17`). All severity comparisons — **including ordering**