Back to Promptfoo

Internal Package Boundaries

docs/architecture/packages.md

0.121.102.3 KB
Original Source

Internal Package Boundaries

Promptfoo still publishes one package today, but the repository is beginning to model the internal boundaries that would support a future multi-package split.

Current Private Layers

LayerCurrent rootsIntended role
facadesrc/index.tsPublic compatibility surface
contractssrc/types, src/validatorsShared serializable contracts and schemas
coreassertions, matchers, prompts, scheduler, test-case logicEvaluation domain logic
nodedatabase, models, config, storage, src/evaluate.ts, src/nodeNode runtime adapters
providerssrc/providersConcrete provider implementations
redteamsrc/redteamRed-team workflows
view-serversrc/serverLocal server and API routes
clisrc/main.ts, src/commandsCommand-line orchestration
appsrc/app/srcBrowser UI

The source of truth for these temporary private layers is architecture/layers.json.

First Enforced Rule

Internal modules must not import src/index.ts.

src/index.ts is the public facade. Importing it from inside the product makes the dependency graph point inward through the public API, which makes later package extraction harder and can hide cycles.

Run the check with:

bash
npm run architecture:check

Dependency Ownership Report

The dependency report groups direct runtime imports by the private layer that currently uses them:

bash
npm run deps:ownership

The report is intentionally descriptive for now. It gives us the evidence needed to move dependencies into future packages without guessing at ownership.