Repository navigation
build: pin libpg_query commit + emsdk 6.0.3; generate every Makefile from x-publish (#170) - #174
pyramation wants to merge 1 commit into
Conversation
…e every Makefile from x-publish Each version's libpg_query repo, branch and commit now live in package.json x-publish and are applied by copy:templates, so regenerating no longer flips 15/17/18 back to pganalyze sources or drops the v18 memory knobs. The build checks out the pinned commit and keys the source cache by it; wasm:make runs the emscripten/emsdk:6.0.3 image instead of the floating default tag.
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Review complete. 🟡 3 medium 💬 Inline comments (1)
📍 Findings outside the diff (2) — 🟡 2 medium — defects on lines GitHub can't attach comments to🟡 Medium — Pin validation throw is swallowed; script exits 0 · copy-templates.js:39–56 · // scripts/copy-templates.js
39 if (version && libpgQueryTag) {
40 if (!libpgQueryRepo || !/^[0-9a-f]{40}$/.test(libpgQueryCommit || '')) {
41 throw new Error(`x-publish needs libpgQueryRepo and a full 40-char libpgQueryCommit`);
42 }
43 configs[version] = {
44 tag: libpgQueryTag,
45 repo: libpgQueryRepo,
46 commit: libpgQueryCommit,
47 hasEmscriptenPatch: version === '13', // Only version 13 needs the patch
48 fullApi
49 };
50 console.log(` Version ${version}: ${libpgQueryTag} @ ${libpgQueryCommit.slice(0, 7)}${fullApi ? ' (full API)' : ''}`);The new validation 🟡 Medium — fetch-protos 404s for repointed pg15/pg17 refs · fetch-protos.js:73 · // scripts/fetch-protos.js
73 const url = `https://raw.githubusercontent.com/pganalyze/libpg_query/refs/tags/${libpgQueryTag}/protobuf/pg_query.proto`;This PR repoints versions 15 and 17 to The change adds
Reviewed commit: 0b8713c |
There was a problem hiding this comment.
This PR switches libpg_query source pinning from tags to explicit fork repo/commit pins across all six version Makefiles and package.json files, with template regeneration support.
Key findings
- 🟡 Pin validation throw is swallowed; script exits 0 — copy-templates.js:39
- 🟡 Failed pin checkout leaves poisoned, unpinned cache dir — Makefile.template:50
- 🟡 fetch-protos 404s for repointed pg15/pg17 refs — fetch-protos.js:73
| $(LIBPG_QUERY_DIR): | ||
| mkdir -p $(CACHE_DIR) | ||
| git clone -b $(LIBPG_QUERY_TAG) --single-branch $(LIBPG_QUERY_REPO) $(LIBPG_QUERY_DIR) | ||
| git -C $(LIBPG_QUERY_DIR) -c advice.detachedHead=false checkout $(LIBPG_QUERY_COMMIT) |
There was a problem hiding this comment.
🟡 bug · medium
Failed pin checkout leaves poisoned, unpinned cache dir
The $(LIBPG_QUERY_DIR) rule stamps the target by directory existence while the new git checkout $(LIBPG_QUERY_COMMIT) line (templates/Makefile.template:53) can fail — e.g. the commit is not reachable from the single ref fetched by git clone -b $(LIBPG_QUERY_TAG) --single-branch, or the run is interrupted. When that happens the directory already exists, so the next make considers the target up to date and silently skips clone, checkout, and the v13 emscripten patch, building against whatever revision the clone was left at instead of the pin. This defeats the byte-for-byte reproducibility the pin was added for.
📋 Prompt for AI Agents
In templates/Makefile.template lines 51-53 (then regenerate all versions/*/Makefile via npm run copy:templates), the $(LIBPG_QUERY_DIR) rule runs mkdir, git clone -b $(LIBPG_QUERY_TAG) --single-branch ..., and git checkout $(LIBPG_QUERY_COMMIT) as separate recipe lines against a directory-existence target: if the checkout fails, the directory remains and later make runs skip the whole recipe, silently building from the branch tip instead of the pin. Combine the clone and checkout into one chained recipe that removes the directory on failure (git clone ... && git -C ... checkout ... || { rm -rf $(LIBPG_QUERY_DIR); exit 1; }), and consider fetching the pinned commit explicitly (git -C $(LIBPG_QUERY_DIR) fetch origin $(LIBPG_QUERY_COMMIT)) so a commit not reachable from the single-branch ref can still be checked out.
Summary
Fixes #170: release builds now record exactly what they were built from, and nothing floats.
What was floating before
LIBPG_QUERY_TAGfor v15/17/18 named a branch ofconstructive-io/libpg_query, so the source could change without any commit here.wasm:makeranemscripten/emsdkwith no tag. Today that pulls 6.0.13, not the 6.0.3 the releases were actually built with.copy:templateshard-coded the pganalyze repo URL. Running it switched 15/17/18 back to pganalyze sources and removed v18'sWASM_*memory knobs (REPO_NOTES.mdwarned about this).Change
x-publishin eachversions/*/package.jsonnow carrieslibpgQueryRepo,libpgQueryTagandlibpgQueryCommit(a full SHA, enforced bycopy:templates).x-publishagain. The build clones the branch, runsgit checkout $(LIBPG_QUERY_COMMIT), and keys the source cache by commit, so a stale cached clone can't be reused.wasm:makenow usesemscripten/emsdk:6.0.3in all versions.WASM_INITIAL_MEMORY/WASM_MAXIMUM_MEMORY/WASM_STACK_SIZEoverrides move into the template, so every version gets them. Defaults are unchanged (128 MiB / 1 GiB / 32 MiB).x-publishships in the publishedpackage.json, so the source commit is recorded in npm metadata next togitHead.Pins are the current branch heads, so a build today produces the same thing it did before this PR:
13-2.2.01097b2c14-3.0.0397cbb9fix/negative-int-pg15ae1050416-5.2.0fce106a17-constructive1ade88018-constructiveb0f5f33Evidence
pnpm run copy:templateson this branch produces no diff.pnpm run wasm:buildon this branch reproduces the published npm packages byte-for-byte:libpg-query@18.1.5: wasm378b64e6…, js219217cc…libpg-query@17.7.4: wasm06fbfc24…Link to Devin session: https://app.devin.ai/sessions/bcd8b2f791164247acb7a659b481efc2
Open in Devin Desktop: https://app.devin.ai/desktop/session/bcd8b2f791164247acb7a659b481efc2?variant=devin
Requested by: @pyramation