Skip to content

refactor(arch): move Commerce into Modules/Commerce - #1094

Merged
mforce merged 4 commits into
mainfrom
refactor/1087-commerce-module
Oct 5, 2026
Merged

mforce merged 4 commits into
mainfrom
refactor/1087-commerce-module

Conversation

@mforce

@mforce mforce commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Refs #1087

S6 of the package-by-module design: Commerce moves into Modules/Commerce in Domain, Application and Api. This is a pure move with no behaviour change. Its repositories and EF configuration stay in place until S9. Rebased onto 51e9cbb5 (#1093, Egg Operations) by resetting onto main and re-running the codemod per commit (split, move + prune, wording, marks); nothing was merged by hand. Proofs compare head 855f2e7b with base 51e9cbb5.

Review order

  1. 4124ec48 split (mechanical): 11 contract types leave 7 mixed files, each a verbatim slice in the same namespace. In Domain, EggUnit, ProductType, ProductUnit, PaymentMethod, SalesOrderStatus, DiscountReasonCode and ListPriceBasis leave their aggregates. In Application, UpdateEggUnitConversionCommand leaves its handler file, CustomerBalance leaves IPaymentRepository.cs, and SettlementScope and SalesOrderListFilter leave ISalesOrderRepository.cs.
  2. ce2d1103 move (generated; skim it): 73 git mvs; namespaces from folders; references, usings, ledger strings, snapshot entity names and paths rewritten by the tool. The rules file Namespaces now holds Cluckwork.Domain.Modules.Commerce and Cluckwork.Application.Modules.Commerce; Implementations is unchanged (S9). No codemod fix and no fixture hand fix were needed.
  3. 66fabc6e fix (read this one): the ICommerceModule, IEggOperationsModule, IFinanceModule and IInventoryModule comments said adapters reach the module "through the types marked [ModuleContract]"; they now name the Contracts folder. Those modules have all moved, so their comments were stale; IFarmModule is left to S7.
  4. 855f2e7b marks: the 36 Commerce [ModuleContract] marks deleted.

Change map

Before After
Domain/{Catalog,Sales}/** (8 files) Domain/Modules/Commerce/{Catalog,Sales}/
7 Domain enums (split out) Domain/Modules/Commerce/Contracts/
Application/Features/{Catalog,Customers,Sales}/** contracts (29 types) Application/Modules/Commerce/Contracts/
Application/Features/{Catalog,Customers,Sales}/** handlers, validators, modules, lookups, repository ports Application/Modules/Commerce/{Catalog,Customers,Sales}/**
Api/Endpoints/{Catalog,Customers,Sales}/* (4) and Api/Hosting/Modules/CommerceModuleServiceCollectionExtensions.cs Api/Modules/Commerce/** (Platform-owned adapters)
AppDbContextModelSnapshot.cs: 22 entity-name lines new CLR names; no migration, and no historical migration or Designer file changed

Checks at push time (rebased head 855f2e7b)

Check Result
dotnet build Cluckwork.sln 0 warnings
Application.Tests Architecture + TenantBypass + Documentation + ImagePin 474/474 (main 474)
Application.Tests Customer/Sale/Product/Payment/Commerce/EggUnitConversion classes; Domain.Tests 80/80; 495/495
ServingGuardCoverageTests, TrackedMutationReadTests 7/7, 2/2

Proofs (base 51e9cbb5 vs head 855f2e7b, re-run after the rebase)

Proof Result
EF migrations has-pending-model-changes "No changes have been made to the model since the last migration." No migration added. The only Migrations/ diff is the 22 snapshot entity-name lines. Control: HasMaxLength(Product.MaxNameLength + 1) makes the same command exit 1
EF with the base snapshot restored (51e9cbb5's AppDbContextModelSnapshot.cs at the head) exit 0, "No changes have been made to the model since the last migration": the 22 rewritten entity names change no relational model. With the head snapshot back and HasMaxLength(Product.MaxNameLength + 1), exit 1 ("Changes have been made to the model")
tools/schema-docs/generate.sh --check "docs/schema/ is up to date" (no content change)
Ordered DI descriptors, Production/Development × serving/one-shot × Redis absent/configured (8) identical after the type map
Generated OpenAPI document (Development) identical
Exact normalized contract set per owner identical: 160 types; Commerce 36 (7 in Domain Contracts, 29 in Application Contracts)
Module-edge report (live edges) the same 73 edges after the type map and the owner-root renames. Five old roots collapse into two (Domain.{Catalog,Sales} → Domain.Modules.Commerce, Application.Features.{Catalog,Customers,Sales} → Application.Modules.Commerce), so three Farm → Commerce edges list a root once instead of twice in ReferencedNamespaces. Compared as sets, every edge is identical
Peer-reach report identical
Table-owner report identical
Adapter-reach report identical except the expected registration entry, as in S1–S4: AddCommerceModule is now under the adapter root, with empty reach and the persistence ban passing
Tenant-bypass registry unchanged (0 changed lines)
coupling-matrix.md unchanged (CouplingMatrixRealTreeTests green)
Unused usings (IDE0005, whole solution) base 224, head 214. The codemod added none. The 11 gone were already-unused usings of the five emptied namespaces. One newly unused: global using Cluckwork.Domain.Common.Architecture; in Cluckwork.Domain/GlobalUsings.cs, because Commerce's enums carried the last Domain [ModuleContract] marks. The design keeps that using until S10

The type map covers every top-level declaration in the 73 moved files, read at the split commit. Positions (file, line) are excluded from the report comparison.

Mutations (spare worktree at the head; each case reset, built and run against the Architecture + TenantBypass filter)

# Mutation Result Contract-set diff vs base
M1a codemod moves Contracts/UpdateCustomerCommand.cs (file and namespace) back to Customers/UpdateCustomer/ red AdapterReachRealTreeTests (CustomerEndpoints reaches a non-contract type), CouplingMatrixRealTreeTests Commerce −UpdateCustomerCommand
M1b same file moved, .Contracts namespace kept red NamespaceFolderAgreementTests only none: the gap the folder rule closes
M1c codemod moves the Domain enum Contracts/SalesOrderStatus.cs back to Domain/Modules/Commerce/Sales/ not caught by a guard; only the contract-set diff sees it. No adapter or peer takes the enum as a parameter, so every guard stays green Commerce −SalesOrderStatus
M2 CustomerEndpoints.GetCustomer also injects ICustomerRepository red AdapterReachRealTreeTests, CouplingMatrixRealTreeTests —

M1c is the case Astra raised on #1088: a contract that no adapter or peer reaches can leave Contracts without any guard noticing; only the per-slice contract-set comparison sees it. This slice's comparison above is identical.

@mforce mforce added this to the Modular monolith milestone Oct 5, 2026
mforce added 4 commits October 5, 2026 22:59
move.py split: the seven Domain enums (EggUnit, ProductType, ProductUnit,
PaymentMethod, SalesOrderStatus, DiscountReasonCode, ListPriceBasis) leave
their aggregates, and UpdateEggUnitConversionCommand, CustomerBalance,
SettlementScope and SalesOrderListFilter leave their handler and repository
files, each into its own file in the same namespace. Each declaration is a
verbatim slice of the original.

Refs #1087
move.py move with the slice's table: Domain, Application and Api files go
under Modules/Commerce, contract types (including the seven Domain enums)
under Contracts, with the namespace taken from the folder. The current model
snapshot follows the moved entities; historical migrations and Designer
files are untouched. The rules file now names Cluckwork.Domain.Modules.Commerce
and Cluckwork.Application.Modules.Commerce; Implementations stay for S9.

Refs #1087
The comments on ICommerceModule, IEggOperationsModule, IFinanceModule and
IInventoryModule still said adapters reach the module through the types
marked [ModuleContract]; those marks are gone in moved modules.

Refs #1087
The thirty-six Commerce contract types now sit in Contracts folders
(Domain's seven enums, Application's twenty-nine types); the folder makes
them contract, and a type with both fails.

Refs #1087
@mforce
mforce force-pushed the refactor/1087-commerce-module branch from eb8de0a to 855f2e7 Compare October 5, 2026 23:02
@mforce
mforce merged commit deae524 into main Oct 5, 2026
19 checks passed
@mforce
mforce deleted the refactor/1087-commerce-module branch October 5, 2026 23:36
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.

1 participant