Repository navigation
refactor(api): split the endpoint groups out of Program.cs - #1257
Merged
Merged
Conversation
Move the /api/v1 MapGroup chains, the OAuth/MCP conditional mapping and the client-errors group verbatim into Hosting/CluckworkEndpointGroups.cs, called from the same position in Program.cs. Program.cs drops to 477 lines and leaves the FileSizeLimitTests legacy list. The three OAuth mutation-check mutants that anchored on the moved text now target the new file. Part of #1215
Cluckwork.Api.Hosting is outside AdapterReach's roots, so a direct route handler added inside MapCluckworkEndpointGroups escaped the persistence ban and the module-reach ledger that the same line in Program.cs meets. Move the class to Cluckwork.Api.Endpoints, an adapter root, and repoint the mutation-check path. Part of #1215
# Conflicts: # tests/Cluckwork.Application.Tests/Architecture/FileSizeLimitTests.cs
The /error ProblemDetails titles moved up to Program.cs:404,422, and the /export group policy now sits in CluckworkEndpointGroups.cs. Part of #1215
# Conflicts: # tests/Cluckwork.Application.Tests/Architecture/FileSizeLimitTests.cs
27 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1215
Moves the
/api/v1endpoint-group registration out ofProgram.csintoMapCluckworkEndpointGroupsinsrc/Cluckwork.Api/Endpoints/CluckworkEndpointGroups.cs.Program.cscalls it from the same position.Program.csgoes from 630 to 478 lines and leaves theFileSizeLimitTestslegacy list. Nothing else changes behavior.What moved and what stayed
Moved, verbatim and re-indented by eight spaces: the 20
MapGroup(...).Map*Endpoints()chains, the OAuth/MCP block that maps only when an issuer is configured, and the client-errors group (base lines 361–494).Stayed in
Program.cs:healthcheckearly return and theProcessRolescomputation/error,/api/{**rest},/health/{**rest}and the SPA fallbackEndpoint-group order relative to the middleware and to the routes after it is unchanged. Moving the endpoint groups was the only cut that keeps registration order and moves nothing an in-test guard reads.
tools/oauth/mutation-check.shis the one reader that had to follow.The class lives in
Cluckwork.Api.Endpoints, notHosting.Hostingis outside the adapter-reach roots. UnderHosting, a handler later added inside this method could takeAppDbContextor reach a new module and still pass the reach guard. The same line inProgram.csfails it. UnderEndpointsthe guard walks the method. Its reach is empty (WebApplicationandCluckworkIdentityRegistrationare Platform), so the ledger and the coupling matrix are unchanged. Regenerating the matrix produced no diff.Readers of Program.cs
CredentialEpochMiddlewareOrderTestsUseAuthentication…IdempotencyMiddlewaresequence andUseExceptionHandler(, by pathMap*route calls inProgram.cstop-level statementsMapGroupis not a route callMapCluckworkEndpointGroups; empty reach, no ledger rowsrc/treeApi.*is the Platform hub, andMapMcpis still inHosting/CluckworkMcp.cstools/oauth/mutation-check.shENDPOINT_GROUPS, anchors re-indented; each matches onceAddSingleton/AddHostedServicecensussrc/docs/architecture.md, decisions 806 and 846Program.csProof of a pure move
Program.cslines 361–494 equal the new method body byte for byte after removing the eight-space indent (134 lines).Program.csis byte-identical to base, apart from the usings and the one call line. The diff removes 20 usings, which only the moved block needed, and addsusing Cluckwork.Api.Endpoints;.Route parity
A temporary
WebApplicationFactorytest dumpedEndpointDataSourcein enumeration order on base and head. It recorded pattern, HTTP methods, order, names, handler signatures and metadata: authorization policies, anonymous access, rate limits, body caps and tags. It ran in four cases:The comparison ignores only
ParameterInfo.MetadataTokenvalues, which are row ids in the assembly metadata table and shift when a method is added.Checks
dotnet build Cluckwork.slnx: 0 warnings, 0 errors (IDE0005 enforced).MapGetwithAppDbContextandICommerceModuleparameters inside the new method turnsAdapterReachRealTreeTestsred for both the forbidden persistence type and the undeclared Commerce reach. With the probe removed, the test is green again.tools/oauth/mutation-check.shwithMUTANT_FILTERon the three repointed mutants: all 3 killed (farm-apps-not-owner-only,mcp-mapped-without-issuer,customers-route-admin-only). Baseline and restore runs were both 509/509 green.Merged with main at 56f90ac
The merge brought in #1256 and #1258 through #1266. One conflict, in
FileSizeLimitTests.cs: I took main'sLegacylist and removed only theProgram.csrow, leavingweb/src/styles.css. Main's oneProgram.cschange (UseTrustedForwardedHeaders, #1260) sits in the pipeline that stays inProgram.csand merged cleanly.tools/oauth/mutation-check.shmerged cleanly and still points its three mutants atCluckworkEndpointGroups.cs. The merge needed no change tomodule-ledger.json, the adapter rows or the coupling matrix.Repointed citations (commit 45cbc59):
tools/verify/features/products.md:120src/Cluckwork.Api/Program.cs:556,574src/Cluckwork.Api/Program.cs:404,422(the two "Concurrency conflict" titles in/error)src/Cluckwork.Api/Modules/Insights/Export/ExportEndpoints.cs:11Program.csCluckworkEndpointGroups.csPlans, designs and decision-record narratives keep their old citations as history.
Checks on the merged head:
dotnet build Cluckwork.slnx: 0 warnings, 0 errors.MapCluckworkEndpointGroupsis still red for both the forbiddenAppDbContextand the undeclared Commerce reach, and green again once removed.