CodeVetter · Repo Unpack · Extension points
prisma/prisma
New behavior is supposed to arrive as a composed descriptor, not a core branch. The control stack orders extension packs and merges authoring contributions, codecs, aggregates, and capabilities. The same extensions array is accepted by defineConfig and by the postgres() runtime options. CLI commands are a record passed to defineCommandFamily, with a factory injection point for the control client. Public npm names are thin shells over internal packages. pgvector is the concrete pattern: a pack meta id, authoring types, a codec registry, and SQL lowering templates.
- createControlStack takes family, target, adapter, driver, and extensions. It orders extensions with buildExtensionLoadOrder, then assembleAuthoringContributions over family, target, optional adapter, and those extensions. The returned stack carries codecLookup, codecDescriptors, aggregateDescriptors, authoringContributions, scalarTypes, controlMutationDefaults, and a merged capability matrix.
- assembleAuthoringContributions walks each descriptor's authoring.entityTypes and claims paths so two packs cannot occupy the same entity slot. The architecture overview names AuthoringContributions.entityTypes as the way a target adds entity kinds without the framework branching on target identity.
- Postgres, Mongo, and SQLite defineConfig all default extensions to [] and pass that array into the core config. Adding a pack is a config edit, not an edit to the family runtime.
- postgres() accepts extensions?: readonly SqlRuntimeExtensionDescriptor<'postgres'>[] and middleware?: readonly SqlMiddleware[], and forwards extensions into createSqlExecutionStack and middleware into PostgresRuntimeImpl. SqlRuntimeBase checks each middleware with checkMiddlewareCompatibility(mw, 'sql', target) in the constructor.
- pgvector's pack meta is kind extension, id pgvector, familyId sql, targetId postgres, and declares capability postgres['pgvector.cosine']. Its authoring.type is pgvectorAuthoringTypes and its codec descriptors come from pgvectorCodecRegistry. The default export of exports/pack.ts is pgvectorPackMeta.
- pgvectorQueryOperations registers cosineDistance and cosineSimilarity on codec pg/vector@1. cosineDistance lowers with template {{self}} <=> {{arg0}} to codec pg/float8@1. That is the extension operation registry the SQL builder consults via queryOperationTypes.
- CLI commands plug in as a Readonly<Record<string, AnyCommand>> passed to defineCommandFamily, plus a redirects array for retired spellings. defineOrmCommand wraps @prisma/cli-engine defineCommand with the ORM error boundary so new commands should not call defineCommand directly.
- createBinCommands(createClient) is the test seam: swapping CreateControlClient remounts db init, db migrate, db schema, db sign, db update, db verify, migration new, and migration plan without mocking modules. Offline commands stay the real implementations.
- Target packages are expected to export three planes: src/exports/control.ts (migration), src/exports/runtime.ts (runtime), and src/exports/pack.ts (shared). New targets must register those globs, including src/core/migrations/** even before the directory exists, or later files inherit the shared plane and hide violations.
- Emitter options are the family SPI: serializeContract, deserializeContract, shouldPreserveEmpty, sortStorage, supportsNamespaces, and resolveImportSpecifier. The framework does not walk the in-memory contract with Object.entries; the target serializer owns the JSON shape.
- The Vite plugin and the CLI are two front doors onto executeContractEmit. A third authoring path is no-emit: pass a TypeScript contract object straight to postgres({ contract }) and skip the files. Both still deserialize through PostgresContractSerializer.
- Skills are an extension surface for agents. Canonical files live in skills-contrib/; the prepare script runs skills add ./skills-contrib and sync-agent-rules. Published facades copy skills in prepack (orm-postgres prepack runs scripts/sync-package-skills.ts). README says each installed Prisma package ships the SKILL.md files that match that version.