Skip to content

sync: port module changes from constructive-db (a909a8a) - #130

Merged
pyramation merged 3 commits into
mainfrom
feat/sync-constructive-db
Sep 16, 2026
Merged

pyramation merged 3 commits into
mainfrom
feat/sync-constructive-db

Conversation

@pyramation

@pyramation pyramation commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Ports the three modules that had drifted from constructive-db/pgpm-modules at constructive-db main a909a8a (post constructive-db#3785). The other 25 shared modules were byte-identical and are untouched; versions stay at 0.45.0 as in prior sync commits.

  • function-resolution: install_mantra, install_route_bindings, resolve_capabilities, validate_capabilities (shared-surface capability resolution, route-binding install)
  • metaschema-modules: billing_module / billing_provider_module tables gain the credit-pack and provider-first subscription seam columns (credit_packs_table_id, grant_meter_credits_function, get_billing_subscription_by_*, get_plan_pricing_by_external_price)
  • metaschema-schema: is_valid_step_up, embedding_chunks

Bundles regenerated with pgpm package. pnpm run policy:check and pgpm test-packages --full-cycle pass.

Also: CI's object-store service container moves from minio/minio:edge-cicd (tag no longer pullable from Docker Hub — every job on main would fail the same way today) to rustfs/rustfs:1.0.0-rc.5, mirroring constructive-db bd08f6532af.

Not ported: db-utils and infra-utils exist only in constructive-db and are not part of this repo.

Link to Devin session: https://app.devin.ai/sessions/42be922ae2324153b365dbda21e5b85d
Open in Devin Desktop: https://app.devin.ai/desktop/session/42be922ae2324153b365dbda21e5b85d?variant=devin
Requested by: @pyramation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@tenki-reviewer

tenki-reviewer Bot commented Sep 16, 2026

Copy link
Copy Markdown

Review complete. 🟠 2 high

💬 Inline comments (1)

📍 Findings outside the diff (1) — 🟠 1 high — defects on lines GitHub can't attach comments to

🟠 High — Drop removed arg from capability test callers · resolve_capabilities.sql:62–69 · unchanged line

// packages/function-resolution/deploy/schemas/function_resolution/procedures/resolve_capabilities.sql
62	CREATE FUNCTION function_resolution.resolve_capabilities(
63	    database_id uuid,
64	    scope text,
65	    entity_id uuid,
66	    function_definition_id uuid,
67	    definition_scope text,
68	    payload jsonb DEFAULT '{}'::jsonb,
69	    channel text DEFAULT NULL

resolve_capabilities and validate_capabilities both drop the definition_database_id parameter, changing their signatures to (uuid, text, uuid, uuid, text, jsonb, text), but the package's own suite still invokes them with the deleted argument (resolve_capabilities.sql:62; callers in capabilities.test.ts at 511, 533, 551, 566, 579, 588, 596, 602). PostgreSQL rejects the stale arity, so every capability test now fails instead of exercising the new contract.

🧹 Nitpicks (1) — 🟢 1 low
  • 🟢 Verify omits new get_active_plan_subscription_function (table.sql:24) — The billing_provider_module verify lists three of the four read-seam columns the deploy adds but omits get_active_plan_subscription_function (verify/.../billing_provider_module/table.sql:25).

This PR changes capability resolution and schema across three pgpm packages. The core behavioral shift is resolve_capabilities/validate_capabilities losing the definition_database_id parameter in favor of frame-key lookup, plus new "redirect" route-binding support in the function-resolution procedures and new billing columns/tables in metaschema-modules, all mirrored in regenerated sql/*--0.45.0.sql bundles.

Files Change
function-resolution deploy/verify/revert procedures Refactor capability resolution to keyed frame lookup, drop definition_database_id, add redirect-binding install logic
function-resolution sql/ bundle Regenerate to match the new procedure signatures and logic
metaschema-modules billing tables + verify Add billing module/provider columns (credit packs, grant function, provider function-name seams) and their verify checks
metaschema-schema step-up + embedding_chunks + bundle Harden is_valid_step_up, add source_fields, regenerate bundle

Two high-severity issues need attention before merge: test callers still invoke the old 8-argument arity, and the redirect-insert path binds a stray $5 parameter on the global tier; the billing-provider verify omits the newly added function column.

Reviewed commit: 84ce602

@tenki-reviewer tenki-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

PR #130 refactors capability resolution to frame-key-based lookup (dropping definition_database_id) and adds redirect route bindings plus billing-module table columns across function-resolution, metaschema-modules, and metaschema-schema, with regenerated sql bundles.

Key findings

Comment on lines +504 to +515
query := format(
'INSERT INTO %I.%I (%sname, to_host, to_path, status_code, preserve_path, preserve_query)
VALUES (%s$1, $2, $3, $4, false, true)
RETURNING id',
redirects_schema,
redirects_table,
CASE WHEN routes_key IS NULL THEN '' ELSE format('%I, ', routes_key) END,
CASE WHEN routes_key IS NULL THEN '' ELSE '$5, ' END
);

EXECUTE query INTO target_id
USING entry_redirect_name, entry_to_host, entry_to_path, entry_status, key_value;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 bug · high

Redirect insert binds stray $5 on global tier

The redirect INSERT always binds five USING parameters including key_value, but on the ownerless/global tier where routes_key is NULL the generated value list is VALUES ($1, $2, $3, $4, false, true) with no $5 placeholder (install_route_bindings.sql:504). plpgsql raises wrong number of parameters for dynamic EXECUTE: expected 4, got 5, so every redirect binding installed onto a global-tier routes plane fails at runtime; the sibling route INSERT balances both branches, marking this one as unintentionally unbalanced.

📋 Prompt for AI Agents

In packages/function-resolution/deploy/schemas/function_resolution/procedures/install_route_bindings.sql at the redirect INSERT (lines 504-515), the EXECUTE always passes 5 USING args (including key_value) but the query references only $1..$4 when routes_key IS NULL, so plpgsql fails with 'wrong number of parameters for dynamic EXECUTE: expected 4, got 5' on the global tier. Restructure the EXECUTE so the USING list is conditional: pass key_value only in the routes_key IS NOT NULL branch (mirroring how the route INSERT balances its key/serving prefixes), keeping the counted parameters equal to the highest referenced placeholder in both branches so redirect installs work on ownerless planes.

@pyramation
pyramation merged commit d07951c into main Sep 16, 2026
29 checks passed
@pyramation
pyramation deleted the feat/sync-constructive-db branch September 16, 2026 23:55
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