Skip to content

Commit 7d5acfd

Browse files
authored
Merge pull request #102 from constructive-io/feat/metaschema-modules-http-route-drift
feat(metaschema-modules): sync http_route_module + resource-bundle columns from constructive-db
2 parents 744a683 + c72102e commit 7d5acfd

7 files changed

Lines changed: 190 additions & 6 deletions

File tree

packages/metaschema-modules/__tests__/__snapshots__/modules.test.ts.snap

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ exports[`db_meta_modules should have all expected module tables 1`] = `
2323
"graph_execution_module",
2424
"graph_module",
2525
"hierarchy_module",
26+
"http_route_module",
2627
"i18n_module",
2728
"identity_providers_module",
2829
"inference_log_module",
@@ -66,8 +67,8 @@ exports[`db_meta_modules should have all expected module tables 1`] = `
6667

6768
exports[`db_meta_modules should verify all module tables exist in metaschema_modules_public schema 1`] = `
6869
{
69-
"moduleTablesCount": 57,
70-
"totalTables": 64,
70+
"moduleTablesCount": 58,
71+
"totalTables": 65,
7172
}
7273
`;
7374

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

135136
exports[`db_meta_modules should verify module table structures have database_id foreign keys 1`] = `
136137
{
137-
"constraintCount": 325437,
138+
"constraintCount": 325438,
138139
}
139140
`;
140141

141142
exports[`db_meta_modules should verify module tables have proper foreign key relationships 1`] = `
142143
{
143-
"constraintCount": 475451,
144+
"constraintCount": 475461,
144145
"foreignTables": [
145146
"database",
146147
"field",
@@ -150,7 +151,9 @@ exports[`db_meta_modules should verify module tables have proper foreign key rel
150151
"infra_secrets_module",
151152
"merkle_store_module",
152153
"namespace_module",
154+
"resource_module",
153155
"schema",
156+
"storage_module",
154157
"table",
155158
],
156159
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
-- Deploy schemas/metaschema_modules_public/tables/http_route_module/table to pg
2+
3+
-- requires: schemas/metaschema_modules_public/schema
4+
-- requires: schemas/metaschema_modules_public/tables/function_module/table
5+
-- requires: schemas/metaschema_modules_public/tables/resource_module/table
6+
-- requires: schemas/metaschema_modules_public/tables/storage_module/table
7+
8+
BEGIN;
9+
10+
CREATE TABLE metaschema_modules_public.http_route_module (
11+
id uuid PRIMARY KEY DEFAULT uuidv7(),
12+
database_id uuid NOT NULL,
13+
entity_field text,
14+
15+
schema_id uuid NOT NULL DEFAULT uuid_nil(),
16+
private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
17+
public_schema_name text,
18+
private_schema_name text,
19+
20+
http_routes_table_id uuid NOT NULL DEFAULT uuid_nil(),
21+
http_routes_table_name text NOT NULL DEFAULT 'http_routes',
22+
resolver_function_name text,
23+
24+
function_module_id uuid,
25+
resource_module_id uuid,
26+
storage_module_id uuid,
27+
28+
api_name text,
29+
private_api_name text,
30+
31+
scope text NOT NULL DEFAULT 'app',
32+
prefix text NOT NULL DEFAULT '',
33+
entity_table_id uuid NULL,
34+
35+
policies jsonb NULL,
36+
provisions jsonb NULL,
37+
default_permissions text[] DEFAULT NULL,
38+
39+
CONSTRAINT http_route_module_db_fkey
40+
FOREIGN KEY (database_id)
41+
REFERENCES metaschema_public.database (id)
42+
ON DELETE CASCADE,
43+
CONSTRAINT http_route_module_schema_fkey
44+
FOREIGN KEY (schema_id)
45+
REFERENCES metaschema_public.schema (id)
46+
ON DELETE CASCADE,
47+
CONSTRAINT http_route_module_private_schema_fkey
48+
FOREIGN KEY (private_schema_id)
49+
REFERENCES metaschema_public.schema (id)
50+
ON DELETE CASCADE,
51+
CONSTRAINT http_route_module_routes_table_fkey
52+
FOREIGN KEY (http_routes_table_id)
53+
REFERENCES metaschema_public.table (id)
54+
ON DELETE CASCADE,
55+
CONSTRAINT http_route_module_function_module_fkey
56+
FOREIGN KEY (function_module_id)
57+
REFERENCES metaschema_modules_public.function_module (id)
58+
ON DELETE CASCADE,
59+
CONSTRAINT http_route_module_resource_module_fkey
60+
FOREIGN KEY (resource_module_id)
61+
REFERENCES metaschema_modules_public.resource_module (id)
62+
ON DELETE CASCADE,
63+
CONSTRAINT http_route_module_storage_module_fkey
64+
FOREIGN KEY (storage_module_id)
65+
REFERENCES metaschema_modules_public.storage_module (id)
66+
ON DELETE CASCADE,
67+
CONSTRAINT http_route_module_entity_table_fkey
68+
FOREIGN KEY (entity_table_id)
69+
REFERENCES metaschema_public.table (id)
70+
ON DELETE CASCADE
71+
);
72+
73+
CREATE INDEX http_route_module_database_id_idx
74+
ON metaschema_modules_public.http_route_module (database_id);
75+
76+
CREATE UNIQUE INDEX http_route_module_unique_scope
77+
ON metaschema_modules_public.http_route_module (database_id, scope);
78+
79+
COMMIT;

packages/metaschema-modules/deploy/schemas/metaschema_modules_public/tables/resource_module/table.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
-- requires: schemas/metaschema_modules_public/schema
44
-- requires: schemas/metaschema_modules_public/tables/namespace_module/table
5+
-- requires: schemas/metaschema_modules_public/tables/merkle_store_module/table
56

67
BEGIN;
78

@@ -30,6 +31,8 @@ CREATE TABLE metaschema_modules_public.resource_module (
3031
resource_usage_samples_table_id uuid NOT NULL DEFAULT uuid_nil(),
3132
resource_usage_summary_table_id uuid NOT NULL DEFAULT uuid_nil(),
3233
namespace_usage_summary_table_id uuid NOT NULL DEFAULT uuid_nil(),
34+
-- Resource-bundles Stage 1: the installation ("release") grouping table.
35+
resource_installations_table_id uuid NOT NULL DEFAULT uuid_nil(),
3336

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

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

76+
-- Resource-bundles Stage 1: the shared merkle store an installation commits
77+
-- its versioned params into (reuses the scope's shared infra store, like
78+
-- db_preset). NULL disables installation versioning (no rollback history).
79+
merkle_store_module_id uuid NULL,
80+
-- Store row name inside the merkle store the installation head commits into.
81+
installation_store_name text NOT NULL DEFAULT 'infra',
82+
7283
-- Configurable security policies (NULL = use defaults based on scope).
7384
policies jsonb NULL,
7485

@@ -90,6 +101,8 @@ CREATE TABLE metaschema_modules_public.resource_module (
90101
CONSTRAINT resource_module_usage_samples_table_fkey FOREIGN KEY (resource_usage_samples_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
91102
CONSTRAINT resource_module_usage_summary_table_fkey FOREIGN KEY (resource_usage_summary_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
92103
CONSTRAINT resource_module_ns_usage_summary_table_fkey FOREIGN KEY (namespace_usage_summary_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
104+
CONSTRAINT resource_module_installations_table_fkey FOREIGN KEY (resource_installations_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
105+
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,
93106
CONSTRAINT resource_module_entity_table_fkey FOREIGN KEY (entity_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
94107
CONSTRAINT resource_module_namespace_module_fkey FOREIGN KEY (namespace_module_id) REFERENCES metaschema_modules_public.namespace_module (id) ON DELETE SET NULL
95108
);

packages/metaschema-modules/pgpm.plan

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ schemas/metaschema_modules_public/tables/i18n_module/table [schemas/metaschema_m
7272
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
7373
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)
7474
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
75-
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)
75+
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)
7676
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
7777
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
7878
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
@@ -82,3 +82,4 @@ schemas/metaschema_modules_public/tables/transfer_log_module/constraints/one_pla
8282
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
8383
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
8484
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
85+
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
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- Revert schemas/metaschema_modules_public/tables/http_route_module/table from pg
2+
3+
BEGIN;
4+
5+
DROP TABLE metaschema_modules_public.http_route_module;
6+
7+
COMMIT;

packages/metaschema-modules/sql/metaschema-modules--0.15.5.sql

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3620,13 +3620,15 @@ CREATE TABLE metaschema_modules_public.resource_module (
36203620
resource_usage_samples_table_id uuid NOT NULL DEFAULT uuid_nil(),
36213621
resource_usage_summary_table_id uuid NOT NULL DEFAULT uuid_nil(),
36223622
namespace_usage_summary_table_id uuid NOT NULL DEFAULT uuid_nil(),
3623+
resource_installations_table_id uuid NOT NULL DEFAULT uuid_nil(),
36233624
resources_table_name text NOT NULL DEFAULT 'resources',
36243625
resource_events_table_name text NOT NULL DEFAULT 'resource_events',
36253626
resource_status_checks_table_name text NOT NULL DEFAULT 'resource_status_checks',
36263627
resource_definitions_table_name text NOT NULL DEFAULT 'resource_definitions',
36273628
resource_usage_samples_table_name text NOT NULL DEFAULT 'resource_usage_samples',
36283629
resource_usage_summary_table_name text NOT NULL DEFAULT 'resource_usage_summaries',
36293630
namespace_usage_summary_table_name text NOT NULL DEFAULT 'namespace_usage_summaries',
3631+
resource_installations_table_name text NOT NULL DEFAULT 'resource_installations',
36303632
rollup_resource_usage_summary_function text NOT NULL DEFAULT '',
36313633
resource_billing_rollup_function text NOT NULL DEFAULT '',
36323634
resolved_requirements_view_name text,
@@ -3637,6 +3639,8 @@ CREATE TABLE metaschema_modules_public.resource_module (
36373639
prefix text NOT NULL DEFAULT '',
36383640
entity_table_id uuid NULL,
36393641
namespace_module_id uuid NULL,
3642+
merkle_store_module_id uuid NULL,
3643+
installation_store_name text NOT NULL DEFAULT 'infra',
36403644
policies jsonb NULL,
36413645
provisions jsonb NULL,
36423646
default_permissions text[] DEFAULT NULL,
@@ -3680,6 +3684,14 @@ CREATE TABLE metaschema_modules_public.resource_module (
36803684
FOREIGN KEY(namespace_usage_summary_table_id)
36813685
REFERENCES metaschema_public.table (id)
36823686
ON DELETE CASCADE,
3687+
CONSTRAINT resource_module_installations_table_fkey
3688+
FOREIGN KEY(resource_installations_table_id)
3689+
REFERENCES metaschema_public.table (id)
3690+
ON DELETE CASCADE,
3691+
CONSTRAINT resource_module_merkle_store_module_fkey
3692+
FOREIGN KEY(merkle_store_module_id)
3693+
REFERENCES metaschema_modules_public.merkle_store_module (id)
3694+
ON DELETE SET NULL,
36833695
CONSTRAINT resource_module_entity_table_fkey
36843696
FOREIGN KEY(entity_table_id)
36853697
REFERENCES metaschema_public.table (id)
@@ -3829,4 +3841,64 @@ CREATE TABLE metaschema_modules_public.webhook_module (
38293841

38303842
CREATE INDEX webhook_module_database_id_idx ON metaschema_modules_public.webhook_module (database_id);
38313843

3832-
CREATE UNIQUE INDEX webhook_module_unique_scope ON metaschema_modules_public.webhook_module (database_id, scope);
3844+
CREATE UNIQUE INDEX webhook_module_unique_scope ON metaschema_modules_public.webhook_module (database_id, scope);
3845+
3846+
CREATE TABLE metaschema_modules_public.http_route_module (
3847+
id uuid PRIMARY KEY DEFAULT uuidv7(),
3848+
database_id uuid NOT NULL,
3849+
entity_field text,
3850+
schema_id uuid NOT NULL DEFAULT uuid_nil(),
3851+
private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
3852+
public_schema_name text,
3853+
private_schema_name text,
3854+
http_routes_table_id uuid NOT NULL DEFAULT uuid_nil(),
3855+
http_routes_table_name text NOT NULL DEFAULT 'http_routes',
3856+
resolver_function_name text,
3857+
function_module_id uuid,
3858+
resource_module_id uuid,
3859+
storage_module_id uuid,
3860+
api_name text,
3861+
private_api_name text,
3862+
scope text NOT NULL DEFAULT 'app',
3863+
prefix text NOT NULL DEFAULT '',
3864+
entity_table_id uuid NULL,
3865+
policies jsonb NULL,
3866+
provisions jsonb NULL,
3867+
default_permissions text[] DEFAULT NULL,
3868+
CONSTRAINT http_route_module_db_fkey
3869+
FOREIGN KEY(database_id)
3870+
REFERENCES metaschema_public.database (id)
3871+
ON DELETE CASCADE,
3872+
CONSTRAINT http_route_module_schema_fkey
3873+
FOREIGN KEY(schema_id)
3874+
REFERENCES metaschema_public.schema (id)
3875+
ON DELETE CASCADE,
3876+
CONSTRAINT http_route_module_private_schema_fkey
3877+
FOREIGN KEY(private_schema_id)
3878+
REFERENCES metaschema_public.schema (id)
3879+
ON DELETE CASCADE,
3880+
CONSTRAINT http_route_module_routes_table_fkey
3881+
FOREIGN KEY(http_routes_table_id)
3882+
REFERENCES metaschema_public.table (id)
3883+
ON DELETE CASCADE,
3884+
CONSTRAINT http_route_module_function_module_fkey
3885+
FOREIGN KEY(function_module_id)
3886+
REFERENCES metaschema_modules_public.function_module (id)
3887+
ON DELETE CASCADE,
3888+
CONSTRAINT http_route_module_resource_module_fkey
3889+
FOREIGN KEY(resource_module_id)
3890+
REFERENCES metaschema_modules_public.resource_module (id)
3891+
ON DELETE CASCADE,
3892+
CONSTRAINT http_route_module_storage_module_fkey
3893+
FOREIGN KEY(storage_module_id)
3894+
REFERENCES metaschema_modules_public.storage_module (id)
3895+
ON DELETE CASCADE,
3896+
CONSTRAINT http_route_module_entity_table_fkey
3897+
FOREIGN KEY(entity_table_id)
3898+
REFERENCES metaschema_public.table (id)
3899+
ON DELETE CASCADE
3900+
);
3901+
3902+
CREATE INDEX http_route_module_database_id_idx ON metaschema_modules_public.http_route_module (database_id);
3903+
3904+
CREATE UNIQUE INDEX http_route_module_unique_scope ON metaschema_modules_public.http_route_module (database_id, scope);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- Verify schemas/metaschema_modules_public/tables/http_route_module/table on pg
2+
3+
BEGIN;
4+
5+
SELECT id, database_id, scope, http_routes_table_id
6+
FROM metaschema_modules_public.http_route_module
7+
WHERE false;
8+
9+
ROLLBACK;

0 commit comments

Comments
 (0)