Source-derived dialect census with anti-drift guards (Epic 19 / R2a function-library audit) - #249
Open
fupelaqu wants to merge 1 commit into
Open
Source-derived dialect census with anti-drift guards (Epic 19 / R2a function-library audit)#249fupelaqu wants to merge 1 commit into
fupelaqu wants to merge 1 commit into
Conversation
…ards (Epic 19 / R2a audit)
One machine-generated, drift-proof inventory of every construct the SQL
dialect accepts: 259 SYNTAX-FORM rows (171 function rows covering all 95
SQLKeywords.functionTokens and all 149 accepted spellings, 29 operators,
36 clauses, 6 literals, 17 units), each anchored to a verbatim source
substring resolved to file:line at emit time (exactly-one-hit,
wrap-tolerant), each example proven parseable by the real Parser, ES
constructs derived from the parsed AST with an es_construct_source
column, Rule-R shape-checked citations (every ansi_adjacent URL fetched),
two-way registry coverage diffs, the 95/95/149 pins, and a phantom-help
corpus walk (13 phantoms, 3 of them wired). Emits
sql/target/epic-19/dialect-census.{csv,json,md} on every run; nothing is
assume-guarded. Green on Scala 2.12.20 + 2.13.16; SQLKeywordsSpec
untouched.
Story 19.1 (dialect-census), Epic 19.
Closed Issue #248
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
fupelaqu
marked this pull request as ready for review
September 1, 2026 05:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Story 19.1 of the R2a function-library audit: one machine-generated, drift-proof inventory of every construct the elasticsql SQL dialect accepts, so Epic 22's jOOQ-render estimate rests on a counted surface that cannot rot between the audit and the implementation that consumes it.
Three test-tree sources under
sql/src/test/scala/app/softnetwork/elastic/sql/census/(no production or published code changes; test artifacts are not published):CensusModel.scala— row model (CensusEntry,Kind,EsConstruct,Standardwith shape-checked Rule-R evidence gates) + emitters (RFC-4180 CSV with every cell quoted, provenance-stamped JSON object{"provenance", "rows"}, GFM markdown with backslash-first|escaping).DialectCensus.scala— 259 hand-authored SYNTAX-FORM rows: 171 function rows covering all 95SQLKeywords.functionTokensand all 149 accepted spellings (54 aliases, 22 computed at runtime byTimeField.words— 9 exist in no source literal, which is why this census RUNS instead of scraping), 29 operators, 36 clauses, 6 literals, 17 units. Everyansi_adjacentcitation fetched from PostgreSQL 16 / MySQL 8.4 / DuckDB docs; everyansirow cites a Feature id grounded on PostgreSQL 16's SQL-conformance table.DialectCensusSpec.scala— the generator/guard: wrap-tolerant anchors resolved tofile:lineat emit time (exactly-one-hit or the build fails naming the anchor), every example parsed through the realParser, ES constructs derived from the parsed AST (es_construct_source= derived 170 / pinned 89), two-way registry coverage diffs, the 95/95/149 pins, per-token minimum-form gates, and a phantom-help corpus walk (13 phantoms, 3 of them wired intojson/_index.json). Nothing isassume-guarded — a wrong working directory fails, it never skips. Runs on everysbt sql/test.Findings recorded in the census (19.2/19.3 inputs)
||(Pipe) and bareEare dead tokens — declared and registered, but no production consumes them; jOOQ renders||, a guaranteed round-trip gap.CROSS JOINis grammar-accepted but rejected byStandardJoin.validate(theCrossJoinexemption inJoin.validateis unreachable).LOGis the NATURAL log (PG/DuckDBlog= base-10);STRPOSreverses PG/DuckDB argument order;DAYOFWEEKnumbering differs across all three engines; canonicalDATE_TRUNC(date, part)reverses PG/DuckDB.Verification
sbt "sql/testOnly *DialectCensusSpec"— 16/16 green; emitssql/target/epic-19/dialect-census.{csv,json,md}.sbt "+ sql/test"— 548/548 on both Scala 2.12.20 and 2.13.16.sbt scalafmtAllclean; baresbt headerCheckgreen;SQLKeywordsSpecuntouched and green.The census tables consumed by stories 19.2/19.3/19.4 are local
_bmad-output/planning-artifacts/epic-19-function-census.{md,csv,json,md-table}deliverables (gitignored by project convention); the reproducibility guarantee is this tracked spec, which regenerates them byte-for-byte.Closes #248
🤖 Generated with Claude Code