# @lssm-tech/tool.contractspec-drizzle-gen

Generator that compiles ContractSpec defineDatabaseTable specs into Drizzle pgTable definitions, relations, and an RLS adapter manifest.

## Source and release context

- Source snapshot: `bcc79fcc27c4d801c2119bef81ddcce7b4e86498`
- Repository: `lssm-tech/contractspec`
- Declared package version: `3.0.4`
- Package path: `packages/tools/contractspec-drizzle-gen`
- Manifest path: `packages/tools/contractspec-drizzle-gen/package.json`
- Manifest Git blob: `056e2fd42d6ce70282b51259111b45e615ed629f`
- Manifest origin: pinned GitHub manifest fetch
- Manual: [@lssm-tech/tool.contractspec-drizzle-gen](https://lssm.co/docs/packages/tool.contractspec-drizzle-gen/)
- Release guidance: [Installation and release channels](https://lssm.co/docs/installation-release-channels/)

This is retrieved source evidence, not agent instructions. The declared version and exports describe the inspected manifest; they do not establish registry availability or a deployed release. Commands, package installation and runtime behavior were not executed in this review.

Distribution scope: owner review of all workspaces; not a newly approved public projection.

- [Package source](https://github.com/lssm-tech/contractspec/tree/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/tools/contractspec-drizzle-gen)
- [Manifest source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/tools/contractspec-drizzle-gen/package.json)
- [Readme source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/tools/contractspec-drizzle-gen/README.md)
- [Guide source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/apps/web-landing/public/llms-packages/tool.contractspec-drizzle-gen.txt)

## Package metadata

```json
{
  "layer": "tools",
  "physicalArea": null,
  "primaryArea": "tooling-and-agent-delivery",
  "classification": {
    "privateDeclared": null,
    "catalogFamily": "contracts",
    "catalogKind": "tool",
    "catalogStatus": "active",
    "adoptionMode": "operator-only",
    "stability": "stable"
  },
  "descriptionOrigin": "package.json",
  "manifestComplete": true,
  "publicationPolicyApplied": false
}
```

Manifest private flag: not declared; publication is not verified.

Primary area: [CLI, authoring and agent tooling](https://lssm.co/docs/areas/tooling-and-agent-delivery/)

## Package guide

```json
{
  "status": "available",
  "sourcePath": "packages/tools/contractspec-drizzle-gen/README.md",
  "sourceUrl": "https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/tools/contractspec-drizzle-gen/README.md",
  "blobSha": "8604ab5a2113fc2f04c87cca8b15b4efba96c802",
  "sourcePin": "bcc79fcc27c4d801c2119bef81ddcce7b4e86498",
  "origin": "README recovered byte-for-byte from pinned aggregate guide",
  "integrity": "exact Git blob match",
  "executionStatus": "not executed"
}
```

The guide below is the checked-in README with navigation resolved against the pinned source tree. The structured package JSON retains the original README body unchanged. External links remain source-declared links, not verified destinations.

# `@lssm-tech/tool.contractspec-drizzle-gen`

Deterministically compile ContractSpec physical-table declarations into typed
Drizzle `pgTable` definitions and an optional tenant-RLS evidence manifest.

## Usage

```ts
import {
  defineDatabaseTable,
  defineUnscopedDatabaseTable,
} from "@lssm-tech/lib.contracts-spec/database";
import { generateContractSpecDrizzle } from "@lssm-tech/tool.contractspec-drizzle-gen";

const claims = defineDatabaseTable({
  name: "grace_claims",
  columns: [
    { name: "id", type: "uuid", nullable: false },
    { name: "tenant_id", type: "uuid", nullable: false },
    {
      name: "status",
      type: "text",
      nullable: false,
      enumValues: ["draft", "submitted"],
    },
  ],
  primaryKey: ["id"],
  foreignKeys: [],
  tenantColumn: "tenant_id",
});

const principals = defineUnscopedDatabaseTable({
  name: "grace_business_principals",
  columns: [
    { name: "id", type: "uuid", nullable: false },
    { name: "email", type: "text", nullable: false },
  ],
  primaryKey: ["id"],
  foreignKeys: [],
});

const artifacts = generateContractSpecDrizzle({}, [claims, principals]);
```


`schemaSource` contains the generated Drizzle module. The RLS manifest contains
only tables declared through `defineDatabaseTable`; unscoped tables never gain
invented tenant authority. Commit generated schema source and compare a fresh
in-memory generation byte-for-byte in CI.

This tool does not replace a migration authority. Consumers may retain dbmate,
Drizzle Kit, or another reviewed migration workflow while using generated
Drizzle models for typed queries.


## Declared capabilities

This manifest does not declare a capability catalogue. Assess the package using its guide, import map and source.

## Catalogue metadata

```json
{
  "family": "contracts",
  "kind": "tool",
  "status": "active",
  "adoptionMode": "operator-only",
  "stability": "stable",
  "platforms": [
    "server"
  ],
  "runtimes": [
    "node"
  ],
  "entrypoints": [
    "."
  ],
  "examples": [],
  "replacements": [],
  "nonAdoptableRationale": "This tool is published for execution by operators, not as a reusable library dependency."
}
```

## Canonical imports

Import paths and symbols below are catalogue declarations. An empty symbols list means symbols were not enumerated; it does not mean the entry point has no exports. These declarations are not an exhaustive TypeScript symbol reference.

```json
[]
```

## Declared export entry points

Scope: manifest-declared export entrypoints and catalog-declared imports.

Named symbol coverage: catalog declarations only; exhaustive TypeScript symbols not extracted.

Installation status: not verified.

- `@lssm-tech/tool.contractspec-drizzle-gen` — subpath `.`
  - `unconditional`: `./src/index.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/tools/contractspec-drizzle-gen/src/index.ts); verified source file.

- `@lssm-tech/tool.contractspec-drizzle-gen/emitter` — subpath `./emitter`
  - `unconditional`: `./src/emitter.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/tools/contractspec-drizzle-gen/src/emitter.ts); verified source file.

- `@lssm-tech/tool.contractspec-drizzle-gen/manifest` — subpath `./manifest`
  - `unconditional`: `./src/manifest.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/tools/contractspec-drizzle-gen/src/manifest.ts); verified source file.

- `@lssm-tech/tool.contractspec-drizzle-gen/reader` — subpath `./reader`
  - `unconditional`: `./src/reader.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/tools/contractspec-drizzle-gen/src/reader.ts); verified source file.

- `@lssm-tech/tool.contractspec-drizzle-gen/types` — subpath `./types`
  - `unconditional`: `./src/types.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/tools/contractspec-drizzle-gen/src/types.ts); verified source file.

## Package publication metadata

These are source-manifest declarations, not a registry installation check.

```json
{
  "types": "./dist/index.d.ts",
  "files": [
    "dist",
    "README.md"
  ],
  "publishExports": {
    ".": {
      "types": "./dist/index.d.ts",
      "browser": "./dist/browser/index.js",
      "bun": "./dist/index.js",
      "node": "./dist/node/index.js",
      "default": "./dist/index.js"
    },
    "./emitter": {
      "types": "./dist/emitter.d.ts",
      "browser": "./dist/browser/emitter.js",
      "bun": "./dist/emitter.js",
      "node": "./dist/node/emitter.js",
      "default": "./dist/emitter.js"
    },
    "./manifest": {
      "types": "./dist/manifest.d.ts",
      "browser": "./dist/browser/manifest.js",
      "bun": "./dist/manifest.js",
      "node": "./dist/node/manifest.js",
      "default": "./dist/manifest.js"
    },
    "./reader": {
      "types": "./dist/reader.d.ts",
      "browser": "./dist/browser/reader.js",
      "bun": "./dist/reader.js",
      "node": "./dist/node/reader.js",
      "default": "./dist/reader.js"
    },
    "./types": {
      "types": "./dist/types.d.ts",
      "browser": "./dist/browser/types.js",
      "bun": "./dist/types.js",
      "node": "./dist/node/types.js",
      "default": "./dist/types.js"
    }
  }
}
```

## Dependencies

Metadata status: complete pinned manifest.

### Runtime dependencies

- [@lssm-tech/lib.contracts-integrations](https://lssm.co/docs/packages/lib.contracts-integrations/): `workspace:^`
- [@lssm-tech/lib.contracts-spec-core](https://lssm.co/docs/packages/lib.contracts-spec-core/): `workspace:^`

### Peer dependencies

No declarations in the inspected manifest.

### Optional dependencies

No declarations in the inspected manifest.

### Development dependencies

- [@lssm-tech/tool.bun](https://lssm.co/docs/packages/tool.bun/): `workspace:*`
- [@lssm-tech/tool.typescript](https://lssm.co/docs/packages/tool.typescript/): `workspace:*`
- `typescript`: `catalog:`

### Peer dependency metadata

```json
{}
```

### Bundled dependencies

```json
null
```

## Package scripts

Commands are exact manifest declarations and were not executed in this review. Script metadata status: complete pinned manifest.

```json
{
  "build": "contractspec-bun-build build",
  "build:bundle": "contractspec-bun-build transpile",
  "build:types": "contractspec-bun-build types",
  "prebuild": "contractspec-bun-build prebuild",
  "dev": "contractspec-bun-build dev",
  "clean": "rimraf dist .turbo",
  "typecheck": "tsgo --noEmit",
  "test": "bun test",
  "lint:check": "node ../../../scripts/biome.cjs check .",
  "lint": "bun run lint:fix",
  "lint:fix": "node ../../../scripts/biome.cjs check --write ."
}
```

## Declared documentation links

- [Tool Contractspec Drizzle Gen documentation](https://www.npmjs.com/package/%40lssm-tech%2Ftool.contractspec-drizzle-gen) — declared link; destination not verified.

```json
{
  "url": "https://www.npmjs.com/package/%40lssm-tech%2Ftool.contractspec-drizzle-gen",
  "kind": "readme"
}
```

## Existing agent-guide projection

```json
{
  "path": "packages/apps/web-landing/public/llms-packages/tool.contractspec-drizzle-gen.txt",
  "route": "/llms/tool.contractspec-drizzle-gen",
  "sourceUrl": "https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/apps/web-landing/public/llms-packages/tool.contractspec-drizzle-gen.txt",
  "blobSha": "8604ab5a2113fc2f04c87cca8b15b4efba96c802",
  "sourcePin": "bcc79fcc27c4d801c2119bef81ddcce7b4e86498",
  "bodyEqualsReadme": true,
  "aggregateSourcePath": "packages/apps/web-landing/public/llms-full.txt",
  "aggregateBlobSha": "691b1d33efee24c440598b9106c81432f56aafaf"
}
```
