@pgpm/metaschema-modules 0.26.1 → 0.26.2

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.
package/Makefile CHANGED
@@ -1,5 +1,5 @@
1
1
  EXTENSION = metaschema-modules
2
- DATA = sql/metaschema-modules--0.26.0.sql
2
+ DATA = sql/metaschema-modules--0.26.1.sql
3
3
 
4
4
  PG_CONFIG = pg_config
5
5
  PGXS := $(shell $(PG_CONFIG) --pgxs)
@@ -35,6 +35,12 @@ CREATE TABLE metaschema_modules_public.agent_module (
35
35
  -- Multi-tenant scope
36
36
  membership_type int DEFAULT NULL,
37
37
 
38
+ -- Module key discriminator: allows multiple agent modules per scope.
39
+ -- 'default' is omitted from table names, any other value becomes
40
+ -- an infix: {prefix}_{key}_agent_thread.
41
+ -- Max 16 chars, lowercase snake_case.
42
+ key text NOT NULL DEFAULT 'default',
43
+
38
44
  -- Entity table for RLS (NULL for app-level, entity table for entity-scoped)
39
45
  entity_table_id uuid NULL,
40
46
 
@@ -69,9 +75,9 @@ CREATE TABLE metaschema_modules_public.agent_module (
69
75
 
70
76
  CREATE INDEX agent_module_database_id_idx ON metaschema_modules_public.agent_module ( database_id );
71
77
 
72
- -- Unique constraint on (database_id, membership_type) using COALESCE to handle NULLs.
73
- -- NULL membership_type = app-level, non-NULL = entity-scoped.
74
- -- Only one agent module per scope.
75
- CREATE UNIQUE INDEX agent_module_unique_scope ON metaschema_modules_public.agent_module ( database_id, COALESCE(membership_type, -1) );
78
+ -- Unique constraint on (database_id, membership_type, key) using COALESCE to handle NULLs.
79
+ -- NULL membership_type = app-level, non-NULL = entity-scoped. key discriminates
80
+ -- multiple agent modules for the same scope (e.g. 'support' + 'internal').
81
+ CREATE UNIQUE INDEX agent_module_unique_scope ON metaschema_modules_public.agent_module ( database_id, COALESCE(membership_type, -1), key );
76
82
 
77
83
  COMMIT;
@@ -12,11 +12,15 @@ CREATE TABLE metaschema_modules_public.config_secrets_user_module (
12
12
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
13
  table_id uuid NOT NULL DEFAULT uuid_nil(),
14
14
  table_name text NOT NULL DEFAULT 'user_secrets',
15
+
16
+ -- Config definitions table ID (populated by the generator)
17
+ config_definitions_table_id uuid NOT NULL DEFAULT uuid_nil(),
15
18
  --
16
19
 
17
20
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
18
21
  CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
19
- CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
22
+ CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
23
+ CONSTRAINT config_defs_table_fkey FOREIGN KEY (config_definitions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
20
24
  );
21
25
 
22
26
  CREATE INDEX config_secrets_user_module_database_id_idx ON metaschema_modules_public.config_secrets_user_module ( database_id );
@@ -135,6 +135,12 @@ CREATE TABLE metaschema_modules_public.entity_type_provision (
135
135
 
136
136
  out_execution_logs_table_id uuid DEFAULT NULL,
137
137
 
138
+ out_secret_definitions_table_id uuid DEFAULT NULL,
139
+
140
+ out_requirements_table_id uuid DEFAULT NULL,
141
+
142
+ out_config_requirements_table_id uuid DEFAULT NULL,
143
+
138
144
  out_graph_module_id uuid DEFAULT NULL,
139
145
 
140
146
  out_graphs_table_id uuid DEFAULT NULL,
@@ -328,12 +334,13 @@ COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.storage IS
328
334
  'Optional JSON array of storage module definitions. Presence triggers provisioning
329
335
  (same inference model as namespaces, functions, agents).
330
336
  Each element provisions a separate storage module with its own tables
331
- ({prefix}_{storage_key}_buckets/files), RLS policies, and feature flags.
337
+ ({prefix}_{key}_buckets/files), RLS policies, and feature flags.
332
338
  NULL = do not provision storage. ''[{}]'' = provision one default storage module.
333
339
  Each array element recognizes (all optional):
334
- - storage_key (text) module discriminator, max 16 chars, lowercase snake_case.
340
+ - key (text) module discriminator, max 16 chars, lowercase snake_case.
335
341
  Defaults to ''default'' (omitted from table names).
336
342
  Non-default keys become infixes: {prefix}_{key}_buckets.
343
+ (storage_key accepted for backward compat)
337
344
  - upload_url_expiry_seconds (integer) presigned PUT URL expiry override
338
345
  - download_url_expiry_seconds (integer) presigned GET URL expiry override
339
346
  - default_max_file_size (bigint) global max file size in bytes for this module
@@ -353,7 +360,7 @@ COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.storage IS
353
360
  Example (single module, backward compat):
354
361
  storage := ''[{"buckets": [{"name": "documents"}]}]''::jsonb
355
362
  Example (multi-module):
356
- storage := ''[{"has_path_shares": true, "buckets": [{"name": "documents"}]}, {"storage_key": "fn", "has_custom_keys": true, "buckets": [{"name": "functions"}]}]''::jsonb';
363
+ storage := ''[{"has_path_shares": true, "buckets": [{"name": "documents"}]}, {"key": "fn", "has_custom_keys": true, "buckets": [{"name": "functions"}]}]''::jsonb';
357
364
 
358
365
  COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_storage_module_id IS
359
366
  'Output: the UUID of the storage_module row created for this entity type. Populated by the trigger when storage is non-NULL and non-empty.';
@@ -20,11 +20,19 @@ CREATE TABLE metaschema_modules_public.function_module (
20
20
  definitions_table_id uuid NOT NULL DEFAULT uuid_nil(),
21
21
  invocations_table_id uuid NOT NULL DEFAULT uuid_nil(),
22
22
  execution_logs_table_id uuid NOT NULL DEFAULT uuid_nil(),
23
+ secret_definitions_table_id uuid NOT NULL DEFAULT uuid_nil(),
24
+ requirements_table_id uuid NOT NULL DEFAULT uuid_nil(),
25
+ config_definitions_table_id uuid NOT NULL DEFAULT uuid_nil(),
26
+ config_requirements_table_id uuid NOT NULL DEFAULT uuid_nil(),
23
27
 
24
- -- Table names (input to the generator)
28
+ -- Table names (input to the generator — bare names without scope prefix).
29
+ -- The trigger prepends the scope prefix automatically.
25
30
  definitions_table_name text NOT NULL DEFAULT 'function_definitions',
26
31
  invocations_table_name text NOT NULL DEFAULT 'function_invocations',
27
32
  execution_logs_table_name text NOT NULL DEFAULT 'function_execution_logs',
33
+ secret_definitions_table_name text NOT NULL DEFAULT 'secret_definitions',
34
+ requirements_table_name text NOT NULL DEFAULT 'function_secret_requirements',
35
+ config_requirements_table_name text NOT NULL DEFAULT 'function_config_requirements',
28
36
 
29
37
  -- API routing (get-or-create: if set, schema is added to this API; if NULL, no API is added)
30
38
  api_name text,
@@ -33,6 +41,18 @@ CREATE TABLE metaschema_modules_public.function_module (
33
41
  -- Multi-tenant function identity
34
42
  membership_type int DEFAULT NULL, -- NULL = database-root (AuthzMembership via app_sprt), non-NULL = entity-scoped (AuthzEntityMembership)
35
43
 
44
+ -- Scope prefix for table naming. Auto-derived from membership_type when
45
+ -- NULL: NULL/1 → 'app', 2 → 'org'. Can be overridden explicitly.
46
+ -- The trigger prepends this to all bare table names
47
+ -- (e.g. prefix='app' + 'function_definitions' → 'app_function_definitions').
48
+ prefix text NULL,
49
+
50
+ -- Module key discriminator: allows multiple function modules per scope.
51
+ -- 'default' is omitted from table names, any other value becomes
52
+ -- an infix: {prefix}_{key}_function_definitions.
53
+ -- Max 16 chars, lowercase snake_case.
54
+ key text NOT NULL DEFAULT 'default',
55
+
36
56
  -- Entity table for RLS (NULL for app-level functions, entity table for entity-scoped functions)
37
57
  entity_table_id uuid NULL,
38
58
 
@@ -43,7 +63,7 @@ CREATE TABLE metaschema_modules_public.function_module (
43
63
  policies jsonb NULL,
44
64
 
45
65
  -- Per-table provisions overrides from blueprint config.
46
- -- Keys are table keys (definitions, invocations, execution_logs).
66
+ -- Keys are table keys (definitions, invocations, execution_logs, secret_definitions, requirements).
47
67
  -- When a key is present, the module trigger skips default security for that table;
48
68
  -- secure_table_provision applies the custom grants/policies instead.
49
69
  provisions jsonb NULL,
@@ -55,14 +75,18 @@ CREATE TABLE metaschema_modules_public.function_module (
55
75
  CONSTRAINT function_module_definitions_table_fkey FOREIGN KEY (definitions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
56
76
  CONSTRAINT function_module_invocations_table_fkey FOREIGN KEY (invocations_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
57
77
  CONSTRAINT function_module_execution_logs_table_fkey FOREIGN KEY (execution_logs_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
78
+ CONSTRAINT function_module_secret_defs_table_fkey FOREIGN KEY (secret_definitions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
79
+ CONSTRAINT function_module_requirements_table_fkey FOREIGN KEY (requirements_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
80
+ CONSTRAINT function_module_config_defs_table_fkey FOREIGN KEY (config_definitions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
81
+ CONSTRAINT function_module_config_reqs_table_fkey FOREIGN KEY (config_requirements_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
58
82
  CONSTRAINT function_module_entity_table_fkey FOREIGN KEY (entity_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
59
83
  );
60
84
 
61
85
  CREATE INDEX function_module_database_id_idx ON metaschema_modules_public.function_module ( database_id );
62
86
 
63
- -- Unique constraint on (database_id, membership_type) using COALESCE to handle NULLs.
64
- -- NULL membership_type = app-level, non-NULL = entity-scoped.
65
- -- Only one function module per scope.
66
- CREATE UNIQUE INDEX function_module_unique_scope ON metaschema_modules_public.function_module ( database_id, COALESCE(membership_type, -1) );
87
+ -- Unique constraint on (database_id, membership_type, key) using COALESCE to handle NULLs.
88
+ -- NULL membership_type = app-level, non-NULL = entity-scoped. key discriminates
89
+ -- multiple function modules for the same scope (e.g. 'webhooks' + 'automations').
90
+ CREATE UNIQUE INDEX function_module_unique_scope ON metaschema_modules_public.function_module ( database_id, COALESCE(membership_type, -1), key );
67
91
 
68
92
  COMMIT;
@@ -50,6 +50,9 @@ CREATE TABLE metaschema_modules_public.memberships_module (
50
50
 
51
51
  prefix text NULL,
52
52
 
53
+ -- Populated by memberships_module generator when get_organization_id is created
54
+ get_org_fn text NULL,
55
+
53
56
  --
54
57
 
55
58
  actor_mask_check text NOT NULL DEFAULT '',
@@ -8,11 +8,13 @@ CREATE TABLE metaschema_modules_public.merkle_store_module (
8
8
  id uuid PRIMARY KEY DEFAULT uuidv7(),
9
9
  database_id uuid NOT NULL,
10
10
 
11
- -- Schema reference (if uuid_nil, resolved from public_schema_name or default)
11
+ -- Schema references (if uuid_nil, resolved from schema name or default)
12
12
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
+ private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
14
 
14
- -- Optional schema name override (used when schema_id is not provided)
15
+ -- Optional schema name overrides (used when schema IDs are not provided)
15
16
  public_schema_name text,
17
+ private_schema_name text,
16
18
 
17
19
  -- Generated table IDs (populated by BEFORE INSERT trigger)
18
20
  object_table_id uuid NOT NULL DEFAULT uuid_nil(),
@@ -24,8 +26,9 @@ CREATE TABLE metaschema_modules_public.merkle_store_module (
24
26
  -- Stored normalized (no trailing underscore); underscore added at generation time
25
27
  prefix text NOT NULL DEFAULT '',
26
28
 
27
- -- API name (if set, schema is added to this API; if NULL, no API is added)
29
+ -- API routing (get-or-create: if set, schema is added to this API; if NULL, no API is added)
28
30
  api_name text,
31
+ private_api_name text,
29
32
 
30
33
  -- Scope field name (column used for multi-tenant isolation)
31
34
  scope_field text NOT NULL DEFAULT 'scope_id',
@@ -36,6 +39,7 @@ CREATE TABLE metaschema_modules_public.merkle_store_module (
36
39
  -- Constraints
37
40
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
38
41
  CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
42
+ CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
39
43
  CONSTRAINT object_table_fkey FOREIGN KEY (object_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
40
44
  CONSTRAINT store_table_fkey FOREIGN KEY (store_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
41
45
  CONSTRAINT commit_table_fkey FOREIGN KEY (commit_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
@@ -46,5 +50,6 @@ CREATE TABLE metaschema_modules_public.merkle_store_module (
46
50
  );
47
51
 
48
52
  CREATE INDEX merkle_store_module_database_id_idx ON metaschema_modules_public.merkle_store_module ( database_id );
53
+ CREATE INDEX merkle_store_module_private_schema_id_idx ON metaschema_modules_public.merkle_store_module ( private_schema_id );
49
54
 
50
55
  COMMIT;
@@ -31,6 +31,12 @@ CREATE TABLE metaschema_modules_public.namespace_module (
31
31
  -- Multi-tenant namespace identity
32
32
  membership_type int DEFAULT NULL, -- NULL = database-root (AuthzMembership via app_sprt), non-NULL = entity-scoped (AuthzEntityMembership)
33
33
 
34
+ -- Module key discriminator: allows multiple namespace modules per scope.
35
+ -- 'default' is omitted from table names, any other value becomes
36
+ -- an infix: {prefix}_{key}_namespaces.
37
+ -- Max 16 chars, lowercase snake_case.
38
+ key text NOT NULL DEFAULT 'default',
39
+
34
40
  -- Entity table for RLS (NULL for app-level namespaces, entity table for entity-scoped namespaces)
35
41
  entity_table_id uuid NULL,
36
42
 
@@ -57,9 +63,9 @@ CREATE TABLE metaschema_modules_public.namespace_module (
57
63
 
58
64
  CREATE INDEX namespace_module_database_id_idx ON metaschema_modules_public.namespace_module ( database_id );
59
65
 
60
- -- Unique constraint on (database_id, membership_type) using COALESCE to handle NULLs.
61
- -- NULL membership_type = app-level, non-NULL = entity-scoped.
62
- -- Only one namespace module per scope (unlike storage_module which has storage_key).
63
- CREATE UNIQUE INDEX namespace_module_unique_scope ON metaschema_modules_public.namespace_module ( database_id, COALESCE(membership_type, -1) );
66
+ -- Unique constraint on (database_id, membership_type, key) using COALESCE to handle NULLs.
67
+ -- NULL membership_type = app-level, non-NULL = entity-scoped. key discriminates
68
+ -- multiple namespace modules for the same scope (e.g. 'config' + 'content').
69
+ CREATE UNIQUE INDEX namespace_module_unique_scope ON metaschema_modules_public.namespace_module ( database_id, COALESCE(membership_type, -1), key );
64
70
 
65
71
  COMMIT;
@@ -23,11 +23,11 @@ CREATE TABLE metaschema_modules_public.storage_module (
23
23
  -- Multi-tenant storage identity
24
24
  membership_type int DEFAULT NULL, -- NULL = global gate (AuthzMembership via app_sprt), non-NULL = entity-scoped (AuthzEntityMembership)
25
25
 
26
- -- Storage module discriminator: allows multiple storage modules per entity type.
26
+ -- Module key discriminator: allows multiple storage modules per entity type.
27
27
  -- 'default' is omitted from table names (backward compat), any other value becomes
28
- -- an infix: {prefix}_{storage_key}_{buckets|files}.
28
+ -- an infix: {prefix}_{key}_{buckets|files}.
29
29
  -- Max 16 chars, lowercase snake_case, cannot be 'buckets'/'files'/'bucket'/'file'.
30
- storage_key text NOT NULL DEFAULT 'default',
30
+ key text NOT NULL DEFAULT 'default',
31
31
 
32
32
  -- Configurable security policies (NULL = use defaults based on membership_type).
33
33
  -- When provided, replaces the default policy set in apply_storage_security.
@@ -100,9 +100,9 @@ CREATE TABLE metaschema_modules_public.storage_module (
100
100
 
101
101
  CREATE INDEX storage_module_database_id_idx ON metaschema_modules_public.storage_module ( database_id );
102
102
 
103
- -- Unique constraint on (database_id, membership_type, storage_key) using COALESCE to handle NULLs.
104
- -- NULL membership_type = app-level, non-NULL = entity-scoped. storage_key discriminates
103
+ -- Unique constraint on (database_id, membership_type, key) using COALESCE to handle NULLs.
104
+ -- NULL membership_type = app-level, non-NULL = entity-scoped. key discriminates
105
105
  -- multiple storage modules for the same entity type (e.g. 'default' + 'fn').
106
- CREATE UNIQUE INDEX storage_module_unique_scope ON metaschema_modules_public.storage_module ( database_id, COALESCE(membership_type, -1), storage_key );
106
+ CREATE UNIQUE INDEX storage_module_unique_scope ON metaschema_modules_public.storage_module ( database_id, COALESCE(membership_type, -1), key );
107
107
 
108
108
  COMMIT;
@@ -1,6 +1,6 @@
1
1
  # metaschema-modules extension
2
2
  comment = 'metaschema-modules extension'
3
- default_version = '0.26.0'
3
+ default_version = '0.26.1'
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.26.1",
3
+ "version": "0.26.2",
4
4
  "description": "Module metadata handling and dependency tracking",
5
5
  "author": "Dan Lynch <pyramation@gmail.com>",
6
6
  "contributors": [
@@ -21,7 +21,7 @@
21
21
  "test:watch": "jest --watch"
22
22
  },
23
23
  "dependencies": {
24
- "@pgpm/metaschema-schema": "0.26.1",
24
+ "@pgpm/metaschema-schema": "0.26.2",
25
25
  "@pgpm/verify": "0.26.0"
26
26
  },
27
27
  "devDependencies": {
@@ -35,5 +35,5 @@
35
35
  "bugs": {
36
36
  "url": "https://github.com/constructive-io/pgpm-modules/issues"
37
37
  },
38
- "gitHead": "e1f2e9bec1c91d0751ebe49e9193459191d3c464"
38
+ "gitHead": "d938867e5d7c0e7b2e130a2bdc5d58cd0d5874e1"
39
39
  }
package/pgpm.plan CHANGED
@@ -60,3 +60,4 @@ schemas/metaschema_modules_public/tables/merkle_store_module/table [schemas/meta
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
61
  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
62
  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
+