Skip to content

Introduce Poly.DomainModeling.V2 immutable domain core with mutation sessions and MCP-oriented authoring tools#18

Draft
Copilot wants to merge 3 commits into
masterfrom
copilot/rewritedomainmodeling-from-scratch-immutable-recor
Draft

Introduce Poly.DomainModeling.V2 immutable domain core with mutation sessions and MCP-oriented authoring tools#18
Copilot wants to merge 3 commits into
masterfrom
copilot/rewritedomainmodeling-from-scratch-immutable-recor

Conversation

Copy link
Copy Markdown

Copilot AI commented May 14, 2026

This PR adds a new Poly.DomainModeling.V2 foundation for UI/API/MCP consumers with an immutable domain model, unified mutation shape, and session-based mutation workflow. It establishes a clean v2 surface for future domain modeling evolution while keeping analysis, rendering, and validation first-class.

  • Immutable V2 domain primitives

    • Added immutable records for Domain, DomainType/Entity, Property, Stage, Action, Relationship.
    • Added IEffect hierarchy with concrete effects: SetProperty, TransitionStage, CreateEntity, InvokeAction.
    • Added relationship kind modeling via RelationshipKind.
  • Builder + DSL authoring surface (internals-backed)

    • Implemented internal fluent builders (DomainBuilder, EntityBuilder, ActionBuilder) with nested lambda composition.
    • Added public DSL entrypoint via DomainFactory.Create(...) and DSL wrappers (DomainDsl, EntityDsl, ActionDsl).
  • Unified mutation contract

    • Added DomainMutation + DomainMutationKind as a single mutation payload model for API/MCP workflows.
    • Implemented mutation application in DomainMutationEngine with immutable updates and validation enforcement.
  • Session lifecycle and traceability

    • Added DomainSessionManager with CreateSession, Mutate, and GetTrace.
    • Added revisioned session state (DomainSession) and mutation history (DomainTraceEntry).
  • MCP-style high-level operations

    • Added DomainMcpTools.CreateEntityWithPattern(...) for opinionated entity bootstrapping.
    • Added DomainMcpTools.AddCRUD(...) for standard action/effect scaffolding.
  • Analysis / rendering / validation support

    • Added DomainValidator, DomainAnalyzer, and DomainRenderer to keep quality and inspectability strong in the v2 surface.
  • E-commerce demo + focused tests

    • Added DomainModelingV2ECommerceDemo showing both DSL-first and session/mutation-driven composition.
    • Added v2-focused tests covering immutable DSL construction, session mutation trace flow, MCP helpers, and analysis/render/validation behavior.
using Poly.DomainModeling.V2;

var domain = DomainFactory.Create("ECommerce", d => d
    .Entity("Order", e => e
        .Property("Id", "Uuid", isRequired: true)
        .Stage("Draft", isInitial: true)
        .Action("Ship", a => a.Effect(new TransitionStage("Shipped"))))
    .Relationship("CustomerOrders", "Customer", "Order", RelationshipKind.OneToMany));

var sessions = new DomainSessionManager();
var session = sessions.CreateSession("ECommerce");
session = sessions.Mutate(session.SessionId, DomainMutation.AddEntity("Customer"));
var trace = sessions.GetTrace(session.SessionId);
Original prompt

Create a new simplified domain modeling system from scratch in Poly.DomainModeling.V2 (or similar) following this exact vision for UI/API/MCP consumers only: Immutable core records for Domain, DomainType/Entity, Property, Stage, Action, Relationship, IEffect hierarchy (SetProperty, TransitionStage, CreateEntity, InvokeAction, etc.). Internal DomainBuilder with fluent nested lambdas. Unified DomainMutation record for API/MCP. Session management with CreateSession, Mutate, GetTrace. High-level MCP tools (CreateEntityWithPattern, AddCRUD, etc.). Keep analysis, rendering, validation strong. Base it on the rewrite/domainmodeling-from-scratch branch. Include e-commerce demo. Make it the foundation for future great domain modeling.

Copilot AI changed the title [WIP] Create simplified domain modeling system for UI/API/MCP consumers Introduce Poly.DomainModeling.V2 immutable domain core with mutation sessions and MCP-oriented authoring tools May 14, 2026
Copilot AI requested a review from scoizzle May 14, 2026 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants