@pgpm/metaschema-modules 0.28.3 → 0.28.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/Makefile +1 -1
  2. package/README.md +1 -16
  3. package/deploy/schemas/metaschema_modules_public/tables/agent_module/table.sql +4 -0
  4. package/deploy/schemas/metaschema_modules_public/tables/billing_module/table.sql +4 -0
  5. package/deploy/schemas/metaschema_modules_public/tables/compute_log_module/table.sql +4 -0
  6. package/deploy/schemas/metaschema_modules_public/tables/config_secrets_module/table.sql +4 -0
  7. package/deploy/schemas/metaschema_modules_public/tables/db_usage_module/table.sql +4 -0
  8. package/deploy/schemas/metaschema_modules_public/tables/events_module/table.sql +4 -0
  9. package/deploy/schemas/metaschema_modules_public/tables/function_deployment_module/table.sql +81 -0
  10. package/deploy/schemas/metaschema_modules_public/tables/function_module/constraints/one_platform_database.sql +18 -0
  11. package/deploy/schemas/metaschema_modules_public/tables/graph_module/table.sql +2 -5
  12. package/deploy/schemas/metaschema_modules_public/tables/hierarchy_module/table.sql +1 -1
  13. package/deploy/schemas/metaschema_modules_public/tables/identity_providers_module/table.sql +4 -0
  14. package/deploy/schemas/metaschema_modules_public/tables/inference_log_module/table.sql +4 -0
  15. package/deploy/schemas/metaschema_modules_public/tables/invites_module/table.sql +4 -0
  16. package/deploy/schemas/metaschema_modules_public/tables/limits_module/table.sql +4 -0
  17. package/deploy/schemas/metaschema_modules_public/tables/memberships_module/table.sql +4 -0
  18. package/deploy/schemas/metaschema_modules_public/tables/merkle_store_module/table.sql +5 -0
  19. package/deploy/schemas/metaschema_modules_public/tables/namespace_module/table.sql +6 -0
  20. package/deploy/schemas/metaschema_modules_public/tables/notifications_module/table.sql +4 -0
  21. package/deploy/schemas/metaschema_modules_public/tables/permissions_module/table.sql +4 -0
  22. package/deploy/schemas/metaschema_modules_public/tables/plans_module/table.sql +4 -0
  23. package/deploy/schemas/metaschema_modules_public/tables/principal_auth_module/table.sql +58 -0
  24. package/deploy/schemas/metaschema_modules_public/tables/profiles_module/table.sql +4 -0
  25. package/deploy/schemas/metaschema_modules_public/tables/rate_limit_meters_module/table.sql +4 -0
  26. package/deploy/schemas/metaschema_modules_public/tables/storage_log_module/table.sql +4 -0
  27. package/deploy/schemas/metaschema_modules_public/tables/storage_module/table.sql +7 -1
  28. package/deploy/schemas/metaschema_modules_public/tables/transfer_log_module/table.sql +4 -0
  29. package/metaschema-modules.control +1 -1
  30. package/package.json +6 -5
  31. package/pgpm.plan +4 -1
  32. package/revert/schemas/metaschema_modules_public/tables/config_secrets_module/table.sql +1 -1
  33. package/revert/schemas/metaschema_modules_public/tables/function_deployment_module/table.sql +7 -0
  34. package/revert/schemas/metaschema_modules_public/tables/function_module/constraints/one_platform_database.sql +7 -0
  35. package/revert/schemas/metaschema_modules_public/tables/principal_auth_module/table.sql +7 -0
  36. package/revert/schemas/metaschema_modules_public/tables/user_credentials_module/table.sql +1 -1
  37. package/revert/schemas/metaschema_modules_public/tables/user_settings_module/table.sql +1 -1
  38. package/sql/{metaschema-modules--0.26.5.sql → metaschema-modules--0.15.5.sql} +428 -215
  39. package/verify/schemas/metaschema_modules_public/tables/agent_chat_module/table.sql +20 -0
  40. package/verify/schemas/metaschema_modules_public/tables/agent_module/table.sql +3 -5
  41. package/verify/schemas/metaschema_modules_public/tables/compute_log_module/table.sql +2 -1
  42. package/verify/schemas/metaschema_modules_public/tables/config_secrets_org_module/table.sql +3 -5
  43. package/verify/schemas/metaschema_modules_public/tables/db_usage_module/table.sql +2 -5
  44. package/verify/schemas/metaschema_modules_public/tables/entity_type_provision/table.sql +3 -5
  45. package/verify/schemas/metaschema_modules_public/tables/function_deployment_module/table.sql +14 -0
  46. package/verify/schemas/metaschema_modules_public/tables/function_invocation_module/table.sql +9 -1
  47. package/verify/schemas/metaschema_modules_public/tables/function_module/constraints/one_platform_database.sql +11 -0
  48. package/verify/schemas/metaschema_modules_public/tables/graph_module/table.sql +3 -5
  49. package/verify/schemas/metaschema_modules_public/tables/inference_log_module/table.sql +2 -1
  50. package/verify/schemas/metaschema_modules_public/tables/merkle_store_module/table.sql +3 -5
  51. package/verify/schemas/metaschema_modules_public/tables/namespace_module/table.sql +1 -3
  52. package/verify/schemas/metaschema_modules_public/tables/principal_auth_module/table.sql +14 -0
  53. package/verify/schemas/metaschema_modules_public/tables/profiles_module/table.sql +0 -1
  54. package/verify/schemas/metaschema_modules_public/tables/relation_provision/table.sql +0 -3
  55. package/verify/schemas/metaschema_modules_public/tables/secure_table_provision/table.sql +0 -1
  56. package/verify/schemas/metaschema_modules_public/tables/session_secrets_module/table.sql +3 -5
  57. package/verify/schemas/metaschema_modules_public/tables/storage_log_module/table.sql +1 -1
  58. package/verify/schemas/metaschema_modules_public/tables/transfer_log_module/table.sql +1 -1
  59. package/verify/schemas/metaschema_modules_public/tables/user_settings_module/table.sql +1 -1
package/Makefile CHANGED
@@ -1,5 +1,5 @@
1
1
  EXTENSION = metaschema-modules
2
- DATA = sql/metaschema-modules--0.26.5.sql
2
+ DATA = sql/metaschema-modules--0.15.5.sql
3
3
 
4
4
  PG_CONFIG = pg_config
5
5
  PGXS := $(shell $(PG_CONFIG) --pgxs)
package/README.md CHANGED
@@ -223,7 +223,7 @@ pnpm test
223
223
 
224
224
  ## Related Tooling
225
225
 
226
- * [pgpm](https://github.com/constructive-io/constructive/tree/main/pgpm/pgpm): **🖥️ PostgreSQL Package Manager** for modular Postgres development. Works with database workspaces, scaffolding, migrations, seeding, and installing database packages.
226
+ * [pgpm](https://github.com/constructive-io/constructive/tree/main/pgpm/cli): **🖥️ PostgreSQL Package Manager** for modular Postgres development. Works with database workspaces, scaffolding, migrations, seeding, and installing database packages.
227
227
  * [pgsql-test](https://github.com/constructive-io/constructive/tree/main/postgres/pgsql-test): **📊 Isolated testing environments** with per-test transaction rollbacks—ideal for integration tests, complex migrations, and RLS simulation.
228
228
  * [supabase-test](https://github.com/constructive-io/constructive/tree/main/postgres/supabase-test): **🧪 Supabase-native test harness** preconfigured for the local Supabase stack—per-test rollbacks, JWT/role context helpers, and CI/GitHub Actions ready.
229
229
  * [graphile-test](https://github.com/constructive-io/constructive/tree/main/graphile/graphile-test): **🔐 Authentication mocking** for Graphile-focused test helpers and emulating row-level security contexts.
@@ -231,21 +231,6 @@ pnpm test
231
231
  * [libpg-query-node](https://github.com/constructive-io/libpg-query-node): **🌉 Node.js bindings** for `libpg_query`, converting SQL into parse trees.
232
232
  * [pg-proto-parser](https://github.com/constructive-io/pg-proto-parser): **📦 Protobuf parser** for parsing PostgreSQL Protocol Buffers definitions to generate TypeScript interfaces, utility functions, and JSON mappings for enums.
233
233
 
234
- ### 📚 Documentation & Skills
235
-
236
- * [constructive-skills](https://github.com/constructive-io/constructive-skills): **📖 Platform documentation and AI agent skills** — feature catalog, blueprint reference, SDK guides, and deployment guides.
237
-
238
- Install skills for AI coding agents:
239
-
240
- ```bash
241
- # All platform skills (security, blueprints, codegen, billing, etc.)
242
- npx skills add constructive-io/constructive-skills
243
-
244
- # Individual repo skills (pgpm, testing, CLI, search, etc.)
245
- npx skills add https://github.com/constructive-io/constructive --skill pgpm
246
- npx skills add https://github.com/constructive-io/constructive --skill constructive-testing
247
- ```
248
-
249
234
  ## Disclaimer
250
235
 
251
236
  AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
@@ -12,6 +12,10 @@ CREATE TABLE metaschema_modules_public.agent_module (
12
12
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
13
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
14
14
 
15
+ -- Schema name overrides: when set, the trigger uses these instead of hardcoded defaults.
16
+ public_schema_name text,
17
+ private_schema_name text,
18
+
15
19
  -- Generated table IDs (populated by the generator)
16
20
  thread_table_id uuid NOT NULL DEFAULT uuid_nil(),
17
21
  message_table_id uuid NOT NULL DEFAULT uuid_nil(),
@@ -11,6 +11,10 @@ CREATE TABLE metaschema_modules_public.billing_module (
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
12
12
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
13
 
14
+ -- Schema name overrides: when set, the trigger uses these instead of hardcoded defaults.
15
+ public_schema_name text,
16
+ private_schema_name text,
17
+
14
18
  -- Meters table: defines what you track (quota, boolean, credit_pool)
15
19
  meters_table_id uuid NOT NULL DEFAULT uuid_nil(),
16
20
  meters_table_name text NOT NULL DEFAULT '',
@@ -11,6 +11,10 @@ CREATE TABLE metaschema_modules_public.compute_log_module (
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
12
12
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
13
 
14
+ -- Schema name overrides: when set, the trigger uses these instead of hardcoded defaults.
15
+ public_schema_name text,
16
+ private_schema_name text,
17
+
14
18
  -- Compute log table (partitioned by completed_at)
15
19
  compute_log_table_id uuid NOT NULL DEFAULT uuid_nil(),
16
20
  compute_log_table_name text NOT NULL DEFAULT '',
@@ -12,6 +12,10 @@ CREATE TABLE metaschema_modules_public.config_secrets_module (
12
12
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
13
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
14
14
 
15
+ -- Schema name overrides: when set, the trigger uses these instead of hardcoded defaults.
16
+ public_schema_name text,
17
+ private_schema_name text,
18
+
15
19
  -- Generated table IDs (populated by the generator)
16
20
  table_id uuid NOT NULL DEFAULT uuid_nil(),
17
21
  config_definitions_table_id uuid NULL DEFAULT NULL,
@@ -11,6 +11,10 @@ CREATE TABLE metaschema_modules_public.db_usage_module (
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
12
12
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
13
 
14
+ -- Schema name overrides: when set, the trigger uses these instead of hardcoded defaults.
15
+ public_schema_name text,
16
+ private_schema_name text,
17
+
14
18
  -- DB table stats log (partitioned — per-table reads/writes/size from pg_stat_user_tables)
15
19
  table_stats_log_table_id uuid NOT NULL DEFAULT uuid_nil(),
16
20
  table_stats_log_table_name text NOT NULL DEFAULT '',
@@ -11,6 +11,10 @@ CREATE TABLE metaschema_modules_public.events_module (
11
11
  --
12
12
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
13
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
14
+
15
+ -- Schema name overrides: when set, the trigger uses these instead of hardcoded defaults.
16
+ public_schema_name text,
17
+ private_schema_name text,
14
18
  --
15
19
 
16
20
  events_table_id uuid NOT NULL DEFAULT uuid_nil(),
@@ -0,0 +1,81 @@
1
+ -- Deploy schemas/metaschema_modules_public/tables/function_deployment_module/table to pg
2
+
3
+ -- requires: schemas/metaschema_modules_public/schema
4
+
5
+ BEGIN;
6
+
7
+ CREATE TABLE metaschema_modules_public.function_deployment_module (
8
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
9
+ database_id uuid NOT NULL,
10
+
11
+ -- Schema references (if uuid_nil, resolved from schema name or default)
12
+ schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
+ private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
14
+
15
+ -- Optional schema name overrides (used when schema IDs are not provided)
16
+ public_schema_name text,
17
+ private_schema_name text,
18
+
19
+ -- Generated table IDs (populated by the generator)
20
+ deployments_table_id uuid NOT NULL DEFAULT uuid_nil(),
21
+ deployment_events_table_id uuid NOT NULL DEFAULT uuid_nil(),
22
+
23
+ -- Table names (input to the generator — bare names without scope prefix).
24
+ -- The trigger prepends the scope prefix automatically.
25
+ deployments_table_name text NOT NULL DEFAULT 'function_deployments',
26
+ deployment_events_table_name text NOT NULL DEFAULT 'function_deployment_events',
27
+
28
+ -- API routing (get-or-create: if set, schema is added to this API; if NULL, no API is added)
29
+ api_name text,
30
+ private_api_name text,
31
+
32
+ -- Scope: determines the security level for this module instance.
33
+ -- Resolved to a membership_type integer at trigger time via membership_types table.
34
+ scope text NOT NULL DEFAULT 'app',
35
+
36
+ -- Table name prefix. Auto-derived from scope by the trigger when empty.
37
+ -- Override to create multiple module instances at the same scope.
38
+ prefix text NOT NULL DEFAULT '',
39
+
40
+ -- Entity table for RLS (NULL for app-level deployments, entity table for entity-scoped)
41
+ entity_table_id uuid NULL,
42
+
43
+ -- FK to function_module: which function definitions table deployments reference
44
+ function_module_id uuid NULL,
45
+
46
+ -- FK to namespace_module: which namespaces table deployments reference
47
+ namespace_module_id uuid NULL,
48
+
49
+ -- Configurable security policies (NULL = use defaults based on scope).
50
+ -- When provided, replaces the default policy set in apply_function_deployment_security.
51
+ -- Accepts a JSON array of policy objects:
52
+ -- {"$type": "AuthzEntityMembership", "privileges": ["select", "update"], "data": {...}}
53
+ policies jsonb NULL,
54
+
55
+ -- Per-table provisions overrides from blueprint config.
56
+ -- Keys are table keys (deployments, deployment_events).
57
+ -- When a key is present, the module trigger skips default security for that table;
58
+ -- secure_table_provision applies the custom grants/policies instead.
59
+ provisions jsonb NULL,
60
+
61
+ -- Default permissions: permission names auto-granted to new members.
62
+ -- NULL uses the module's built-in defaults; explicit array overrides them.
63
+ default_permissions text[] DEFAULT NULL,
64
+
65
+ -- Constraints
66
+ CONSTRAINT function_deployment_module_db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
67
+ CONSTRAINT function_deployment_module_schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
68
+ CONSTRAINT function_deployment_module_private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
69
+ CONSTRAINT function_deployment_module_deployments_table_fkey FOREIGN KEY (deployments_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
70
+ CONSTRAINT function_deployment_module_events_table_fkey FOREIGN KEY (deployment_events_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
71
+ CONSTRAINT function_deployment_module_entity_table_fkey FOREIGN KEY (entity_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
72
+ CONSTRAINT function_deployment_module_function_module_fkey FOREIGN KEY (function_module_id) REFERENCES metaschema_modules_public.function_module (id) ON DELETE SET NULL,
73
+ CONSTRAINT function_deployment_module_namespace_module_fkey FOREIGN KEY (namespace_module_id) REFERENCES metaschema_modules_public.namespace_module (id) ON DELETE SET NULL
74
+ );
75
+
76
+ CREATE INDEX function_deployment_module_database_id_idx ON metaschema_modules_public.function_deployment_module ( database_id );
77
+
78
+ -- Unique constraint: one function deployment module per database per scope per prefix.
79
+ CREATE UNIQUE INDEX function_deployment_module_unique_scope ON metaschema_modules_public.function_deployment_module ( database_id, scope, prefix );
80
+
81
+ COMMIT;
@@ -0,0 +1,18 @@
1
+ -- Deploy schemas/metaschema_modules_public/tables/function_module/constraints/one_platform_database to pg
2
+
3
+ -- requires: schemas/metaschema_modules_public/tables/function_module/table
4
+
5
+ BEGIN;
6
+
7
+ -- No-op migration: platform database uniqueness is enforced at the application
8
+ -- layer by resolveDatabaseId(), which queries:
9
+ -- SELECT database_id FROM function_module WHERE scope = 'platform' LIMIT 1
10
+ --
11
+ -- A hard UNIQUE constraint on ((true)) WHERE scope='platform' would break
12
+ -- test isolation (each test database independently provisions platform-scope
13
+ -- modules in the same shared table). The existing unique index
14
+ -- (database_id, scope, prefix) already prevents duplicates within a single
15
+ -- database. Cross-database uniqueness (only one platform DB in production)
16
+ -- is enforced operationally and validated at compute worker startup.
17
+
18
+ COMMIT;
@@ -27,9 +27,8 @@ CREATE TABLE metaschema_modules_public.graph_module (
27
27
  merkle_store_module_id uuid NOT NULL,
28
28
 
29
29
  -- Generated table IDs (populated by BEFORE INSERT trigger)
30
+ -- Only the graphs (definition) table — execution tables live in graph_execution_module
30
31
  graphs_table_id uuid NOT NULL DEFAULT uuid_nil(),
31
- executions_table_id uuid NOT NULL DEFAULT uuid_nil(),
32
- outputs_table_id uuid NOT NULL DEFAULT uuid_nil(),
33
32
 
34
33
  -- API routing (get-or-create: if set, schema is added to this API; if NULL, no API is added)
35
34
  api_name text,
@@ -44,7 +43,7 @@ CREATE TABLE metaschema_modules_public.graph_module (
44
43
  policies jsonb NULL,
45
44
 
46
45
  -- Per-table provisions overrides from blueprint config.
47
- -- Keys are table keys (graphs, executions, outputs).
46
+ -- Keys are table keys (graphs).
48
47
  -- When a key is present, the module trigger skips default security for that table;
49
48
  -- secure_table_provision applies the custom grants/policies instead.
50
49
  provisions jsonb NULL,
@@ -62,8 +61,6 @@ CREATE TABLE metaschema_modules_public.graph_module (
62
61
  CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
63
62
  CONSTRAINT merkle_store_fkey FOREIGN KEY (merkle_store_module_id) REFERENCES metaschema_modules_public.merkle_store_module (id) ON DELETE CASCADE,
64
63
  CONSTRAINT graphs_table_fkey FOREIGN KEY (graphs_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
65
- CONSTRAINT executions_table_fkey FOREIGN KEY (executions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
66
- CONSTRAINT outputs_table_fkey FOREIGN KEY (outputs_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
67
64
  CONSTRAINT graph_module_entity_table_fkey FOREIGN KEY (entity_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
68
65
 
69
66
  -- Only one graph module per database + merkle store combination
@@ -33,7 +33,7 @@ CREATE TABLE metaschema_modules_public.hierarchy_module (
33
33
  prefix text NOT NULL DEFAULT '',
34
34
 
35
35
  -- Resolved names for RLS parser lookups
36
- private_schema_name text NOT NULL DEFAULT '',
36
+ private_schema_name text NOT NULL DEFAULT '',
37
37
  sprt_table_name text NOT NULL DEFAULT '',
38
38
 
39
39
  -- Function names for helper functions
@@ -11,6 +11,10 @@ CREATE TABLE metaschema_modules_public.identity_providers_module (
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
12
12
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
13
 
14
+ -- Schema name overrides: when set, the trigger uses these instead of hardcoded defaults.
15
+ public_schema_name text,
16
+ private_schema_name text,
17
+
14
18
  table_id uuid NOT NULL DEFAULT uuid_nil(),
15
19
 
16
20
  table_name text NOT NULL DEFAULT 'identity_providers',
@@ -11,6 +11,10 @@ CREATE TABLE metaschema_modules_public.inference_log_module (
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
12
12
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
13
 
14
+ -- Schema name overrides: when set, the trigger uses these instead of hardcoded defaults.
15
+ public_schema_name text,
16
+ private_schema_name text,
17
+
14
18
  -- Inference log table (partitioned by created_at)
15
19
  inference_log_table_id uuid NOT NULL DEFAULT uuid_nil(),
16
20
  inference_log_table_name text NOT NULL DEFAULT '',
@@ -11,6 +11,10 @@ CREATE TABLE metaschema_modules_public.invites_module (
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
12
12
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
13
 
14
+ -- Schema name overrides: when set, the trigger uses these instead of hardcoded defaults.
15
+ public_schema_name text,
16
+ private_schema_name text,
17
+
14
18
  emails_table_id uuid NOT NULL DEFAULT uuid_nil(),
15
19
  users_table_id uuid NOT NULL DEFAULT uuid_nil(),
16
20
 
@@ -10,6 +10,10 @@ CREATE TABLE metaschema_modules_public.limits_module (
10
10
  --
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
12
12
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
+
14
+ -- Schema name overrides: when set, the trigger uses these instead of hardcoded defaults.
15
+ public_schema_name text,
16
+ private_schema_name text,
13
17
  ---
14
18
  table_id uuid NOT NULL DEFAULT uuid_nil(),
15
19
  table_name text NOT NULL DEFAULT '',
@@ -11,6 +11,10 @@ CREATE TABLE metaschema_modules_public.memberships_module (
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
12
12
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
13
 
14
+ -- Schema name overrides: when set, the trigger uses these instead of hardcoded defaults.
15
+ public_schema_name text,
16
+ private_schema_name text,
17
+
14
18
  memberships_table_id uuid NOT NULL DEFAULT uuid_nil(),
15
19
  memberships_table_name text NOT NULL DEFAULT '',
16
20
 
@@ -39,6 +39,11 @@ CREATE TABLE metaschema_modules_public.merkle_store_module (
39
39
  -- any other value is used as-is. Tables always keep their prefix regardless of this setting.
40
40
  function_prefix text DEFAULT NULL,
41
41
 
42
+ -- Permission key for SELECT gating: when set, all 4 merkle tables require this
43
+ -- permission for SELECT at platform/app scope (e.g., 'manage_graphs').
44
+ -- NULL means the caller intentionally wants open membership SELECT.
45
+ permission_key text DEFAULT NULL,
46
+
42
47
  -- Timestamps
43
48
  created_at timestamptz NOT NULL DEFAULT now(),
44
49
 
@@ -39,6 +39,12 @@ CREATE TABLE metaschema_modules_public.namespace_module (
39
39
  -- Entity table for RLS (NULL for app-level namespaces, entity table for entity-scoped namespaces)
40
40
  entity_table_id uuid NULL,
41
41
 
42
+ -- Platform namespace table reference (for cross-scope mirror trigger).
43
+ -- When scope != 'platform', the insert trigger resolves this automatically
44
+ -- from the platform-scope namespace_module row.
45
+ -- NULL means no mirror trigger (platform scope, or no platform module exists).
46
+ platform_namespaces_table_id uuid NULL,
47
+
42
48
  -- Configurable security policies (NULL = use defaults based on scope).
43
49
  -- When provided, replaces the default policy set in apply_namespace_security.
44
50
  -- Accepts a JSON array of policy objects:
@@ -11,6 +11,10 @@ CREATE TABLE metaschema_modules_public.notifications_module (
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
12
12
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
13
 
14
+ -- Schema name overrides: when set, the trigger uses these instead of hardcoded defaults.
15
+ public_schema_name text,
16
+ private_schema_name text,
17
+
14
18
  notifications_table_id uuid NOT NULL DEFAULT uuid_nil(),
15
19
  read_state_table_id uuid NOT NULL DEFAULT uuid_nil(),
16
20
  -- Feature-gated tables: NULL when the corresponding has_* flag is off.
@@ -10,6 +10,10 @@ CREATE TABLE metaschema_modules_public.permissions_module (
10
10
  --
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
12
12
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
+
14
+ -- Schema name overrides: when set, the trigger uses these instead of hardcoded defaults.
15
+ public_schema_name text,
16
+ private_schema_name text,
13
17
  table_id uuid NOT NULL DEFAULT uuid_nil(),
14
18
  table_name text NOT NULL DEFAULT '',
15
19
  --
@@ -11,6 +11,10 @@ CREATE TABLE metaschema_modules_public.plans_module (
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
12
12
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
13
 
14
+ -- Schema name overrides: when set, the trigger uses these instead of hardcoded defaults.
15
+ public_schema_name text,
16
+ private_schema_name text,
17
+
14
18
  -- Plans table: defines plan tiers (Free, Pro, Enterprise)
15
19
  plans_table_id uuid NOT NULL DEFAULT uuid_nil(),
16
20
  plans_table_name text NOT NULL DEFAULT '',
@@ -0,0 +1,58 @@
1
+ -- Deploy schemas/metaschema_modules_public/tables/principal_auth_module/table to pg
2
+
3
+ -- requires: schemas/metaschema_modules_public/schema
4
+
5
+ BEGIN;
6
+
7
+ CREATE TABLE metaschema_modules_public.principal_auth_module (
8
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
9
+ database_id uuid NOT NULL,
10
+
11
+ schema_id uuid NOT NULL DEFAULT uuid_nil(),
12
+ principals_table_id uuid NOT NULL DEFAULT uuid_nil(),
13
+ principal_entities_table_id uuid NOT NULL DEFAULT uuid_nil(),
14
+ principal_scope_overrides_table_id uuid NOT NULL DEFAULT uuid_nil(),
15
+ users_table_id uuid NOT NULL DEFAULT uuid_nil(),
16
+ sessions_table_id uuid NOT NULL DEFAULT uuid_nil(),
17
+ session_credentials_table_id uuid NOT NULL DEFAULT uuid_nil(),
18
+ audits_table_id uuid NOT NULL DEFAULT uuid_nil(),
19
+
20
+ principals_table_name text NOT NULL DEFAULT 'principals',
21
+ create_principal_function text NOT NULL DEFAULT 'create_principal',
22
+ delete_principal_function text NOT NULL DEFAULT 'delete_principal',
23
+
24
+ -- Org principal function names (generated when org memberships exist)
25
+ create_org_principal_function text NOT NULL DEFAULT 'create_org_principal',
26
+ delete_org_principal_function text NOT NULL DEFAULT 'delete_org_principal',
27
+
28
+ -- Org API key function names (generated when org memberships exist)
29
+ create_org_api_key_function text NOT NULL DEFAULT 'create_org_api_key',
30
+ revoke_org_api_key_function text NOT NULL DEFAULT 'revoke_org_api_key',
31
+
32
+ api_name text DEFAULT 'auth',
33
+
34
+ CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
35
+ CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
36
+ CONSTRAINT principals_table_fkey FOREIGN KEY (principals_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
37
+ CONSTRAINT principal_entities_table_fkey FOREIGN KEY (principal_entities_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
38
+ CONSTRAINT users_table_fkey FOREIGN KEY (users_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
39
+ CONSTRAINT sessions_table_fkey FOREIGN KEY (sessions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
40
+ CONSTRAINT session_credentials_table_fkey FOREIGN KEY (session_credentials_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
41
+ );
42
+
43
+ CREATE INDEX principal_auth_module_database_id_idx ON metaschema_modules_public.principal_auth_module ( database_id );
44
+
45
+ COMMENT ON CONSTRAINT principals_table_fkey
46
+ ON metaschema_modules_public.principal_auth_module IS E'@omit';
47
+ COMMENT ON CONSTRAINT users_table_fkey
48
+ ON metaschema_modules_public.principal_auth_module IS E'@omit';
49
+ COMMENT ON CONSTRAINT sessions_table_fkey
50
+ ON metaschema_modules_public.principal_auth_module IS E'@omit';
51
+ COMMENT ON CONSTRAINT session_credentials_table_fkey
52
+ ON metaschema_modules_public.principal_auth_module IS E'@omit';
53
+ COMMENT ON CONSTRAINT principal_entities_table_fkey
54
+ ON metaschema_modules_public.principal_auth_module IS E'@omit';
55
+
56
+ COMMENT ON TABLE metaschema_modules_public.principal_auth_module IS 'Provisions the principals subsystem: a principals table, a principal_entities junction table, create/delete mutations, and org API key management. Supports both human-owned principals (AuthzDirectOwner, AuthzHumanOnly) and org-owned principals (AuthzEntityMembership with is_admin). Org principal and org API key functions are only generated when an org-scoped memberships_module exists for the database.';
57
+
58
+ COMMIT;
@@ -10,6 +10,10 @@ CREATE TABLE metaschema_modules_public.profiles_module (
10
10
  --
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
12
12
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
+
14
+ -- Schema name overrides: when set, the trigger uses these instead of hardcoded defaults.
15
+ public_schema_name text,
16
+ private_schema_name text,
13
17
 
14
18
  -- Main profiles table
15
19
  table_id uuid NOT NULL DEFAULT uuid_nil(),
@@ -13,6 +13,10 @@ CREATE TABLE metaschema_modules_public.rate_limit_meters_module (
13
13
  -- Private schema: rate_limit_state table, check_rate_limit function (internal)
14
14
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
15
15
 
16
+ -- Schema name overrides: when set, the trigger uses these instead of hardcoded defaults.
17
+ public_schema_name text,
18
+ private_schema_name text,
19
+
16
20
  -- State table: sliding window tracking per entity/actor/meter/window (private)
17
21
  rate_limit_state_table_id uuid NOT NULL DEFAULT uuid_nil(),
18
22
  rate_limit_state_table_name text NOT NULL DEFAULT '',
@@ -11,6 +11,10 @@ CREATE TABLE metaschema_modules_public.storage_log_module (
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
12
12
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
13
 
14
+ -- Schema name overrides: when set, the trigger uses these instead of hardcoded defaults.
15
+ public_schema_name text,
16
+ private_schema_name text,
17
+
14
18
  -- Storage log table (partitioned by snapshot_at)
15
19
  storage_log_table_id uuid NOT NULL DEFAULT uuid_nil(),
16
20
  storage_log_table_name text NOT NULL DEFAULT '',
@@ -12,6 +12,11 @@ CREATE TABLE metaschema_modules_public.storage_module (
12
12
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
13
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
14
14
 
15
+ -- Schema name overrides: when set, the trigger uses these instead of hardcoded defaults.
16
+ -- Enables putting storage tables into a dedicated schema (e.g. per-entity isolation).
17
+ public_schema_name text,
18
+ private_schema_name text,
19
+
15
20
  -- Generated table IDs (populated by the generator)
16
21
  buckets_table_id uuid NOT NULL DEFAULT uuid_nil(),
17
22
  files_table_id uuid NOT NULL DEFAULT uuid_nil(),
@@ -92,7 +97,8 @@ CREATE TABLE metaschema_modules_public.storage_module (
92
97
 
93
98
  -- Constraints
94
99
  -- API routing (configurable per-module)
95
- api_name text DEFAULT 'admin',
100
+ -- NULL = no automatic API routing (caller must route explicitly or use entity_type_provision).
101
+ api_name text DEFAULT NULL,
96
102
  private_api_name text DEFAULT NULL,
97
103
 
98
104
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
@@ -11,6 +11,10 @@ CREATE TABLE metaschema_modules_public.transfer_log_module (
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
12
12
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
13
 
14
+ -- Schema name overrides: when set, the trigger uses these instead of hardcoded defaults.
15
+ public_schema_name text,
16
+ private_schema_name text,
17
+
14
18
  -- Transfer log table (partitioned by created_at)
15
19
  transfer_log_table_id uuid NOT NULL DEFAULT uuid_nil(),
16
20
  transfer_log_table_name text NOT NULL DEFAULT '',
@@ -1,6 +1,6 @@
1
1
  # metaschema-modules extension
2
2
  comment = 'metaschema-modules extension'
3
- default_version = '0.26.5'
3
+ default_version = '0.15.5'
4
4
  module_pathname = '$libdir/metaschema-modules'
5
5
  requires = 'plpgsql,uuid-ossp,metaschema-schema,services,pgpm-verify'
6
6
  relocatable = false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgpm/metaschema-modules",
3
- "version": "0.28.3",
3
+ "version": "0.28.4",
4
4
  "description": "Module metadata handling and dependency tracking",
5
5
  "author": "Dan Lynch <pyramation@gmail.com>",
6
6
  "contributors": [
@@ -21,11 +21,12 @@
21
21
  "test:watch": "jest --watch"
22
22
  },
23
23
  "dependencies": {
24
- "@pgpm/metaschema-schema": "0.28.3",
25
- "@pgpm/verify": "0.28.3"
24
+ "@pgpm/metaschema-schema": "0.28.4",
25
+ "@pgpm/verify": "0.28.4"
26
26
  },
27
27
  "devDependencies": {
28
- "pgpm": "^4.23.2"
28
+ "constructive-test": "^0.4.1",
29
+ "pgpm": "^4.28.7"
29
30
  },
30
31
  "repository": {
31
32
  "type": "git",
@@ -35,5 +36,5 @@
35
36
  "bugs": {
36
37
  "url": "https://github.com/constructive-io/pgpm-modules/issues"
37
38
  },
38
- "gitHead": "ebab5300b911578a615bf8d267fe7c5c244caea3"
39
+ "gitHead": "08979b82f1f68af396b540c6ce0cda4b438d34f0"
39
40
  }
package/pgpm.plan CHANGED
@@ -58,6 +58,7 @@ schemas/metaschema_modules_public/tables/db_usage_module/table [schemas/metasche
58
58
  schemas/metaschema_modules_public/tables/agent_module/table [schemas/metaschema_modules_public/schema] 2026-05-12T23:01:00Z devin <devin@cognition.ai> # add agent_module config table for AI agent conversation threads, messages, and tasks
59
59
  schemas/metaschema_modules_public/tables/merkle_store_module/table [schemas/metaschema_modules_public/schema] 2026-05-21T00:00:00Z devin <devin@cognition.ai> # add merkle_store_module config table for content-addressed Merkle object stores
60
60
  schemas/metaschema_modules_public/tables/graph_module/table [schemas/metaschema_modules_public/schema schemas/metaschema_modules_public/tables/merkle_store_module/table] 2026-05-21T01:00:00Z devin <devin@cognition.ai> # add graph_module config table for FBP graph utilities on top of merkle store
61
+ schemas/metaschema_modules_public/tables/graph_execution_module/table [schemas/metaschema_modules_public/schema schemas/metaschema_modules_public/tables/graph_module/table] 2026-06-12T00:00:00Z devin <devin@cognition.ai> # add graph_execution_module config table for partitioned execution state + merkle tree time-travel debugging
61
62
  schemas/metaschema_modules_public/tables/namespace_module/table [schemas/metaschema_modules_public/schema] 2026-05-21T02:00:00Z devin <devin@cognition.ai> # add namespace_module config table for entity-aware namespace provisioning
62
63
  schemas/metaschema_modules_public/tables/function_module/table [schemas/metaschema_modules_public/schema] 2026-05-21T03:00:00Z devin <devin@cognition.ai> # add function_module config table for entity-aware function definitions
63
64
  schemas/metaschema_modules_public/tables/function_invocation_module/table [schemas/metaschema_modules_public/schema] 2026-06-08T00:00:00Z devin <devin@cognition.ai> # add function_invocation_module config table for entity-scoped invocations and execution logs
@@ -66,4 +67,6 @@ schemas/metaschema_modules_public/tables/user_credentials_module/table [schemas/
66
67
  schemas/metaschema_modules_public/tables/user_settings_module/table [schemas/metaschema_modules_public/schema] 2026-05-28T00:00:00Z devin <devin@cognition.ai> # add user_settings_module for extensible per-user preferences (1:1 with users)
67
68
 
68
69
  schemas/metaschema_modules_public/tables/i18n_module/table [schemas/metaschema_modules_public/schema] 2026-05-28T00:00:00Z devin <devin@cognition.ai> # add i18n_module config table for internationalization settings
69
- schemas/metaschema_modules_public/tables/graph_execution_module/table [schemas/metaschema_modules_public/schema schemas/metaschema_modules_public/tables/graph_module/table] 2026-06-12T00:00:00Z devin <devin@cognition.ai> # add graph_execution_module config table for partitioned execution state + merkle tree time-travel debugging
70
+ 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
71
+ 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)
72
+ 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
@@ -2,6 +2,6 @@
2
2
 
3
3
  BEGIN;
4
4
 
5
- DROP TABLE IF EXISTS metaschema_modules_public.config_secrets_module;
5
+ DROP TABLE metaschema_modules_public.config_secrets_module;
6
6
 
7
7
  COMMIT;
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/metaschema_modules_public/tables/function_deployment_module/table from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP TABLE IF EXISTS metaschema_modules_public.function_deployment_module;
6
+
7
+ COMMIT;
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/metaschema_modules_public/tables/function_module/constraints/one_platform_database from pg
2
+
3
+ BEGIN;
4
+
5
+ -- No-op: nothing to revert (deploy was a no-op documentation migration)
6
+
7
+ COMMIT;
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/metaschema_modules_public/tables/principal_auth_module/table from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP TABLE metaschema_modules_public.principal_auth_module;
6
+
7
+ COMMIT;
@@ -2,6 +2,6 @@
2
2
 
3
3
  BEGIN;
4
4
 
5
- DROP TABLE IF EXISTS metaschema_modules_public.user_credentials_module;
5
+ DROP TABLE metaschema_modules_public.user_credentials_module;
6
6
 
7
7
  COMMIT;
@@ -2,6 +2,6 @@
2
2
 
3
3
  BEGIN;
4
4
 
5
- DROP TABLE IF EXISTS metaschema_modules_public.user_settings_module;
5
+ DROP TABLE metaschema_modules_public.user_settings_module;
6
6
 
7
7
  COMMIT;