Skip to content

feat(portability): cross-shape transpilation proof — subsystem substitution in both directions - #28

Merged
pyramation merged 2 commits into
mainfrom
feat/portability
Jul 30, 2026
Merged

pyramation merged 2 commits into
mainfrom
feat/portability

Conversation

@pyramation

Copy link
Copy Markdown
Collaborator

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.documents with FK + RLS policy, extensions.uuid_generate_v4() defaults, grants to authenticated
  • auth-provider — tiny generic replacement subsystem: app_auth.users (uuid PK) + app_auth.current_user_id() reading jwt.claims.user_id
  • vendor-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 onto auth.*, extensions re-qualified, roles translated back); refusal with named diagnostics when a surviving reference has no substitute
  • contract.test.ts — the measured external contract of the real vendored fixture's auth schema: a single auth.users FK target; 40+ objects are droppable internals
  • deploy-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 against app_auth.users, and RLS through app_auth.current_user_id() + jwt.claims.user_id with the translated role
  • deploy-vendor.test.ts (VENDOR_STACK=1 only) — 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 native auth.users and whose policy calls its native accessor — no provider deployed at all

CI: new .github/workflows/portability.yml with two jobs — pgpm-image (plain postgres-plus:18 service, vendor suite skipped) and vendor-image (Supabase stack, VENDOR_STACK=1). The existing ci.yml tutorial workflow is untouched.

Note: @pgpmjs/* deps are pinned via pnpm overrides to local tarballs in portability/.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

@pyramation pyramation self-assigned this Jul 30, 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

@pyramation
pyramation merged commit 26a1815 into main Jul 30, 2026
7 checks passed
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