π§ Domain Modeler Agent Specification¶
π― Purpose¶
The Domain Modeler Agent is responsible for transforming business language, bounded contexts, and use case responsibilities into a structured, expressive, and implementation-ready Domain Model, grounded in Domain-Driven Design (DDD) and Clean Architecture.
Its purpose is to define the semantic core of a service, enabling:
- Accurate representation of real-world business concepts
- Isolation of domain logic from application/infrastructure concerns
- Safe reuse of invariants, rules, and entities across the platform
- Domain understanding shared by agents, developers, and testers
ποΈ Strategic Role in ConnectSoft Factory¶
flowchart TD
EnterpriseArchitect --> SystemArchitect
SystemArchitect --> SolutionArchitect
SolutionArchitect --> DomainModeler
DomainModeler --> ApplicationArchitect
DomainModeler --> MicroserviceGenerator
DomainModeler --> EventDrivenArchitect
DomainModeler --> TestGenerator
- The Domain Modeler Agent receives architectural context and bounded context definitions
- It becomes the source of truth for all domain logic used across services, events, and behaviors
π§ Core Objectives¶
| Objective | Description |
|---|---|
| π¦ Define Domain Language | Model entities, aggregates, value objects, domain events using a ubiquitous and precise vocabulary |
| π§± Establish Domain Boundaries | Encapsulate invariants, lifecycles, rules, and business workflows per bounded context |
| π Enable Autonomous Execution | Emit clear models usable by Application Architect and downstream agents without human intervention |
| π§ͺ Support Testability and Simulation | Produce stubs, diagrams, and invariants for testing and validation agents |
| π Drive Consistency Across Services | Standardize reuse of enums, identities, currencies, states, and behavior markers |
π‘ Why It Matters¶
Without the Domain Modeler Agent:
- Agents downstream rely on ad-hoc or inconsistent domain assumptions
- Event names, entities, and use cases may drift apart
- Invariants and rules are lost in application glue code
- Testing becomes less meaningful, validation is shallow
- Business logic becomes implementation-driven rather than domain-driven
With the Domain Modeler Agent:
- Domain becomes explicit, traceable, and contract-first
- Clean separation of concerns is maintained
- Teams and agents share a common language
- The platform supports scale, reuse, and evolution
π Example Output Scenario¶
For the
Billingbounded context, model:
-Invoice(aggregate root with lifecycle states)
-InvoiceLineItem(value object)
-InvoiceStatus(enum)
-ApplyDiscountandInvoiceCreated(domain events)
-TaxPolicyEvaluator(domain service)
Outputs:
domain-model.yamlInvoice.cs,InvoiceStatus.cs,TaxPolicyEvaluator.csinvoice-lifecycle.mmd(state diagram)- Semantic hint tags (e.g.,
aggregate_root: true)
π§ Agent Design Principles¶
- π§± Tactical DDD First
- π Isolated Aggregates
- β Invariant Enforcement
- π Artifact-First Modeling
- π§ͺ Validation-Driven Design
ποΈ Scope of Influence¶
The Domain Modeler Agent governs the core domain layer of every service within a bounded context.
Its scope is centered on the tactical building blocks of Domain-Driven Design, which form the foundation of:
- Business logic
- Invariant enforcement
- Entity lifecycles
- Event emission
- Internal service behavior
It ensures that the semantic backbone of each microservice is expressive, correct, reusable, and consistent.
π Layers and Components the Agent Owns¶
π¦ 1. Aggregates and Entities¶
| Element | Description |
|---|---|
| Aggregate Roots | Main access point to clustered entities enforcing invariants (e.g., Invoice, Order, Customer) |
| Entities | Objects with identity, lifecycle, and business behavior within an aggregate |
| Relationships | Parent-child, one-to-many, composed-by (e.g., Invoice β LineItems) |
π― 2. Value Objects (VOs)¶
| Element | Description |
|---|---|
| Immutability | Represent concepts without identity (e.g., Money, Address, TaxCode) |
| Equality | Compared by value not by reference |
| Reuse | Encouraged across bounded contexts where ubiquitous meaning applies |
π 3. Enumerations and Specifications¶
| Element | Description |
|---|---|
| Enums | Define known states/variants (e.g., InvoiceStatus, SubscriptionTier) |
| Specifications | Encapsulate query rules or policies (e.g., HasOverdueBalance, EligibleForUpgrade) |
π 4. Domain Services¶
| Element | Description |
|---|---|
| Domain Services | Stateless operations that coordinate multiple aggregates or external domain logic |
| Policies | Algorithms, pricing rules, or eligibility engines that don't belong to a single entity |
π’ 5. Domain Events¶
| Element | Description |
|---|---|
| Internal Events | Triggered within aggregates to signal state changes (e.g., InvoiceCreated, DiscountApplied) |
| Externalizable Events | May be promoted by downstream agents into integration events |
| Event Metadata | Correlation IDs, traceability, invariants enforced when emitted |
π 6. Supporting DSL and Diagrams¶
| Artifact | Purpose |
|---|---|
domain-model.yaml |
Machine-readable structure describing aggregates, VOs, entities, and rules |
*.cs or DSL skeletons |
Class/interface/enum/value object stubs |
*.mmd diagrams |
State machines, class diagrams, entity hierarchies |
validation-matrix.yaml |
Rules per entity field (e.g., Amount must be > 0) |
π« Out of Scope¶
| Item | Handled By |
|---|---|
| Application service orchestration | β Application Architect Agent |
| API design and surface definition | β API Designer Agent |
| External adapters, persistence | β Microservice Generator + Adapter Agent |
| Infrastructure layer decisions | β Infrastructure Architect Agent |
| Non-functional requirements | β Solution Architect Agent |
| Business glossary / definitions | β Ubiquitous Language Agent |
π§ Domain Modeler Boundary Map¶
flowchart TD
subgraph "Owned by Domain Modeler Agent"
A1[Aggregate Roots]
A2[Entities]
A3[Value Objects]
A4[Enumerations]
A5[Domain Services]
A6[Domain Events]
end
subgraph "Used by Others"
B1[Application Architect Agent]
B2[Test Generator Agent]
B3[Microservice Generator Agent]
end
A1 --> B1
A2 --> B3
A6 --> B2
π§ Summary¶
The Domain Modeler Agent owns the domain layer, but its influence spans every downstream agent.
It is the semantic contract keeper of ConnectSoft services, providing the deepest source of truth for business behavior.
π Core Responsibilities¶
The Domain Modeler Agent is responsible for designing the rich, invariant-driven, and reusable domain layer within each bounded context.
Its outputs serve as the semantic foundation for all downstream agents.
π§± 1. Aggregate and Entity Modeling¶
| Task | Description |
|---|---|
| Identify Aggregates | Determine root entities responsible for enforcing business invariants and lifecycle boundaries |
| Define Entities | Structure objects with identity, behavior, and relationships (e.g., Invoice, Customer, Payment) |
| Model Relationships | Parent-child hierarchies, composition patterns, internal collections |
| Lifecycle and State | Define lifecycle states, transitions, and versioning controls if needed |
π¦ 2. Value Object Definition¶
| Task | Description |
|---|---|
| Model Concepts Without Identity | Immutable objects such as Money, EmailAddress, Address, PhoneNumber |
| Embed into Aggregates | Used as properties within entities (not referenced externally) |
| Ensure Equality and Reusability | Enforce by-value equality and encourage reuse across services |
π 3. Enumeration & Specification Design¶
| Task | Description |
|---|---|
| Enumerations | Define controlled vocabularies or states (e.g., InvoiceStatus, UserRole, RiskLevel) |
| Specifications | Create boolean rules for filtering, policies, or validation (e.g., HasOverdueBalance, IsEligibleForFreeTrial) |
| Use within Aggregates | Allow aggregates to apply specifications internally during commands or lifecycle decisions |
π§ 4. Domain Service and Policy Modeling¶
| Task | Description |
|---|---|
| Extract Complex Logic | Externalize logic that doesnβt naturally belong to an entity (e.g., pricing, scoring, eligibility) |
| Coordinate Aggregates | Allow multi-aggregate orchestration with invariant checking |
| Model as Stateless Services | Output as interface-based contracts that can be unit-tested or decorated by downstream agents |
π’ 5. Domain Event Generation¶
| Task | Description |
|---|---|
| Emit Internal Events | Define rich events emitted from domain logic (e.g., InvoiceCreated, PaymentFailed, CustomerBlacklisted) |
| Define Payload Contracts | Include entity references, value object snapshots, correlation IDs |
| Categorize as Internal or Externalizable | Mark events that may need to be promoted to integration events |
| Support Replay and Event Sourcing (optional) | If event-sourced, structure events to allow reconstruction of entity state |
π 6. Output Artifact Assembly¶
| Artifact | Description |
|---|---|
domain-model.yaml |
Main structure of domain definitions in DSL |
.cs stubs |
Optional generated files for Entity, VO, Enum, Specification, and DomainService |
validation-map.yaml |
Rules for fields (e.g., DueDate must be β₯ IssueDate) |
entity-lifecycle.mmd |
Mermaid state diagrams for aggregate states |
domain-events.json |
Catalog of internal event types emitted by the model |
π§ͺ 7. Validation & Consistency Enforcement¶
| Task | Description |
|---|---|
| Enforce Aggregate Rules | No direct access to child entities from outside aggregate root |
| Ensure Immutability of VOs | Prevent mutation after instantiation |
| Field Validation Rules | Embed validation constraints for downstream validator generation |
| Semantic Duplication Prevention | Detect duplicate concept naming across services (via memory) |
π 8. Emission and Collaboration¶
| Task | Description |
|---|---|
Emit DomainModelPublished Event |
Trigger downstream agents with blueprint references |
| Coordinate with App & Event Agents | Expose aggregate behaviors, events, and specifications for orchestration |
| Support Test Generator | Tag testable behaviors, rules, edge cases |
β Responsibility Summary¶
| Area | Responsibilities |
|---|---|
| Aggregates | β Identity, lifecycle, invariant holders |
| Entities | β Structure, relationships, behaviors |
| VOs | β Embedded immutables with equality |
| Enums/Specs | β Controlled vocabularies, boolean logic |
| Domain Services | β Stateless orchestrators for complex logic |
| Events | β Internal messages emitted by domain behaviors |
| Outputs | β YAML, JSON, DSL, C#, Diagrams |
| Collaboration | β Downstream trigger events, shared contracts |
π₯ Core Inputs¶
The Domain Modeler Agent synthesizes domain structures from explicit business knowledge, bounded context blueprints, and service responsibilities defined upstream.
These inputs allow it to:
- Extract ubiquitous terms
- Identify candidate aggregates
- Define entities, value objects, and rules
- Align with use cases, events, and external behaviors
π Required Inputs¶
| Artifact | Source | Required |
|---|---|---|
| Solution Blueprint | Solution Architect Agent | β |
| Bounded Context Definition | System or Enterprise Architect Agent | β |
| Service Responsibilities | Application Architect Agent | β |
| Ubiquitous Language Glossary | (Optional) Ubiquitous Language Agent | β οΈ Strongly recommended |
| Event Catalog | Event-Driven Architect Agent | β |
| API Surface (Input Triggers) | API Designer Agent | β |
| NFR/Compliance Tags | Solution Blueprint | β (for auditability, immutability, and edge modeling) |
π§© Input Field Mapping¶
π§ 1. Bounded Context Metadata¶
| Field | Purpose |
|---|---|
bounded_context |
Defines model boundary for aggregates/entities |
core_responsibilities |
Used to infer domain behavior |
service_name |
Maps to folder/project/namespace prefix |
π 2. Glossary & Language Hints¶
| Field | Purpose |
|---|---|
term: Invoice |
Suggests candidate aggregate |
term: Money, Address, Email |
Suggests candidate Value Objects |
term: InvoiceCreated, DiscountApplied |
Suggests domain event names and use case triggers |
π§© 3. Use Cases and Commands¶
| Field | Purpose |
|---|---|
CreateInvoice β Invoice + AddLineItem |
Determines aggregate + root methods |
ApplyDiscount |
Suggests entity method + value object |
SendReminder |
May involve multiple aggregates or services |
π¦ 4. API Surface and Event Catalog¶
| Field | Purpose |
|---|---|
POST /invoice |
Implies new Invoice aggregate root |
InvoiceCreatedEvent |
Triggered inside aggregate lifecycle |
PaymentSucceededEvent |
Consumed event may cause state transition |
π 5. Compliance-Related Hints¶
| Field | Purpose |
|---|---|
immutable_fields: [invoiceTotal] |
Field must not mutate after creation |
auditable: true |
Domain events must capture before/after states or include causality metadata |
data_sensitivity: high |
May require pseudonymization or masking in test stubs and logs |
π§ Semantic Memory Use (Optional)¶
| Query | Match Result |
|---|---|
"Invoice" + "ApplyDiscount" |
Prior Invoice aggregate YAML with ApplyDiscount() method, Discount VO |
"Subscription" + "Cancel" |
Returns matching lifecycle diagram and past domain events (SubscriptionCancelled) |
"Money" |
Returns canonical VO with formatting, currency, arithmetic, and equality rules |
π Example Input Template (Simplified YAML)¶
assignment: "generate-domain-model"
project_id: "connectsoft-saas"
trace_id: "domain-32991"
bounded_context: "Billing"
service: "BillingService"
responsibilities:
- "Create Invoice"
- "Apply Discount"
- "Calculate Tax"
- "Send Reminder"
glossary:
- term: Invoice
type: Aggregate
- term: InvoiceStatus
type: Enumeration
- term: Money
type: ValueObject
events:
- InvoiceCreated
- PaymentSucceeded
β Input Validation Checklist¶
| Input | Required |
|---|---|
bounded_context, service |
β |
responsibilities |
β |
event_catalog, api_surface |
β |
glossary |
β οΈ Optional but improves accuracy |
nfr.tags, compliance.hints |
β if compliance required |
π€ Core Outputs¶
The Domain Modeler Agent produces a complete, normalized, and clean Domain Model Blueprint that serves as the semantic foundation for all downstream agents.
Its outputs are traceable, testable, and aligned with Domain-Driven Design (DDD) and Clean Architecture.
π Key Artifacts and Structures¶
π 1. domain-model.yaml¶
| Attribute | Description |
|---|---|
| Format | YAML (ConnectSoft DSL) |
| Purpose | Centralized DSL representation of all domain structures. |
| Sections | - aggregates: Names, methods, child entities, rules. |
- entities: Nested definitions or shared components. |
|
- value_objects: Immutable, by-value domain concepts. |
|
- enumerations: Controlled vocabularies or states. |
|
- specifications: Predicates for decision logic. |
|
- domain_services: Stateless logic helpers. |
|
- domain_events: Event definitions, emitters, payloads. |
|
- validation_rules: Constraints for properties or transitions. |
Used by Application Architect, Test Generator, Microservice Generator, and Domain Event agents
π§± 2. .cs Domain Skeletons (optional)¶
| Files | Description |
|---|---|
- Invoice.cs β aggregate root |
|
- InvoiceLineItem.cs β entity |
|
- Discount.cs, Money.cs β value objects |
|
- InvoiceStatus.cs β enum |
|
- TaxPolicyEvaluator.cs β domain service |
|
- InvoiceCreated.cs β domain event class |
Structured for .NET 8 / Clean Architecture with
internal, interface, and immutability enforcement
π§© 3. validation-map.yaml¶
| Format | YAML | | Purpose | Defines invariants and rules per field/entity for test & validator agents |
Invoice:
Amount:
- rule: "must be greater than 0"
- rule: "must equal sum of line items"
DueDate:
- rule: "must be after IssueDate"
π’ 4. domain-events.json¶
| Format | JSON |
| Fields |
- event_name
- emitted_by
- triggered_by_method
- payload_fields
- is_externalizable
- trace_id
Used by Event-Driven Architect Agent to decide promotion to integration events
π 5. Domain Diagrams (Mermaid)¶
| File Types |
- entity-hierarchy.mmd
- invoice-lifecycle.mmd
- vo-relationship.mmd
| Example |
stateDiagram-v2
[*] --> Draft
Draft --> Issued: Issue()
Issued --> Paid: RecordPayment()
Issued --> Cancelled: Cancel()
π¦ 6. Output Metadata¶
| File | domain-blueprint-metadata.yaml |
| Fields |
- trace_id, project_id, bounded_context, agent_version
- aggregate_count, vo_count, event_count
- compliance_notes: (e.g., fields_requiring_masking, auditable_events)
- reuse_tags: VO/enums reusable across services
π¨ 7. Emitted Event: DomainModelPublished¶
| Format | JSON | | Fields |
{
"event": "DomainModelPublished",
"boundedContext": "Billing",
"projectId": "connectsoft-saas",
"traceId": "domain-arch-2031",
"blueprintUrl": "https://.../domain-model.yaml",
"entityDiagramUrl": "https://.../entity-hierarchy.mmd",
"timestamp": "2025-05-01T20:08:00Z"
}
β Output Validation Criteria¶
| Rule | Description |
|---|---|
domain-model.yaml is schema-compliant |
β |
| All aggregates have unique root names | β |
| Value objects are immutable and by-value | β |
| Events contain correlation metadata | β |
| At least one entity or aggregate emits a domain event | β |
| Diagrams render and match structure | β |
| Skeletons align with Clean Architecture standards | β |
π Output Summary Table¶
| Output | Format | Target Agents |
|---|---|---|
| Domain Model | YAML | Application Architect, Code Generator |
| Class Stubs | C# / DSL | Microservice Generator |
| Events Catalog | JSON | Event Architect, Integration Modeler |
| Validation Rules | YAML | Validator + Test Generator |
| Diagrams | Mermaid | Human oversight + documentation |
| Blueprint Event | JSON | ConnectSoft Agent Bus |
π Knowledge Base¶
The Domain Modeler Agent leverages a powerful hybrid knowledge base consisting of:
- βοΈ Tactical DDD modeling patterns
- π‘ Reusable value objects, enums, and specifications
- π Prior domain models and aggregate designs
- π« Anti-pattern libraries for avoiding incorrect modeling
- π Ubiquitous language semantic mappings to maintain term consistency
This knowledge base is versioned, traceable, and filterable by bounded context, domain concept, and reuse tags.
π§± 1. Tactical DDD Patterns Repository¶
| Pattern | Description |
|---|---|
| Aggregate Lifecycle Templates | Examples of modeling lifecycles using state transitions and invariant guards |
| Entity Composition Strategies | Patterns for composing rich aggregates vs referencing ID-only entities |
| Value Object Equality | Pre-defined IEquatable<T> implementations and immutability templates |
| Event Emission Within Aggregates | Triggering, queuing, and registering domain events from entity state changes |
| Specifications as Policies | Boolean business rule objects modeled as reusable, testable predicates |
π¦ 2. Reusable Domain Elements Library¶
| Type | Examples |
|---|---|
| Value Objects | Money, EmailAddress, PhoneNumber, Percentage, Coordinates |
| Enumerations | InvoiceStatus, PaymentMethod, UserRole, SubscriptionTier |
| Common Specifications | HasOverdueBalance, IsWithinGeoFence, IsActiveMember |
Each entry is tagged with:
reusable: truebounded_context_scopeversioncompliance_sensitive: true/false
π 3. Prior Model Fragments¶
| Retrieved By | Used For |
|---|---|
"Invoice" + "ApplyDiscount" |
Match known aggregate structure, reuse VO patterns |
"Subscription" + "Cancel" |
Retrieve state machine + event cascade pattern |
"Customer + create" |
Suggest base aggregate structure with validation, creation event, and status enum |
Frags are vectorized and stored using Azure Cognitive Search, Pinecone, or equivalent.
π 4. Glossary-to-Model Mapping Memory¶
| Term | Mapped Output |
|---|---|
Invoice |
Aggregate with AddLineItem, ApplyDiscount, Issue() methods |
Discount |
Value object with Percentage, Reason, and AppliesTo |
SubscriptionStatus |
Enum + lifecycle transitions |
TaxPolicyEvaluator |
Domain service used by Invoice.CalculateTax() |
Also used to normalize naming across agents and avoid duplication.
π« 5. Anti-Pattern Prevention Rules¶
| Anti-Pattern | Rejection Reason |
|---|---|
| Mutable value objects | Break equality and validation guarantees |
| βFat enumsβ with logic | Violates SRP β should use Specification |
| Overloaded aggregates with unrelated responsibilities | Breaks cohesion β split into multiple aggregates |
| Domain event with raw DTO as payload | Violates domain encapsulation and forward compatibility |
| Repositories returning IQueryable | Breaks encapsulation and allows query leakage |
If any are detected, a warning or auto-correction will trigger via DomainValidationSkill.
π§ Semantic Memory Retrieval Examples¶
| Query | Memory Match |
|---|---|
Money + Amount |
Money VO with currency code, decimal amount, math ops, equality contract |
CreateInvoice |
Invoice aggregate skeleton with line item collection, status enum, domain event |
Email + confirmation |
EmailAddress VO + EmailConfirmed domain event |
TimeZone |
TimeZoneOffset VO or ZonedDateTime VO pattern with NodaTime-like behavior |
π Governance and Reuse Rules¶
| Rule | Enforcement |
|---|---|
Reused pattern must have pattern_version: approved |
β |
Reuse must emit source trace (origin_trace_id, reuse_confidence) |
β |
Compliance-tagged fields (e.g., SSN) must be masked in test stubs |
β |
Domain event reuse allowed only if payload_version: compatible |
β |
π Memory Integration Diagram¶
flowchart TD
A[Start Modeling] --> B[Query Semantic Memory]
B --> C[Get Patterns, Reusable VOs, Enums]
C --> D[Inject into Model Draft]
D --> E[Log Source Trace + Confidence Score]
π Execution Flow¶
The Domain Modeler Agent follows a modular, validated, and memory-augmented pipeline
to convert bounded context definitions, ubiquitous language, and use case triggers into a rich, DDD-aligned Domain Model Blueprint.
Each step is powered by a specific skill, validated independently, and emits observability data for traceability.
π Execution Phases¶
| Phase | Description |
|---|---|
1οΈβ£ Input Validation & Semantic Memory Retrieval¶
- Validate presence of:
bounded_contextservice_responsibilitiesglossary,event_catalog
- Retrieve matching domain models, reusable VOs, enums from vector memory
- Match glossary terms to model elements (aggregate, VO, event)
2οΈβ£ Aggregate Root Identification¶
- Analyze service responsibilities and triggers
- Group related behaviors under potential root entities (e.g.,
Invoice,Customer) - Detect composition needs: child entities, collections, VO dependencies
3οΈβ£ Entity and Value Object Modeling¶
- Define entity properties, identities, and relationships
- Generate value objects for immutable concepts (
Money,DateRange,EmailAddress) - Apply equality contracts and immutability hints
4οΈβ£ Enumeration and Specification Design¶
- Infer enums from field types and business states (
InvoiceStatus,RiskLevel) - Model common validation/filtering rules as specifications (
IsEligibleForUpgrade) - Suggest cross-context reuse of well-known enums/specs
5οΈβ£ Domain Service & Policy Extraction¶
- Detect stateless logic or multi-aggregate operations
- Define interfaces for rule engines, pricing calculators, eligibility checks
- Annotate compliance-critical logic
6οΈβ£ Domain Event Inference¶
- Identify behaviors that transition state or trigger workflows
- Emit internal events tied to methods (e.g.,
IssueInvoiceβInvoiceIssued) - Annotate with payload fields, correlation hints,
is_externalizableflag
7οΈβ£ Validation & Invariant Mapping¶
- Apply validation rules:
- Required fields
- Type constraints
- Temporal or business logic conditions
- Emit
validation-map.yamlfor use by validator and test agents
8οΈβ£ Artifact Assembly & Emission¶
- Compose:
domain-model.yaml.csskeletons (optional)domain-events.json- Mermaid diagrams (
entity-hierarchy.mmd,state-machine.mmd) domain-blueprint-metadata.yaml
- Emit
DomainModelPublishedevent with artifact links and trace info
π Observability Emissions¶
| Telemetry | Example |
|---|---|
aggregate_discovery_count |
3 |
value_object_reuse_count |
5 |
validation_rule_count |
12 |
semantic_memory_reuse_confidence_avg |
0.87 |
output_schema_validation_status |
pass |
π Retry/Correction Paths¶
| Phase | Error | Action |
|---|---|---|
| VO modeling | Mutable VO detected | Regenerate with immutability rule |
| Event design | Payload missing | Retry with fallback contract template |
| Enum overlap | Conflict in glossary | Trigger namespace prefixing |
| Invalid YAML | Structure mismatch | Run SchemaFixerSkill with auto-patch hints |
π§ Process Flow Diagram¶
flowchart TD
A[Validate Inputs] --> B[Retrieve Glossary & Memory]
B --> C[Identify Aggregates]
C --> D[Model Entities + VOs]
D --> E[Define Enums + Specs]
E --> F[Create Domain Services + Policies]
F --> G[Emit Domain Events]
G --> H[Validate Rules + Invariants]
H --> I[Assemble Artifacts]
I --> J[Emit DomainModelPublished Event]
π οΈ Core Skills and Kernel Functions¶
The Domain Modeler Agent operates through a well-structured set of Semantic Kernel skills, each responsible for a single modeling responsibility.
These skills are:
- π Retryable β Each skill can be retriggered individually if its output is invalid or incomplete
- π Schema-bound β Outputs must conform to domain-modeling schemas and validators
- π‘ Observable β All executions are traceable via OpenTelemetry with metadata and telemetry spans
π Key Skills Overview¶
| Skill Name | Responsibility |
|---|---|
π₯ Input & Memory Skills¶
| InputValidatorSkill | Confirms required input artifacts and metadata (bounded_context, service, trace_id) |
| SemanticMemoryRetrieverSkill | Retrieves reusable value objects, enums, specs, and prior aggregate structures |
| GlossaryMapperSkill | Maps business terms to modeling primitives (e.g., βInvoiceβ β Aggregate) |
π§± Aggregate & Entity Modeling¶
| AggregateBuilderSkill | Discovers candidate aggregates, models lifecycles, and assigns commands |
| EntityComposerSkill | Builds entity structures, fields, relationships, and versioning metadata |
| LifecycleStatePlannerSkill | Models aggregate state transitions using methods and state machines |
π¦ Value Object & Enumeration Design¶
| ValueObjectGeneratorSkill | Produces immutable, by-value domain concept classes (e.g., Money, TaxCode) |
| EnumerationModelerSkill | Structures enums with state mappings, usage hints, and validation rules |
| SpecificationCreatorSkill | Builds Boolean logic filters as reusable predicates (e.g., IsOverdue) |
π Domain Services & Policy Skills¶
| DomainServiceExtractorSkill | Identifies externalized stateless business logic (e.g., DiscountEvaluator) |
| PolicyAnnotatorSkill | Tags compliance-sensitive or rule-based operations for auditing or review |
π’ Event Emission & Rule Mapping¶
| DomainEventEmitterSkill | Attaches events to methods (ApplyDiscount β DiscountAppliedEvent) and defines payloads |
| ValidationRuleBuilderSkill | Extracts field rules and invariant mappings (DueDate must be β₯ IssueDate) |
π€ Output Assembly & Emission¶
| DomainArtifactAssemblerSkill | Compiles YAML/JSON spec files and emits final artifacts |
| MermaidDiagramEmitterSkill | Generates class diagrams, lifecycle state machines, and VO/entity relationship graphs |
| BlueprintEventEmitterSkill | Emits DomainModelPublished with trace metadata and artifact URLs |
π§ Skill Chaining and Dependencies¶
flowchart TD
InputValidator --> GlossaryMapper
GlossaryMapper --> SemanticMemoryRetriever
SemanticMemoryRetriever --> AggregateBuilder
AggregateBuilder --> EntityComposer
EntityComposer --> ValueObjectGenerator
ValueObjectGenerator --> DomainEventEmitter
DomainEventEmitter --> ValidationRuleBuilder
ValidationRuleBuilder --> DomainArtifactAssembler
DomainArtifactAssembler --> BlueprintEventEmitter
π Retry Path Hooks¶
| Skill | Retry Trigger |
|---|---|
ValueObjectGeneratorSkill |
VO missing immutability or equality contract |
DomainEventEmitterSkill |
Event lacks required field or cannot link to method |
SpecificationCreatorSkill |
Output fails predicate validation test |
EnumerationModelerSkill |
Duplicate enum values or missing mapping |
Each retry emits:
skill_nameretry_attempttrace_idoutcome: success | failed
π§ Skill Design Principles¶
| Principle | Description |
|---|---|
| Single Responsibility | Each skill models only one construct (e.g., entity, VO, enum) |
| Schema-Driven | Outputs validated against ConnectSoft domain-modeling schemas |
| Composable | Skills can be run sequentially or independently (supports partial modeling) |
| Traceable | Execution spans, input parameters, and retries are all logged |
π οΈ Core Technologies and Tools¶
The Domain Modeler Agent is powered by a modular, schema-governed, memory-augmented toolchain tailored for Domain-Driven Design (DDD), Clean Architecture, and ConnectSoftβs automation ecosystem.
The stack supports:
- Structured domain modeling in YAML and C#
- AI-assisted reasoning and prompt orchestration
- Semantic memory retrieval and validation
- Diagram generation and event emission
- End-to-end traceability and governance
π Core Technologies and Roles¶
π§ 1. Semantic Reasoning and Orchestration¶
| Component | Role |
|---|---|
| Semantic Kernel (.NET) | Orchestrates skill composition and memory access |
| Azure OpenAI (GPT-4) | Powers naming, heuristics, pattern matching, and fallback generation |
| ConnectSoft SkillPack: DomainModeling | Plug-and-play skill modules for aggregates, VOs, enums, events |
π 2. Domain Modeling Language & Output¶
| Component | Role |
|---|---|
| ConnectSoft DSL (YAML-based) | Used for domain model declaration (aggregates, VOs, events) |
.cs code skeleton templates |
Optional class/interface outputs for C#-based domain layers |
| Domain Modeling Schema Validator | Ensures generated YAML and JSON files conform to ConnectSoftβs structure contracts |
π 3. Observability & Tracing¶
| Component | Role |
|---|---|
| OpenTelemetry SDK (.NET) | Emits spans, durations, retry counts, and skill traces |
| Azure Application Insights | Stores telemetry logs and metrics for review |
| ConnectSoft Dashboard | Visual UI for aggregate count, reuse index, validation status, and diagram links |
π 4. Memory, Reuse, and Governance¶
| Component | Role |
|---|---|
| Pinecone / Azure Cognitive Search | Stores reusable pattern embeddings (VOs, Enums, Domain Events) |
| Semantic Retrieval API | Enables context-aware model suggestion based on bounded context + term + |
| behavior | |
| Governance Engine | Prevents use of blacklisted anti-patterns (e.g., mutable VOs, anemic aggregates) |
π 5. Diagram Generation¶
| Tool | Output |
|---|---|
| Mermaid.js Generator | |
- entity-hierarchy.mmd |
|
- aggregate-lifecycle.mmd |
|
- vo-relationship.mmd |
|
| PlantUML (optional) | Alternative to Mermaid for enterprise-level integration |
| ConnectSoft Diagram Validator | Ensures renderability and completeness of diagrams emitted |
π§ͺ 6. Testing, Validation, and Compliance Integration¶
| Component | Role |
|---|---|
| ValidationMapEmitterSkill + YAML | Outputs invariant maps used by Test Generator and Validation Agent |
| Compliance Tagger | Annotates fields (e.g., PII, financial data) with security and governance hints |
| Immutable Structure Validator | Prevents value object mutation and enforces by-value equality patterns |
π‘ 7. Artifact Publishing and Emission¶
| Component | Role |
|---|---|
| Artifact Storage API | Saves all blueprint artifacts (YAML, JSON, C#, diagrams) with versioning |
| ConnectSoft Event Bus (Azure Event Grid) | Emits DomainModelPublished for downstream agents |
| Schema Registry | Validates event payloads and domain model contracts |
β Stack Alignment to ConnectSoft Principles¶
| Principle | Supported by |
|---|---|
| π§± DDD First | YAML DSL, reusable modeling primitives |
| π§ͺ Test-First | Invariant map + specification structure |
| π Clean Architecture | Aggregate-centric model with strict layering |
| π Reuse | Memory + versioned contract store |
| π§© Modularity | Skill composition, diagram separation, output layering |
| π‘ Observability | Full OpenTelemetry instrumentation |
| π‘οΈ Governance | Schema validation, anti-pattern prevention, audit tagging |
π¦ Output Format Matrix¶
| Output Type | Format |
|---|---|
| Domain Blueprint | domain-model.yaml |
| Class Templates | .cs |
| Domain Events | .json |
| Validation Rules | validation-map.yaml |
| Diagrams | .mmd (Mermaid) |
| Event | DomainModelPublished (JSON) |
π System Prompt (Bootstrapping Instruction)¶
The System Prompt defines the intent, responsibilities, and constraints of the Domain Modeler Agent.
It ensures every modeling session aligns with ConnectSoftβs principles of DDD, Clean Architecture, governance, and agent interoperability.
This prompt is invoked at agent startup and serves as the operational contract for autonomous domain generation.
β Full Prompt Definition (YAML + Natural Language)¶
You are the **Domain Modeler Agent** of the ConnectSoft AI Software Factory.
Your responsibility is to generate a complete, consistent, and reusable **domain model blueprint**
for a single service within a bounded context.
You must analyze the serviceβs responsibilities, glossary, event triggers, and known use cases
to model its **aggregates, entities, value objects, enums, specifications, domain services, and events**.
---
## You must:
1. Validate that all required inputs are available:
- Bounded Context metadata
- Service name and responsibilities
- Glossary or Ubiquitous Language definitions (optional but preferred)
- Event catalog
- API input triggers (for behavior inference)
2. Discover one or more **aggregate roots** based on behavioral clustering and lifecycle scope.
3. For each aggregate, model:
- Entities and relationships
- State transitions and invariants
- Lifecycle behaviors and validations
4. Define:
- Value Objects (immutable, by-value)
- Enumerations (finite sets of known variants)
- Specifications (Boolean business rules)
- Domain Services (stateless logic orchestrators)
5. Emit **internal domain events** that reflect state transitions, business workflows, or triggers.
6. Produce the following output artifacts:
- `domain-model.yaml` (main DSL model)
- `*.cs` skeletons (optional class templates)
- `validation-map.yaml` (invariant rules)
- `domain-events.json` (event definitions)
- Mermaid diagrams (state machines, class maps)
- Metadata file with counts, version, compliance hints
7. Ensure:
- No infrastructure or application logic leaks into the domain layer
- No mutable value objects
- All events are traceable to specific behaviors
- Output conforms to ConnectSoft schemas
8. Emit a `DomainModelPublished` event with links to all artifacts.
---
## Output Constraints
- Value Objects must be **immutable** and **implement equality by value**
- Aggregates must **enforce invariants** through methods, not passive properties
- Domain Events must **contain correlation metadata** and structured payloads
- Enumerations must be **closed sets** β no unbounded expansion
---
## Output Format Expectations
- YAML-based DSL (`domain-model.yaml`)
- Optional C# skeletons (for `.NET 8`)
- Mermaid diagrams for human and governance review
- All outputs include: `trace_id`, `project_id`, `bounded_context`, `agent_version`
---
## Observability Requirements
- Emit OpenTelemetry spans per skill execution
- Log reuse from memory (`pattern_source`, `confidence_score`)
- Track retry attempts, validation outcomes, and diagram compilation
---
## Success Criteria
β
Clean, layered domain structure
β
Artifacts validatable and downstream-consumable
β
Events, VOs, specs reusable and versioned
β
Fully traceable and observable execution
β
Zero anti-patterns detected (mutable VO, anemic domain, rule leakage)
π Prompt Governance Guarantees¶
| Rule | Enforced |
|---|---|
| Schema validation of all artifacts | β |
| Memory reuse traced and versioned | β |
| Output tagged with trace metadata | β |
| Retry or failure triggers event escalation | β |
π Example Initialization Context¶
"You are modeling the domain for
BillingServicein theBillingbounded context.
You received 4 responsibilities (CreateInvoice,ApplyDiscount,SendReminder,IssueInvoice)
and a glossary withInvoice,Discount, andMoney.
Event triggers includeInvoiceCreated,PaymentSucceeded.
Your goal is to emit a fully validated domain-model package, with diagrams, validation rules, and C# stubs."
π₯ Input Prompt Template¶
The Domain Modeler Agent receives a structured prompt containing all the data necessary to synthesize a rich, bounded, and validated domain model.
This prompt is generated by upstream agents (e.g., Solution Architect, Ubiquitous Language Agent, Application Architect) or manually by a domain expert.
β Prompt Format (YAML)¶
assignment: "generate-domain-model"
project:
project_id: "connectsoft-saas-2025"
trace_id: "domain-billing-9832"
bounded_context: "Billing"
service_name: "BillingService"
agent_version: "1.1.0"
inputs:
glossary_url: "https://artifacts.connectsoft.dev/glossary/billing.yaml"
responsibilities_url: "https://artifacts.connectsoft.dev/services/billing/responsibilities.yaml"
api_surface_url: "https://artifacts.connectsoft.dev/apis/billing-api.yaml"
event_catalog_url: "https://artifacts.connectsoft.dev/events/billing-events.json"
nfr_url: "https://artifacts.connectsoft.dev/nfrs/billing-nfr.yaml"
settings:
output_format: [yaml, json, cs, mermaid]
language: "csharp"
generate_diagrams: true
include_class_stubs: true
reuse_patterns: true
π§© Field Breakdown¶
π· assignment¶
Always set to
"generate-domain-model"
π· project metadata¶
| Field | Description |
|---|---|
project_id |
Unique solution reference |
trace_id |
Full traceability for spans, events, storage |
bounded_context |
Bounded domain scope |
service_name |
Maps output to the owning microservice |
agent_version |
Tracks which version of the agent produced the outputs |
π· inputs¶
| Artifact | Purpose |
|---|---|
glossary_url |
Terminology-to-model mapping |
responsibilities_url |
Use case clustering for aggregates |
api_surface_url |
Behavior inference (commands/queries) |
event_catalog_url |
Event-driven transition discovery |
nfr_url |
Edge constraints (immutability, auditing, sensitivity) |
π· settings¶
| Field | Description |
|---|---|
output_format |
Accepted: yaml, json, cs, mermaid, markdown |
language |
Used to structure .cs class generation or future Kotlin/F# |
generate_diagrams |
Whether Mermaid state and hierarchy diagrams are included |
include_class_stubs |
Whether .cs domain types are emitted |
reuse_patterns |
If enabled, agent queries memory for reusable VOs, Enums, etc. |
π§ Example Prompt (Minimal)¶
assignment: generate-domain-model
project:
project_id: connectsoft-payments
trace_id: domain-4314
bounded_context: Payments
service_name: PaymentService
inputs:
glossary_url: https://.../glossary.yaml
responsibilities_url: https://.../payments-responsibilities.yaml
api_surface_url: https://.../payments-api.yaml
event_catalog_url: https://.../events.json
π§ͺ Validation Rules (Input Layer)¶
| Rule | Enforcement |
|---|---|
bounded_context, service_name, trace_id required |
β |
At least one of glossary, responsibilities, or event_catalog must be provided |
β |
If generate_diagrams = true, ensure diagram rendering engine is enabled |
β |
| URLs must be accessible, schema-validated, and signed or trusted | β |
π Interoperability Notes¶
- Input prompt aligns with MKDocs trace metadata, allowing documentation linking
- Downstream agents (Test Generator, App Architect) subscribe to outputs via
DomainModelPublishedevent - Settings flags map to output content and verbosity, controlling downstream load
π€ Output Expectations¶
The Domain Modeler Agent produces a suite of structured, traceable, and reusable artifacts that define the semantic core of a microservice.
Outputs are designed for autonomous consumption by downstream agents (Application Architect, Test Generator, Microservice Generator), as well as for developer onboarding, validation, and documentation.
All artifacts must conform to ConnectSoft DDD schema specifications, be versioned, and include traceability metadata.
π 1. domain-model.yaml (Primary Blueprint)¶
| Format | YAML (ConnectSoft DSL) |
| Sections |
- aggregates: names, methods, child entities, rules
- entities: nested definitions or shared components
- value_objects: immutable, by-value concepts
- enumerations: enums with values and usage hints
- domain_services: stateless logic helpers
- specifications: predicates for decision logic
- domain_events: event definitions, emitters, payloads
- validation_rules: constraints for properties or transitions
β Must pass ConnectSoft Domain Model Schema Validator
π§± 2. Class Skeletons (.cs)¶
| Format | C# (.NET 8 clean architecture convention) |
| Emitted Files |
- Invoice.cs, InvoiceLineItem.cs
- Money.cs, TaxCode.cs
- InvoiceStatus.cs, PaymentMethod.cs
- TaxPolicyEvaluator.cs, EligibilitySpecification.cs
- InvoiceCreatedEvent.cs, PaymentAppliedEvent.cs
β Optional based on
include_class_stubsflag
β Stub methods use TODO markers and type annotations
π 3. validation-map.yaml¶
| Format | YAML | | Purpose | Captures invariants and validation logic for all domain elements |
Invoice:
TotalAmount:
- rule: must be greater than 0
- rule: must equal sum of line items
DueDate:
- rule: must be after IssueDate
β Used by Validation Agent and Test Generator to scaffold contract tests
π’ 4. domain-events.json¶
| Format | JSON |
| Fields |
- event_name
- emitted_by_method
- aggregate
- payload_schema
- correlation_fields
- is_externalizable
- trace_id, bounded_context, event_version
β Must validate against
ConnectSoft.EventContractSchema
π 5. Diagrams (*.mmd Mermaid Files)¶
| Files |
- entity-hierarchy.mmd β shows relationships
- aggregate-lifecycle.mmd β state transitions
- vo-map.mmd β dependencies and reuse
β Must render successfully and link to entity names declared in the YAML model
π¦ 6. domain-blueprint-metadata.yaml¶
| Purpose | Metadata bundle for observability and trace lineage |
| Fields |
- trace_id, project_id, agent_version
- aggregate_count, vo_count, event_count, spec_count
- governance_warnings: anti-patterns corrected or flagged
- reused_elements: from prior blueprints (VOs, Enums, Specs)
π¨ 7. Emitted Event: DomainModelPublished¶
| Format | JSON | | Sample |
{
"event": "DomainModelPublished",
"boundedContext": "Billing",
"service": "BillingService",
"projectId": "connectsoft-saas",
"traceId": "domain-xyz-4812",
"modelUrl": "https://.../domain-model.yaml",
"eventsUrl": "https://.../domain-events.json",
"metadataUrl": "https://.../domain-blueprint-metadata.yaml",
"timestamp": "2025-05-01T20:30:00Z"
}
β This event is required for downstream orchestration to begin
π Output Validation Rules¶
| Rule | Description |
|---|---|
| All YAML/JSON files must pass schema validation | β |
| All diagrams must compile successfully | β |
| At least one aggregate must be present | β |
| All emitted domain events must link to emitting methods | β |
| All VOs must declare equality + immutability flags | β |
| Output traceability metadata required in all files | β |
π Output Summary Table¶
| Output | Format | Used By |
|---|---|---|
| Domain Model Blueprint | domain-model.yaml |
App Architect, Generator, Validator |
| Class Skeletons | .cs |
Microservice Generator |
| Validation Map | validation-map.yaml |
Validator, Test Generator |
| Domain Events | .json |
Event Architect, Messaging Layer |
| Diagrams | .mmd |
Docs, Governance UI |
| Metadata | .yaml |
Dashboards, Audits |
| Event | DomainModelPublished |
All subscribers in Agent Bus |
π§ Memory Strategy Overview¶
The Domain Modeler Agent uses a hybrid memory model to ensure consistency, reuse, correctness, and learning over time.
It supports:
- π Reusing proven VOs, enums, and event patterns
- π§ Contextual adaptation from prior services
- π« Avoidance of anti-patterns
- π Traceable reuse with governance validation
π§ Short-Term Memory (Session-Scoped)¶
| Memory Area | Description |
|---|---|
| Aggregate Discovery Log | Tracks which aggregates were inferred from which responsibilities or glossary terms |
| VO Generation Cache | Temporary map of VOs created, reused, or restructured within the current service |
| Entity Relationship Tree | In-memory graph of entity β child relationships and embedding VOs |
| Retry Journal | Stores corrections applied after skill validation errors (e.g., VO mutation fix) |
Used to assemble coherent output, handle dependency resolution, and enable incremental retries.
ποΈ Long-Term Memory (Semantic Memory)¶
Stored in vector embeddings and governed via reuse metadata, this memory allows the agent to bootstrap modeling using prior patterns.
π¦ 1. Reusable Value Objects¶
| Example | Metadata Tags |
|---|---|
Money |
immutable: true, used_by: [Invoice, Subscription], currency_aware: true |
Address |
supports_validation: true, type: billing | shipping, used_by: Customer |
TaxCode |
has_enum_constraint: true, compliance_tag: finance.tax |
π§© 2. Enums and Specifications¶
| Memory Example | Use |
|---|---|
InvoiceStatus |
Suggests enum values (Draft, Issued, Paid, Cancelled) with transitions |
HasOverdueBalance |
Boolean rule specification based on DueDate < Today and Outstanding > 0 |
π 3. Prior Aggregates¶
| Query | Result |
|---|---|
"Subscription" + "Cancel" |
Returns reusable Subscription.cs structure with Cancel(), Resume(), and Status enum |
"Customer + Onboarding" |
Suggests entity graph for Customer, Profile, Account |
π’ 4. Domain Event Catalog¶
| Query | Response |
|---|---|
"InvoiceCreated" |
Returns structured event with known payload, emitting method (Issue()), and event version |
"PaymentApplied" |
Matches event for ApplyPayment() in Invoice aggregate |
"DiscountApplied" |
Matches to event and VO Discount with known structure (percentage, appliesTo) |
π§± 5. Reuse Confidence and Governance Filtering¶
Each memory hit includes:
pattern_source_trace_idpattern_confidence_score(0.0β1.0)governance_verified: true/falselast_used_by: service_name / agent_version
β οΈ Only patterns with
governance_verified: trueand confidence β₯0.80are reused autonomously.
π Memory Retrieval Workflow¶
flowchart TD
A[Start Session] --> B[Glossary + Term Analysis]
B --> C[Query Semantic Memory]
C --> D[Match Aggregates, VOs, Enums, Events]
D --> E[Inject into Current Model]
E --> F[Log Pattern Use with Confidence Score + Trace ID]
π§ͺ Anti-Pattern Filtering¶
The agent maintains an internal blacklist (also retrieved from governance memory) of dangerous patterns:
| Anti-Pattern | Example |
|---|---|
| β Mutable value objects | Money.Amount += x |
| β Overloaded aggregate root | Customer managing Subscription, Invoice, BillingMethod |
| β Enum with unknown variant fallback | Status = -1 β Unknown |
| β Domain event that wraps external DTO | UserCreatedEvent { RawUserDto } |
These are blocked or automatically corrected during generation.
π οΈ Feedback to Memory¶
When a reused VO or Enum is included in final output, the agent emits a reuse confirmation span, including:
pattern_id,used_in_project,agent_version,confidence_score,usage_success: true/false
This feedback loop supports memory pruning, pattern promotion, and self-governing reuse.
β Benefits of Memory-Driven Modeling¶
| Capability | Benefit |
|---|---|
| Semantic Reuse | Reduces modeling effort, increases consistency |
| Pattern Learning | Improves over time with real-world usage |
| Governance Control | Prevents reuse of deprecated or invalid structures |
| Traceability | Every reused structure is linkable and explainable |
| Cross-Agent Coherence | Shared modeling elements across services (e.g., Money, Status enums) |
β Validation and Correction Framework¶
The Domain Modeler Agent applies a multi-phase validation pipeline to ensure:
- Schema conformance of all artifacts
- DDD best practices are respected (e.g., VO immutability, aggregate boundaries)
- Model completeness and correctness
- Prevention of architectural anti-patterns
When errors are detected, the agent triggers skill-specific retries, fallback logic, or flags items for manual escalation.
π Validation Phases¶
1οΈβ£ Input Validation¶
| Checks |
- Are bounded_context, service_name, and trace_id present?
- Are responsibilities, glossary, or triggers included?
- Are URLs resolvable and accessible?
- Are glossary terms mappable?
β If failed: Retry with
InputValidatorSkill; escalate if unresolved.
2οΈβ£ Structural Model Validation¶
| Artifact | Rules Enforced |
|---|---|
domain-model.yaml |
Must match schema, include β₯1 aggregate, reference trace_id |
| Aggregates | Must expose at least one behavior (method) |
| Entities | Must have unique identity and no orphan status |
| VOs | Must be immutable and implement equality |
| Events | Must include emitted_by, payload, correlation_id |
| Enums | Must define β₯2 values, no duplicates |
β If failed: Retry appropriate modeling skill (e.g.,
AggregateBuilderSkill,ValueObjectGeneratorSkill)
3οΈβ£ Dependency Graph Validation¶
| Checks |
- Are entity β VO β enum relationships consistent?
- Are cyclic relationships avoided?
- Are aggregates not overloaded with unrelated behavior?
- Do child entities exist only within a single aggregate root?
β If failed: Execute correction skill or emit warning via
GovernanceValidationSkill
4οΈβ£ Invariant & Rule Validation¶
| Artifact | Rules |
|---|---|
validation-map.yaml |
Must include β₯1 rule per aggregate |
Constraint syntax must match supported DSL (must be > 0, must be after date) |
|
| Events tied to method transitions must emit at valid state points |
β If failed: Retry with
ValidationRuleBuilderSkill
5οΈβ£ Reuse & Memory Validation¶
| Rule | Enforced |
|---|---|
Memory items must have governance_verified: true |
β |
Reused fragments must embed source_trace_id, reuse_score β₯ 0.80 |
β |
| Reused VOs/specs must be compatible with current aggregate version | β |
β If failed: Skip reuse or fallback to internal DSL fragment
π Retry and Correction Logic¶
| Phase | Retry Skill |
|---|---|
| VO mutation detected | ValueObjectGeneratorSkill (force readonly, With(...) method pattern) |
| Enum overlap or conflict | EnumerationModelerSkill (prefix or split strategy) |
| Event missing correlation fields | DomainEventEmitterSkill (inject TraceId, EntityId) |
| Validation syntax issue | ValidationRuleBuilderSkill (patch malformed constraint) |
Each retry emits:
retry_typeskill_nameattempt_numberresolved: true/falsetrace_id
π Observability Outputs (Validation Phase)¶
| Metric | Description |
|---|---|
domain_validation_passed |
True if all phases succeeded |
retry_count_by_skill |
Aggregate count of retries per skill |
schema_validation_status |
Pass/fail per artifact |
anti_pattern_blocked_count |
Detected and auto-corrected design flaws |
output_structure_score |
% of model components with required metadata and correctness |
π Example Validation Trace (Event)¶
{
"trace_id": "domain-8741",
"agent": "DomainModeler",
"skill": "ValueObjectGeneratorSkill",
"retry": true,
"reason": "VO is mutable",
"correction_applied": "added 'readonly' to all fields",
"resolved": true
}
π§ Escalation Triggers (Manual Review Required)¶
| Condition | Action |
|---|---|
| Unable to infer any aggregates | Flag for Solution Architect Agent |
| Event contract fails schema 2+ times | Emit DomainModelValidationFailed |
| Non-resolvable ambiguity in glossary term | Emit ManualGlossaryMappingRequired |
| Large retry loop (>3 cycles) on VO conflict | Escalate to Platform Governance Officer |
π€ Collaboration Interfaces¶
The Domain Modeler Agent plays a central role in the ConnectSoft AI Software Factoryβs agentic design chain, providing the semantic contract for all services.
It collaborates upstream with architect agents for context and business vocabulary, and downstream with implementation and runtime agents for scaffolding, testing, and orchestration.
π‘ Upstream Collaboration¶
| Upstream Agent | Interface |
|---|---|
| Solution Architect Agent | |
- Input: solution-blueprint.md |
|
| - Provides: service responsibilities, bounded context, trace metadata |
| Ubiquitous Language Agent |
- Input: glossary.yaml
- Provides: business terms mapped to domain elements (Aggregate, VO, Event, etc.) |
| API Designer Agent |
- Input: api-surface.yaml
- Provides: inferred use cases and domain commands from REST/gRPC structure |
| Event-Driven Architect Agent |
- Input: event-catalog.json
- Provides: behavior triggers and emitted events used in domain method mapping |
π¦ Downstream Collaboration¶
| Downstream Agent | Consumes |
|---|---|
π§± Application Architect Agent¶
domain-model.yamlvalidation-map.yamldomain-events.jsonUses: entity structures, aggregate logic, port boundaries, method-to-event mapping
π§ͺ Test Generator Agent¶
validation-map.yamldomain-model.yaml*.csskeletonsUses: aggregate rules, VO structure, event emission, lifecycle validation
ποΈ Microservice Generator Agent¶
*.csdomain skeletonsdomain-model.yamlUses: pre-scaffolded aggregates/entities for code generation
π’ Event-Driven Architect Agent¶
domain-events.jsonaggregate.event_emissions[]Uses: internal events as candidates for promotion to integration events
π¨ Emitted Event: DomainModelPublished¶
| Format | JSON |
| Triggers |
- Microservice Generation
- Test Generation
- Application Architecture
- Diagram Rendering
- Compliance Checks
{
"event": "DomainModelPublished",
"service": "BillingService",
"boundedContext": "Billing",
"projectId": "connectsoft-saas",
"traceId": "domain-arch-0923",
"blueprintUrl": "https://.../domain-model.yaml",
"timestamp": "2025-05-01T20:45:00Z"
}
π Orchestration Flow Diagram¶
flowchart TD
SolutionArchitect --> DomainModeler
UbiquitousLanguage --> DomainModeler
APIDesigner --> DomainModeler
EventDrivenArchitect --> DomainModeler
DomainModeler --> ApplicationArchitect
DomainModeler --> TestGenerator
DomainModeler --> MicroserviceGenerator
DomainModeler --> EventDrivenArchitect
π¦ Shared Artifact APIs¶
| API | Role |
|---|---|
| Artifact Storage API | Stores all outputs (domain-model.yaml, diagrams, stubs) with version tags |
| ConnectSoft Event Bus | Transmits blueprint lifecycle events (DomainModelPublished) |
| Schema Registry | Validates YAML/JSON outputs and event payloads |
| Glossary Mapping API | Allows terms from glossary to be resolved dynamically or flagged for ambiguity |
π‘ Metadata Tracing Standards¶
All emitted artifacts and events must include:
trace_id,project_id,bounded_context,service_name,agent_versionpattern_reuse(if applicable)governance_scoreandvalidation_statusfor downstream dashboards
π‘ Observability Hooks¶
The Domain Modeler Agent is fully instrumented using OpenTelemetry to provide deep traceability and runtime diagnostics.
It emits metrics, spans, and structured logs at each stage of the modeling pipeline.
π Telemetry Emissions¶
| Metric | Description |
|---|---|
domain_modeling_duration_ms |
Total time taken for the modeling session |
aggregate_discovery_count |
Number of aggregates modeled |
vo_reuse_count |
Number of value objects reused from semantic memory |
event_emission_total |
Number of domain events defined |
validation_passed |
Boolean outcome of final artifact validation |
retry_count_by_skill{name} |
Retries triggered per skill |
anti_pattern_blocked_count |
Violations caught and corrected automatically |
All telemetry entries are tagged with:
trace_id,project_id,bounded_context,agent_version,skill_name
π Observability Dashboards¶
| Dashboard | Purpose |
|---|---|
| Domain Blueprint Overview | Aggregates, entities, VOs, events, complexity map |
| Retry Heatmap | Frequency and type of retries per skill |
| Semantic Reuse Index | Memory-driven design effectiveness |
| Governance Compliance Panel | Scorecards for anti-patterns, completeness, trace metadata |
π§ Human Oversight Hooks¶
Although autonomous, the Domain Modeler Agent includes manual intervention safeguards:
| Trigger | Action |
|---|---|
| β No aggregates discovered | Escalate to Solution Architect Agent |
| β Conflicting glossary mappings | Emit ManualGlossaryResolutionRequired |
| β VO reusability score < threshold | Skip reuse, emit warning |
| β Structural schema validation fails > 1 retry | Emit DomainModelValidationFailed |
All escalations are visible in ConnectSoft governance dashboards with supporting telemetry.
π§Ύ Compliance and Traceability¶
| Enforced |
|---|
| Output traceability in all artifacts (trace_id, agent_version, reuse source) |
| Compliance hints in metadata for sensitive fields or audit-required events |
| Immutable artifact publishing with artifact hash and schema version |
β Conclusion¶
The Domain Modeler Agent defines the semantic and structural foundation of every ConnectSoft microservice.
It guarantees that services are not just operational, but meaningful, cohesive, and correctly bounded.
π Strategic Outcomes¶
β
DDD-aligned, clean, reusable models
β
Agent-to-agent interoperability via YAML/JSON
β
Test and code generation readiness
β
Traceability for every modeling decision
β
Platform-wide domain consistency
β
Governance-ready and audit-proof
π¦ Final Artifact Summary¶
| Artifact | Format |
|---|---|
domain-model.yaml |
YAML |
domain-events.json |
JSON |
.cs skeletons (optional) |
C# |
validation-map.yaml |
YAML |
Diagrams (*.mmd) |
Mermaid |
Metadata (domain-blueprint-metadata.yaml) |
YAML |
Emitted Event (DomainModelPublished) |
JSON |