Skip to content

feat: DomainModeling.V2 — simplified session API for UI/API/MCP consumers#19

Draft
Copilot wants to merge 3 commits into
rewrite/domainmodeling-from-scratchfrom
copilot/create-simplified-domainmodeling-v2
Draft

feat: DomainModeling.V2 — simplified session API for UI/API/MCP consumers#19
Copilot wants to merge 3 commits into
rewrite/domainmodeling-from-scratchfrom
copilot/create-simplified-domainmodeling-v2

Conversation

Copy link
Copy Markdown

Copilot AI commented May 14, 2026

Introduces a new Poly.DomainModeling.V2 namespace with a streamlined, exception-safe authoring surface designed for UI, API, and MCP consumers. The core design principle: every mutation returns a DomainTransactionResult — no exceptions escape the session boundary.

New surface (Poly/DomainModeling/V2/)

  • DomainSession — wraps Domain with revision tracking (64-snapshot rolling window), cached AnalysisResult, and atomic Apply(intent[s]) that catches both intent-dispatch exceptions and analysis rollbacks into a uniform result
  • DomainSessionStore — thread-safe registry; Create() bootstraps canonical built-in types and seeds revision 0
  • DomainDispatcher — named convenience wrappers over session.Apply() (AddEntity, AddRelationship, etc.)
  • DomainSessionIntentExtensions — same surface as fluent extension methods on DomainSession
  • DomainModelSnapshot + SnapshotBuilder — immutable record projection of the live domain for serialization/diff
  • DomainRenderer — ASCII rendering for full domain, single entity, and stage summaries
  • ECommerceDemo — full e-commerce domain (Customer/Order/Product/Shipment/Payment/Review/Category) ported to V2 intent-based authoring with low-level effect/policy wiring
  • DomainSessionBuilder (internal) — fluent test builder for isolated unit tests

Engine change

DomainMutationIntentEngine gains ApplyWithTrace() overloads and an internal Populate() method, factoring the existing Apply() through a shared PopulateAndApply() path without behavioral change.

Usage

var store = new DomainSessionStore();
var (sessionId, session) = store.Create("Order Management");

// High-level extension methods
session.AddEntity("Order");
session.AddProperty("Order", "Status", "Text");  // separate Apply — intent dispatch resolves against committed state
session.AddStage("Order", "Pending");

// Dispatcher style
var dispatcher = new DomainDispatcher(session);
dispatcher.AddRelationship("CustomerOrders", "Customer", "Order", RelationshipCardinality.OneToMany, sourceOwnsTarget: true);

// Always returns a result, never throws
DomainTransactionResult result = session.Apply(new AddActionToEntityIntent("Order", "Cancel"));
// result.Succeeded, result.Revision, result.Diagnostics, result.Trace

// Immutable snapshot for serialization
DomainModelSnapshot snapshot = session.ToSnapshot();
string report = session.RenderAsText();

Key constraint: intent dispatch resolves object references against the already-committed domain state, so entity/event-type creation and subsequent property/stage additions must be in separate Apply() calls.

Original prompt

Create a new simplified DomainModeling.V2 implementation from scratch optimized for UI, API, and MCP consumers. Include: immutable core records, unified mutation dispatcher, session management with transactions/traces, high-level intent tools, e-commerce demo ported, analysis and rendering preserved. Place in Poly.DomainModeling.V2 namespace/folder. Make internal builder for tests.

Copilot AI and others added 2 commits May 14, 2026 12:41
…shots, renderer, and e-commerce demo

Agent-Logs-Url: https://github.com/scoizzle/Poly/sessions/2564565d-70e9-4c8e-8a29-e3b3f5178dca

Co-authored-by: scoizzle <2981795+scoizzle@users.noreply.github.com>
…, TrimSnapshots, comment clarity

Agent-Logs-Url: https://github.com/scoizzle/Poly/sessions/2564565d-70e9-4c8e-8a29-e3b3f5178dca

Co-authored-by: scoizzle <2981795+scoizzle@users.noreply.github.com>
Copilot AI changed the title [WIP] Create new simplified DomainModeling.V2 implementation feat: DomainModeling.V2 — simplified session API for UI/API/MCP consumers May 14, 2026
Copilot AI requested a review from scoizzle May 14, 2026 12:46
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