Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f6ccdfa
docs(decisions): record the client API redesign and manual versioning
albertospelta Nov 22, 2026
60e0570
build(dotnet)!: remove the 1.x sources and retarget the projects
albertospelta Nov 22, 2026
89f6d4a
feat(dotnet)!: add the public model of the 2.0 client
albertospelta Nov 22, 2026
ccda54e
feat(dotnet): add the settings and the wire format of the client
albertospelta Nov 22, 2026
81471fa
feat(dotnet): format the DAX of model objects, functions included
albertospelta Nov 22, 2026
f7767c8
feat(dotnet): add the transport with timeouts and retries
albertospelta Nov 22, 2026
a0b5694
feat(dotnet): split a large call into requests
albertospelta Nov 22, 2026
4fe464f
feat(dotnet)!: add the 2.0 client
albertospelta Nov 22, 2026
ae760d9
docs(dotnet): rewrite the package readme for 2.0
albertospelta Nov 22, 2026
ceaa7c0
test(dotnet): add live tests that run only on request
albertospelta Nov 22, 2026
4c0c548
build(dotnet)!: set the package version to 2.0.0
albertospelta Nov 22, 2026
ed2a1ca
docs: describe the 2.0 client and its versioning
albertospelta Nov 22, 2026
8a29b09
fix(dotnet): send the package version in the User-Agent header
albertospelta Nov 22, 2026
32fc7de
refactor(dotnet): simplify the client after a review pass
albertospelta Nov 22, 2026
9447543
fix(dotnet): handle the edge cases found in review
albertospelta Nov 22, 2026
bfbd1ff
docs(dotnet): correct the typed client registration in the readme
albertospelta Nov 22, 2026
4bc2a82
docs(dotnet): show one call for objects of different types
albertospelta Nov 22, 2026
958d7ca
docs(dotnet): keep the package readme to the usage of the client
albertospelta Nov 22, 2026
b831227
refactor(dotnet): merge the client constructors that take an HttpClient
albertospelta Nov 22, 2026
3dbb4aa
feat(dotnet): expose the operation id and text indexes of a failed re…
albertospelta Nov 22, 2026
64b5c09
docs(dotnet): say that the failure reason can gain values
albertospelta Nov 22, 2026
e097e32
docs: record how the client API grows
albertospelta Nov 22, 2026
ad28162
docs(dotnet): use a record in the readme sample for objects of differ…
albertospelta Nov 22, 2026
f400163
feat(dotnet): describe the server of the model with enums
albertospelta Nov 22, 2026
79baa6a
docs: say that the name hash must stay the one of 1.x
albertospelta Nov 22, 2026
ad8935f
docs: shorten the name hash note and record its case debt
albertospelta Nov 22, 2026
7e4eca0
chore(dotnet): mark the release as 2.0.0-beta.1 and shorten the readme
albertospelta Nov 22, 2026
26284ea
docs(dotnet): reword the request to describe the model
albertospelta Nov 22, 2026
b19103b
docs(dotnet): name the target frameworks in the readme
albertospelta Nov 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions docs/backlog.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
# Backlog

Next ID: B-17
Next ID: B-25

Reports and requests from users stay in [GitHub Issues](https://github.com/sql-bi/DaxFormatter/issues); an item here links its issue instead of copying it.

## Next
- B-1 The MCP server's workflows run on a supported Node.js LTS: `typescript-ci.yml` and `typescript-release-daxformatter-mcp.yml` set `node-version: "20"`, which reached end of life on 2026-04-30; on 2026-11-19 the LTS majors are 22, 24 and 26 ([release schedule](https://github.com/nodejs/Release#release-schedule)). It lands before the next MCP release: on Node.js 20, `npm ci` in the release may fail without a placeholder `NODE_AUTH_TOKEN`, which setup-node v7 no longer sets ([setup-node](https://github.com/actions/setup-node)). Done when both workflows set the same supported LTS major and CI passes on it. `engines` in `package.json` stays out: changing it changes the published package.
- B-2 npm trusted publishing for the MCP server release: the release workflow publishes with a long-lived npm token, which can leak and is rotated by hand. Done when the trusted publisher on npm names `typescript-release-daxformatter-mcp.yml`, the release job runs on Node.js 22.14 or later with npm 11.5.1 or later, a release publishes without the token, and a maintainer deletes the token. Depends on B-1.
- B-3 MCP registry entry for the stdio server, so that AI clients that browse the registry find it. Done when a `server.json` describes the npm package with `repository.subfolder` set to `typescript/packages/daxformatter-mcp`, the server appears in the registry, and `typescript/AGENTS.md` has the command that updates the entry.
- B-19 The .NET release workflow stops before the build when the tag of the version already exists: since the version is written by hand ([ADR-0006](decisions/0006-write-the-dax-formatter-package-version-by-hand.md)), a release from a `master` whose version was already published is stopped only by `dotnet nuget push`, after the build and the tests. Done when `dotnet-release-dax-formatter.yml` fails right after it reads the version if the tag `Dax.Formatter-v<version>` exists, with a message that says to raise the version in `dotnet/version.json`.

## Later
- B-4 OpenAPI contract in `spec/`, with test vectors shared by all clients: one definition of the REST contract (see Known debt).
- B-5 TypeScript client library in `typescript/packages/daxformatter`, extracted from the port inside the MCP package and used by it.
- B-4 OpenAPI contract in `spec/`, with test vectors shared by all clients: one definition of the REST contract (see Known debt). The vectors start from the fixtures of the .NET tests in `dotnet/tests/Dax.Formatter.Tests/Fixtures/`, which hold nothing specific to .NET ([client API](design/client-api.md#code-and-tests)).
- B-5 TypeScript client library in `typescript/packages/daxformatter`: a port of the client model of [`client-api.md`](design/client-api.md) ([ADR-0005](decisions/0005-decouple-the-client-api-from-the-rest-contract.md)), which replaces the port inside the MCP package and is used by it. Done when it passes the shared fixtures (B-4).
- B-6 npm workspaces rooted at `typescript/`, so the npm packages share one lockfile and one install; needed once there are two npm packages.
- B-7 Python client in `python/`.
- B-8 `timeout-minutes` for the job of `dotnet-ci.yml`, whose tests call the live service: without it, a stuck run lasts up to GitHub's default of 360 minutes ([workflow syntax](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idtimeout-minutes)).
- B-8 `timeout-minutes` for the job of `dotnet-ci.yml`: without it, a stuck run lasts up to GitHub's default of 360 minutes ([workflow syntax](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idtimeout-minutes)).
- B-9 `concurrency` groups in both CI workflows, so that a newer push to a pull request cancels its older run.
- B-17 The .NET client finds the text that makes a request fail: when the service fails on one text, the whole request fails and the call with it, and the exception names only the texts of that request by their indexes. Done when the client sends the texts of a failed request again in smaller requests, reports the one that fails, and [`client-api.md`](design/client-api.md) says how.
- B-18 Measured limits for the requests of the .NET client: 250 texts and 250,000 characters for each request and 2 requests at a time are estimates ([client API](design/client-api.md#requests)). Done when the numbers come from measures on the service with real models, and `client-api.md` states them.
- B-23 Package validation for `Dax.Formatter` once 2.0.0 is on nuget.org: `PublicApiTests` shows every change of the public surface, but doesn't tell an addition from a breaking change ([ADR-0007](decisions/0007-keep-the-batch-api-on-the-callers-items-and-grow-it-only-by-addition.md)). Done when `Dax.Formatter.csproj` sets `EnablePackageValidation` and `PackageValidationBaselineVersion` to `2.0.0`, and a pack fails on a removed public member ([package validation](https://learn.microsoft.com/dotnet/fundamentals/apicompat/package-validation/overview)).
- B-21 One version scheme for both packages when the MCP server leaves its beta: until then it stays on `0.2-beta` with the git height as its third number, while `Dax.Formatter` has a version written by hand ([ADR-0006](decisions/0006-write-the-dax-formatter-package-version-by-hand.md)). Done when a decision record says which scheme the MCP server follows from its first stable version.

## Open decisions
- B-20 Remove NBGV from the .NET toolchain? Since [ADR-0006](decisions/0006-write-the-dax-formatter-package-version-by-hand.md) it no longer computes the package version: it stamps the one in `dotnet/version.json`, adds the commit suffix outside `master` and puts the git height in the file version. The options: keep it, or set the version in the project file and change the release workflow, which reads the version from NBGV. The answer depends on whether the commit suffix and the file version are worth the tool, and on the scheme the MCP server takes (B-21).

## Known debt
- B-10 The clients send enums in different forms: the .NET client sends `ServerMode`, `ServerEdition` and `ServerLocation` as numbers, the TypeScript port as strings; `ServerType` is a string in both. Cost: the service receives two forms of the same fields, a new client has no rule to follow, and changing the .NET form changes the wire format of a published package. Repay with the OpenAPI contract, which fixes one form for every client.
- B-11 The REST contract is restated in each client: the .NET request and response models, the TypeScript port's types and serializer, and the zod schemas of the MCP tool. Cost: every contract change touches each copy, and the copies already drift (B-10). Repay with the OpenAPI contract and its shared test vectors.
- B-12 The getting-started sample references `Dax.Formatter` 1.0.0, while nuget.org has 1.2.2. Cost: the sample builds against a package from 2021, not the one users install. Repay in the next change to the sample.
- B-13 The .NET tests call the live service (`DaxFormatterClientTests`). Cost: .NET CI depends on the service and the network, and an outage fails unrelated pull requests. Repay with the shared test vectors: unit tests against recorded responses, and the live tests in a separate job.
- B-11 The REST contract is restated in each client: the .NET wire types in `dotnet/src/Dax.Formatter/Wire/`, the TypeScript port's types and serializer, and the zod schemas of the MCP tool. Cost: every contract change touches each copy. Repay with the OpenAPI contract and its shared test vectors (B-4).
- B-14 The MCP server says that `formatted` is null for invalid DAX, in the tool description in `typescript/packages/daxformatter-mcp/src/format-tool.ts` and in the comment of `formatted` in `src/daxformatter/types.ts`, while the service returns an empty string ([REST API, Response](design/rest-api.md#response)). Cost: an AI client that follows the tool description misses the empty string. Repay by fixing both texts, which raises the MCP server's version.
- B-15 Releases are tied to `master` only by the branch guard of the release workflows: a run uses the workflow file of the commit it runs on ([Workflows](https://docs.github.com/en/actions/concepts/workflows-and-actions/workflows)), so a branch whose copy drops the guard runs with the repository secrets, and the nuget.org Trusted Publishing policy names the workflow file, not a branch. Cost: whoever can push a branch and run workflows can publish from it. Repay: remove the nuget.org policy for `release.yml`, the .NET release workflow's name before the move in `6df1bf0`; run each release job in a GitHub environment that only `master` can deploy to, which holds the release secrets and which the nuget.org policy names ([Trusted Publishing](https://learn.microsoft.com/en-us/nuget/nuget-org/trusted-publishing), [environments](https://docs.github.com/en/actions/reference/workflows-and-actions/deployments-and-environments)).
- B-16 Some files under `dotnet/` don't follow `.editorconfig`: a missing or unwanted byte order mark, no final newline, trailing whitespace, and tabs, including in the two `.sln` files, which Visual Studio writes with tabs. Cost: saving one in an editor that applies `.editorconfig` puts changes unrelated to the edit in the diff. Repay with one commit that only normalizes these files, and a `[*.sln]` section with `indent_style = tab`.
- B-16 Some files under `dotnet/` don't follow `.editorconfig`: a missing or unwanted byte order mark, no final newline, trailing whitespace, and tabs, including in `Dax.Formatter.sln`, which Visual Studio writes with tabs. Cost: saving one in an editor that applies `.editorconfig` puts changes unrelated to the edit in the diff. Repay with one commit that only normalizes these files, and a `[*.sln]` section with `indent_style = tab`.
- B-24 The hash of a server or database name is not normalized: the same name in different case gives different hashes. Cost: the same server is counted more than once. Repay: decide whether to normalize the name before hashing.
- B-22 The service rejects three kinds of valid DAX with a syntax error: a function without parameters, a function parameter with a default value and, sent as the expression of a model object, an expression with `=>` inside a string or a comment ([client API](design/client-api.md#limits-of-the-service)). Cost: no client can format them, and each returns the syntax error to its caller. Repay in the service, which is outside this repository; then remove the limits from `client-api.md` and `rest-api.md`, and update the live test that pins them.
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
status: accepted
date: 2026-11-22
decision-makers: Alberto Spelta
---

# Decouple the client API from the REST contract

## Context and Problem Statement

`Dax.Formatter` 1.2 exposes the request and response of the REST contract as its public API. A caller builds a request object, gets back responses to match with its own objects by position, and reads the outcome from an empty `Formatted` and a nullable `Errors`. A call waits at most 60 seconds, whatever its size, and a call with thousands of expressions goes out as one request, which can fail for its size or its duration ([sql-bi/DaxFormatter#40](https://github.com/sql-bi/DaxFormatter/issues/40), [sql-bi/Bravo#963](https://github.com/sql-bi/Bravo/issues/963)). The tools that format the objects of a model each write the same code around the client: a `[x] :=` line before every expression, its removal from the result, and the match of results by index. A TypeScript client library and a Python client are planned ([backlog](../backlog.md)). What should the public API of a DAX Formatter client be, so that it stays the same when the service contract changes, and the same across languages?

## Considered Options

* Keep the request and response of the REST contract as the public API, and add splitting and timeouts to it
* Keep the 1.x types and add a layer of helpers for expressions and batches
* A new API on a model of its own: kinds of text, outcomes as values, splitting inside the client

## Decision Outcome

Chosen option: "A new API on a model of its own", because the work that every caller repeats belongs to the client, and an API that doesn't show the wire format can keep its shape when the contract changes and be ported to other languages. It is version 2.0.0 of the package, with breaking changes; [`client-api.md`](../design/client-api.md) describes the model.

- The public types are the client, its options, the options of a call, the result of a text, a syntax error, a progress value and one exception. The types of the wire format are internal.
- A call says what its texts are with a kind. `Auto` sends a text as it is; `Expression` is the DAX of one model object without its name, user-defined functions included. There is no `Query` kind, which would behave like `Auto`, and no `Function` kind: the client recognizes a function body by itself.
- An outcome is a value: a syntax error is part of the result of its text. A failure of the service or of the network is one exception type with a reason, and a cancellation by the caller is the cancellation exception of the language.
- A result can carry the caller's object, so nothing is matched by position. A call returns every result, in the order of the input, or throws.
- The client splits a large call into requests, limits how many are in progress, retries the failures that can be temporary and reports progress. How much a request carries is an internal constant, not an option.
- The client uses only the endpoint that takes several texts, which formats DAX only: the client doesn't format MDX.
- The client doesn't convert line breaks: the service returns those inside strings and comments as they were sent, so converting all of them would change the content of strings. It doesn't halve a request that timed out: the service keeps working on a request that the client abandoned, so halving would double the load when the service is slow.
- The descriptions of the model, which the service uses for statistics, are enums where the values form a known set, as in 1.x and in the TypeScript port: the type, mode, edition and location of the server. Mode, edition and location have the names and values of the enums of the Analysis Services client libraries, and the client sends the name of the member, so a caller converts a value of those libraries by its name.
- The shape must exist in every target language and for every consumer of the .NET package: no `init`, `required` or record in public types, which a .NET Framework project on C# 7.3 can't use; no interface next to the client, whose methods are virtual; asynchronous methods only; no new dependency. The .NET package targets `netstandard2.0` and `net10.0`.

### Consequences

* Good, because a caller passes its objects and reads results: the header line, the match by index and the outcome check are no longer written in each tool.
* Good, because a call with thousands of texts no longer depends on one request ([sql-bi/DaxFormatter#40](https://github.com/sql-bi/DaxFormatter/issues/40)).
* Good, because the TypeScript and Python clients get a model to port, with test vectors that don't depend on a language.
* Bad, because every application on 1.x must change its code to move to 2.0.
* Bad, because the client now knows some DAX: where strings, names and comments start and end, and what a function body looks like. A change of the DAX syntax there reaches the client.
* Bad, because `Expression` depends on how the service writes its answer: the client sends a header line, expects it back, and removes it with the indentation that the service adds under a function header. A different answer is a failure, never a wrong text, and the live tests pin the answers.
* Bad, because the client can't work around three limits of the service, which it returns as syntax errors ([`client-api.md`](../design/client-api.md#limits-of-the-service)).
* Bad, because applications that formatted MDX with the single-text methods of 1.x lose it.
* Bad, because a server value that the Analysis Services libraries add can't be sent until a minor version of the package adds it to its enum.

### Confirmation

- `PublicApiTests` compares the public surface with `PublicApi.approved.txt` on each target framework, and checks that every public type is in the `Dax.Formatter` namespace: a change of the surface shows up as a change of that file.
- The fixtures under `dotnet/tests/Dax.Formatter.Tests/Fixtures/` hold the request bodies, the recorded answers of the service and the expected results; the tests of every client run them.
- The live tests, run on request, check the recorded answers against the service.
- `ReadmeTests` keeps the code of the package readme equal to code that compiles and runs.

## Pros and Cons of the Options

### Keep the request and response of the REST contract as the public API, and add splitting and timeouts to it

* Good, because no caller has to change its code.
* Bad, because a request object that the client splits no longer maps to one request, so the wire types would stop describing the wire.
* Bad, because a change of the contract stays a change of the public API, as when the metadata enums change form.
* Bad, because the header line, the match by index and the outcome check stay in every caller.

### Keep the 1.x types and add a layer of helpers for expressions and batches

* Good, because existing code keeps working and new code gets the helpers.
* Bad, because two ways to do everything stay in the package, and the old one keeps the failures the new one solves.
* Bad, because the helpers would return the 1.x response types, with their implicit outcome and nullable fields.

### A new API on a model of its own: kinds of text, outcomes as values, splitting inside the client

* Good, because the API is small: two operations, two option types, one result type.
* Good, because it follows the conventions that .NET developers know (see More Information).
* Bad, because it is a breaking change of a published package.

## More Information

- The model and its behavior: [`client-api.md`](../design/client-api.md); the contract it calls: [`rest-api.md`](../design/rest-api.md).
- Names and shapes: [Framework Design Guidelines, names of type members](https://learn.microsoft.com/dotnet/standard/design-guidelines/names-of-type-members) and [enum design](https://learn.microsoft.com/dotnet/standard/design-guidelines/enum), which says not to reserve enum values for future use; [Azure SDK general guidelines](https://azure.github.io/azure-sdk/general_design.html) for client, options and result types; [Task-based Asynchronous Pattern](https://learn.microsoft.com/dotnet/standard/asynchronous-programming-patterns/task-based-asynchronous-pattern-tap#progress-reporting-optional) for progress; [`IdentityResult`](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.identity.identityresult) for `Succeeded` with `Errors`.
- The arrow `=>` belongs to function definitions only: [FUNCTION statement](https://learn.microsoft.com/dax/function-statement-dax).
- The shared `HttpClient`: [Guidelines for using HttpClient](https://learn.microsoft.com/dotnet/fundamentals/networking/http/httpclient-guidelines).
- The version of the package: [ADR-0006](0006-write-the-dax-formatter-package-version-by-hand.md).
- How a batch takes the caller's objects, and how the API grows: [ADR-0007](0007-keep-the-batch-api-on-the-callers-items-and-grow-it-only-by-addition.md).
- Revisit if the service gets an endpoint that takes the kind of a text, which would make the header line unnecessary, or if users ask for MDX again.
Loading