Skip to content

feat: sync shared pgpm modules with constructive-db main - #112

Merged
pyramation merged 2 commits into
mainfrom
feat/sync-constructive-db-main
Aug 3, 2026
Merged

feat: sync shared pgpm modules with constructive-db main#112
pyramation merged 2 commits into
mainfrom
feat/sync-constructive-db-main

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

Mirrors constructive-db main's pgpm-modules/ sources into these published copies (constructive-db #2684, #2689/#2690, #2701, #2703). Versions untouched — lerna publish stays a manual step. The repo-local conventions are preserved: pgsql-test (not constructive-test) imports, downstream 0.34.0 versions, and the extra READMEs.

Adds @pgpm/errors, which the workspace can no longer do without: jwt-claims now hard-fails on a missing database claim instead of returning NULL, so it requires errors:

-requires = 'plpgsql,pgpm-types,pgpm-verify'
+requires = 'plpgsql,errors,pgpm-types,pgpm-verify'
-- jwt_private.current_database_id(): the claim is set at every session boundary,
-- so a missing one means a scoped write is about to run unattributed
IF database_id IS NULL THEN
  PERFORM errors.raise_error('DATABASE_CLAIM_REQUIRED', …, 'internal');
END IF;

Other substantive drift:

  • jwt-claims — every current_* claim reader drops its EXCEPTION WHEN OTHERS wrapper for pg_input_is_valid(), which validates without raising, so the reads no longer open a subtransaction per call: LANGUAGE plpgsql STABLELANGUAGE sql STABLE (current_user_id also LEAKPROOF).
  • metaschema-modules — new pages_module; catalog_module gains the four sites_web_config / sites_error_pages / sites_app_links / sites_deep_links _table_id + _table_name pairs and their FKs; FK-covering indexes added across the module tables (index count 459 → 476).
  • metaschema-schema — new view_behavior, table_behavior, field_behavior, unique_constraint_behavior, foreign_key_constraint_behavior tables; FK-covering indexes; database.schema_hash comment '@omit''@behavior -*'.
  • app-scope, database-jobs, object-tree, achievements, base32, inflection, verify — source/test drift.

Two upstream bugs surfaced while validating and are fixed here (and in constructive-db, so the next sync stays a no-op):

  1. metaschema-schema revert/…/field/table.sql still dropped field_table_id_idx, which deploy no longer creates (the UNIQUE (table_id, name) index covers it) — pgpm test-packages --full-cycle failed the revert with index "field_table_id_idx" does not exist.
  2. The function-resolution catalog_module seed inserts enumerate every _table_id column, and the four new ones are NOT NULL DEFAULT uuid_nil() with an FK to metaschema_public.table, so the default tripped catalog_module_sites_web_config_table_fkey on 30 tests.

Verified locally: pgpm test-packages --full-cycle passes for all 28 modules (deploy → verify → revert), and every package with a jest suite passes, including the whole CI matrix. metaschema-modules snapshots refreshed for pages_module; sql/<name>--<version>.sql and bundle artifacts regenerated for the changed modules only.

Link to Devin session: https://app.devin.ai/sessions/001d2eec896340a09d5a2dd7ed898f0c
Requested by: @pyramation

Mirrors constructive-db main's pgpm-modules/ sources into the published copies
(constructive-io/constructive-db#2684, #2689, #2690, #2701, #2703). Versions are
untouched; publishing stays a manual step.

- New @pgpm/errors module: jwt-claims now requires it (jwt_private.current_database_id
  raises DATABASE_CLAIM_REQUIRED through errors.raise_error instead of returning NULL),
  so the workspace was no longer self-contained without it.
- jwt-claims: the current_* claim readers become LANGUAGE sql over
  pg_input_is_valid() instead of plpgsql EXCEPTION blocks, which opened a
  subtransaction on every call.
- metaschema-modules: new pages_module; catalog_module gains the four
  sites_web_config/sites_error_pages/sites_app_links/sites_deep_links table id +
  name pairs and their FKs; FK-covering indexes added across the module tables.
- metaschema-schema: new view/table/field/unique-constraint/foreign-key
  behavior tables; FK-covering indexes; database.schema_hash comment becomes
  '@behavior -*'.
- app-scope, database-jobs, object-tree, achievements, base32, inflection,
  verify: source and test drift.
- Fixed a stale revert in metaschema-schema field/table (dropped
  field_table_id_idx, which deploy no longer creates, so the full revert cycle
  failed), and the function-resolution catalog_module seed inserts, which omitted
  the four new NOT NULL DEFAULT uuid_nil() table id columns and tripped their FKs.
- metaschema-modules snapshots refreshed for pages_module.
- sql/<name>--<version>.sql + bundle artifacts regenerated for the changed modules.
@pyramation pyramation self-assigned this Aug 3, 2026
@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

The portability suite's beforeAll deploys the full metaschema + app-scope +
function-resolution closure, which now exceeds jest's 5s default hook timeout on
CI runners. Matches metaschema-modules, whose config already sets 60s for the
same reason.
@pyramation
pyramation merged commit 0cb9ae7 into main Aug 3, 2026
25 checks passed
@pyramation
pyramation deleted the feat/sync-constructive-db-main branch August 3, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant