@pgpm/metaschema-modules 0.26.0 → 0.26.1

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 (40) hide show
  1. package/Makefile +1 -1
  2. package/deploy/schemas/metaschema_modules_public/tables/agent_module/table.sql +77 -0
  3. package/deploy/schemas/metaschema_modules_public/tables/billing_module/table.sql +5 -0
  4. package/deploy/schemas/metaschema_modules_public/tables/compute_log_module/table.sql +44 -0
  5. package/deploy/schemas/metaschema_modules_public/tables/db_usage_module/table.sql +52 -0
  6. package/deploy/schemas/metaschema_modules_public/tables/entity_type_provision/table.sql +99 -24
  7. package/deploy/schemas/metaschema_modules_public/tables/function_module/table.sql +68 -0
  8. package/deploy/schemas/metaschema_modules_public/tables/graph_module/table.sql +73 -0
  9. package/deploy/schemas/metaschema_modules_public/tables/inference_log_module/table.sql +7 -2
  10. package/deploy/schemas/metaschema_modules_public/tables/merkle_store_module/table.sql +50 -0
  11. package/deploy/schemas/metaschema_modules_public/tables/namespace_module/table.sql +65 -0
  12. package/deploy/schemas/metaschema_modules_public/tables/storage_log_module/table.sql +44 -0
  13. package/deploy/schemas/metaschema_modules_public/tables/storage_module/table.sql +5 -6
  14. package/deploy/schemas/metaschema_modules_public/tables/transfer_log_module/table.sql +44 -0
  15. package/deploy/schemas/metaschema_modules_public/tables/user_auth_module/table.sql +1 -1
  16. package/metaschema-modules.control +1 -1
  17. package/package.json +3 -3
  18. package/pgpm.plan +9 -0
  19. package/revert/schemas/metaschema_modules_public/tables/agent_module/table.sql +7 -0
  20. package/revert/schemas/metaschema_modules_public/tables/compute_log_module/table.sql +3 -0
  21. package/revert/schemas/metaschema_modules_public/tables/db_usage_module/table.sql +3 -0
  22. package/revert/schemas/metaschema_modules_public/tables/function_module/table.sql +7 -0
  23. package/revert/schemas/metaschema_modules_public/tables/graph_module/table.sql +7 -0
  24. package/revert/schemas/metaschema_modules_public/tables/merkle_store_module/table.sql +7 -0
  25. package/revert/schemas/metaschema_modules_public/tables/namespace_module/table.sql +7 -0
  26. package/revert/schemas/metaschema_modules_public/tables/storage_log_module/table.sql +3 -0
  27. package/revert/schemas/metaschema_modules_public/tables/transfer_log_module/table.sql +3 -0
  28. package/sql/{metaschema-modules--0.15.5.sql → metaschema-modules--0.26.0.sql} +563 -22
  29. package/verify/schemas/metaschema_modules_public/tables/agent_module/table.sql +7 -0
  30. package/verify/schemas/metaschema_modules_public/tables/billing_module/table.sql +2 -0
  31. package/verify/schemas/metaschema_modules_public/tables/compute_log_module/table.sql +9 -0
  32. package/verify/schemas/metaschema_modules_public/tables/db_usage_module/table.sql +10 -0
  33. package/verify/schemas/metaschema_modules_public/tables/function_module/table.sql +7 -0
  34. package/verify/schemas/metaschema_modules_public/tables/graph_module/table.sql +7 -0
  35. package/verify/schemas/metaschema_modules_public/tables/inference_log_module/table.sql +3 -2
  36. package/verify/schemas/metaschema_modules_public/tables/merkle_store_module/table.sql +7 -0
  37. package/verify/schemas/metaschema_modules_public/tables/namespace_module/table.sql +14 -0
  38. package/verify/schemas/metaschema_modules_public/tables/profiles_module/table.sql +2 -1
  39. package/verify/schemas/metaschema_modules_public/tables/storage_log_module/table.sql +10 -0
  40. package/verify/schemas/metaschema_modules_public/tables/transfer_log_module/table.sql +10 -0
@@ -0,0 +1,65 @@
1
+ -- Deploy schemas/metaschema_modules_public/tables/namespace_module/table to pg
2
+
3
+ -- requires: schemas/metaschema_modules_public/schema
4
+
5
+ BEGIN;
6
+
7
+ CREATE TABLE metaschema_modules_public.namespace_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
+ namespaces_table_id uuid NOT NULL DEFAULT uuid_nil(),
21
+ namespace_events_table_id uuid NOT NULL DEFAULT uuid_nil(),
22
+
23
+ -- Table names (input to the generator)
24
+ namespaces_table_name text NOT NULL DEFAULT 'namespaces',
25
+ namespace_events_table_name text NOT NULL DEFAULT 'namespace_events',
26
+
27
+ -- API routing (get-or-create: if set, schema is added to this API; if NULL, no API is added)
28
+ api_name text,
29
+ private_api_name text,
30
+
31
+ -- Multi-tenant namespace identity
32
+ membership_type int DEFAULT NULL, -- NULL = database-root (AuthzMembership via app_sprt), non-NULL = entity-scoped (AuthzEntityMembership)
33
+
34
+ -- Entity table for RLS (NULL for app-level namespaces, entity table for entity-scoped namespaces)
35
+ entity_table_id uuid NULL,
36
+
37
+ -- Configurable security policies (NULL = use defaults based on membership_type).
38
+ -- When provided, replaces the default policy set in apply_namespace_security.
39
+ -- Accepts a JSON array of policy objects:
40
+ -- {"$type": "AuthzEntityMembership", "privileges": ["select", "update"], "data": {...}}
41
+ policies jsonb NULL,
42
+
43
+ -- Per-table provisions overrides from blueprint config.
44
+ -- Keys are table keys (namespaces, namespace_events).
45
+ -- When a key is present, the module trigger skips default security for that table;
46
+ -- secure_table_provision applies the custom grants/policies instead.
47
+ provisions jsonb NULL,
48
+
49
+ -- Constraints
50
+ CONSTRAINT namespace_module_db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
51
+ CONSTRAINT namespace_module_schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
52
+ CONSTRAINT namespace_module_private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
53
+ CONSTRAINT namespace_module_namespaces_table_fkey FOREIGN KEY (namespaces_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
54
+ CONSTRAINT namespace_module_events_table_fkey FOREIGN KEY (namespace_events_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
55
+ CONSTRAINT namespace_module_entity_table_fkey FOREIGN KEY (entity_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
56
+ );
57
+
58
+ CREATE INDEX namespace_module_database_id_idx ON metaschema_modules_public.namespace_module ( database_id );
59
+
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) );
64
+
65
+ COMMIT;
@@ -0,0 +1,44 @@
1
+ -- Deploy schemas/metaschema_modules_public/tables/storage_log_module/table to pg
2
+
3
+ -- requires: schemas/metaschema_modules_public/schema
4
+
5
+ BEGIN;
6
+
7
+ CREATE TABLE metaschema_modules_public.storage_log_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
+ private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
+
14
+ -- Storage log table (partitioned by snapshot_at)
15
+ storage_log_table_id uuid NOT NULL DEFAULT uuid_nil(),
16
+ storage_log_table_name text NOT NULL DEFAULT '',
17
+
18
+ -- Pre-aggregated daily rollup table
19
+ usage_daily_table_id uuid NOT NULL DEFAULT uuid_nil(),
20
+ usage_daily_table_name text NOT NULL DEFAULT '',
21
+
22
+ -- Partition lifecycle configuration
23
+ "interval" text NOT NULL DEFAULT '1 month',
24
+ retention text NOT NULL DEFAULT '12 months',
25
+ premake int NOT NULL DEFAULT 2,
26
+
27
+ -- Scope configuration: 'app' = per-app usage (actor_id RLS), 'platform' = tenant metering (database_id RLS)
28
+ scope text NOT NULL DEFAULT 'app',
29
+ actor_fk_table_id uuid NULL,
30
+ entity_fk_table_id uuid NULL,
31
+
32
+ prefix text NULL,
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 private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
37
+ CONSTRAINT storage_log_table_fkey FOREIGN KEY (storage_log_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
38
+ CONSTRAINT usage_daily_table_fkey FOREIGN KEY (usage_daily_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
39
+ CONSTRAINT storage_log_module_database_id_prefix_unique UNIQUE NULLS NOT DISTINCT (database_id, prefix)
40
+ );
41
+
42
+ CREATE INDEX storage_log_module_database_id_idx ON metaschema_modules_public.storage_log_module ( database_id );
43
+
44
+ COMMIT;
@@ -35,12 +35,11 @@ CREATE TABLE metaschema_modules_public.storage_module (
35
35
  -- {"$type": "AuthzEntityMembership", "privileges": ["select", "update"], "data": {...}}
36
36
  policies jsonb NULL,
37
37
 
38
- -- Per-table skip list for apply_storage_security default policies.
39
- -- When a table role name ("files", "buckets") is listed here,
40
- -- apply_storage_security skips its default policies for that table.
41
- -- Used by entity_type_provision to mark tables whose policies are
42
- -- supplied via provisions (secure_table_provision).
43
- skip_default_policy_tables text[] NOT NULL DEFAULT '{}',
38
+ -- Per-table provisions overrides from blueprint config.
39
+ -- Keys are table keys (files, buckets).
40
+ -- When a key is present, the module trigger skips default security for that table;
41
+ -- secure_table_provision applies the custom grants/policies instead.
42
+ provisions jsonb NULL,
44
43
 
45
44
  -- Entity table for RLS (NULL for app-level storage, entity table for entity-scoped storage)
46
45
  entity_table_id uuid NULL,
@@ -0,0 +1,44 @@
1
+ -- Deploy schemas/metaschema_modules_public/tables/transfer_log_module/table to pg
2
+
3
+ -- requires: schemas/metaschema_modules_public/schema
4
+
5
+ BEGIN;
6
+
7
+ CREATE TABLE metaschema_modules_public.transfer_log_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
+ private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
+
14
+ -- Transfer log table (partitioned by created_at)
15
+ transfer_log_table_id uuid NOT NULL DEFAULT uuid_nil(),
16
+ transfer_log_table_name text NOT NULL DEFAULT '',
17
+
18
+ -- Pre-aggregated daily rollup table
19
+ usage_daily_table_id uuid NOT NULL DEFAULT uuid_nil(),
20
+ usage_daily_table_name text NOT NULL DEFAULT '',
21
+
22
+ -- Partition lifecycle configuration
23
+ "interval" text NOT NULL DEFAULT '1 month',
24
+ retention text NOT NULL DEFAULT '12 months',
25
+ premake int NOT NULL DEFAULT 2,
26
+
27
+ -- Scope configuration: 'app' = per-app usage (actor_id RLS), 'platform' = tenant metering (database_id RLS)
28
+ scope text NOT NULL DEFAULT 'app',
29
+ actor_fk_table_id uuid NULL,
30
+ entity_fk_table_id uuid NULL,
31
+
32
+ prefix text NULL,
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 private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
37
+ CONSTRAINT transfer_log_table_fkey FOREIGN KEY (transfer_log_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
38
+ CONSTRAINT usage_daily_table_fkey FOREIGN KEY (usage_daily_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
39
+ CONSTRAINT transfer_log_module_database_id_prefix_unique UNIQUE NULLS NOT DISTINCT (database_id, prefix)
40
+ );
41
+
42
+ CREATE INDEX transfer_log_module_database_id_idx ON metaschema_modules_public.transfer_log_module ( database_id );
43
+
44
+ COMMIT;
@@ -19,7 +19,7 @@ CREATE TABLE metaschema_modules_public.user_auth_module (
19
19
  session_credentials_table_id uuid NOT NULL DEFAULT uuid_nil(),
20
20
 
21
21
  audits_table_id uuid NOT NULL DEFAULT uuid_nil(),
22
- audits_table_name text NOT NULL DEFAULT 'audit_logs',
22
+ audits_table_name text NOT NULL DEFAULT 'audit_log_auth',
23
23
 
24
24
  -- api_id uuid NOT NULL REFERENCES services_public.apis (id),
25
25
 
@@ -1,6 +1,6 @@
1
1
  # metaschema-modules extension
2
2
  comment = 'metaschema-modules extension'
3
- default_version = '0.15.5'
3
+ default_version = '0.26.0'
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.0",
3
+ "version": "0.26.1",
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.0",
24
+ "@pgpm/metaschema-schema": "0.26.1",
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": "3badf1e5e2fc71deae9e194b779599d17ab28a0d"
38
+ "gitHead": "e1f2e9bec1c91d0751ebe49e9193459191d3c464"
39
39
  }
package/pgpm.plan CHANGED
@@ -51,3 +51,12 @@ schemas/metaschema_modules_public/tables/realtime_module/table [schemas/metasche
51
51
  schemas/metaschema_modules_public/tables/rate_limit_meters_module/table [schemas/metaschema_modules_public/schema] 2026-05-16T00:00:00Z devin <devin@cognition.ai> # add rate_limit_meters_module for rolling window abuse protection (standalone rate limiting)
52
52
  schemas/metaschema_modules_public/tables/config_secrets_org_module/table [schemas/metaschema_modules_public/schema] 2026-05-18T00:00:00Z devin <devin@cognition.ai> # add config_secrets_org_module config table for org-scoped encrypted secrets
53
53
  schemas/metaschema_modules_public/tables/inference_log_module/table [schemas/metaschema_modules_public/schema] 2026-05-12T23:00:00Z devin <devin@cognition.ai> # add inference_log_module config table for partitioned LLM inference logging
54
+ schemas/metaschema_modules_public/tables/compute_log_module/table [schemas/metaschema_modules_public/schema] 2026-05-18T20:00:00Z devin <devin@cognition.ai> # add compute_log_module config table for partitioned compute usage logging
55
+ schemas/metaschema_modules_public/tables/transfer_log_module/table [schemas/metaschema_modules_public/schema] 2026-05-18T21:00:00Z devin <devin@cognition.ai> # add transfer_log_module config table for partitioned transfer/bandwidth logging
56
+ schemas/metaschema_modules_public/tables/storage_log_module/table [schemas/metaschema_modules_public/schema] 2026-05-18T21:00:01Z devin <devin@cognition.ai> # add storage_log_module config table for partitioned object storage usage logging
57
+ schemas/metaschema_modules_public/tables/db_usage_module/table [schemas/metaschema_modules_public/schema] 2026-05-18T21:00:02Z devin <devin@cognition.ai> # add db_usage_module config table for partitioned database-level usage metrics
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
+ 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
+ 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/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
+ 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
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/metaschema_modules_public/tables/agent_module/table from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP TABLE metaschema_modules_public.agent_module;
6
+
7
+ COMMIT;
@@ -0,0 +1,3 @@
1
+ -- Revert schemas/metaschema_modules_public/tables/compute_log_module/table from pg
2
+
3
+ DROP TABLE IF EXISTS metaschema_modules_public.compute_log_module;
@@ -0,0 +1,3 @@
1
+ -- Revert schemas/metaschema_modules_public/tables/db_usage_module/table from pg
2
+
3
+ DROP TABLE IF EXISTS metaschema_modules_public.db_usage_module;
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/metaschema_modules_public/tables/function_module/table from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP TABLE metaschema_modules_public.function_module;
6
+
7
+ COMMIT;
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/metaschema_modules_public/tables/graph_module/table from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP TABLE metaschema_modules_public.graph_module;
6
+
7
+ COMMIT;
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/metaschema_modules_public/tables/merkle_store_module/table from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP TABLE metaschema_modules_public.merkle_store_module;
6
+
7
+ COMMIT;
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/metaschema_modules_public/tables/namespace_module/table from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP TABLE IF EXISTS metaschema_modules_public.namespace_module;
6
+
7
+ COMMIT;
@@ -0,0 +1,3 @@
1
+ -- Revert schemas/metaschema_modules_public/tables/storage_log_module/table from pg
2
+
3
+ DROP TABLE IF EXISTS metaschema_modules_public.storage_log_module;
@@ -0,0 +1,3 @@
1
+ -- Revert schemas/metaschema_modules_public/tables/transfer_log_module/table from pg
2
+
3
+ DROP TABLE IF EXISTS metaschema_modules_public.transfer_log_module;