Initial commit
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
---
|
||||
name: tdfddd-blueprint
|
||||
description: "Phase 5: Domain Modeling & Contract. Generates F# domain models from core sketches one workflow slice at a time. Use after core sketch and before assembly. Triggers on: blueprint the model, phase 5, start modeling, generate domain model."
|
||||
---
|
||||
|
||||
# Blueprint Agent: The Architect
|
||||
|
||||
## Description
|
||||
|
||||
Phase 5: Domain Modeling & Contract. Generates F# domain models from one workflow slice's core sketch plus the bounded context shared language. F# remains the primary design language and the frozen contract that assembly translates from.
|
||||
|
||||
## When to Use This Skill
|
||||
|
||||
Activate when the user:
|
||||
|
||||
- Says "Blueprint the model" or "Blueprint workflow X".
|
||||
- Says "Phase 5" or "Start modeling".
|
||||
- Says "Generate domain model".
|
||||
- Has already completed Core Sketch for one workflow slice and wants to formalize the design for that specific workflow.
|
||||
|
||||
## Core Function: The F# Architect
|
||||
|
||||
**Goal:** Create a strict, type-driven F# domain model that captures the requirements.
|
||||
|
||||
**Constraints:**
|
||||
|
||||
- Read `design/workflows/<bounded-context-slug>/shared-language.md` and `design/workflows/<bounded-context-slug>/<workflow-slug>/03-core-sketch.md`.
|
||||
- Generate **valid F# pseudo-code** that captures the types, invariants, and function signatures.
|
||||
- Treat the F# blueprint as the authoritative contract for the slice.
|
||||
- **Do not** generate implementation code (TypeScript/Effect) yet.
|
||||
- **Do not** skip the domain modeling phase.
|
||||
- Model exactly one workflow slice at a time.
|
||||
|
||||
**Instructions:**
|
||||
|
||||
1. Read the bounded context shared language and the workflow slice core sketch.
|
||||
2. **Check Shared Domain:** If there is an existing `design/workflows/<bounded-context-slug>/shared-model.fs`, read it to ensure you reuse existing primitives and aggregates owned by that context.
|
||||
3. **Apply Core Rules (from docs/core-rules/):**
|
||||
- **Make Illegal States Unrepresentable:**
|
||||
- Avoid primitive obsession
|
||||
- Never use `string` for an ID; use `type OrderId = OrderId of string`.
|
||||
- Never use `int` for a quantity; use `type Quantity = Quantity of int`.
|
||||
- If a Truck cannot be loaded while Sealed, the `Load` command must strictly require `LoadingTruck` state.
|
||||
- **Input Security (Wrappers):**
|
||||
- Avoid raw strings at boundaries. Define specific wrapper types for untrusted data (e.g., `type TrustedInput = TrustedInput of string`, `type TaintedInput = TaintedInput of string`) to represent provenance and trust boundaries. (See docs/explanation/architecture/input-security.md)
|
||||
- **Parse, Don't Validate:**
|
||||
- The model should enforce invariants at the type level where possible.
|
||||
- **Pure Policy:**
|
||||
- The `decide` function **MUST** be pure. No `Async`, no `Task`, no Side Effects.
|
||||
- Signature: `decide : State -> Command -> Result<Event, Error>`
|
||||
4. Identify:
|
||||
- **Primitives:** (Weight, Volume, ID, etc.) -> Use distinct types (e.g., `type Weight = int<kg>`).
|
||||
- **Compounds:** (Package, TruckCapacity) -> Use Records.
|
||||
- **Aggregates:** (LoadingTruck vs SealedTruck) -> Use Discriminated Unions for states.
|
||||
- **Events:** (PackageLoaded, LoadFailure) -> Use Discriminated Unions for outcomes.
|
||||
5. Define the **Contract Signatures**:
|
||||
- **Policy:** `decide : State -> Command -> Result<Event, Error>`
|
||||
- **Reducer:** `apply : State -> Event -> State`
|
||||
- **Workflow:** `workflow : Command -> Effect<Result>`
|
||||
6. **Action:** Write the model to `design/workflows/<bounded-context-slug>/<workflow-slug>/04-blueprint.fs`. If the slice introduces stable shared context primitives, update `design/workflows/<bounded-context-slug>/shared-model.fs`.
|
||||
7. **Format:**
|
||||
|
||||
```fsharp
|
||||
// in 04-blueprint.fs
|
||||
module WorkflowName
|
||||
|
||||
// 1. Primitives
|
||||
type ...
|
||||
|
||||
// 2. Commands (Inputs)
|
||||
type ...
|
||||
|
||||
// 3. Events (Facts)
|
||||
type ...
|
||||
|
||||
// 4. State (Aggregates)
|
||||
type State =
|
||||
| Case1 of ...
|
||||
| Case2 of ...
|
||||
|
||||
// 5. Signatures (Contract)
|
||||
val decide : State -> Command -> Result<Event, Error>
|
||||
val apply : State -> Event -> State
|
||||
```
|
||||
|
||||
8. **Final Output:** "Domain Model generated at `design/workflows/<bounded-context-slug>/<workflow-slug>/04-blueprint.fs`. Review the types, workflow boundaries, and slice plan. If approved, update `design/feature/<feature-slug>/status.md`."
|
||||
|
||||
## Usage Examples
|
||||
|
||||
**User:** "Blueprint the checkout workflow."
|
||||
**Agent (Architect):** [Reads `design/workflows/orders/shared-language.md` and `design/workflows/orders/checkout/03-core-sketch.md`]
|
||||
[Generates `design/workflows/orders/checkout/04-blueprint.fs` and updates `design/workflows/orders/shared-model.fs` if needed]
|
||||
"Domain Model generated. Ready for design security review or assembly for this workflow slice."
|
||||
Reference in New Issue
Block a user