(llm-first): context budget, validation, and eval harness, orchestration general-prompt
This commit is contained in:
@@ -1,34 +1,42 @@
|
||||
# DSL Language Specification
|
||||
|
||||
This document describes the single DSL (Domain Specific Language) used to specify fullstack CRUD applications. The only required DSL input is `domain/*.dsl`.
|
||||
This document describes the DSL system used to specify fullstack CRUD applications.
|
||||
|
||||
`domain-summary.json` is a derived artifact generated from this DSL to stabilize LLM-first generation and feed the lightweight validation gate. It must never replace the DSL as the source of truth. The active prompt corpus that consumes this contract lives in `prompts/`.
|
||||
`domain/*.api.dsl` is the single source of truth for the entire domain model and API
|
||||
contract. It drives Prisma schema generation, NestJS module generation, and React Admin
|
||||
resource generation.
|
||||
|
||||
`api-summary.json` is a derived artifact generated from the api.dsl to stabilize
|
||||
LLM-first generation and feed the lightweight validation gate. It must never replace the
|
||||
DSL as the source of truth. The active prompt corpus that consumes this contract lives in
|
||||
`prompts/`.
|
||||
|
||||
---
|
||||
|
||||
# DSL Responsibility
|
||||
# DSL Architecture
|
||||
|
||||
The domain DSL defines only:
|
||||
## `domain/*.api.dsl`
|
||||
|
||||
- domain model
|
||||
- relations
|
||||
- enums
|
||||
The api.dsl is the authoritative source of truth for:
|
||||
|
||||
The domain DSL is the single source of truth for:
|
||||
- entities and their attributes
|
||||
- scalar types and enums
|
||||
- primary keys and foreign keys
|
||||
- database-level constraints (required, unique, default)
|
||||
- relations between entities
|
||||
- DTO shapes per operation (Create, Update, Read, List)
|
||||
- nullability and requiredness of each DTO attribute per operation
|
||||
- HTTP methods and paths for each endpoint
|
||||
- endpoint names and groupings
|
||||
- pagination request/response contracts
|
||||
|
||||
- entities
|
||||
- attributes
|
||||
- primary keys
|
||||
- foreign keys
|
||||
- enums
|
||||
The api.dsl drives: Prisma schema, NestJS controller/service/DTO generation,
|
||||
and React Admin resource generation.
|
||||
|
||||
The following layers are always derived from the domain DSL and must not be authored as standalone authoritative DSL inputs:
|
||||
Constraint: every `map Entity.field` or `sync Entity.field` reference in `domain/*.api.dsl`
|
||||
must resolve to an entity and field defined within the same api.dsl file.
|
||||
|
||||
- DTO
|
||||
- API
|
||||
- UI
|
||||
|
||||
Optional extension mechanism:
|
||||
## Optional extension mechanism
|
||||
|
||||
```text
|
||||
overrides/
|
||||
@@ -40,7 +48,8 @@ Override rules:
|
||||
|
||||
- Overrides are optional.
|
||||
- The generator must work without them.
|
||||
- Overrides may refine derived API or UI behavior, but they must not duplicate or redefine entities, attributes, primary keys, foreign keys, relations, or enums.
|
||||
- Overrides may refine derived API or UI behavior, but they must not duplicate or redefine
|
||||
entities, attributes, primary keys, foreign keys, relations, or enums.
|
||||
|
||||
---
|
||||
|
||||
@@ -77,13 +86,15 @@ attribute name {
|
||||
|
||||
**Modifiers:**
|
||||
|
||||
- `type` — required; one of: `string`, `uuid`, `integer`, `decimal`, `date`, `text`, or an enum name.
|
||||
- `type` — required; one of: `string`, `uuid`, `integer`, `decimal`, `date`, `text`, `boolean`, `number`, or an enum name.
|
||||
- `key primary` — this attribute is the primary key.
|
||||
- `key foreign { relates Entity.field }` — foreign key to another entity's field.
|
||||
- `is required` — non-nullable.
|
||||
- `is unique` — unique constraint.
|
||||
- `is nullable` — explicitly nullable.
|
||||
- `default Value` — default value (for enums or literals).
|
||||
- `description "..."` — human-readable description.
|
||||
- `label "..."` — display label for UI.
|
||||
|
||||
---
|
||||
|
||||
@@ -164,19 +175,21 @@ attribute equipmentTypeCode {
|
||||
|
||||
## DSL → Prisma
|
||||
|
||||
| DSL Concept | Prisma Result |
|
||||
| ------------ | --------------------------- |
|
||||
| entity | model |
|
||||
| attribute | field |
|
||||
| enum | enum |
|
||||
| key primary | @id or @id @default(uuid()) |
|
||||
| key foreign | relation + references |
|
||||
| type string | String |
|
||||
| type uuid | String @id @default(uuid()) |
|
||||
| type integer | Int |
|
||||
| type decimal | Decimal |
|
||||
| type date | DateTime |
|
||||
| type text | String |
|
||||
| DSL Concept | Prisma Result |
|
||||
| ------------- | --------------------------- |
|
||||
| entity | model |
|
||||
| attribute | field |
|
||||
| enum | enum |
|
||||
| key primary | @id or @id @default(uuid()) |
|
||||
| key foreign | relation + references |
|
||||
| type string | String |
|
||||
| type uuid | String @id @default(uuid()) |
|
||||
| type integer | Int |
|
||||
| type number | Float |
|
||||
| type decimal | Decimal |
|
||||
| type date | DateTime |
|
||||
| type text | String |
|
||||
| type boolean | Boolean |
|
||||
|
||||
---
|
||||
|
||||
@@ -203,15 +216,26 @@ API paths are derived from entity name: PascalCase → kebab-case, pluralized (e
|
||||
| attribute | Form field / column |
|
||||
| type string | TextInput, TextField |
|
||||
| type integer/decimal | NumberInput, NumberField |
|
||||
| type number | NumberInput, NumberField |
|
||||
| type date | DateInput, DateField |
|
||||
| type boolean | BooleanInput, BooleanField |
|
||||
| enum | SelectInput with choices |
|
||||
| foreign key | ReferenceInput, ReferenceField |
|
||||
|
||||
---
|
||||
|
||||
# Derived Layer Mapping
|
||||
# API DSL Layer Mapping
|
||||
|
||||
- **Create DTO** — derived from domain attributes and must not include generated primary keys (for example no `id` for uuid PKs).
|
||||
- **Update DTO** — derived from the same domain attributes with all fields optional for partial updates.
|
||||
- **API response shape** — derived from domain attributes and must expose React Admin-compatible identifiers when needed.
|
||||
- **UI field mapping** — derived from attribute types, descriptions, enums, and foreign keys without a separate UI DSL.
|
||||
DTO shapes and endpoint contracts are declared in `domain/*.api.dsl`. The api.dsl
|
||||
is the authoritative source for:
|
||||
|
||||
- **Create DTO** — declared as `dto DTO.<Entity>Create` in api.dsl. Must not include
|
||||
server-generated primary keys (e.g. no `id` for uuid PKs). Required/nullable per field
|
||||
is explicit in the api.dsl, not inferred.
|
||||
- **Update DTO** — declared as `dto DTO.<Entity>Update` in api.dsl. All fields are
|
||||
typically nullable for partial update semantics.
|
||||
- **API response shape** — declared as `dto DTO.<Entity>` in api.dsl. Must expose
|
||||
React Admin-compatible `id` field.
|
||||
- **UI field mapping** — derived from the DTO shapes in api.dsl, not from domain
|
||||
attributes directly. The Create form uses `DTO.<Entity>Create` fields; the Edit form
|
||||
uses `DTO.<Entity>Update` fields; List and Show use `DTO.<Entity>` fields.
|
||||
|
||||
Reference in New Issue
Block a user