↑↓ to navigate Enter to open "…" all these words ANDOR to combine

Architecture Decision Record

ADR-078: CSV Export as a Dedicated Endpoint, Not Content Negotiation

Status

Accepted (2026-08-13; revised 2026-08-18, 2026-08-31, 2026-09-19, 2026-10-01, 2026-10-06, 2026-10-07, 2026-10-21). The endpoint ships in the MMCA.Common "enterprise capability wave" release (v1.150.0), its scoping hook in v1.151.0, and the widened read hook that supersedes that hook in v1.165.0; all three consumers run on pins that carry them. Every controller deriving from EntityControllerBase gains the route automatically, under that controller's own authorization posture, so the consumers that carry OpenAPI contract tests (ADC and Store) re-baseline their snapshots in the sweep. What it returns is not automatic: since v1.218.0 the export is fail-closed, and a derivative that declares no row scope and does not opt in through AllowUnscopedExport answers 403 Export.RowScopeRequired. Revised 2026-10-06: the export is fail-closed since v1.218.0 (an unscoped derivative must opt in through AllowUnscopedExport or get 403), and since v1.219.0 each page is rendered into memory and written to the response with awaited writes only. Revised 2026-10-07: anchors refreshed after the v1.233.0 release. Revised 2026-10-21: anchors refreshed after the v1.250.0 release. Revised 2026-10-26: the "CSV flattens" trade-off now says collection-valued fields are dropped (only nested values get a convention rendering), Related cites ADR-073 for the no-interface-member reasoning, and anchors are refreshed. Revised 2026-10-28: anchors refreshed after the v1.265.1 release. Revised 2026-11-23: the read hook is honored by seven read actions, the cache bypass covers bypass permissions as well as roles, ADC's Forbid gates sit on twelve export overrides, and the file-import contract (dry run 200, commit 202, file-level 400 Problem Details, row-level ImportRowErrorDTO; ADC the only adopter) is recorded as the import-side twin; anchors refreshed.

Context

The request is "export what you filtered". The generic entity surface of ADR-034 already accepts a full query vocabulary on the paged route (Source/Presentation/MMCA.Common.API/Controllers/EntityControllerBase.cs:153): sparse fieldsets through fields, dynamic per-type filtering bound by QueryFilterModelBinder (EntityControllerBase.cs:165), sortColumn / sortDirection, and pagination reported in X-Pagination. A user who has narrowed a grid to the rows they care about wants those exact rows as a file. The framework produced no file at all: the four generic reads that predate this record (EntityControllerBase.cs:106, :153, :318, :357) return JSON and nothing else.

The obvious implementation is content negotiation: keep the same URL, have the client send Accept: text/csv, and register an OutputFormatter. Exploration of the real source found two behaviors that make that the wrong shape here.

  • The output cache does not vary by Accept. PublicEndpointOutputCachePolicy (ADR-040) sets context.CacheVaryByRules.QueryKeys = "*" (Source/Presentation/MMCA.Common.API/Caching/PublicEndpointOutputCachePolicy.cs:127). The key has exactly one other dimension, and it is not a header: when ITenantContext resolves a tenant the policy stamps that tenant into CacheVaryByRules.VaryByValues[TenantVaryByKey] (PublicEndpointOutputCachePolicy.cs:133-137, the "t" key constant at :53), and an unresolved tenant adds nothing. A caller holding one of the policy's configured bypass roles, or one of its configured bypass permissions, is out of the cache altogether rather than in a different entry: the policy leaves AllowCacheLookup and AllowCacheStorage false for that request (:112-116, IsBypassedCaller at :172-189, the permission check at :180-188). Nothing in the policy varies by Accept. On any endpoint carrying that policy, a CSV request and a JSON request to the same URL with the same query string, from the same tenant and a non-bypass caller, are the same cache entry, so a CSV request can be served a stored JSON body with a Content-Type that no longer matches what the formatter would have produced.
  • A negotiation failure is silent. AddAPI sets options.ReturnHttpNotAcceptable = false (Source/Presentation/MMCA.Common.API/DependencyInjection.cs:49), so a request for a media type no formatter can produce does not get 406: it falls back to the default formatter. A caller asking for CSV against a controller where the formatter did not apply receives JSON with a 200 and no signal that it asked for something else.

Neither global setting is free to change: flipping ReturnHttpNotAcceptable changes the failure mode of every endpoint in every consumer in one release, and adding Accept to the cache variance multiplies cache entries on the read-scaling path for a format almost nobody requests. A second question had no answer either: how many rows an export returns. The query pipeline caps any unpaginated read at EntityQueryPipeline.MaxUnboundedResultLimit = 1000 (Source/Core/MMCA.Common.Application/Services/Query/EntityQueryPipeline.cs:23, applied by Take(...) at :99, :195 and :250, and clamping a paged read's page size in ApplyPaging at :274-283), and there is no IAsyncEnumerable path through it. A naive "read it all, write CSV" export therefore returns 1000 rows and says nothing about the rest.

Decision

A dedicated route, not a media type

EntityControllerBase gains a virtual [HttpGet("export")] ExportAsync(...) action (Source/Presentation/MMCA.Common.API/Controllers/EntityControllerBase.cs:253, method at :258-303). It accepts the same query surface as the paged route: sortColumn, sortDirection, fields, includeFKs, and filters bound by [ModelBinder(typeof(QueryFilterModelBinder))], so a grid that produced a paged URL produces an export URL by changing one path segment. It returns a streamed text/csv response with a Content-Disposition attachment filename of {controller}-{yyyyMMddTHHmmssZ}.csv: the routed controller name as the stem (ExportFileNamePrefix, EntityControllerBase.cs:576-589) and a UTC timestamp in basic-format ISO 8601, a literal T separator and a trailing Z with no other separators, so the name is legal on every file system and sorts chronologically in any locale (BuildExportFileName, :691-694).

A distinct path avoids both findings without touching either global setting: the route is not the cached route, and a client cannot ask for CSV and silently receive JSON, because asking for CSV means calling a different URL.

The page loop is how the row cap is answered

ExportAsync does not issue one unpaged query. It hands the CSV work to the internal static EntityCsvExporter<TEntityDTO> (Source/Presentation/MMCA.Common.API/Export/EntityCsvExporter.cs:17, called from EntityControllerBase.cs:280-299), whose loop (WriteAsync, EntityCsvExporter.cs:116-202, loop at :138-190) runs server-side over the existing paged IEntityQueryService.GetAllAsync (Source/Core/MMCA.Common.Application/Interfaces/Mapping/IEntityQueryService.cs:72-83) at a page size of ApplicationSettings.MaxPageSize (Source/Core/MMCA.Common.Application/Settings/ApplicationSettings.cs:17, default 500), writing each page into the response as it materializes, until the last page is written or the export cap is reached. Each page is rendered into an in-memory buffer (a MemoryStream, :132, behind the StreamWriter at :135) and DrainAsync (:209-221) then copies it to the response body with awaited WriteAsync and FlushAsync only, so the export never performs synchronous I/O, which Kestrel forbids by default; only one page is ever held in memory. A short page counts as the last page only when the rows written have reached the page's reported TotalItemCount (or the page is empty), because the query pipeline clamps every page to its own ceiling and a full clamped page can come back shorter than the requested size (IsLastPage, EntityCsvExporter.cs:229-230). Every page is a bounded, already-supported read, so MaxUnboundedResultLimit is never the thing that decides how large an export is.

Adding an IAsyncEnumerable path through EntityQueryPipeline is the better long-term answer: one query, one open reader, no repeated Skip. It is deliberately deferred out of this wave. It changes the shared read path that every entity in every consumer uses, and this record buys the capability without touching it.

The row ceiling is a setting, and hitting it is visible in the body

ApplicationSettings gains MaxExportRows, default 100,000, range-attributed [Range(1, 10_000_000)] (Source/Core/MMCA.Common.Application/Settings/ApplicationSettings.cs:32-33); the controller independently treats a configured value of zero or less as unconfigured and falls back to the same default (EntityControllerBase.cs:78-86, DefaultMaxExportRows at :513), because a cap of zero would serve every caller a header-only file. The ceiling is advertised in a header and the truncation is not, and the split is forced by streaming. BeginExportResponse sets the content type, the Content-Disposition filename and one export header, X-Export-Row-Limit, carrying the configured cap (ExportRowLimitHeaderName, EntityControllerBase.cs:522, sent at :675-682, invoked by the exporter at EntityCsvExporter.cs:160 once the first page has succeeded) before the first body byte goes out. Whether the cap was actually reached is known only after the last page is read, by which time the headers are frozen, and buffering the whole file to learn the answer first would defeat the streaming the endpoint exists for. So at the ceiling the export stops and writes a final CSV comment row into the body, # export truncated at N rows (TruncationMarker, EntityCsvExporter.cs:356-357, written at :192-195), where it is still writable. A page cut short by the cap marks the export truncated at once (:172-176). When the cap lands exactly on a page boundary, the page's reported TotalItemCount decides whether rows were left behind, without querying a further page (:183-187). There is no X-Export-Truncated header. Truncation is a normal outcome with a signal, not an error: the response has already begun streaming by the time the cap is reached, so a status code is no longer available to carry it either.

The same reasoning answers the other post-header failure. A page query that fails after streaming began cannot return Problem Details either, so the export logs a warning (LogExportPageFailure, EntityControllerBase.cs:702-714, passed to the exporter at :298) and closes the file with a second trailing marker, # export incomplete after N rows (IncompleteMarker, EntityCsvExporter.cs:362-363, written at :151 inside the mid-stream failure branch at :142-153). The two markers say different things on purpose: truncated means the cap stopped a healthy read, incomplete means the read itself broke. Without the second one a failed export would look like a complete export of fewer rows. A failure on the FIRST page, before any byte is written, comes back from the exporter as a failed Result (EntityCsvExporter.cs:144-145) that the controller still returns through HandleFailure (EntityControllerBase.cs:302).

An unscoped export is refused unless the controller opts in

Since v1.218.0 the export is fail-closed. When the read specification resolves to null and the controller's AllowUnscopedExport (protected virtual, false by default, EntityControllerBase.cs:549) is not overridden, ExportAsync queries nothing and returns HandleFailure([UnscopedExportRefused()]) (:274-275): a 403 built with Error.Forbidden (:664-669) carrying ExportRowScopeRequiredErrorCode = "Export.RowScopeRequired" (:528). A non-null specification is always honored and never consults the property, so a scoped export needs no opt-in. The property is read per request, so it may depend on the principal. A null specification still means an unscoped read for the JSON routes (:594-597, :632-634); only the bulk file is refused. A controller whose rows really are visible to every caller allowed to reach it opts in with => true (Helpdesk's TicketsController, Store's InventoryItemsController), and one that scopes everyone except an administrator opts in for that role only (Store's OrdersController and ShoppingCartsController).

The CSV writer is in-house

CsvWriter (public static, Source/Core/MMCA.Common.Shared/Serialization/CsvWriter.cs:45) implements RFC 4180: quote a field when it contains the separator, a quote, or a line break; escape an embedded quote by doubling it; terminate rows with CRLF; lead with a UTF-8 BOM. The BOM is unconditional, not a setting (CsvWriter.cs:58). It is written once by the exporter at EntityCsvExporter.cs:162 (through WriteByteOrderMark, CsvWriter.cs:85), via the page-buffer StreamWriter constructed with CsvWriter.Utf8NoPreamble (EntityCsvExporter.cs:136, encoding at CsvWriter.cs:68), so the encoding emits no preamble of its own and the file gets exactly one BOM rather than two. Without it Excel reads a UTF-8 file in the machine's ANSI code page and every accented character becomes mojibake on the desktops these exports are opened on; three bytes is a cheaper price than a flag nobody would find in time, and the parsers that show a junk first column are the minority that pays for it.

No CsvHelper dependency is taken. The framework's export input is already a rectangle of stringified shaped values, the escaping rules are a page of code, and a published framework that takes a dependency imposes it on every consumer of every package pin (ADR-038, ADR-016).

Column names come from the same shaper the JSON response uses

ResolveColumns (EntityCsvExporter.cs:293-312) takes the header row from the keys of the first row of page one, normalized by ShapeRow (EntityCsvExporter.cs:323-325): a field-subset request already arrives as a shaped dictionary from the query service, and a full-DTO request is shaped by QueryFieldService.ShapeData (Source/Core/MMCA.Common.Application/Services/QueryFieldService.cs:82), the single-row sibling of the ShapeCollectionData (:103) the JSON reads run over a page. Both project through the same cached accessors and write each value under its camelCase name via JsonNamingPolicy.CamelCase (QueryFieldService.cs:50, converted at :68, written at :90 and :117), so there is no second naming convention to keep in step. When page one comes back empty there is no row to read keys from, so the columns fall back to reflection over TEntityDTO in property-declaration order, filtered by the requested fields (EntityCsvExporter.cs:299-311), which is the order the shaper would have produced had there been a row.

The one place the CSV columns are not the JSON property names is subtraction, never renaming: both paths drop the columns CSV cannot render faithfully (IsExportableColumn, EntityCsvExporter.cs:246, applied at :297 and by type at :308), so a binary or collection-typed property is absent from the file while it is present in the JSON response for the same request.

IEntityControllerBase is deliberately not touched

The endpoint is a base-class method only. Adding a member to the public IEntityControllerBase interface (Source/Presentation/MMCA.Common.API/Controllers/IEntityControllerBase.cs:14) is breaking for any consumer that implements it explicitly rather than inheriting the base, and a default interface member would hide that break behind a runtime surprise instead of removing it. This is the same reasoning ADR-073 applies to the new IPhysicalDbContextFactory.Create overload.

The streamed response passes the failure filter untouched

UnhandledResultFailureFilter acts only when the action result is an ObjectResult carrying a failed Result (Source/Presentation/MMCA.Common.API/Middleware/UnhandledResultFailureFilter.cs:28). ExportAsync returns an EmptyResult (EntityControllerBase.cs:302), which is neither, so it flows through the filter pipeline unmodified and the ADR-013 contract stays intact for the JSON routes without a special case for this one. A failure detected before streaming begins, the fail-closed 403 included, still returns through HandleFailure (:268, :275, :302).

The route is inherited; the rows need a declared scope or an opt-in

ADC, Store, and Helpdesk inherit the /export route on every EntityControllerBase derivative the moment they take the pin, and no registration call exists to make. Since v1.218.0 the route alone returns rows only where the controller declares a row scope or opts in through AllowUnscopedExport. Helpdesk's TicketsController derives from the base at Source/Modules/Tickets/MMCA.Helpdesk.Tickets.API/Controllers/TicketsController.cs:65 and carries one line of export code: AllowUnscopedExport => true (:68), because tickets are a shared queue every caller of the controller already lists in full. The visible work in the ADC and Store sweep PRs is re-baselining the OpenAPI contract snapshots asserted by OpenApiContractTestsBase (ADR-058), which otherwise fail on the added path; Helpdesk subclasses no OpenApiContractTestsBase and has no snapshots to move.

The import side is a file upload with a dry run

The twin of the export is a file-import endpoint, and its contract is a set of shared conventions in MMCA.Common/Source/Core/MMCA.Common.Shared/Imports/ImportConventions.cs:25, not a base-class action. A dry run is asked for through a form or query field named ImportConventions.DryRunFieldName ("dryRun", :28), default false; it writes nothing and answers 200 with a report. A synchronous commit answers 200 with a report, and a queued commit answers 202 with the application's own run DTO (:13-17). A file-level problem (a malformed file, missing columns, a file over the size cap) is a 400 Problem Details, never a report, and a row-level problem is an ImportRowErrorDTO (file line, optional column, code, message; Imports/ImportRowErrorDTO.cs:9-24) in the report (ImportConventions.cs:19-22). ADC is the only adopter today, and Store and Helpdesk do not use it. ADC adopts it partially: its server-side roster report derives from ImportReportDTO (MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.Application/Tickets/UseCases/ImportTicketRoster/TicketRosterImportReport.cs:13), but the 200 dry-run body on the wire is its own TicketRosterImportResultDTO mapped by ToResult() (:32-44, which carries no row errors), not an ImportReportDTO (MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.API/Controllers/TicketRosterImportController.cs:61, :108).

Rationale

  • A route is an unambiguous request; an Accept header is a preference. Given a cache policy that ignores Accept and a pipeline configured to never return 406, a client that negotiates has no way to know what it got. A separate path makes the request explicit and the response deterministic, and it does it without editing two settings that every consumer's every endpoint depends on.
  • The cheapest correct fix beats the most idiomatic one here. OutputFormatter is the textbook answer and would have been right if the two findings had gone the other way. The cost of making them go the other way (a 406 behavior change plus a cache-entry multiplier on the read-scaling path) is paid by every consumer for a feature used by few.
  • Page-looping reuses a read that is already correct. Filtering, validation, sorting, projection, include handling, and DTO mapping stay exactly as the paged route runs them, so an export cannot disagree with the grid it was launched from, and no new code touches the query pipeline in this wave.
  • A hard ceiling with a signal beats an unbounded stream. 100,000 rows is a number an operator can reason about; an unbounded export is a way to hold a connection and a database read open for as long as the data allows. X-Export-Row-Limit names the boundary up front rather than hiding it, and a trailing marker row says when the export ran into it (or, in the other post-header failure, that the read broke before the rows ran out).
  • A framework declines dependencies its consumers cannot decline. Every pin MMCA.Common takes is one its packages carry into three applications under lockstep versioning (ADR-016), and RFC 4180 quoting is small, stable, and fully testable in-repo.
  • One naming source keeps two formats honest. Deriving the header row from the same shaper the JSON response uses makes the CSV columns a projection of an existing contract instead of a second one. CSV subtracts from that contract (the columns it cannot render) and never renames within it.

Trade-offs

  • Every derivative gains the route, and every consumer has to declare what it returns. The route is inherited unconditionally, but since v1.218.0 an unscoped bulk read is opt-in: a controller with no row scope answers 403 Export.RowScopeRequired until it overrides AllowUnscopedExport (EntityControllerBase.cs:549). The cost moved from exposure to work: the v1.218.0 sweep had every consumer either declare a scope or opt in controller by controller, and a scoped resource that was safe to page 20 rows at a time is still exportable 100,000 rows at a time by the same caller.
  • Ownership scoping does not carry over by default. Both read hooks return null unless overridden. Before v1.218.0 that meant a controller whose list endpoints row-scope by owner (the ADR-033 ownership axis) still answered /export unscoped: during the v1.150.0 sweep this would have let a Store customer token export every customer's orders. The v1 mitigation is gating: consumers with owner-scoped reads override ExportAsync behind a privileged-role posture (Store and ADC did, with a test pinning each gate). The follow-up shipped in v1.151.0 as GetExportSpecification(), a protected virtual hook whose result the export applies to every page it streams. v1.165.0 supersedes it by widening the hook rather than replacing it: the primary hook is now GetReadSpecificationAsync(CancellationToken) (EntityControllerBase.cs:627-629), honored by all seven read actions (:115, :170, :271, :325, :369, the cursor read at :422 and the changes read at :469; listed at :591-597), with GetExportSpecification() (:657) demoted to its synchronous default. Asynchrony is the point: row scoping is usually resolved through a query handler or a claim lookup that hits a store, and the synchronous hook forced such a controller to hand-override every read action just to get an await in first. Both hooks default to null, which leaves the JSON reads unscoped and, since v1.218.0, makes the export refuse unless AllowUnscopedExport opts in; the specification is resolved once per request so one instance filters every page of the loop (:270-271). Store scopes through both shapes: OrdersController overrides the synchronous hook (Source/Modules/Sales/MMCA.Store.Sales.API/Controllers/OrdersController.cs:242-243, its admin gate relaxed back to ownership scoping with only the fail-closed owner check left in its ExportAsync override at :221-233), ShoppingCartsController the async one (ShoppingCartsController.cs:202-204, with its own owner-check ExportAsync override at :174-187). Both return null for an administrator, so both also opt that role in with AllowUnscopedExport => OwnershipHelper.IsAdmin(...) (OrdersController.cs:250, ShoppingCartsController.cs:211); without it an admin export would be refused. ADC's Conference controllers express their read predicates as specifications through the same hooks (EventsController.GetExportSpecification() at Source/Modules/Conference/MMCA.ADC.Conference.API/Controllers/Events/EventsController.cs:73-74, Controllers/Sessions/SessionQuestionAnswersController.cs:111, and async overrides on Controllers/Sessions/SessionsController.cs:80, Controllers/Speakers/SpeakersController.cs:116, Controllers/Sponsors/SponsorsController.cs:71 among others), opt their privileged readers in through AllowUnscopedExport (for example EventsController.cs:81, SessionsController.cs:98, SpeakersController.cs:126, SponsorsController.cs:89, SessionQuestionAnswersController.cs:123; CategoryItemsController, ConferenceCategoriesController and QuestionsController opt every caller in with => true, Controllers/Questions/QuestionsController.cs:43), and keep Forbid gates on bulk export anyway in twelve ExportAsync overrides (Controllers/Events/EventsController.cs:112, Controllers/Events/EventSpeakersController.cs:126, Controllers/Events/EventQuestionAnswersController.cs:261, Controllers/Sessions/SessionsController.cs:257, Controllers/Sessions/SessionSpeakersController.cs:126, Controllers/Sessions/SessionCategoryItemsController.cs:124, Controllers/Sessions/SessionQuestionAnswersController.cs:261, Controllers/Speakers/SpeakersController.cs:326, Controllers/Speakers/SpeakerCategoryItemsController.cs:124, Controllers/Sponsors/SponsorsController.cs:144, Controllers/Partners/PartnersController.cs:133, Controllers/Activities/ActivitiesController.cs:143): a deliberate privileged-reader-only policy on a whole-catalog file, not a gap in what the framework can scope. v1.151.0 also hardened the formatter: binary and collection properties produce no column instead of rendering type names (IsExportableType, EntityCsvExporter.cs:239-242, which excludes byte[], ReadOnlyMemory<byte> and non-string enumerables), and a fields= request naming one fails validation up front (ValidateFields, EntityCsvExporter.cs:61-78, called first in ExportAsync at EntityControllerBase.cs:266-268).
  • N queries, not one stream. An export at the default settings is up to 200 round trips (MaxExportRows 100,000 over MaxPageSize 500), each with its own Skip/Take, and it holds a response open for their combined duration. There is no export-specific timeout budget: the page loop (EntityCsvExporter.cs:138-190) opens no CancellationTokenSource of its own, so the limits are the row cap and whatever the host and client already enforce.
  • A short file is signalled where spreadsheets do not look. The one export header, X-Export-Row-Limit, names the ceiling and never says whether the export hit it, and both trailing comment rows that do say so (truncated at the cap, incomplete on a mid-stream query failure) are invisible to a user who double-clicks the downloaded file: each opens as one more row at the bottom of a sheet. A partial export can therefore be read as a complete one.
  • No Accept: text/csv support at all. A client that negotiates instead of routing gets JSON. That is the behavior this record chose, and it is still surprising to anyone who expects a modern API to answer a media type request.
  • The framework now owns a CSV implementation. Embedded quotes, embedded newlines, a leading separator, and encoding all become framework correctness obligations covered by framework tests. The spreadsheet formula-injection question (a cell whose value begins with =, +, -, or @) is answered by the shipped writer, and answered in the exposed direction: it does not prefix or otherwise neutralize such values (Serialization/CsvWriter.cs:39; pinned by CsvWriterTests.WriteRow_FormulaLikeValue_IsWrittenVerbatim, Tests/Core/MMCA.Common.Shared.Tests/Serialization/CsvWriterTests.cs:181), because CSV is treated here as a data-faithful format and mangling a field that opens with a minus sign would corrupt legitimate negative numbers. The price is a known spreadsheet risk carried by every consumer: a host that opens untrusted exports has to import them as text rather than double-click them.
  • CSV flattens, and the query surface does not. A collection-valued field has no natural cell and is dropped as a column (IsExportableType, EntityCsvExporter.cs:239-242). A nested or class-typed field is kept and rendered by a framework convention, not a standard (CsvWriter.FormatCell and FormatObject, Serialization/CsvWriter.cs:144-168): an IFormattable value in its invariant form (:151), Money as amount and currency code ("49.99 USD", :176-180), Currency as its code (:165), a type whose ToString is compiler-generated or inherited from object as compact web-default JSON (:166, HasNoValueText at :187-195), and any other type as its own ToString text (:164). The Money and Currency cells do not round-trip back into the JSON shape those values have on the sibling read routes.
  • The endpoint is not output-cached, by construction. Every export is a live read against the database, which is correct for an operator extract and means an export cannot be absorbed by the cache tier the way the read routes are (ADR-019 rate limiting is the only load control on it).
  • Adding an endpoint to a shared base moves every consumer's OpenAPI document in one release. Under lockstep versioning (ADR-016) there is no phased rollout: the consumers with OpenAPI contract tests (ADC and Store) re-baseline their contract snapshots (ADR-058) in the same sweep.

Revision (2026-10-01)

No decision or rationale changed. The CSV machinery now lives outside the controller, in the internal static EntityCsvExporter<TEntityDTO> (Source/Presentation/MMCA.Common.API/Export/EntityCsvExporter.cs:17): the page loop (:124-177), both trailing markers (:323-324, :329-330), column resolution and row shaping (renamed ResolveColumns at :260-279 and ShapeRow at :290-292), the exportability checks (:205-208, :213) and field validation (renamed ValidateFields, :60-77), along with the StreamWriter and BOM write (:121, :148). The controller keeps the action, the row scope, the file name and the headers (EntityControllerBase.cs:248-293, :569-576, :585-588), and passes BeginExportResponse and LogExportPageFailure to the exporter as callbacks (:287-288); the record's citations are re-anchored accordingly, along with the drifted EntityControllerBase.cs, cache policy, AddAPI, query pipeline, Store and ADC line numbers. Two statements are corrected to match the code: a short page ends the loop only once the rows written reach the reported TotalItemCount, because the pipeline clamps pages (IsLastPage, EntityCsvExporter.cs:196-197; the clamp is EntityQueryPipeline.cs:274-283), and at a cap that falls on a page boundary truncation is decided from that total (EntityCsvExporter.cs:170-173). The contract-snapshot sweep work applies to ADC (four OpenApiContractTestsBase subclasses) and Store (three), not to Helpdesk, which has none. ADC also commits build-time OpenAPI documents that list the added /export paths (MMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/openapi/MMCA.ADC.Conference.Service.json).

Revision (2026-10-06)

  • The export decision changed, which the 2026-10-01 revision predates: since v1.218.0 (a Breaking entry in MMCA.Common/CHANGELOG.md:289) the export is fail-closed. A null read specification plus the default AllowUnscopedExport => false (EntityControllerBase.cs:508) answers 403 Export.RowScopeRequired (:273-274, :487, :608-613). The Status block, the new "An unscoped export is refused unless the controller opts in" decision, the adoption section and the first two trade-offs are rewritten: the route is still inherited automatically, but an unscoped bulk read is now opt-in rather than opt-out.
  • Corrected: Helpdesk's TicketsController is not free of export code; it opts in with AllowUnscopedExport => true (TicketsController.cs:64). Store's OrdersController and ShoppingCartsController opt administrators in (:249, :209), and ShoppingCartsController carries its own ExportAsync owner-check override (:173-185); ADC's Conference controllers opt privileged readers in (for example EventsController.cs:80).
  • Added: since v1.219.0 (CHANGELOG.md:269) each page is rendered into an in-memory buffer and copied to the response with awaited writes only (EntityCsvExporter.cs:132-135, DrainAsync at :210-222), so the export no longer fails on a host that forbids synchronous I/O. IsExportableType also excludes ReadOnlyMemory<byte> (:239-242).
  • Every path:line anchor in the live sections was re-verified against current source and re-anchored where the code had moved.

Revision (2026-10-07)

Re-verified against current source. No decision, default or rationale changed: the dedicated route, the page loop, the fail-closed unscoped export, the unconditional BOM, the absence of formula-injection neutralization and the ADC privileged-reader Forbid gates all hold as written. Only line anchors moved.

  1. Anchors re-verified against current source: the CsvWriter declaration at MMCA.Common/Source/Presentation/MMCA.Common.API/Export/CsvWriter.cs:44, the BOM constant and its remarks at :46-55, Utf8NoPreamble at :65, WriteByteOrderMark at :82 and the formula-injection paragraph at :38-41 (EntityCsvExporter.cs:135 and :162 unchanged); the ADC Forbid gates at MMCA.ADC/Source/Modules/Conference/MMCA.ADC.Conference.API/Controllers/Events/EventsController.cs:147-150 and Controllers/Sessions/SessionsController.cs:258-261. The CHANGELOG anchors in the 2026-10-06 revision have since moved (v1.218.0 fail-closed export at MMCA.Common/CHANGELOG.md:314, AllowUnscopedExport at :329; v1.219.0 awaited writes at :294) and stay as written there.

Revision (2026-10-21)

Re-verified against current source. No decision, default or rationale changed: the cache policy still varies by query string and resolved tenant only (never by Accept), bypass-role callers still skip lookup and storage, and ADC's Conference controllers still scope reads, opt privileged readers in and keep their Forbid gates on bulk export. Only line anchors moved.

  1. Anchors re-verified against current source: in MMCA.Common/Source/Presentation/MMCA.Common.API/Caching/PublicEndpointOutputCachePolicy.cs, QueryKeys = "*" at :101, the tenant lookup and VaryByValues stamp at :107-111, and IsBypassedCaller at :146-147 (:86-90 and TenantVaryByKey at :50 unchanged); in MMCA.ADC/Source/Modules/Conference/MMCA.ADC.Conference.API/Controllers/, the async GetReadSpecificationAsync overrides at Sessions/SessionsController.cs:76 and Speakers/SpeakersController.cs:110, AllowUnscopedExport at SessionsController.cs:94, and the Forbid gate at SessionsController.cs:259-262 (EventsController.cs:72-73, :80 and :147-150, SponsorsController.cs:69, SessionQuestionAnswersController.cs:109 and :121 unchanged). The CHANGELOG anchors cited in the 2026-10-06 and 2026-10-07 revisions have moved again and stay as written there: v1.218.0 is at MMCA.Common/CHANGELOG.md:623 (fail-closed ExportAsync entry at :633, AllowUnscopedExport added at :648) and v1.219.0 at :593 (awaited writes at :613).

Revision (2026-10-26)

Re-verified against current source. No decision, default or rationale changed: the dedicated route, the page loop, the fail-closed unscoped export, the unconditional BOM and the ADC privileged-reader Forbid gates all hold as written. One trade-off and the Related list are corrected, and line anchors moved.

  1. Corrected: the "CSV flattens" trade-off said a collection-valued shaped field gets a writer-convention rendering. It does not: a non-string enumerable is dropped as a column (IsExportableType, MMCA.Common/Source/Presentation/MMCA.Common.API/Export/EntityCsvExporter.cs:238-241), as the column-subtraction section already says. Only nested or class-typed values are rendered by convention (IFormattable invariant, Money as amount and currency code, Currency as its code, a type with compiler-generated or inherited ToString as compact JSON, anything else as its own ToString; MMCA.Common/Source/Presentation/MMCA.Common.API/Export/CsvWriter.cs:141-165, :187-195, MMCA.Common/CHANGELOG.md:703).
  2. Corrected: Related credited ADR-016 and ADR-038 with "why a public interface gains no member". Neither carries that reasoning; ADR-073 does (the deliberately non-default IPhysicalDbContextFactory.Create overload), and the body already cites it. ADR-073 is added to Related and the second clause is dropped from the ADR-016/ADR-038 gloss.
  3. Anchors re-verified against current source: in EntityCsvExporter.cs, beginResponse() at :160, the BOM write at :161, WriteAsync at :116-202, the loop at :138-190, DrainAsync at :209-221, IsLastPage at :229-230, IsExportableType at :238-241, IsExportableColumn at :246 (applied at :297, the type filter at :308), ResolveColumns at :293-312 (empty-page fallback :299-311), ShapeRow at :323-325, TruncationMarker at :356-357 (written at :192-195), IncompleteMarker at :362-363, the cut-short branch at :172-176 and the page-boundary branch at :183-187 (:17, :61-78, :132, :135, :142-153, :144-145 and :151 unchanged); in MMCA.ADC/Source/Modules/Conference/MMCA.ADC.Conference.API/Controllers/Sessions/SessionsController.cs, GetReadSpecificationAsync at :75, AllowUnscopedExport at :93 and the Forbid gate at :258-261. The CHANGELOG anchors cited in the earlier revisions have moved again and stay as written there: v1.218.0 is now at MMCA.Common/CHANGELOG.md:838 and v1.219.0 at :808.

Revision (2026-10-28)

Re-verified against current source. No decision, default or rationale changed: Store's ownership scoping through both read hooks, the fail-closed owner checks on the two ExportAsync overrides and the administrator opt-in through AllowUnscopedExport hold as written. Only line anchors moved.

  1. Anchors re-verified against current source: in MMCA.Store/Source/Modules/Sales/MMCA.Store.Sales.API/Controllers/OrdersController.cs, GetExportSpecification at :242-243, the ExportAsync override at :221-233 (its RequireResolvableOwner gate at :230) and AllowUnscopedExport at :250; in ShoppingCartsController.cs (same folder), GetReadSpecificationAsync at :202-204, the ExportAsync override at :174-187 and AllowUnscopedExport at :211. The Trade-offs text now names ShoppingCartsController.cs on its async-hook anchor, which previously read as an OrdersController line. The CHANGELOG anchors cited in the earlier revisions have moved again and stay as written there: v1.218.0 is now at MMCA.Common/CHANGELOG.md:881, v1.219.0 at :851, and the Money/Currency/compact-JSON cell-rendering entry at :746.

Revision (2026-11-23)

Re-verified against current source. No export decision, default or rationale changed: the dedicated route, the page loop, the fail-closed unscoped export, the unconditional BOM, the absence of formula-injection neutralization and the Accept-blind cache key all hold as written. The read-hook count, the cache bypass rule and the ADC gate list are corrected, the import-side contract is added, and line anchors moved.

  1. Corrected: GetReadSpecificationAsync is honored by seven read actions, not five: both GetAll overloads, lookup, by-id, export, cursor and changes (MMCA.Common/Source/Presentation/MMCA.Common.API/Controllers/EntityControllerBase.cs:115, :170, :271, :325, :369, :422, :469; the summary at :591-597, "all seven read actions" at :641). The Trade-offs text now says seven.
  2. Corrected: the output-cache bypass is a role OR a permission. PublicEndpointOutputCachePolicy takes bypassPermissions beside bypassRoles (Caching/PublicEndpointOutputCachePolicy.cs:84-92) and IsBypassedCaller checks them through PermissionAuthorizationHandler.Holds (:180-188). The Context text names both.
  3. Corrected: ADC keeps privileged-reader Forbid gates on twelve ExportAsync overrides, not two, all in the Conference API: Events, EventSpeakers, EventQuestionAnswers, Sessions, SessionSpeakers, SessionCategoryItems, SessionQuestionAnswers, Speakers, SpeakerCategoryItems, Sponsors, Partners and Activities (under MMCA.ADC/Source/Modules/Conference/MMCA.ADC.Conference.API/Controllers/, for example Speakers/SpeakersController.cs:326, Sponsors/SponsorsController.cs:144, Events/EventQuestionAnswersController.cs:261, Activities/ActivitiesController.cs:143). The Trade-offs text lists all twelve gates and gives the AllowUnscopedExport opt-ins (sixteen controllers) as examples.
  4. Added: the file-import endpoint contract, as the import-side twin of this export, in a new Decision subsection. The conventions are MMCA.Common/Source/Core/MMCA.Common.Shared/Imports/ImportConventions.cs:25: a dryRun field (DryRunFieldName, :28, default false) whose request writes nothing and answers 200 with a report; a synchronous commit answers 200 with a report and a queued commit answers 202 with the application's run DTO (:13-17); a file-level problem is a 400 Problem Details, never a report, and a row-level problem is an ImportRowErrorDTO (Imports/ImportRowErrorDTO.cs:9-24) in the report (ImportConventions.cs:19-22).
  5. Added: ADC is the only adopter, and Store and Helpdesk do not use the import conventions. ADC's TicketRosterImportController reads the upload through ReadCsvAsync (MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.API/Controllers/TicketRosterImportController.cs:77), answers a dry run with 200 (:102-108) and a commit with 202 and the queued run (:111-115), and its client posts the flag under ImportConventions.DryRunFieldName (MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.UI/Services/Tickets/TicketService.cs:94). Its server-side report derives from the framework's ImportReportDTO (MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.Application/Tickets/UseCases/ImportTicketRoster/TicketRosterImportReport.cs:13), but ToResult() (:32-44) maps it to the roster's own TicketRosterImportResultDTO of counts, which is the response type (TicketRosterImportController.cs:61), so no ImportRowErrorDTO row travels on that endpoint today. The Decision text states this partial adoption.
  6. Anchors re-verified against current source: in EntityControllerBase.cs, the paged route at :153, QueryFilterModelBinder at :165, the four generic reads at :106, :153, :318, :357, the export route at :253 with ExportAsync at :258-303, ValidateFields at :266-268, the once-per-request resolution at :270-271, the fail-closed check at :274-275, the exporter call at :280-299 (beginResponse at :297, LogExportPageFailure passed at :298), HandleFailure and EmptyResult at :268, :275, :302, MaxExportRows at :78-86, DefaultMaxExportRows at :513, ExportRowLimitHeaderName at :522, ExportRowScopeRequiredErrorCode at :528, AllowUnscopedExport at :549, ExportFileNamePrefix at :576-589, the null-spec statements at :594-597 and :632-634, GetReadSpecificationAsync at :627-629, GetExportSpecification at :657, UnscopedExportRefused at :664-669, BeginExportResponse at :675-682, BuildExportFileName at :691-694 and LogExportPageFailure at :702-714; in PublicEndpointOutputCachePolicy.cs, TenantVaryByKey at :53, the bypass at :112-116, QueryKeys = "*" at :127, the tenant stamp at :133-137 and IsBypassedCaller at :172-189; in MMCA.Common/Source/Core/MMCA.Common.Application/Services/QueryFieldService.cs, the CamelCase policy at :50, ConvertName at :68, ShapeData at :82, ShapeCollectionData at :103 and the camelCase writes at :90 and :117; the paged GetAllAsync at MMCA.Common/Source/Core/MMCA.Common.Application/Interfaces/Mapping/IEntityQueryService.cs:72-83; Helpdesk's TicketsController base type at MMCA.Helpdesk/Source/Modules/Tickets/MMCA.Helpdesk.Tickets.API/Controllers/TicketsController.cs:65 and AllowUnscopedExport => true at :68; in ADC's Conference controllers, the Events hook at EventsController.cs:73-74, opt-in at :81 and gate at :110-113, Sessions GetReadSpecificationAsync at SessionsController.cs:80, opt-in at :98 and gate at :255-258, Speakers hook at :116 and opt-in at :126, Sponsors hook at :71 and opt-in at :89, and SessionQuestionAnswers GetExportSpecification at :111 and opt-in at :123; CsvWriter.cs:38-41, :44, :46-55, :65 and :82 unchanged. The anchors cited inside the earlier revisions (the CHANGELOG lines among them) stay as written there.

ADR-034 (the generic entity surface and query contract this extends, and the MaxUnboundedResultLimit ceiling that forced the page loop), ADR-040 (the output-cache policy whose Accept-blind cache key is one of the two forcing findings), ADR-013 (the Result contract at the edge and the unhandled-failure filter the streamed result passes through untouched), ADR-058 (the shipped OpenAPI contract snapshots ADC and Store re-baseline for the added path), ADR-016 and ADR-038 (why a published framework declines a CSV dependency), ADR-073 (the same no-default-interface-member reasoning that keeps IEntityControllerBase untouched), ADR-019 (the per-principal limiter that is the only load control standing in front of a bulk read), ADR-076 (the other export in this wave, and the boundary between a data-subject package assembled for one person and an operator's filtered extract of a table).