Repository navigation
feat(portability): cross-shape transpilation proof — subsystem substitution in both directions - #28
Merged
Merged
Conversation
…tution in both directions
🤖 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
New top-level
portability/area (separate from the tutorial packages) proving that a package written for one PostgreSQL environment shape can be mechanically transformed into another — and back — using pgpm's apply/substitution pipeline (exclude+ rebind routes + extension/role routing).Fixtures:
vendor-app— source-shaped module:auth.users,auth.uid(),app.documentswith FK + RLS policy,extensions.uuid_generate_v4()defaults, grants toauthenticatedauth-provider— tiny generic replacement subsystem:app_auth.users(uuid PK) +app_auth.current_user_id()readingjwt.claims.user_idvendor-app-ported/pgpm.apply.json— the substitution spec:{ "exclude": { "schemas": ["auth"] }, "route": [ { "fromSchema": "auth", "kind": "table", "name": "users", "toSchema": "app_auth" }, { "fromSchema": "auth", "kind": "function", "name": "uid", "toSchema": "app_auth", "toName": "current_user_id" } ], "extensions": { "toSchema": null, "from": ["extensions"] }, "roles": { "authenticated": "app_authenticated" }, "requires": ["auth-provider"] }Tests (
portability-tests, 10 tests):transpile.test.ts— forward direction (subsystem excluded → tombstones, FK/accessor rebinds, extension de-qualification, role translation) and reverse direction (provider objects rebound back ontoauth.*, extensions re-qualified, roles translated back); refusal with named diagnostics when a surviving reference has no substitutecontract.test.ts— the measured external contract of the real vendored fixture's auth schema: a singleauth.usersFK target; 40+ objects are droppable internalsdeploy-ported.test.ts— live deploy on plain PostgreSQL: provider deploys as an ordinary module, ported package on top; asserts the excluded schema never exists, FK enforcement againstapp_auth.users, and RLS throughapp_auth.current_user_id()+jwt.claims.user_idwith the translated roledeploy-vendor.test.ts(VENDOR_STACK=1only) — reverse direction deployed on the real vendor stack: deploys the original vendored fixture first (regression check), then the reverse-transpiled package whose FK points at the stack's nativeauth.usersand whose policy calls its native accessor — no provider deployed at allCI: new
.github/workflows/portability.ymlwith two jobs —pgpm-image(plainpostgres-plus:18service, vendor suite skipped) andvendor-image(Supabase stack,VENDOR_STACK=1). The existingci.ymltutorial workflow is untouched.Note:
@pgpmjs/*deps are pinned via pnpm overrides to local tarballs inportability/.tarballs/(unpublished builds carrying constructive-io/constructive#1530). Swap to published versions once released.Link to Devin session: https://app.devin.ai/sessions/025fb88043964fdbb335ac5e39df2478
Requested by: @pyramation