Sync SQL sources from constructive-db (trigger attachments, attribution, module tables) - #124
Merged
Conversation
Port the drifted deploy/revert/verify trees and plan entries for app-scope, database-jobs, function-resolution, jwt-claims, metaschema-modules and metaschema-schema, repackage the sql/ artifacts, and update the tests those sources need.
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
These modules are edited in
constructive-io/constructive-db(itspgpm-modules/tree) and published from here, and the two copies had drifted — this catches up the six packages whose SQL sources differ, so the next@pgpm/*release carries them.What lands, by package:
metaschema_public.functionbecomes a declarative definition row (kind IN ('reservation','sql','plpgsql','trigger'),arguments/returns/volatility/body_ast/api_exposed, with the reservation-carries-no-definition and trigger-signature CHECKs), andmetaschema_public.triggergains the customer trigger attachment:kind IN ('reservation','attachment'),function_id→function(id)ON DELETE RESTRICT,timing,events,for_each_row,when_ast. A reservation is a name a generator or introspection owns; an attachment is a row the physicalCREATE TRIGGERis re-derived from. Also new:metaschema_public.identity_provider_registry.require_database_id,require_user_id,require_entity_id,require_entity_type) andjwt_private.assert_attribution(actor_id, entity_id, entity_type), which raisesATTRIBUTION_REQUIREDwhen a write carries neither an actor nor an entity (warn-only underjwt.strict_attribution = 'false').app_jobs.add_job/add_scheduled_job/run_scheduled_jobdefault their attribution columns from the claims and go throughassert_attribution, so a job can no longer be enqueued unattributed.app_scope.actor_entity(actor/entity pair lookup) andapp_scope.frame_owns(frame-chain ownership test for write-path guards).enqueuereads the execution database throughrequire_database_id; newinstall_route_bindingsandinstall_mantra.catalog_module.app_store_identities_table_idand the repository/resource relationships.Two test fixes the ported sources require (these vendored tests are not run in constructive-db, which is why they were stale there):
await pg.query(`SELECT set_config('jwt.claims.database_id', $1, true)`, [TENANT_DB]); + // add_job attributes the job from the claims and refuses one with no actor + await pg.query(`SELECT set_config('jwt.claims.user_id', $1, true), …`, [ACTOR_ID]); await pg.one(`SELECT * FROM function_resolution.enqueue(task_identifier := 'email:send', scope := 'app')`);sql/*.sql+*.bundle.tar.gzregenerated withpgpm package(pgpm 5.18.0, matching CI). Locally green: all 26 CI matrix packages,pgpm test-packages --full-cycle(27/27 deploy→verify→revert), andpnpm run policy:check. No version bumps here — releasing stays a separatelerna version/lerna publish from-packagestep.Link to Devin session: https://app.devin.ai/sessions/fd9f9aa438b24c75b2861f1a9ffc0e3c
Open in Devin Desktop: https://app.devin.ai/desktop/session/fd9f9aa438b24c75b2861f1a9ffc0e3c?variant=devin
Requested by: @pyramation