Skip to content

Makefile: cat_tools install override (CAT_TOOLS_GIT_REF/CAT_TOOLS_SKIP_INSTALL), default unchanged - #10

Open
jnasbyupgrade wants to merge 1 commit into
Postgres-Extensions:masterfrom
jnasbyupgrade:fix-cat-tools-install
Open

Makefile: cat_tools install override (CAT_TOOLS_GIT_REF/CAT_TOOLS_SKIP_INSTALL), default unchanged#10
jnasbyupgrade wants to merge 1 commit into
Postgres-Extensions:masterfrom
jnasbyupgrade:fix-cat-tools-install

Conversation

@jnasbyupgrade

@jnasbyupgrade jnasbyupgrade commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Redesigned. The original version unconditionally replaced the Makefile's
default cat_tools install (plain pgxn install) with a git-source build,
for every consumer of this repo -- not just CI. That's wrong: PGXN's stale
listing is CI's/testing's problem to work around, not something that should
change the default make install/pgxn install behavior everyone else gets.

What this PR actually does now

Reverts the default cat_tools recipe to exactly what it was
(pgxn install 'cat_tools>=0.2.1' --sudo), and adds two empty-by-default
variables as an explicit, opt-in override:

  • CAT_TOOLS_GIT_REF: when set, installs cat_tools from that git ref
    instead of PGXN.
  • CAT_TOOLS_SKIP_INSTALL: when set, skips installing cat_tools entirely
    (for pg_tle-mode testing, where cat_tools is already provided via pg_tle
    registration and a filesystem install as a side effect would defeat the
    point of the test).

Neither variable changes anything for a caller that doesn't set them --
make/make install/pgxn install extension_drop behave identically to
before this PR.

No version/META changes here. Bumping the declared cat_tools floor and
actually wiring CI to use CAT_TOOLS_GIT_REF is a separate concern, handled
in the version-pin PR (#25) stacked on this one -- keeping "add the override
mechanism" and "decide which version to use" as independent, separately
reviewable changes.

Verified locally (PG17)

  • Default (no vars set): pgxn install 'cat_tools>=0.2.1' --sudo runs,
    installs 0.2.1, exactly as before.
  • CAT_TOOLS_GIT_REF=0.3.0: clones and builds cat_tools at the 0.3.0 tag,
    installs correctly, cleans up its build dir afterward.
  • CAT_TOOLS_SKIP_INSTALL=yes: true no-op, confirmed nothing gets installed.
  • Confirmed make -n cat_tools is genuinely dry (prints without executing)
    in all three cases -- an earlier draft of this recipe accidentally forced
    real execution under -n by referencing $(MAKE) (GNU Make always runs
    recipes containing that literal text, even under -n, so it can show what
    a sub-make would do) and separately had a cd $(CAT_TOOLS_BUILD_DIR) &&
    that persisted across the whole joined shell recipe, breaking a later -C
    reference to the same relative path. Fixed by using plain make (not
    $(MAKE)) for the nested build and git -C <dir> instead of cd &&.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0e375649-0cdb-4795-86f9-4362e81421c4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

jnasbyupgrade added a commit to jnasbyupgrade/extension_tools that referenced this pull request Jul 31, 2026
A real release must never be cut while a dependency is temporarily
pinned to a git source (like the cat_tools pin added in Postgres-Extensions#10): the
resulting release's declared dependency floor wouldn't actually be
resolvable via `pgxn install` for anyone downloading it from PGXN.
Document this in RELEASE.md and add a small predicate script,
bin/in_release, that reports whether we're at/cutting a release
(HISTORY.asc's top heading is a real version) versus mid-development
(heading is the `STABLE` placeholder) -- for now a manual check to run
before releasing, not yet wired into CI.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@jnasbyupgrade
jnasbyupgrade marked this pull request as ready for review August 4, 2026 18:36
jnasbyupgrade added a commit to jnasbyupgrade/extension_tools that referenced this pull request Aug 4, 2026
…redate this branch

CI on this branch showed the switch to `make test && make verify-results`
surfacing real pgTAP failures on PostgreSQL 9.3/9.6 (cat_tools/extension_drop
never actually install there). Checked PR Postgres-Extensions#10's own baseline CI
(Postgres-Extensions#10, run
30665031257): PG 9.3 and 9.6 already report "3 of 3 tests failed" in the raw
job log there too, just silently reported as a passing check because
pg-build-test's underlying `make test` hits pgxntool's
`.IGNORE: installcheck` the same way. So this isn't a regression from this
PR's own changes -- it's the exact masking problem RELEASE.md already
documents, just now applying to a different, older part of the PG matrix
than the PRs (#6/#7) it originally cites. Reverting the ci.yml step back to
pg-build-test here keeps this PR scoped to test/install infrastructure;
fixing cat_tools's install path on pre-PG10 belongs to whoever owns that
dependency setup (PR Postgres-Extensions#10 or a follow-up), not this PR.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
jnasbyupgrade added a commit to jnasbyupgrade/extension_tools that referenced this pull request Aug 4, 2026
actions/checkout v4.4.0 (backported to all major-version tags) added a
new default-on refusal for checking out a fork PR's head under
pull_request_target, since it can't see that this job is already
gated to the trusted jnasbyupgrade fork only (see the if: condition
and SECURITY comment above) and never builds or executes the fetched
code. Root-caused via the actual failed run logs on PRs Postgres-Extensions#10/Postgres-Extensions#14/Postgres-Extensions#15,
which all failed at this checkout step with:

  Refusing to check out fork pull request code from a
  'pull_request_target' workflow. ... set
  'allow-unsafe-pr-checkout: true' on the actions/checkout step.

Without this, track_progress: true (added in the prior commit) never
had a chance to matter -- the workflow was failing before the review
step ever ran.
jnasbyupgrade added a commit to jnasbyupgrade/extension_tools that referenced this pull request Aug 4, 2026
…redate this branch

CI on this branch showed the switch to `make test && make verify-results`
surfacing real pgTAP failures on PostgreSQL 9.3/9.6 (cat_tools/extension_drop
never actually install there). Checked PR Postgres-Extensions#10's own baseline CI
(Postgres-Extensions#10, run
30665031257): PG 9.3 and 9.6 already report "3 of 3 tests failed" in the raw
job log there too, just silently reported as a passing check because
pg-build-test's underlying `make test` hits pgxntool's
`.IGNORE: installcheck` the same way. So this isn't a regression from this
PR's own changes -- it's the exact masking problem RELEASE.md already
documents, just now applying to a different, older part of the PG matrix
than the PRs (#6/#7) it originally cites. Reverting the ci.yml step back to
pg-build-test here keeps this PR scoped to test/install infrastructure;
fixing cat_tools's install path on pre-PG10 belongs to whoever owns that
dependency setup (PR Postgres-Extensions#10 or a follow-up), not this PR.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
jnasbyupgrade added a commit that referenced this pull request Aug 4, 2026
…redate this branch

CI on this branch showed the switch to `make test && make verify-results`
surfacing real pgTAP failures on PostgreSQL 9.3/9.6 (cat_tools/extension_drop
never actually install there). Checked PR #10's own baseline CI
(#10, run
30665031257): PG 9.3 and 9.6 already report "3 of 3 tests failed" in the raw
job log there too, just silently reported as a passing check because
pg-build-test's underlying `make test` hits pgxntool's
`.IGNORE: installcheck` the same way. So this isn't a regression from this
PR's own changes -- it's the exact masking problem RELEASE.md already
documents, just now applying to a different, older part of the PG matrix
than the PRs (#6/#7) it originally cites. Reverting the ci.yml step back to
pg-build-test here keeps this PR scoped to test/install infrastructure;
fixing cat_tools's install path on pre-PG10 belongs to whoever owns that
dependency setup (PR #10 or a follow-up), not this PR.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Claude Code is working…

I'll analyze this and get back to you.

View job run

jnasbyupgrade added a commit that referenced this pull request Aug 5, 2026
#28)

PR #15's `allow-unsafe-pr-checkout: true` fix silenced the
checkout-refusal
error but was solving the wrong problem, and traded it for a new one:
after merging, review runs on #10 and #16 failed with a different error,
`fatal: couldn't find remote ref pull/10/head`.

Root cause: `anthropics/claude-code-action`'s own `docs/security.md`
explicitly names our checkout step's pattern (checking out the PR's own
untrusted ref, from the fork, into the workspace root) as the
anti-pattern
to avoid, and its "preferred" fix is a plain checkout of the base ref
with
no override. The action fetches and reads the PR's actual content itself
-- confirmed by reading its source (`src/github/operations/branch.ts`):
for
a fork PR it runs `git fetch origin ... pull/<n>/head`, a ref GitHub
maintains on the BASE repo for any PR (fork or not), so it never needs
direct access to the fork's remote. Our step redirecting `origin` to the
fork broke that internal fetch, since `refs/pull/<n>/head` doesn't exist
there.

Fix: remove the `repository:`/`ref:`/`allow-unsafe-pr-checkout` overrides
entirely -- just `uses: actions/checkout@v7` with no inputs, checking out
this repo's own base branch. Updated the surrounding comments (the
top-of-file SECURITY note and the job's trust-check warning) to match --
they previously described the now-removed manual fork-checkout.
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Claude finished @jnasbyupgrade's task in 2m 55s —— View job


Claude finished reviewing PR #10

  • Gather context (diff, changed files, CLAUDE.md)
  • Review Makefile changes (cat_tools git-source build)
  • Review META.in.json / META.json version bump
  • Review README.md / RELEASE.md changes
  • Review bin/in_release helper
  • Post final review

Summary

Solid, well-documented fix. The root cause analysis (PGXN's cat_tools listing being stuck at a 9-year-old 0.2.1) is correct and thoroughly verified per the PR description (12 PG versions in CI). One process gap worth fixing before merge, plus a couple of minor/optional notes.

Findings

1. Missing HISTORY.asc entry (should fix)

RELEASE.md's own "Ongoing development" section (pre-existing, not touched by this PR) requires:

If a PR makes a user-facing change (bug fix, behavior change...), add an entry to HISTORY.asc... If the top section is a real version number, insert a new section above it headed STABLE.

HISTORY.asc's top heading is currently 1.0.0 (a real released version, confirmed via bin/in_release's own logic — no STABLE section exists yet). This PR is squarely a user-facing bug fix (per its own description, CREATE EXTENSION extension_drop CASCADE "has likely never actually succeeded" without it), but it doesn't touch HISTORY.asc. Per the project's documented convention, it should insert a new STABLE section above 1.0.0 describing the fix.

Fix this →

2. git clone is a full clone of master (minor/optional)

Makefile line 41 does a full git clone then git checkout $(CAT_TOOLS_GIT_REF) (line 42), where CAT_TOOLS_GIT_REF = master. Since the ref is a branch name (not yet pinned to a SHA), git clone --branch master --depth 1 ... would be faster and lighter in CI, with the explicit git checkout still there ready to take a SHA once/if this needs pinning later. Not a correctness issue — just an optimization opportunity, and worth leaving as full-clone if you want the checkout line to already look correct for a future SHA pin without editing the clone line too.

3. No protection against upstream master drift between CI runs (acknowledged risk)

Because CAT_TOOLS_GIT_REF tracks a moving branch rather than a SHA, two CI runs at different times could build against different cat_tools commits, so a future breaking change on cat_tools upstream could break this repo's CI without any change here. This is explicitly called out as an accepted, temporary tradeoff in the PR description and Makefile comment (no tagged release exists yet to pin to), so it's not blocking — just flagging that it's a real (if intentional) gap, not purely theoretical.

Nice-to-haves already handled well

  • META.in.json/META.json bump is consistent and META.json was correctly regenerated rather than hand-edited.
  • extension_drop.control's bare requires = 'cat_tools' correctly left untouched (PostgreSQL .control requires has no version syntax).
  • The new RELEASE.md "never release with a pin" callout and bin/in_release helper are a good, low-cost safety net for a real footgun this PR introduces (a temporarily unpinnable dependency floor).
  • Comments in the Makefile clearly separate the durable technique (build-from-git-ref as a supported fallback) from the temporary state (tracking master because no tag exists), which will make the eventual revert straightforward.

Not addressed by this PR (correctly out of scope, per the PR description)

These are all called out explicitly in the PR body and tracked/flagged appropriately rather than silently ignored.

Redesign of the original fix: that version unconditionally replaced
the default pgxn install with a git-source build for every consumer of
this Makefile, not just CI. Reverted to that concern: the default
cat_tools recipe is exactly what it was before (plain
`pgxn install 'cat_tools>=0.2.1' --sudo`), gated on the same
prerequisite file it always was.

Two new, empty-by-default variables give CI an explicit opt-in without
touching that default:
- CAT_TOOLS_GIT_REF: when set, installs cat_tools from that git ref
  instead of PGXN (for when PGXN's published listing lags what's
  actually needed -- CI sets this, nothing else does).
- CAT_TOOLS_SKIP_INSTALL: when set, skips installing cat_tools at all
  (for pg_tle-mode CI, where cat_tools is already provided via pg_tle
  registration and a filesystem install as a side effect would defeat
  the point of the test).

No META/version-floor changes here -- that's a separate concern,
handled where it belongs (the version-pin PR).
@jnasbyupgrade
jnasbyupgrade force-pushed the fix-cat-tools-install branch from 26c9fe5 to ef2e29d Compare August 5, 2026 23:08
@jnasbyupgrade jnasbyupgrade changed the title Fix cat_tools dependency: install from pinned git SHA, not PGXN Makefile: cat_tools install override (CAT_TOOLS_GIT_REF/CAT_TOOLS_SKIP_INSTALL), default unchanged Aug 5, 2026
jnasbyupgrade added a commit to jnasbyupgrade/extension_tools that referenced this pull request Aug 5, 2026
The version decision this repo actually needs, separated from PR Postgres-Extensions#10's
install-mechanism change. extension_drop.sql calls
cat_tools.routine__parse_arg_types_text(), which only exists starting
at cat_tools 0.3.0 -- PGXN's published listing is stuck at a stale
2017 0.2.1 lacking it. Bumping META's declared floor makes a plain
`pgxn install extension_drop` fail cleanly at dependency-resolution
time instead of installing successfully and breaking later at
CREATE EXTENSION time.

Sets CAT_TOOLS_GIT_REF=0.3.0 at ci.yml's workflow level (not per-job),
so every job that builds the extension -- including ones in other
stacked PRs that already read this value via
`make print-CAT_TOOLS_GIT_REF` -- picks it up automatically.

Updates RELEASE.md's release-blocking guardrail: the real signal is
now whether ci.yml's CAT_TOOLS_GIT_REF is actually set to a non-empty
value, not whether the Makefile merely declares the variable (it
always does now, as a normally-empty opt-in override).
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Claude finished @jnasbyupgrade's task in 3m 39s —— View job


Claude finished reviewing PR #10

  • Gather context (diff, changed files, CLAUDE.md)
  • Review Makefile changes (cat_tools install override)
  • Cross-check CI workflow wiring
  • Post final review

Summary

Note up front: the PR description/title above describe an earlier version of this PR (git-source build by default, META.in.json/README.md/RELEASE.md/bin/in_release changes). The branch has since been redesigned — the current diff is a single commit, ef2e29d ("Makefile: cat_tools install override, default behavior unchanged"), touching only Makefile (+25/-1). This review is against that current diff, not the stale description text.

The redesign is a real improvement over the previous approach: it makes the git-source build strictly opt-in via CAT_TOOLS_GIT_REF/CAT_TOOLS_SKIP_INSTALL, so every other consumer of this Makefile still gets the original pgxn install 'cat_tools>=0.2.1' --sudo behavior untouched. That's a good, low-blast-radius design. Two issues below are worth resolving before merge.

Findings

1. The new opt-in vars aren't set anywhere, so this PR alone doesn't fix the underlying bug (should confirm)

Makefile:24-25 adds CAT_TOOLS_GIT_REF ?= and CAT_TOOLS_SKIP_INSTALL ?=, both empty by default, with the commit message stating "CI sets this, nothing else does." But .github/workflows/ci.yml's test job (pg-build-test) isn't touched by this PR and doesn't set CAT_TOOLS_GIT_REF anywhere. That means the cat_tools recipe (Makefile:30-41) will still fall through to the else branch — the plain pgxn install 'cat_tools>=0.2.1' --sudo — exactly as before. Since PGXN's published cat_tools listing is still stuck at 0.2.1 (missing routine__parse_arg_types_text, per this PR's own rationale), sql/extension_drop.sql:38's call to that function will still fail to resolve, and CREATE EXTENSION extension_drop CASCADE will still be broken in CI after this merges — unless a companion PR (updating ci.yml to pass CAT_TOOLS_GIT_REF=master or similar) lands alongside it.

If that wiring is intentionally deferred to a separate PR, worth saying so explicitly in the PR description so reviewers don't assume this one is a complete fix on its own. If it isn't planned elsewhere yet, ci.yml needs a CAT_TOOLS_GIT_REF (or make variable passthrough) added for test's pg-build-test step.

Fix this →

2. Git-source install path is missing --sudo, unlike the PGXN path it replaces (should confirm)

Makefile:40 (pgxn install 'cat_tools>=0.2.1' --sudo) explicitly needs --sudo to write into $(DESTDIR)$(datadir)/extension. That requirement exists precisely because the pgxn-tools CI container's default user can't write there directly (see pgxntool/HISTORY.asc's "Use --sudo option when installing pgtap" entry, and pgxntool/base.mk:686's own pgxn install pgtap --sudo). The new git-source branch at Makefile:37 runs make -C $(CAT_TOOLS_BUILD_DIR) install PG_CONFIG=$(PG_CONFIG) DESTDIR=$(DESTDIR) with no privilege escalation at all. If the same directory-permission constraint applies (likely, since it's the same target directory), this will fail with a permission error the first time CAT_TOOLS_GIT_REF is actually exercised — e.g. once finding #1 above is wired up. Worth prefixing with sudo (or confirming the container's ownership model makes it unnecessary before relying on this path in CI).

Fix this →

Nice-to-haves already handled well

  • Scoping the override behind empty-by-default CAT_TOOLS_GIT_REF/CAT_TOOLS_SKIP_INSTALL variables (Makefile:14-26) rather than changing the default recipe is the right call — every other consumer of this Makefile is unaffected.
  • CAT_TOOLS_SKIP_INSTALL cleanly supports the pg_tle testing mode (where cat_tools is registered a different way) without forcing a filesystem install as a side effect.
  • Build dir cleanup (rm -rf before and after the clone) avoids leaving stale checkouts around, and tmp/ is already gitignored.
  • Deferring the META.in.json/version-floor bump to a separate PR (per the commit message) is a reasonable scope cut — this commit is purely mechanism, not policy.

Not addressed by this PR (pre-existing, out of scope)

  • Makefile:4's pre-existing typo ($(DESTDIR)$datadir)/extension/extension_drop_test.control missing a ( before datadir) — unrelated to this diff, untouched here.

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