sync: port module changes from constructive-db (a909a8a) - #130
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
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 · // 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
🧹 Nitpicks (1) — 🟢 1 low
This PR changes capability resolution and schema across three pgpm packages. The core behavioral shift is
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 Reviewed commit: 84ce602 |
There was a problem hiding this comment.
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
- 🟠 Drop removed arg from capability test callers — resolve_capabilities.sql:62
- 🟠 Redirect insert binds stray
$5on global tier — install_route_bindings.sql:504
| 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; |
There was a problem hiding this comment.
🟠 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.
Summary
Ports the three modules that had drifted from
constructive-db/pgpm-modulesat constructive-dbmaina909a8a (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_moduletables 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_chunksBundles regenerated with
pgpm package.pnpm run policy:checkandpgpm test-packages --full-cyclepass.Also: CI's object-store service container moves from
minio/minio:edge-cicd(tag no longer pullable from Docker Hub — every job onmainwould fail the same way today) torustfs/rustfs:1.0.0-rc.5, mirroring constructive-db bd08f6532af.Not ported:
db-utilsandinfra-utilsexist 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