Skip to content

test(v18): commit the outputs for every kitchen-sink statement - #221

Merged
devin-ai-integration[bot] merged 1 commit into
mainfrom
feat/output-snapshots
Nov 26, 2026
Merged

devin-ai-integration[bot] merged 1 commit into
mainfrom
feat/output-snapshots

Conversation

@pyramation

@pyramation pyramation commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

18.2.5 changed 1,000+ fingerprints and the parse output without anyone noticing, because no test stated what the outputs are. This commits them, so any output change shows up as a failing test and as a diff in the PR that causes it. No comparison with a published version.

  • versions/18/test/snapshots/corpus.json: the 24,159 kitchen-sink statements, copied from pgsql-parser's __fixtures__/generated/generated.json (at pgsql-parser@1069446).
  • versions/18/test/snapshots/pg18.json: one line per statement with the fingerprint and a 12-hex sha256 of the parseSync tree (without version), the normalizeSync query and the scanSync tokens. A thrown error is stored as error: <message>.
  • versions/18/test/snapshots.test.js: runs the corpus (about 2 s) and lists each changed output as name column: old -> new.
"pretty/types-1.sql": ["801615c574f69ece","b9582b549620","36b2b5cab55b","9cf100efc75a"],

When a change is intended: UPDATE_SNAPSHOTS=1 node --test test/snapshots.test.js, and the diff of pg18.json shows how many statements and which functions it touched.

The test fails on builds whose outputs differ

Same file pointed at published packages (Node 22):

Release Result
18.1.5 fail, 3,169 outputs changed (fingerprint and parse)
18.2.4 fail, 3,169 outputs changed
18.2.7 pass
this build pass

Things to know

  • Hashes, not full outputs: full parse trees for this corpus are tens of MB. The test names the statement and function; the old output comes from running the previous build.
  • Both files are 2.5–2.9 MB and are not published (files is wasm/*).
  • PL/pgSQL fixtures (parsePlPgSQL) are not included.
  • The snapshot was generated on Linux; macOS and Windows CI show whether outputs are identical across platforms.

libpg-query and parser opened this PR for Dan
Implemented in session Find why regressions slip past our release process
Review with Devin · Open in Devin Desktop


Summary by CodeRabbit

  • Tests
    • Added automated snapshot checks for PostgreSQL 18 statements, covering fingerprints, parse trees, normalized queries, and scan-token output.
    • The checks compare results with stored snapshots and report differences, helping identify changes in query-processing outputs. Snapshots can also be regenerated when expected outputs change.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@luxor-code-review

luxor-code-review Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This PR introduces a versioned PostgreSQL 18 test suite for libpg-query-node. It pins the @libpg-query/parser dependency in the version manifest and adds a snapshot test runner that parses a SQL corpus and compares parse output against committed golden files, including regeneration support via an update mode. No code defects above the reporting threshold were found; one low-severity robustness note about the snapshot-regeneration write path (non-atomic fs.writeFileSync with no post-write verification) fell just below the confidence cutoff and is not included inline.

Files Change
versions/18/package.json Pins the PostgreSQL 18 parser dependency for the new versioned suite.
versions/18/test/snapshots.test.js New snapshot harness: parses the corpus and diffs parse output against the golden file, with an update-regeneration mode.
versions/18/test/snapshots/corpus.json Adds the SQL corpus fixture (~thousands of statements) used as snapshot input.
versions/18/test/snapshots/pg18.json Adds the committed golden parse-output snapshot for the corpus.

Reviewed commit: 44b8522

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

Walkthrough

Adds PG18 snapshot tests that compute fingerprint, parse-tree, normalized-query, and scan-token outputs for corpus statements. The test can write updated snapshots or compare outputs with the existing snapshot. The package test script now runs this test.

Changes: PG18 snapshot testing

Layer / File(s) Summary
Output helpers
versions/18/test/snapshots.test.js
Adds helpers to compute and serialize fingerprint, parse-tree, normalized-query, and scan-token outputs. Errors are recorded as output strings.
Corpus snapshot test and test script
versions/18/test/snapshots.test.js, versions/18/package.json
Loads the WASM module and processes each corpus statement. With UPDATE_SNAPSHOTS set, the test writes pg18.json; otherwise, it checks statement names and outputs. The package test script includes the test.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Possibly related PRs

Suggested reviewers: luxor-code-review

Security architecture risk: Minimal · up to 44b85

The new test checks parser outputs against a committed baseline. It does not change the published package interface or production behavior.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "test(v18): commit the outputs for every kitchen-sink statement" matches the main change. The PR adds committed snapshot outputs (fingerprint, parse-tree hash, normalized query, scan tokens)…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "test(v18): commit the outputs for every kitchen-sink statement" matches the main change. The PR adds committed snapshot outputs (fingerprint, parse-tree hash, normalized query, scan tokens) for every kitchen-sink SQL statement in the v18 test suite, and adds a snapshot test that compares these outputs. The title is specific, concise, and follows the conventional commit style. It does not describe the package.json test-script change in detail, which is expected for a title.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Review coverage is incomplete: 2 files could not be fully reviewed. Findings from completed review steps are included; see review info for details.

Usage-based review receipt

  • Mode: Continue automatically
  • Reviewed files: 2
  • Waived: $0.50 (charged $0.00)
  • View usage details

Note

This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 1f6ac60 and 44b8522.

Files selected for processing: 4

  • versions/18/package.json
  • versions/18/test/snapshots.test.js
  • versions/18/test/snapshots/corpus.json
  • versions/18/test/snapshots/pg18.json
Files not reviewed because the changes were too large to process: 2

  • versions/18/test/snapshots/corpus.json
  • versions/18/test/snapshots/pg18.json

Limit details: You’ve used all 10 included reviews currently available.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@devin-ai-integration
devin-ai-integration Bot merged commit 860db1c into main Nov 26, 2026
66 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