Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ describe('request-lane resolution reads', () => {
it('lists every database-scope plane in resolution order for its grantee', async () => {
const planes = await pg.any(`SELECT * FROM function_resolution.routing_planes()`);
expect(planes).toEqual([
{ database_id: PLATFORM_DB, schema_name: 'platform_storage_public', resolver_function_name: 'resolve_route' },
{ database_id: TENANT_DB, schema_name: 'tenant_storage_public', resolver_function_name: 'resolve_route' },
{ database_id: OTHER_DB, schema_name: 'other_storage_public', resolver_function_name: 'resolve_route' }
{ database_id: PLATFORM_DB, schema_name: 'platform_storage_public', resolver_schema_name: 'platform_storage_public', resolver_function_name: 'resolve_route' },
{ database_id: TENANT_DB, schema_name: 'tenant_storage_public', resolver_schema_name: 'tenant_storage_public', resolver_function_name: 'resolve_route' },
{ database_id: OTHER_DB, schema_name: 'other_storage_public', resolver_schema_name: 'other_storage_public', resolver_function_name: 'resolve_route' }
]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,24 @@ BEGIN;
--
-- It enumerates every tenant database, so it is granted to no request role:
-- only the platform login (granted at provision) calls it, on its own
-- connection with no role switch. A plane whose route_module names no schema
-- or no resolver is returned as-is so the caller fails loudly on it.
-- connection with no role switch. schema_name is the plane's public schema
-- (its tables); resolver_schema_name is the schema its resolver is generated
-- into, so callers qualify the resolver from it rather than assuming. The
-- readers are still generated into the public schema, so for now both columns
-- carry the same value; resolver_schema_name changes to the plane's private
-- schema when the readers move there. A plane whose route_module names no
-- schema or no resolver is returned as-is so the caller fails loudly on it.
CREATE FUNCTION function_resolution.routing_planes()
RETURNS TABLE (
database_id uuid,
schema_name text,
resolver_schema_name text,
resolver_function_name text
) AS $$
SELECT
rm.database_id,
s.schema_name::text,
s.schema_name::text,

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 · medium

resolver_schema_name duplicates schema_name verbatim

The new resolver_schema_name column is populated with the same expression as schema_name (s.schema_name::text, packages/function-resolution/deploy/schemas/function_resolution/procedures/routing_planes.sql:30), making it an exact alias of the existing column.

The new header comment says it is "the schema its resolver is generated into, so callers qualify the resolver from it rather than assuming", but metaschema_modules_public.route_module stores no resolver-schema field, so the value can never differ from schema_name and the documented contract is not implemented by any data path.

If resolver generation ever targets a schema other than the plane's public schema, callers that qualify the resolver from this column will silently get the wrong schema. The updated test asserts resolver_schema_name === schema_name for every fixture, so it cannot detect the divergence.

📋 Prompt for AI Agents

In packages/function-resolution/deploy/schemas/function_resolution/procedures/routing_planes.sql line 30, replace the duplicate s.schema_name::text with an expression that yields the schema the resolver is actually generated into — e.g. add a resolver-schema source column to metaschema_modules_public.route_module (packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/route_module/table.sql) and join on it. If a separate field is out of scope, amend the function's header comment (lines 15-19) to state that resolver_schema_name currently equals schema_name so callers do not rely on divergent semantics. Extend packages/function-resolution/tests/request-lane-reads.test.ts (around lines 218-224) with a fixture whose resolver schema differs from the plane's public schema. Mirror any SQL change into packages/function-resolution/sql/pgpm-function-resolution--0.47.6.sql and regenerate the bundle.

rm.resolver_function_name
FROM metaschema_modules_public.route_module AS rm
LEFT JOIN metaschema_public.schema AS s ON s.id = rm.schema_id
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2408,11 +2408,13 @@ $EOFCODE$ LANGUAGE plpgsql VOLATILE;
CREATE FUNCTION function_resolution.routing_planes() RETURNS TABLE (
database_id uuid,
schema_name text,
resolver_schema_name text,
resolver_function_name text
) AS $EOFCODE$
SELECT
rm.database_id,
s.schema_name::text,
s.schema_name::text,
rm.resolver_function_name
FROM metaschema_modules_public.route_module AS rm
LEFT JOIN metaschema_public.schema AS s ON s.id = rm.schema_id
Expand Down
Loading