Repository navigation
packages database
Scope. Root workspace package for the legacy golden-path demo (Postgres
safrs_localon127.0.0.1:54329). It is not the database for SentraBot, Kediri, Avery, or Smartboard. Those capsules own their own schemas. New capsules must not import this package (ADR 0006).
Prisma 7 + PostgreSQL client, reset guard, and a deterministic local seed for the golden-path demo. In the root workspace it is the only package allowed to touch this Prisma schema and these migrations.
Migrations and schema changes here are R2. Production data and destructive production operations are R3 and may only be prepared until Chief authorizes execution (packages/database/AGENTS.md).
| File | Purpose |
|---|---|
packages/database/prisma/schema.prisma |
Data model (Demo) |
packages/database/prisma.config.ts |
Prisma config: schema path, migrations dir, seed command |
packages/database/src/client.ts |
Prisma client singleton over @prisma/adapter-pg, connection pool from serverEnv.DATABASE_URL
|
packages/database/src/index.ts |
Barrel: database + assertDisposableDatabase
|
packages/database/src/reset-guard.ts |
Destructive-operation guard (see below) |
packages/database/src/local-tooling.ts |
Resolves a local disposable DATABASE_URL for local tooling, falling back to .env / .env.example
|
packages/database/src/seed.ts |
Idempotent seed of one demo |
packages/database/scripts/run-local-prisma.mjs |
Runs Prisma CLI with local-tooling URL resolution |
packages/database/prisma/schema.prisma uses the prisma-client generator (engineType = "client", ESM output into src/generated/prisma) and a PostgreSQL datasource.
Models present in the schema today:
| Model | Role |
|---|---|
Demo |
Golden-path demo record (demos) |
User, Session, Account, Verification
|
Better Auth tables (golden-path AGENTS lists auth as a non-goal; schema leftover) |
SentraBotDeploymentSettings, SentraBotBot, SentraBotThread, SentraBotThreadMessage, SentraBotMemoryDocument, SentraBotRoutine
|
Product tables left in the root schema. Live SentraBot persistence is projects/product/sentrabot/packages/db. Treat these root models as a sovereignty defect, not as SentraBot's database. |
packages/database/src/reset-guard.ts is the enforcement point for destructive operations. assertDisposableDatabase(connectionUrl) rejects a connection unless every condition holds:
- protocol is
postgresql: - a password is present
- host is
127.0.0.1orlocalhost - port is
54329 - exactly one path segment, ending in
_localor_test - no query string
assertDisposableTestDatabase additionally requires the _test suffix. pnpm db:reset refuses anything else, so a production or remote DATABASE_URL can never be reset by mistake. The guard is shared with tools/doctor and packages/database/src/local-tooling.ts.
packages/database/src/seed.ts runs an idempotent upsert for one demo (Sentra Demo). It requires DATABASE_URL and is wired into prisma.config.ts (node --experimental-strip-types src/seed.ts).
-
@safrs/apidefaults itsDemoStoreto the livedatabaseclient (packages/api/src/app.ts). -
@safrs/webconsumes@safrs/databaseon the server; Prisma andDATABASE_URLnever reach the browser. -
tools/doctorruns the sameassertDisposableDatabasecheck against the local.envto report environment safety. -
Local PostgreSQL runs in Docker Compose on
localhost:54329; seecompose.yamlandpnpm db:start.
From repository root:
pnpm db:generate # generate Prisma client
pnpm db:migrate # apply migrations
pnpm db:seed # seed local data
pnpm db:studio # Prisma Studio
pnpm db:reset # local reset (guard enforced; requires explicit reset authorization)
pnpm --filter @safrs/database test- API — the consumer of the demo store
-
Environment — validated
DATABASE_URL - Doctor tool — local database diagnostics
- Shared packages
SAFRS — the Sentra Agent-First Repository Standard — defines how a software repository should be structured, governed, and enforced when autonomous Artificial Intelligence agents perform a substantial share of engineering work by Sentra Artificial Intelligence.
SAFRS v1.1 addresses that problem through five coupled mechanisms:
- a six-layer repository architecture from Trust Boundary to Human Authority;
- a role-based permission model in which capability never implies trust;
- a four-tier risk model with cumulative mandatory controls;
- a multi-agent execution protocol with explicit task states and one mutation owner per bounded scope;
- a knowledge governance model that distinguishes current architecture, historical decisions, execution plans, Git history, and running code.
Built in Indonesia as part of the Sentra Artificial Intelligence ecosystem.
Sentra Artificial Intelligence · Source Repository · Official Website
Dr Ferdi Iskandar — Creator & Maintainer
LinkedIn ·
ORCID ·
Hugging Face ·
Kaggle ·
Medium ·
Substack ·
X ·
Threads
MyPrompt · Sentra Artificial Intelligence · Indonesia
- SentraBot
- Kediri History
- Academic Smartboard
- Avery
- Portfolio Dr. Novia
- Golden Path (legacy demonstrator)
- Control Center
- Capsule template
- Risk model (R0–R3)
- Agent roles and permissions
- Capsule sovereignty
- Multi-agent protocol
- Document lifecycle
- Sensitive paths
- Verification integrity
Lore — how this repository grew
- Schemas (
@safrs/schemas) - Environment (
@safrs/env) - Database (
@safrs/database) - API (
@safrs/api) - UI (
@safrs/ui) - Telemetry (
@safrs/telemetry) - Token (
@sentra/token) - Config (
@safrs/config) - Auth (
packages/auth)
- SAFRS governance checkers
- SAFRS Automation Control Plane
- Gaffer Runtime
- Doctor
- Project wizard
- project-standalone
- Capabilities
- Codegen
- Deps-graph
- Status CLI
- Task CLI