Milestones 1 and 2: scaffolding, codegen, oracle, and corpus goldens - #2
Merged
Conversation
Module skeleton pinned to libpg_query 17-6.2.2 (PostgreSQL 17.7, patched): - go.mod with the single runtime dependency (google.golang.org/protobuf), MIT + PostgreSQL + libpg_query license notices, CI (CGO_ENABLED=0 build/test + generated-files-are-current check) - srcdata/ vendors the libpg_query generator inputs (struct/enum/typedef metadata JSON + pg_query.proto); internal/reference/ vendors gram.y, scan.l, parser.c (patches 01/03/04/09 applied) and kwlist.h - cmd/generate emits ast/pg_query.pb.go (via protoc), aliases.go (621 root-package type aliases plus enum consts/vars into ast/), and internal/lexer/keywords.go (491 keywords, four reserved-ness categories + bare-label attribute) - oliphant.go mirrors pg_query_go's pg_query.go function-for-function; makefuncs.go ported verbatim; parser subpackage carries the Error type and byte-level entry points, all returning not-implemented for now Gate: pg_query_go v6.2.2's parse_test.go expected-tree literals compile unchanged against oliphant's types (parse_test.go, import swap only), with a skip guard until the parser milestones land. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VbG2Ht5x88uCDisDHUVCcz
- oracle/ is a separate go module (the only cgo anywhere) wrapping the pinned pg_query_go v6.2.2 behind a JSONL stdin/stdout protocol - cmd/regenerate derives parser/testdata from the oracle: the PostgreSQL regression suite (psql metacommands and COPY-FROM-stdin payloads filtered), both deparser corpora, the libpg_query inline test tables (inputs transcribed mechanically, expectations always from the oracle), and pg_query_go's fingerprint corpus incl. the 1.1 MB stress insert - eight suites: parse, scan, normalize, normalize_utility, fingerprint, deparse, split_scanner, split_parser - internal/testfile reads/writes the family's ==/-- corpus format (with escaping for SQL's own "--" comment lines) and the metadata.json todo sidecars; regeneration preserves passing status so only real diffs return to the todo list - parser corpus harness: todo cases skip by default, non-todo failures are regressions, and -check-parse harvests newly passing cases into the sidecars; cmd/next-test picks the next todo case in milestone order Gate: two regeneration runs produce byte-identical trees (verified, and enforced weekly by the regenerate workflow). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VbG2Ht5x88uCDisDHUVCcz
1,525 .test files / 217,229 cases produced by cmd/regenerate against the pinned oracle; every case starts on the todo list. Never edit these by hand - the oracle writes them or nobody does. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VbG2Ht5x88uCDisDHUVCcz
Mark both gates met and add as-built notes: measured corpus counts at the pin, the escaped .test format addition, regenerate's todo preservation, the protoc requirement, and the deliberately deferred tiers (sqlc endtoend, plpgsql_regress, summary). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VbG2Ht5x88uCDisDHUVCcz
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.
Implements the first two milestones of PLAN.md, pinned to libpg_query 17-6.2.2 (PostgreSQL 17.7, patched). Both acceptance gates verified.
Milestone 1 — scaffolding + codegen
github.com/sqlc-dev/oliphantwith the single runtime dependency (google.golang.org/protobuf); MIT + PostgreSQL + libpg_query license notices; CI builds and tests withCGO_ENABLED=0and checks generated files are current.srcdata/(libpg_query metadata JSON +pg_query.proto) andinternal/reference/(gram.y,scan.l,parser.cfrom the PostgreSQL 17.7 tarball with libpg_query patches 01/03/04/09 applied, pluskwlist.h) — docs-only, with provenance READMEs.cmd/generateemitsast/pg_query.pb.go(273 messages, 71 enums),aliases.go(621 root-package type aliases plus every enum const/var, sopg_query.SelectStmtetc. resolve exactly as in pg_query_go), andinternal/lexer/keywords.go(491 keywords, four reserved-ness categories + bare-label attribute).oliphant.gomirrors pg_query_go's API function-for-function;makefuncs.goported verbatim;parsersubpackage carries theErrortype and byte-level entry points. Everything fails loudly with a not-implemented error (pinned byTestNotImplementedErrors) until its milestone lands.parse_test.goexpected-tree literals compile unchanged (parse_test.go, import path swap only, plus a skip guard until the parser exists).Milestone 2 — corpus + oracle
oracle/is a separate go module — the only cgo anywhere — wrapping pg_query_go v6.2.2 behind a JSONL stdin/stdout protocol. The main module never links it; rootgo build ./...compiles no C.cmd/regeneratederivesparser/testdatafrom the oracle: the PostgreSQL regression suite (224 files; psql metacommands and COPY-FROM-stdin payloads filtered), both deparse corpora (15 + 150 files), the libpg_query inline test tables (inputs transcribed mechanically — expectations only ever come from the oracle), and pg_query_go's fingerprint corpus including the 1.1 MB stress insert..testfiles / 217,229 cases (~80 MB) across eight suites —parse,scan,normalize,normalize_utility,fingerprint,deparse,split_scanner,split_parser— every case starting astodo.internal/testfileimplements the family's==/--corpus format with one addition: content lines colliding with the markers are|-escaped (SQL comment banners of exactly--are everywhere in the regress files); round-trip is unit-tested.go test ./parserskips todo cases and treats any non-todo failure as a hard regression;-check-parseharvests newly passing cases out of themetadata.jsonsidecars.cmd/next-testpicks the next todo in milestone order (lexer first).regenerateworkflow re-verifies reproducibility against a freshly built oracle.Deliberately deferred
plpgsql_regress/(milestone 11) and summary goldens (milestone 10).Verification
CGO_ENABLED=0 go build ./... && go test ./...green;go vetand gofmt clean.SELECT 1→ fingerprint50fde20626009aba; error goldens carry message/cursorpos/filename/funcname).diff -rqover two independentcmd/regenerateruns: no differences.🤖 Generated with Claude Code
https://claude.ai/code/session_01VbG2Ht5x88uCDisDHUVCcz
Generated by Claude Code