Architecture Decision Record
ADR-034: Generic Entity Controllers with a Dynamic Query Contract
Status
Accepted (2026-06-30). Amended (2026-07-23): the filter strategy registry now also
covers long/long? via LongFilterStrategy. Amended (2026-07-25): the keyed
by-id fast path is named TryGetFastPathIncludes in code; citations rebased.
Extended by ADR-099 (2026-08-29, v1.170.0): the write
half this record left at create and delete gains a generic update, through an
IEntityUpdateCommandApplier the module implements, an UpdateEntityCommand / UpdateEntityHandler pair,
an AddEntityCrud registration for all three verbs, and a CrudEntityControllerBase carrying the
PUT. The PUT ships on a new derived base rather than on AggregateRootEntityControllerBase, whose
generic arity is deliberately unchanged; everything below is untouched.
Revised (2026-08-31): the update-applier interface is named IEntityUpdateCommandApplier
(Source/Core/MMCA.Common.Application/UseCases/Crud/IEntityUpdateCommandApplier.cs:38); source
citations below rebased to their current lines.
Revised 2026-09-07 (sort keys, filter keys and lookup name columns resolve against the response
contract rather than the entity, navigation depth and lookup rows are capped, and the selector cache
is bounded).
Revised 2026-10-21: the generic create now builds its Location itself and returns Created
rather than CreatedAtRoute, the filter registry also covers the Email value object, and the
fail-closed CSV export is recorded among the virtual reads; anchors refreshed.
Revised 2026-10-26: anchors refreshed after the create's Location and Created lines and the
delete action in AggregateRootEntityControllerBase.cs moved up one line.
Revised 2026-10-28: eight filter strategies (seven built-in primitive strategies plus the strongly
typed identifier) implement CanParseValue, not six; EmailFilterStrategy takes the default.
Revised 2026-11-23: the read base also declares two opt-in GET routes, a keyset cursor page and a
changes feed, both virtual and clamped to MaxPageSize; anchors refreshed.
Revised 2026-11-30 (v1.324.0): an IN filter with an unparseable item and a request with more than
MaxFilters (50) filters are validation errors (400) instead of a silently narrowed or widened result;
QueryFilterService.RegisterStrategy and its mutable registry are removed; PagingMath.Clamp returns a
PageWindow; a list read with a specification takes the specification's ordering as its default when
the request names no sort, and the request's sort and paging win otherwise (the repository side is
ADR-055's). System.Linq.Dynamic.Core stays, deliberately. See the Revision (2026-11-30) at the end.
Context
Every module exposes many entities, and most of them need the same read and write surface: list, page, look up for a dropdown, fetch by id, create, delete. Hand writing a controller, a query service, and a filter/sort/paginate implementation per entity is repetitive, drifts in shape from one entity to the next, and is the bulk of the boilerplate a modular monolith accumulates as it grows.
The framework chose the opposite default: a generic resource layer plus an OData-lite dynamic query contract that every entity inherits for free, rather than bespoke per-entity endpoints. A concrete controller is a few lines that close the generic type parameters; the verbs, routes, filtering, sorting, pagination, field projection, and include behavior come from the base. The mechanics are documented in the onboarding chapters; the trade-off this represents (a generic, dynamically queryable contract coupled to the entity model versus narrow bespoke endpoints) was never recorded as a decision.
Decision
Give every entity a generic REST resource surface and a bounded dynamic query contract, supplied by two controller bases over a shared query pipeline.
Generic read controller.
EntityControllerBase<TEntity, TEntityDTO, TIdentifierType>(Source/Presentation/MMCA.Common.API/Controllers/EntityControllerBase.cs:33,[ApiController]/[Route("[controller]")]/[ApiVersion("1.0")]atEntityControllerBase.cs:30-32) exposes four core GET routes for any entity (plus a[HttpGet("export")]CSV action atEntityControllerBase.cs:253, between the paged and lookup routes):[HttpGet]list (EntityControllerBase.cs:106),[HttpGet("paged")](EntityControllerBase.cs:153),[HttpGet("lookup")]for id/name dropdown entries (EntityControllerBase.cs:318), and[HttpGet("{id}")](EntityControllerBase.cs:357). Two further GET routes are declared on the base but are opt-in through[OptInAction]:[HttpGet("cursor")](EntityControllerBase.cs:403, gated onSupportsCursorPagingAttributeat:404), a keyset page ordered by the sort column withIdas tie-break, and[HttpGet("changes")](EntityControllerBase.cs:456, gated onSupportsChangeFeedAttributeat:457), a change feed of upserts and tombstones ordered by(LastModifiedOn, Id). Both clamp the page size toMaxPageSize(:419,:467) and are scoped byGetReadSpecificationAsync; the cursor read takes no filters, field projection or includes and emits no pagination header (remarks at:398-402).Generic write controller.
AggregateRootEntityControllerBase<TEntity, TEntityDTO, TIdentifierType, TCreateRequest>(Source/Presentation/MMCA.Common.API/Controllers/AggregateRootEntityControllerBase.cs:29) inherits all of the above and adds[HttpPost]create (AggregateRootEntityControllerBase.cs:75) and[HttpDelete("{id}")](AggregateRootEntityControllerBase.cs:106). The create returns 201 throughCreated(location, created)(AggregateRootEntityControllerBase.cs:97), with theLocationresolved before the result is returned:Url.Link(GetByIdRouteName, ...)when the named route resolves (:93,GetByIdRouteNamedefaulting toGet{EntityName}ByIdat:57), otherwise the new id appended to the collection path the POST was made to (:95). The create action is decorated with[Idempotent](AggregateRootEntityControllerBase.cs:76) so a retried POST does not create a duplicate (ADR-017).Sparse fieldsets via
fields. A comma-separatedfieldsquery parameter (EntityControllerBase.cs:110,:162,:366) drives a server-side projection:QueryFieldService.ApplyFieldSelection(Source/Core/MMCA.Common.Application/Services/QueryFieldService.cs:290) builds aMemberInitexpression that selects only the requested writable properties (QueryFieldService.cs:358) so only those columns leave the database. The compiled projections are cached per field set, capped atMaxCacheEntries512 (QueryFieldService.cs:39); once the cache is full, a new field set skips the server-side projection (QueryFieldService.cs:310-318) and the response is still trimmed to the requested fields.Dynamic per-type filtering. The paged route binds
Dictionary<string, (string Operator, string Value)> filtersthrough[ModelBinder(typeof(QueryFilterModelBinder))](EntityControllerBase.cs:165), which parsesfilters[Property].operator/filters[Property].valuequery keys (Source/Presentation/MMCA.Common.API/ModelBinders/QueryFilterModelBinder.cs:24).QueryFilterService.ApplyFilters(Source/Core/MMCA.Common.Application/Services/Filtering/QueryFilterService.cs:82, with a second overload at:103) resolves aIFilterStrategy(Source/Core/MMCA.Common.Application/Services/Filtering/IFilterStrategy.cs:6) per property CLR type from a strategy registry (string, bool, int, long, DateTime, decimal, Guid and their nullables, plus theEmailvalue object throughEmailFilterStrategy; declared atQueryFilterService.cs:34, entries at:37-50), each strategy declaring itsSupportedOperators(IFilterStrategy.cs:24). Extra types register viaQueryFilterService.RegisterStrategy(QueryFilterService.cs:66; removed by the Revision (2026-11-30): the built-in map is frozen and no extra type registers); a strongly typed identifier column (ADR-115) needs no registration, becauseResolveStrategy(QueryFilterService.cs:413) builds aStronglyTypedIdFilterStrategyon first use (:421) and memoizes it beside the built-ins.Sort.
sortColumn/sortDirection(EntityControllerBase.cs:160-161) feedQueryFieldService.ApplySorting(QueryFieldService.cs:162, second overload at:191), anOrderBy("<col> ascending|descending")over the entity property the DTO name maps to.Pagination and the
X-Paginationheader. The paged route clamps the requested page size withMath.Min(pageSize, MaxPageSize)(EntityControllerBase.cs:168), whereMaxPageSizeresolvesIOptions<ApplicationSettings>from the request's services and falls back to 500 (EntityControllerBase.cs:58, resolution at:62, default atSource/Core/MMCA.Common.Application/Settings/ApplicationSettings.cs:17), then clamps the configured value to between 1 andEntityQueryPipeline.MaxUnboundedResultLimit(EntityControllerBase.cs:63), so configuration cannot raise the page size above the pipeline ceiling. It is read per request rather than captured in the constructor so a configuration change takes effect without a restart. The pagination metadata is serialized into theX-Paginationresponse header byResponse.AppendPaginationHeader(EntityControllerBase.cs:187; header name atSource/Presentation/MMCA.Common.API/Pagination/PaginationHeaderExtensions.cs:17).A last-resort safety ceiling. Independent of the API page-size clamp,
EntityQueryPipeline.MaxUnboundedResultLimit = 1000(Source/Core/MMCA.Common.Application/Services/Query/EntityQueryPipeline.cs:23) caps any unpaginated query withquery.Take(MaxUnboundedResultLimit), at three call sites (EntityQueryPipeline.cs:99,:195,:250), andApplyPagingclamps a paged request to the same limit (EntityQueryPipeline.cs:278-281), so even a direct service caller that omits pagination cannot trigger an unbounded full-table load.Two include paths.
includeFKs/includeChildren(EntityControllerBase.cs:111-112for the list overload,:158-159for the paged overload) select navigation loading.EntityQueryPipeline(EntityQueryPipeline.cs:13) runs PATH 1 for source-supported includes via EF Core.Include()translated to SQL (EntityQueryPipeline.cs:129-135) and PATH 2 for unsupported includes via manualINavigationPopulatorbatch loading after materialization (EntityQueryPipeline.cs:50), the populator strategy of ADR-002.
Rationale
- Write the resource surface once, inherit it everywhere. The verbs, routes, filter contract, pagination, and header are defined once on the two bases; a concrete controller closes the type parameters and gets a uniform, predictable contract. New entities cost almost nothing and cannot drift in shape.
- Bounded dynamic querying, not open SQL. Filtering is dynamic over the wire but
not unbounded in the engine: each property is filtered only by a registered
IFilterStrategywhoseSupportedOperatorsare validated before the database is touched (QueryFilterService.ValidateFilters,QueryFilterService.cs:167and:183, invoked atSource/Core/MMCA.Common.Application/Services/EntityQueryService.cs:304), andMaxUnboundedResultLimit(EntityQueryPipeline.cs:23) plus theMaxPageSizeclamp (EntityControllerBase.cs:168) bound the result size. - Composes with manual DTO mapping (ADR-001). Entities are projected to DTOs by
an injected
IEntityDTOMapper(EntityQueryService.cs:36, property at:91) viaDTOMapper.MapToDTOs(EntityQueryService.cs:361); aDTOToEntityPropertyMap(EntityQueryService.cs:101) translates DTO field names to entity property paths for filter and sort, so the wire contract speaks DTO names while the engine speaks entity names. - Composes with populators (ADR-002). The unsupported-include path delegates to
INavigationPopulator(EntityQueryService.cs:37), the same cross-source batch loader that bridges relationships EF cannot JOIN.
Trade-offs
- The wire contract tracks the entity model. Filterable, sortable, and
projectable surface is the entity's property set. A model change is an API change
unless mediated by the DTO and
DTOToEntityPropertyMap(EntityQueryService.cs:101), which is the boundary that decouples the two when needed. - Dynamic filtering is an injection and over-fetch surface. Arbitrary
client-supplied property/operator/value triples are an attack surface; it is
bounded by validating properties and operators up front
(
QueryFilterService.ValidateFilters,QueryFilterService.cs:167), routing each type through its registeredIFilterStrategyrather than free-form expression evaluation, and capping rows withMaxUnboundedResultLimit(EntityQueryPipeline.cs:23). Sparse fieldsets reject non-writable properties withInvalidEntityFieldduring field validation (QueryFieldService.cs:576-578), and the projection itself selects only writable properties (QueryFieldService.cs:358). - Generic endpoints are less self-documenting than bespoke ones. One generic shape per entity is consistent but conveys less domain intent than a named, purpose-built endpoint; the query contract (filter key syntax, operators) must be learned once rather than read off each endpoint.
- Opting out means overriding the base. All five default reads (list, paged, CSV export,
lookup and by-id:
EntityControllerBase.cs:109,:157,:258,:321,:362), the two opt-in reads (cursor and change feed::408,:461) and the two writes (AggregateRootEntityControllerBase.cs:80,:111) arevirtual, so a controller that needs bespoke behavior overrides the specific action rather than abandoning the base, but the default surface is opt-out, not opt-in. The two opt-in reads are the exception: their convention is read off the base action, so an override still needs[SupportsCursorPaging]or[SupportsChangeFeed]on the controller or it is removed as well (OptInActionAttribute.cs:12-13,:29-32;SupportsCursorPagingAttribute.cs:14,SupportsChangeFeedAttribute.cs:14). - The CSV export widens the inherited surface, so it fails closed.
ExportAsync(EntityControllerBase.cs:258) reads pages ofMaxPageSizerows (:278) up toMaxExportRows(defaultDefaultMaxExportRows100_000,EntityControllerBase.cs:513; settings default atSource/Core/MMCA.Common.Application/Settings/ApplicationSettings.cs:33), announcing that ceiling in theX-Export-Row-Limitheader (ExportRowLimitHeaderName:522, appended at:681). When the controller declares no row scope it refuses with a 403 carryingExport.RowScopeRequired(:274-275, code at:528) unlessAllowUnscopedExport(:549, defaultfalse) opts in, so a controller that forgot to scope its export serves no rows rather than every row.
Revision (2026-09-07)
The query layer's shape is unchanged. What a caller is allowed to name is not, from the 2026-09-07 security review.
- Client keys resolve against the DTO contract (SEC-Common-25 / SEC-ADC-09).
QueryFieldContract(MMCA.Common/Source/Core/MMCA.Common.Application/Services/Query/QueryFieldContract.cs:34) holds a response type's public property names, built withFor<TContract>()(:56) or narrowed withForNames(:83), and tested throughAllowsClientKey(:103).EntityQueryService.FieldContractdefaults toQueryFieldContract.For<TEntityDTO>()(MMCA.Common/Source/Core/MMCA.Common.Application/Services/EntityQueryService.cs:123) and flows throughEntityQueryParametersinto sorting and filtering. A key the property map does not cover must name a contract field, and a dotted path the server did not author is refused, so a caller can neither order a public page by a column the mapper redacts nor turn a list endpoint into an inference oracle over the object graph. OverridingFieldContractwithnullrestores the old entity-based resolution. - Navigation depth is capped at three segments.
QueryFieldContract.MaxNavigationDepth(:42) is enforced byIsWithinNavigationDepth(:115,:130) on any resolved entity path, whoever authored it. A self-referencing segment repeated hundreds of times is otherwise that many LEFT JOINs from one anonymous request (SEC-Store-13). - The lookup read is contract-bound and capped (SEC-Common-24).
EntityQueryService.LookupNameContract(:135, defaulting toFieldContract) validates the caller'snamePropertyand answers 400 for anything else (:393), andEFReadRepository.GetAllForLookupAsyncappliesEntityQueryPipeline.MaxUnboundedResultLimit(1000,MMCA.Common/Source/Core/MMCA.Common.Application/Services/Query/EntityQueryPipeline.cs:23) atMMCA.Common/Source/Core/MMCA.Common.Infrastructure/Persistence/Repositories/EFReadRepository.cs:244. The lookup was the one read that never entered the pipeline enforcing that limit. - The selector cache is bounded and canonically keyed (SEC-Store-14).
QueryFieldServicecaps the compiled-selector cache atMaxCacheEntries512 (MMCA.Common/Source/Core/MMCA.Common.Application/Services/QueryFieldService.cs:39, documented at:323and:574) and keys on the property's canonical name, so the case permutations of one real column collapse onto a single entry instead of minting an unevictable one each.
Adopting this is a behaviour change. A client key naming a field only the entity carries now
answers 400. The fix is to add the field to the DTO, map it in DTOToEntityPropertyMap, or override
FieldContract.
Related
ADR-001 (manual DTO mapping: the generic controllers project through
IEntityDTOMapper), ADR-002 (navigation populators: the unsupported-include path),
ADR-013 (Result pattern at the edge: every action returns through
HandleFailure(result.Errors), EntityControllerBase.cs:128), ADR-017 (idempotency:
the generic create is [Idempotent], AggregateRootEntityControllerBase.cs:76),
ADR-019 (rate limiting: these GET routes are the authenticated read surface the
always-on global limiter caps per principal).
Revision (2026-07-24)
Filter and pagination corrections from a code review. The contract shape is unchanged; these close cases where the engine widened a result set instead of narrowing it, or reported a total it did not have.
- An unparseable filter value is a 400, not an unfiltered read. Every strategy silently returned
the query unchanged when it could not parse a value, and validation never looked at values at all,
so
?filter=id:equals:abcreturned the whole (capped) result set rather than no matches. That is the wrong direction for a fail-safe default on an endpoint whose filter may be the only scoping.IFilterStrategy.CanParseValue(a default interface member returningtrue, so custom strategies are unaffected until they opt in) is implemented by the six value-type strategies and checked inValidateFilters, which now emitsFilter.Value.Invalid. Presence operators still ignore the value,INneeds at least one parseable item, andBETWEENneeds exactly two bounds. - A mapped filter is applied, not silently dropped.
ApplyFiltersandValidateFiltersdisagreed on how to resolve aDTOToEntityPropertyMapentry: validation fell back to the mapped entity name while application retried the DTO name. A plain rename entry therefore passed validation and was then skipped, returning an unfiltered result set with a 200. Both now share one resolver, so anything validation accepts is what gets applied. - Pagination edges. The Skip offset was computed with checked 32-bit arithmetic, so a page
number near
int.MaxValueoverflowed into a 500 instead of the empty page it describes; it is now 64-bit and range-checked. An unpaginated read reported theMaxUnboundedResultLimitsafety cap asTotalItemCount, telling callers the set was exactly that size; it now issues a count query only when the materialized rows actually reach the cap.PaginationMetadata.PageSizereports the size the pipeline applied rather than the one requested. - The keyed by-id fast path is reachable again. The fast-path predicate treated
includeFKsas disqualifying whileGetByIdAsyncdefaults it totrue, so every REST by-id read fell through to the dynamic-filter pipeline (a parsed string predicate,TOP 1000, and a client-sideFirstOrDefault) where a keyedTOP 1 WHERE Id = @idwould do. The flags now disqualify only when the entity actually has navigations to include.
Revision (2026-07-25)
Citation maintenance from an ADR audit. No decision or behavior changed; the source anchors above were rebased to their current declaration and call-site lines.
- The fast-path predicate is named
TryGetFastPathIncludes. Revision item 4 above referred to it asIsPrimaryKeyOnlyLookup, a symbol that no longer exists in the framework source. The current method (Source/Core/MMCA.Common.Application/Services/EntityQueryService.cs:162, called from the by-id fast path atEntityQueryService.cs:130) both decides whether the request is a plain key lookup and returns the navigations it must eager-load. The described behavior is unchanged: requested include flags no longer disqualify on their own, and only unsupported (cross-source) includes send the read back to the pipeline (EntityQueryService.cs:185-188).
Revision (2026-10-01)
No decision or rationale changed; this records clarifications and refreshed citations from an ADR audit.
MaxPageSizeis clamped to the pipeline ceiling. The resolved setting is nowMath.Clamp(settings?.MaxPageSize ?? 500, 1, EntityQueryPipeline.MaxUnboundedResultLimit)(Source/Presentation/MMCA.Common.API/Controllers/EntityControllerBase.cs:64), so a configured page size above 1000 or below 1 no longer reaches the pipeline, andApplyPagingclamps to the same limit (Source/Core/MMCA.Common.Application/Services/Query/EntityQueryPipeline.cs:278-281).- The column-narrowing projection is bounded. Once the field-set projection cache holds
MaxCacheEntries512 entries (Source/Core/MMCA.Common.Application/Services/QueryFieldService.cs:39), a new field set skips server-side projection (QueryFieldService.cs:298-299) rather than growing the cache; the response is still shaped to the requested fields. - Strongly typed identifiers filter without registration.
ResolveStrategybuilds and memoizes aStronglyTypedIdFilterStrategyfor an ADR-115 identifier column (Source/Core/MMCA.Common.Application/Services/Filtering/QueryFilterService.cs:406-416). - Non-writable sparse fields are rejected at validation.
InvalidEntityFieldis raised inValidateFields(QueryFieldService.cs:517-523); the projection only filters to writable properties (QueryFieldService.cs:337).
Citations in Decision, Rationale, Trade-offs and Related were rebased to their current lines
(EntityControllerBase.cs, QueryFieldService.cs, QueryFilterService.cs, EntityQueryPipeline.cs,
EntityQueryService.cs). Anchors inside the earlier Revision sections are left as recorded.
Revision (2026-10-06)
No decision, rationale or behavior changed; this pass refreshes citations from an ADR audit.
- Anchors recorded in earlier Revision sections have moved. They stay as recorded; the current
locations are: the fast-path predicate
TryGetFastPathIncludesis declared atSource/Core/MMCA.Common.Application/Services/EntityQueryService.cs:196, called from the by-id fast path at:164, and sends a read with unsupported includes back to the pipeline at:219-222;EFReadRepository.GetAllForLookupAsyncappliesMaxUnboundedResultLimitatSource/Core/MMCA.Common.Infrastructure/Persistence/Repositories/EFReadRepository.cs:246; theMaxCacheEntriescap is documented atQueryFieldService.cs:328and:619; the projection-cache skip is atQueryFieldService.cs:302-303, the writable-only projection at:341, and the non-writableInvalidEntityFieldrejection at:559-561.
Anchors in Decision and Trade-offs were re-verified against current source and rebased
(EntityControllerBase.cs, QueryFieldService.cs). Anchors inside the earlier Revision sections are
left as recorded.
Revision (2026-10-21)
Re-verified against current source. The two controller bases, the dynamic query contract and the pipeline bounds are unchanged; the create's 201 construction, the filter type list and the read surface moved.
- The create resolves its own
Location.CreateAsync(Source/Presentation/MMCA.Common.API/Controllers/AggregateRootEntityControllerBase.cs:80) returnsCreated(location, created)(:98) instead ofCreatedAtRoute. The location isUrl.Link(GetByIdRouteName, ...)when that route resolves (:94), otherwise the new id appended to the request's collection path (:96), so a derived controller that does not declare the named route no longer turns a saved create into a 500 when the result executes (rationale at:67-74). - The filter registry covers
Email. The built-in entries (Source/Core/MMCA.Common.Application/Services/Filtering/QueryFilterService.cs:37-50) now include[typeof(Email)] = new ValueObjects.EmailFilterStrategy()(:50); Decision item 4 lists it. - The CSV export is part of the inherited read surface.
ExportAsync(Source/Presentation/MMCA.Common.API/Controllers/EntityControllerBase.cs:257) is a fifthvirtualread. It pages atMaxPageSize(:277), stops atMaxExportRows(default 100_000,:472), announces the ceiling inX-Export-Row-Limit(:481, appended at:625) and refuses an unscoped export with a 403Export.RowScopeRequired(:273-274,:487) unlessAllowUnscopedExport(:508) opts in. Trade-offs records it. - Anchors re-verified against current source:
AggregateRootEntityControllerBase.csclass:29,[HttpPost]:75,[Idempotent]:76,[HttpDelete("{id}")]:107,DeleteAsync:112;EntityControllerBase.csreads:110,:158,:257,:320,:361;QueryFilterService.csregistry:34,ApplyFilters:81and:102,RegisterStrategy:65,ValidateFilters:166and:182,ResolveStrategy:413,StronglyTypedIdFilterStrategy.TryCreate:421;EntityQueryService.csValidateFilterscall:304,MapToDTOs:361, and (for revision 2026-09-07 item 3, left as recorded) theLookupNameContractcheck at:394;EFReadRepository.GetAllForLookupAsyncappliesMaxUnboundedResultLimitatSource/Core/MMCA.Common.Infrastructure/Persistence/Repositories/EFReadRepository.cs:245, with the otherTakeat:288.
Revision (2026-10-26)
Re-verified against current source. No decision, rationale or behavior changed: the create still
resolves its own Location and returns Created, and the delete is still a virtual write. Only
the line anchors in AggregateRootEntityControllerBase.cs moved.
- Anchors re-verified against current source:
Source/Presentation/MMCA.Common.API/Controllers/AggregateRootEntityControllerBase.csclass:29,GetByIdRouteName:57, rationale remarks:67-74,[HttpPost]:75,[Idempotent]:76,CreateAsync:80,Url.Link:93, collection-path fallback:95,Created(location, created):97,[HttpDelete("{id}")]:106,DeleteAsync:111(rebased in Decision item 2 and Trade-offs). Anchors inside the earlier Revision sections are left as recorded; the revision 2026-09-07 item 3LookupNameContractcheck stays at the:394revision 2026-10-21 item 4 gives.
Revision (2026-10-28)
Re-verified against current source. No decision, rationale or behavior changed. The fail-closed value check of revision 2026-07-24 item 1 holds, but its count of implementing strategies is stale; that section is left as recorded and the current set is stated here.
- Eight strategies implement
CanParseValue, not six. The default interface member returnstrue(Source/Core/MMCA.Common.Application/Services/Filtering/IFilterStrategy.cs:44). The private helperValidateValueParseablechecks it (Source/Core/MMCA.Common.Application/Services/Filtering/QueryFilterService.cs:318), called fromValidateSingleFilteratQueryFilterService.cs:297underValidateFilters(QueryFilterService.cs:182), and the error it adds still namesValidateFiltersas its source (QueryFilterService.cs:323). Seven built-in primitive strategies implement it:StringFilterStrategy.cs:26,BoolFilterStrategy.cs:20,IntFilterStrategy.cs:25,LongFilterStrategy.cs:24,DateTimeFilterStrategy.cs:25,DecimalFilterStrategy.cs:24andGuidFilterStrategy.cs:21(all underSource/Core/MMCA.Common.Application/Services/Filtering/), plusStronglyTypedIdFilterStrategy.cs:34.EmailFilterStrategy(Source/Core/MMCA.Common.Application/Services/Filtering/ValueObjects/EmailFilterStrategy.cs:27) does not implement it and so takes the default. - Anchors re-verified against current source:
IFilterStrategy.CanParseValuedefault:44,QueryFilterService.csvalue check:318andEmailregistry entry:50. The by-id fast path anchors recorded in revisions 2026-07-25 and 2026-09-07 stay as recorded; revision 2026-10-06 item 1 already gives their current locations.
Revision (2026-11-23)
Re-verified against current source. The two controller bases, the dynamic query contract, the
pipeline bounds and the fail-closed export are unchanged; the read base gained two opt-in routes and
the EntityControllerBase.cs, QueryFieldService.cs and QueryFilterService.cs anchors moved.
- Two opt-in GET routes sit on the read base.
[HttpGet("cursor")](Source/Presentation/MMCA.Common.API/Controllers/EntityControllerBase.cs:403,GetCursorPageAsync:408) returns a keyset page ordered by the sort column withIdas tie-break, and[HttpGet("changes")](:456,GetChangesAsync:461) returns a change feed of upserts and tombstones ordered by(LastModifiedOn, Id). Each exists only on a controller carrying its attribute through[OptInAction](SupportsCursorPagingAttribute:404,SupportsChangeFeedAttribute:457), clamps the page size toMaxPageSize(:419,:467) and is scoped byGetReadSpecificationAsync. Both arevirtual. Decision item 1 and Trade-offs record them. - Anchors re-verified against current source:
EntityControllerBase.csattributes:30-32, class:33,MaxPageSize:58, settings read:62,Math.Clamp:63,[HttpGet]:106, list read:109, listfields:110and include flags:111-112,HandleFailure(result.Errors):128,[HttpGet("paged")]:153, paged read:157, paged include flags:158-159, sort parameters:160-161, pagedfields:162, filter binder:165,Math.Min:168,AppendPaginationHeader:187,[HttpGet("export")]:253,ExportAsync:258, unscoped refusal:274-275, export page size:278,[HttpGet("lookup")]:318, lookup read:321,[HttpGet("{id}")]:357, by-id read:362, by-idfields:366,DefaultMaxExportRows:513,ExportRowLimitHeaderName:522,ExportRowScopeRequiredErrorCode:528,AllowUnscopedExport:549, header append:681;Source/Presentation/MMCA.Common.API/Pagination/PaginationHeaderExtensions.cs:17(X-Pagination);Source/Core/MMCA.Common.Application/Settings/ApplicationSettings.cs:17(MaxPageSize500) and:33(MaxExportRows100_000);QueryFieldService.csMaxCacheEntries:39,ApplySorting:162and:191,ApplyFieldSelection:290, cache-full skip:310-318, writable-only projection:358, non-writableInvalidEntityField:576-578;QueryFilterService.csApplyFilters:82and:103,RegisterStrategy:66,ValidateFilters:167and:183,ValidateValueParseablecall:298and declaration:306,Filter.Value.Invalid:322with sourcenameof(ValidateFilters):324,ResolveStrategy:413. Anchors inside the earlier Revision sections are left as recorded.
Revision (2026-11-30)
MMCA.Common v1.324.0 (MMCA.Common/CHANGELOG.md:19, :37). The generic surface and the query contract
are unchanged in shape; four places where a malformed or oversized request was silently reinterpreted
now answer 400, and the list order follows a specification when the request names none.
INis strict. AnINvalue list is valid only when every item parses (MMCA.Common/Source/Core/MMCA.Common.Application/Services/Filtering/FilterValueParser.cs:55-63,EveryItemParsesat:78-82); one unparseable item fails validation withFilter.Value.Invalid, the codeBETWEENalready used (.../Services/Filtering/QueryFilterService.cs:331-338). Before this release at least one parseable item sufficed (the Revision (2026-10-28) records that rule) and the others were dropped, narrowing the result without telling the caller.- Too many filters is an error, not a truncation.
QueryFilterService.MaxFiltersis 50 (QueryFilterService.cs:42), andValidateFiltersrefuses a larger set as a whole, before any key is resolved, withFilter.TooMany(:196-203; translated atMMCA.Common/Source/Presentation/MMCA.Common.API/Resources/ErrorResources.resx:202andErrorResources.es.resx:202).QueryFilterModelBinder.MaxFiltersis the same constant (.../MMCA.Common.API/ModelBinders/QueryFilterModelBinder.cs:34), and the binder no longer drops the surplus, which widened the result past what the caller asked for. - The strategy registry is frozen.
RegisterStrategyand its process-wide mutable registry are removed (no adopter); the built-in strategies are aFrozenDictionaryfixed at type initialization (QueryFilterService.cs:45-62), and strongly typed identifier strategies are still built on first use and memoized, keyed by model CLR types only (:68, resolved at:425). PagingMath.Clampreturns aPageWindow.PageWindow(PageNumber, PageSize, Skip, Take)(.../Services/Query/PageWindow.cs:23;PagingMath.cs:33) replaces the(Skip, Take)tuple, so the clamped page and size used for the pagination metadata come from the same computation as the skip.- Sort precedence on a list read with a specification: the request wins. The specification's
OrderBybecomesEntityQueryParameters.DefaultOrdering(.../Services/Query/EntityQueryParameters.cs:25, set at.../Services/Query/EntityQueryService.cs:329) and applies only when the request sends nosortColumn(.../Services/Query/EntityQueryPipeline.cs:250-261); the request's paging pages the read and the specification's ownSkip/Takedoes not, andTotalCountcounts the filtered set before the page is taken (EntityQueryService.cs:321-326). A consumer list endpoint that passes a specification withOrderByand no sort now returns that order. How the specification reaches the list read at all is ADR-055's Revision (2026-11-30). - System.Linq.Dynamic.Core stays, deliberately (decided 2026-11-30). Replacing it with hand-built
expression trees was weighed and deferred: sorting resolves a DTO property through each query
service's
DTOToEntityPropertyMapand hands the result to Dynamic LINQ (.../Services/Query/QueryFieldService.cs:204-214, parsing config in.../Services/Filtering/DynamicQueryConfig.cs), and consumer maps hold free-form expressions, not only property paths: MMCA.Store mapsVariantCounttoProductVariants.Count(),ProductCounttoProducts.Count()andIsOutOfStockto(AvailableQuantity == 0)(MMCA.Store/Source/Modules/Catalog/MMCA.Store.Catalog.Application/Products/ProductEntityQueryService.cs:34,.../Categories/CategoryEntityQueryService.cs:33,MMCA.Store/Source/Modules/Sales/MMCA.Store.Sales.Application/Inventory/InventoryItemEntityQueryService.cs:35). The package stays referenced (MMCA.Common/Directory.Packages.props:95,MMCA.Common/Source/Core/MMCA.Common.Application/MMCA.Common.Application.csproj:29). Revisit when no consumer map holds an expression, or when the maps move to typed expressions. - Marked in place: the Decision's
RegisterStrategysentence. The dated Revisions keep their wording.