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 @@ -23,6 +23,7 @@ exports[`db_meta_modules should have all expected module tables 1`] = `
"graph_execution_module",
"graph_module",
"hierarchy_module",
"http_route_module",
"i18n_module",
"identity_providers_module",
"inference_log_module",
Expand Down Expand Up @@ -66,8 +67,8 @@ exports[`db_meta_modules should have all expected module tables 1`] = `

exports[`db_meta_modules should verify all module tables exist in metaschema_modules_public schema 1`] = `
{
"moduleTablesCount": 57,
"totalTables": 64,
"moduleTablesCount": 58,
"totalTables": 65,
}
`;

Expand Down Expand Up @@ -134,13 +135,13 @@ exports[`db_meta_modules should verify emails_module table structure 1`] = `

exports[`db_meta_modules should verify module table structures have database_id foreign keys 1`] = `
{
"constraintCount": 325437,
"constraintCount": 325438,
}
`;

exports[`db_meta_modules should verify module tables have proper foreign key relationships 1`] = `
{
"constraintCount": 475451,
"constraintCount": 475461,
"foreignTables": [
"database",
"field",
Expand All @@ -150,7 +151,9 @@ exports[`db_meta_modules should verify module tables have proper foreign key rel
"infra_secrets_module",
"merkle_store_module",
"namespace_module",
"resource_module",
"schema",
"storage_module",
"table",
],
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
-- Deploy schemas/metaschema_modules_public/tables/http_route_module/table to pg

-- requires: schemas/metaschema_modules_public/schema
-- requires: schemas/metaschema_modules_public/tables/function_module/table
-- requires: schemas/metaschema_modules_public/tables/resource_module/table
-- requires: schemas/metaschema_modules_public/tables/storage_module/table

BEGIN;

CREATE TABLE metaschema_modules_public.http_route_module (
id uuid PRIMARY KEY DEFAULT uuidv7(),
database_id uuid NOT NULL,
entity_field text,

schema_id uuid NOT NULL DEFAULT uuid_nil(),
private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
public_schema_name text,
private_schema_name text,

http_routes_table_id uuid NOT NULL DEFAULT uuid_nil(),
http_routes_table_name text NOT NULL DEFAULT 'http_routes',
resolver_function_name text,

function_module_id uuid,
resource_module_id uuid,
storage_module_id uuid,

api_name text,
private_api_name text,

scope text NOT NULL DEFAULT 'app',
prefix text NOT NULL DEFAULT '',
entity_table_id uuid NULL,

policies jsonb NULL,
provisions jsonb NULL,
default_permissions text[] DEFAULT NULL,

CONSTRAINT http_route_module_db_fkey
FOREIGN KEY (database_id)
REFERENCES metaschema_public.database (id)
ON DELETE CASCADE,
CONSTRAINT http_route_module_schema_fkey
FOREIGN KEY (schema_id)
REFERENCES metaschema_public.schema (id)
ON DELETE CASCADE,
CONSTRAINT http_route_module_private_schema_fkey
FOREIGN KEY (private_schema_id)
REFERENCES metaschema_public.schema (id)
ON DELETE CASCADE,
CONSTRAINT http_route_module_routes_table_fkey
FOREIGN KEY (http_routes_table_id)
REFERENCES metaschema_public.table (id)
ON DELETE CASCADE,
CONSTRAINT http_route_module_function_module_fkey
FOREIGN KEY (function_module_id)
REFERENCES metaschema_modules_public.function_module (id)
ON DELETE CASCADE,
CONSTRAINT http_route_module_resource_module_fkey
FOREIGN KEY (resource_module_id)
REFERENCES metaschema_modules_public.resource_module (id)
ON DELETE CASCADE,
CONSTRAINT http_route_module_storage_module_fkey
FOREIGN KEY (storage_module_id)
REFERENCES metaschema_modules_public.storage_module (id)
ON DELETE CASCADE,
CONSTRAINT http_route_module_entity_table_fkey
FOREIGN KEY (entity_table_id)
REFERENCES metaschema_public.table (id)
ON DELETE CASCADE
);

CREATE INDEX http_route_module_database_id_idx
ON metaschema_modules_public.http_route_module (database_id);

CREATE UNIQUE INDEX http_route_module_unique_scope
ON metaschema_modules_public.http_route_module (database_id, scope);

COMMIT;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

-- requires: schemas/metaschema_modules_public/schema
-- requires: schemas/metaschema_modules_public/tables/namespace_module/table
-- requires: schemas/metaschema_modules_public/tables/merkle_store_module/table

BEGIN;

Expand Down Expand Up @@ -30,6 +31,8 @@ CREATE TABLE metaschema_modules_public.resource_module (
resource_usage_samples_table_id uuid NOT NULL DEFAULT uuid_nil(),
resource_usage_summary_table_id uuid NOT NULL DEFAULT uuid_nil(),
namespace_usage_summary_table_id uuid NOT NULL DEFAULT uuid_nil(),
-- Resource-bundles Stage 1: the installation ("release") grouping table.
resource_installations_table_id uuid NOT NULL DEFAULT uuid_nil(),

-- Table names (input to the generator — bare names without scope prefix).
-- The trigger prepends the scope prefix automatically.
Expand All @@ -40,6 +43,7 @@ CREATE TABLE metaschema_modules_public.resource_module (
resource_usage_samples_table_name text NOT NULL DEFAULT 'resource_usage_samples',
resource_usage_summary_table_name text NOT NULL DEFAULT 'resource_usage_summaries',
namespace_usage_summary_table_name text NOT NULL DEFAULT 'namespace_usage_summaries',
resource_installations_table_name text NOT NULL DEFAULT 'resource_installations',

-- Generated functions (populated by the generator)
rollup_resource_usage_summary_function text NOT NULL DEFAULT '',
Expand Down Expand Up @@ -69,6 +73,13 @@ CREATE TABLE metaschema_modules_public.resource_module (
-- FK to namespace_module: which namespaces table resources are scoped to
namespace_module_id uuid NULL,

-- Resource-bundles Stage 1: the shared merkle store an installation commits
-- its versioned params into (reuses the scope's shared infra store, like
-- db_preset). NULL disables installation versioning (no rollback history).
merkle_store_module_id uuid NULL,
-- Store row name inside the merkle store the installation head commits into.
installation_store_name text NOT NULL DEFAULT 'infra',

-- Configurable security policies (NULL = use defaults based on scope).
policies jsonb NULL,

Expand All @@ -90,6 +101,8 @@ CREATE TABLE metaschema_modules_public.resource_module (
CONSTRAINT resource_module_usage_samples_table_fkey FOREIGN KEY (resource_usage_samples_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
CONSTRAINT resource_module_usage_summary_table_fkey FOREIGN KEY (resource_usage_summary_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
CONSTRAINT resource_module_ns_usage_summary_table_fkey FOREIGN KEY (namespace_usage_summary_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
CONSTRAINT resource_module_installations_table_fkey FOREIGN KEY (resource_installations_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
CONSTRAINT resource_module_merkle_store_module_fkey FOREIGN KEY (merkle_store_module_id) REFERENCES metaschema_modules_public.merkle_store_module (id) ON DELETE SET NULL,
CONSTRAINT resource_module_entity_table_fkey FOREIGN KEY (entity_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
CONSTRAINT resource_module_namespace_module_fkey FOREIGN KEY (namespace_module_id) REFERENCES metaschema_modules_public.namespace_module (id) ON DELETE SET NULL
);
Expand Down
3 changes: 2 additions & 1 deletion packages/metaschema-modules/pgpm.plan
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ schemas/metaschema_modules_public/tables/i18n_module/table [schemas/metaschema_m
schemas/metaschema_modules_public/tables/function_deployment_module/table [schemas/metaschema_modules_public/schema schemas/metaschema_modules_public/tables/function_module/table schemas/metaschema_modules_public/tables/namespace_module/table] 2026-06-11T06:00:00Z devin <devin@cognition.ai> # add function_deployment_module config table for function-to-namespace deployment binding
schemas/metaschema_modules_public/tables/function_module/constraints/one_platform_database [schemas/metaschema_modules_public/tables/function_module/table] 2026-06-11T08:00:00Z devin <devin@cognition.ai> # enforce at most one platform-scope function_module (unambiguous resolveDatabaseId)
schemas/metaschema_modules_public/tables/principal_auth_module/table [schemas/metaschema_modules_public/schema] 2026-06-24T11:15:00Z devin <devin@cognition.ai> # add principal_auth_module config table for scoped API keys and agent principals
schemas/metaschema_modules_public/tables/resource_module/table [schemas/metaschema_modules_public/schema schemas/metaschema_modules_public/tables/namespace_module/table] 2026-07-02T00:00:00Z devin <devin@cognition.ai> # add resource_module config table for unified K8s resource management (kind-based dispatch)
schemas/metaschema_modules_public/tables/resource_module/table [schemas/metaschema_modules_public/schema schemas/metaschema_modules_public/tables/namespace_module/table schemas/metaschema_modules_public/tables/merkle_store_module/table] 2026-07-02T00:00:00Z devin <devin@cognition.ai> # add resource_module config table for unified K8s resource management (kind-based dispatch)
schemas/metaschema_modules_public/tables/integration_providers_module/table [schemas/metaschema_modules_public/schema] 2026-07-11T17:30:00Z devin <devin@cognition.ai> # add integration_providers_module config table for branded service integration definitions
schemas/metaschema_modules_public/tables/graph_module/constraints/one_platform_scope [schemas/metaschema_modules_public/tables/graph_module/table] 2026-07-08T07:30:00Z devin <devin@cognition.ai> # enforce at most one platform-scope graph_module per database
schemas/metaschema_modules_public/tables/events_module/constraints/one_platform_scope [schemas/metaschema_modules_public/tables/events_module/table] 2026-07-08T07:30:00Z devin <devin@cognition.ai> # enforce at most one platform-scope events_module per database
Expand All @@ -82,3 +82,4 @@ schemas/metaschema_modules_public/tables/transfer_log_module/constraints/one_pla
schemas/metaschema_modules_public/tables/storage_log_module/constraints/one_platform_scope [schemas/metaschema_modules_public/tables/storage_log_module/table] 2026-07-08T07:30:00Z devin <devin@cognition.ai> # enforce at most one platform-scope storage_log_module per database
schemas/metaschema_modules_public/tables/db_usage_module/constraints/one_platform_scope [schemas/metaschema_modules_public/tables/db_usage_module/table] 2026-07-08T07:30:00Z devin <devin@cognition.ai> # enforce at most one platform-scope db_usage_module per database
schemas/metaschema_modules_public/tables/webhook_module/table [schemas/metaschema_modules_public/schema schemas/metaschema_modules_public/tables/function_module/table schemas/metaschema_modules_public/tables/function_invocation_module/table schemas/metaschema_modules_public/tables/infra_secrets_module/table schemas/metaschema_modules_public/tables/namespace_module/table] 2026-07-15T06:30:00Z devin <devin@cognition.ai> # add scoped webhook ingress module registration
schemas/metaschema_modules_public/tables/http_route_module/table [schemas/metaschema_modules_public/schema schemas/metaschema_modules_public/tables/function_module/table schemas/metaschema_modules_public/tables/resource_module/table schemas/metaschema_modules_public/tables/storage_module/table] 2026-07-15T23:41:00Z devin <devin@cognition.ai> # add generated HTTP route module config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Revert schemas/metaschema_modules_public/tables/http_route_module/table from pg

BEGIN;

DROP TABLE metaschema_modules_public.http_route_module;

COMMIT;
74 changes: 73 additions & 1 deletion packages/metaschema-modules/sql/metaschema-modules--0.15.5.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3620,13 +3620,15 @@ CREATE TABLE metaschema_modules_public.resource_module (
resource_usage_samples_table_id uuid NOT NULL DEFAULT uuid_nil(),
resource_usage_summary_table_id uuid NOT NULL DEFAULT uuid_nil(),
namespace_usage_summary_table_id uuid NOT NULL DEFAULT uuid_nil(),
resource_installations_table_id uuid NOT NULL DEFAULT uuid_nil(),
resources_table_name text NOT NULL DEFAULT 'resources',
resource_events_table_name text NOT NULL DEFAULT 'resource_events',
resource_status_checks_table_name text NOT NULL DEFAULT 'resource_status_checks',
resource_definitions_table_name text NOT NULL DEFAULT 'resource_definitions',
resource_usage_samples_table_name text NOT NULL DEFAULT 'resource_usage_samples',
resource_usage_summary_table_name text NOT NULL DEFAULT 'resource_usage_summaries',
namespace_usage_summary_table_name text NOT NULL DEFAULT 'namespace_usage_summaries',
resource_installations_table_name text NOT NULL DEFAULT 'resource_installations',
rollup_resource_usage_summary_function text NOT NULL DEFAULT '',
resource_billing_rollup_function text NOT NULL DEFAULT '',
resolved_requirements_view_name text,
Expand All @@ -3637,6 +3639,8 @@ CREATE TABLE metaschema_modules_public.resource_module (
prefix text NOT NULL DEFAULT '',
entity_table_id uuid NULL,
namespace_module_id uuid NULL,
merkle_store_module_id uuid NULL,
installation_store_name text NOT NULL DEFAULT 'infra',
policies jsonb NULL,
provisions jsonb NULL,
default_permissions text[] DEFAULT NULL,
Expand Down Expand Up @@ -3680,6 +3684,14 @@ CREATE TABLE metaschema_modules_public.resource_module (
FOREIGN KEY(namespace_usage_summary_table_id)
REFERENCES metaschema_public.table (id)
ON DELETE CASCADE,
CONSTRAINT resource_module_installations_table_fkey
FOREIGN KEY(resource_installations_table_id)
REFERENCES metaschema_public.table (id)
ON DELETE CASCADE,
CONSTRAINT resource_module_merkle_store_module_fkey
FOREIGN KEY(merkle_store_module_id)
REFERENCES metaschema_modules_public.merkle_store_module (id)
ON DELETE SET NULL,
CONSTRAINT resource_module_entity_table_fkey
FOREIGN KEY(entity_table_id)
REFERENCES metaschema_public.table (id)
Expand Down Expand Up @@ -3829,4 +3841,64 @@ CREATE TABLE metaschema_modules_public.webhook_module (

CREATE INDEX webhook_module_database_id_idx ON metaschema_modules_public.webhook_module (database_id);

CREATE UNIQUE INDEX webhook_module_unique_scope ON metaschema_modules_public.webhook_module (database_id, scope);
CREATE UNIQUE INDEX webhook_module_unique_scope ON metaschema_modules_public.webhook_module (database_id, scope);

CREATE TABLE metaschema_modules_public.http_route_module (
id uuid PRIMARY KEY DEFAULT uuidv7(),
database_id uuid NOT NULL,
entity_field text,
schema_id uuid NOT NULL DEFAULT uuid_nil(),
private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
public_schema_name text,
private_schema_name text,
http_routes_table_id uuid NOT NULL DEFAULT uuid_nil(),
http_routes_table_name text NOT NULL DEFAULT 'http_routes',
resolver_function_name text,
function_module_id uuid,
resource_module_id uuid,
storage_module_id uuid,
api_name text,
private_api_name text,
scope text NOT NULL DEFAULT 'app',
prefix text NOT NULL DEFAULT '',
entity_table_id uuid NULL,
policies jsonb NULL,
provisions jsonb NULL,
default_permissions text[] DEFAULT NULL,
CONSTRAINT http_route_module_db_fkey
FOREIGN KEY(database_id)
REFERENCES metaschema_public.database (id)
ON DELETE CASCADE,
CONSTRAINT http_route_module_schema_fkey
FOREIGN KEY(schema_id)
REFERENCES metaschema_public.schema (id)
ON DELETE CASCADE,
CONSTRAINT http_route_module_private_schema_fkey
FOREIGN KEY(private_schema_id)
REFERENCES metaschema_public.schema (id)
ON DELETE CASCADE,
CONSTRAINT http_route_module_routes_table_fkey
FOREIGN KEY(http_routes_table_id)
REFERENCES metaschema_public.table (id)
ON DELETE CASCADE,
CONSTRAINT http_route_module_function_module_fkey
FOREIGN KEY(function_module_id)
REFERENCES metaschema_modules_public.function_module (id)
ON DELETE CASCADE,
CONSTRAINT http_route_module_resource_module_fkey
FOREIGN KEY(resource_module_id)
REFERENCES metaschema_modules_public.resource_module (id)
ON DELETE CASCADE,
CONSTRAINT http_route_module_storage_module_fkey
FOREIGN KEY(storage_module_id)
REFERENCES metaschema_modules_public.storage_module (id)
ON DELETE CASCADE,
CONSTRAINT http_route_module_entity_table_fkey
FOREIGN KEY(entity_table_id)
REFERENCES metaschema_public.table (id)
ON DELETE CASCADE
);

CREATE INDEX http_route_module_database_id_idx ON metaschema_modules_public.http_route_module (database_id);

CREATE UNIQUE INDEX http_route_module_unique_scope ON metaschema_modules_public.http_route_module (database_id, scope);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- Verify schemas/metaschema_modules_public/tables/http_route_module/table on pg

BEGIN;

SELECT id, database_id, scope, http_routes_table_id
FROM metaschema_modules_public.http_route_module
WHERE false;

ROLLBACK;
Loading