Skip to content

conformance: add a corpus compile report - #3

Merged
be-thomas merged 2 commits into
mainfrom
feat/conformance-report
Oct 26, 2026
Merged

be-thomas merged 2 commits into
mainfrom
feat/conformance-report

Conversation

@be-thomas

Copy link
Copy Markdown
Owner

What this changes

Adds a measured report over the checked-in query corpus, and publishes it in
the README.

make corpus-report prints, per collection and in total:

  • how many queries parse to the IR (*ast.Pipeline),
  • how many of those (IR→target) and how many overall (SPL→target) emit to
    ES|QL,
  • the same for PromQL.

There is no separate SQL back-end: ES|QL is the SQL-style target and PromQL the
other, which the README section states.

Collection Queries → IR SPL→IR → ES|QL SPL→ES|QL IR→ES|QL → PromQL SPL→PromQL IR→PromQL
spl1 549 69 12.6% 59 10.7% 85.5% 6 1.1% 8.7%
spl1-detections 2,171 15 0.7% 6 0.3% 40.0% 0 0.0% 0.0%
spl2 92 0 0.0% 0 0.0% — 0 0.0% —
Total 2,812 84 3.0% 65 2.3% 77.4% 6 0.2% 7.1%

All figures use the compiled-in default mapping with no per-query index,
metric, or span override.

Implementation

  • conformance/report_test.go: TestCorpusReport, skipped unless
    -corpus-report is set, so go test ./conformance is unchanged. It reuses
    the corpus loader and counts a query as emitted only when the emitter
    returns no error and a non-empty query.
  • Makefile: corpus-report target and help line.
  • README.md: new "Conformance report" section with the generated table.
  • CONFORMANCE.md: points at the report as the measurement companion to
    TestCorpus's assertions.
  • CHANGELOG.md: entry under Unreleased.

Tests run

  • make check — format, vet, tests, build: pass.
  • make corpus-report twice: same table.
  • The generated table was copied into the README and compared line by line.

Open questions

  1. Drift guard. The README table is generated by hand (make corpus-report
    then paste). Should CI compare the README table with the generated one and
    fail on a stale report, the way make generate-check protects the ANTLR
    output?
  2. Overrides. The report uses defaults, so queries that only need an
    --index or --metric count as failures. Should the report also measure
    the best case with per-query overrides, or stay on the default path?

`make corpus-report` measures the checked-in corpus instead of asserting
its outcomes: how many queries parse to the IR, how many of those emit to
ES|QL, and how many emit to PromQL, with end-to-end percentages as well.

The report is printed by TestCorpusReport, which is skipped unless
-corpus-report is set, so the ordinary test run is unchanged. The current
table is published in the README's "Conformance report" section.

@be-thomas be-thomas left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review of ffd9645, verified on a clean checkout of the commit.

What I checked:

  • make check passes (gofmt, vet, tests, build).
  • make corpus-report exits 0 and prints an identical table on two runs; only the surrounding go test timing lines differ.
  • Recomputed every cell independently (separate loader; ParseVersion by each collection's dialect; Transpile with compiler.Options{}; plus a second pass through compiler.Compile with mapping.Default()). All counts and percentages match the README. Denominators are correct: SPL→x divides by all queries and IR→x by parsed queries, parse failures never start an emit attempt, and the Total row sums the tallies (2,812 = 549 + 2,171 + 92; 84 = 69 + 15 + 0; 65 and 6 likewise). The — cells are the zero IR denominators in spl2.
  • emits matches the CLI: ESQL's result() blanks the query when an error diagnostic exists and PromQL's abort returns an empty query, so err == nil && non-empty cannot miss a success or count a failure. The corpus contains no case of err == nil with empty output or err != nil with output. Options{} leaves Mapping nil, which both emitters resolve to mapping.Default(), and leaves index/metric/span empty, the CLI's defaults.
  • Dialect selection matches runCorpus (metadata spl2 → SPLVersion2, otherwise SPLVersion1), and corpusDirs sorts its glob, so row order is stable and matches the README.
  • Without -corpus-report the test skips and go test ./conformance is unchanged; the Makefile passes -v -count=1, so the table is visible, the run is uncached, and a failure exits non-zero.
  • Spot checks against the CLI agree for parse+emit, parse+refuse (both targets), and parse-fail. tstats is the first refusal for exactly 1,022 detection queries, as the prose says.

Two documentation nits are inline.

Comment thread README.md Resolved
Comment thread README.md Resolved
The printed table now matches the README exactly: collection names are
code-formatted, every Total cell is bold, and the total row is built from
the total flag rather than a name. Correct the PromQL refusal prose to the
measured breakdown instead of attributing most refusals to four stages.
@be-thomas
be-thomas merged commit 0e59d2c into main Oct 26, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant