Skip to content

docs(website): document version negotiation for v0.6.0 - #1423

Draft
SnowboardTechie wants to merge 24 commits into
CORE-v0.6.0from
bryan/1389-versioning-docs
Draft

SnowboardTechie wants to merge 24 commits into
CORE-v0.6.0from
bryan/1389-versioning-docs

Conversation

@SnowboardTechie

@SnowboardTechie SnowboardTechie commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Changes proposed

The protocol docs now describe version negotiation as ADR 0032 settles it, so a client or implementer can read how to find, request and retire versions without reading the ADR.

  • The specification page moves to v0.6.0 and its Versions section states the negotiation rules. New subsections cover requesting a version with CG-Version, the response headers, the four version errors, the discovery route, retiring a version, and changing the default.
  • The patch rule is corrected. The page said a patch "adds new optional functionality". It now says a patch never changes schemas, validation, required routes or status codes, as the ADR requires.
  • The specification defines the link that announces a change of default: Link with rel="successor-version" on responses served by default, with the date in discovery's upcomingDefault and no Deprecation or Sunset.
  • A new Versioning page (/protocol/versioning/), modeled on Authentication and scopes, walks through discovery, asking for a version, confirming what was served, the version errors, and the retirement and default-change signals. It ends with tables and TypeSpec for the discovery and version error schemas.
  • GET /versions is listed in the routes tables as optional, with the rule that a server serving more than one version MUST implement it stated in the text.
  • A v0.6.0 migration notes entry says the release is additive and what a server adopting negotiation does.

Model, type and response pages and the API docs dropdown are not touched here. They belong to #1391.

Context for reviewers

Only three files are this PR's own: website/src/content/docs/protocol/specification/index.md, website/src/content/docs/protocol/versioning.mdx and the sidebar entry in website/astro.config.mjs. The comparison from the second merge commit shows just those.

The rest of the diff comes from two open PRs this branch is built on, and drops out as they land:

  1. docs(website): show the whole declaration in protocol docs code tabs #1420 (protocol pages find their code by schema name, targets main). The new page uses its <SchemaTable schema="…" /> and <SchemaFormatTabs schema="…" typeSpec /> components. Once it merges, main gets merged into CORE-v0.6.0.
  2. feat(core): add the versions discovery route #1399 (the versions discovery route, targets CORE-v0.6.0). The new page renders its VersionDiscovery schemas. Merging it here conflicted only in the generated openapi.0.6.0.yaml, which was regenerated with the website's TypeSpec step.

This stays a draft until both have merged.

Things worth a look:

  • The specification text is normative and the Versioning page explains. Every example in the Versioning page's text is copied from ADR 0032. The Example tabs in its schema sections are generated from the TypeSpec.
  • The schema tabs are TypeSpec only, because the SDKs don't declare the version schemas yet.
  • VersionErrorScope has a hand-written table. The generated JSON Schema doesn't carry the enum members' descriptions, so the generated table had an empty description column. SortOrder on the sorting page is written the same way.
  • Two places where the TypeSpec is looser than the ADR, both documented as the ADR states them: a 400 for a body validation error MUST carry CG-Version-Served, but the shared 400 response declares it optional because version errors use the same status and must not carry it; and discovery on a version error is optional in TypeSpec because a single-version server needn't publish discovery.
  • Left out of the specification text: the ADR's note that how a server represents data an older version can't express is out of scope. It isn't a rule.
  • This merges into the hold branch, so the issue closes when CORE-v0.6.0 reaches main, not when this PR merges.

Verified by building the site on this branch (pnpm run build, all internal links valid), pnpm run test (1,264 tests pass), eslint, Prettier, tsc, astro check and cspell, then reading the built specification and versioning pages against ADR 0032.

Additional information

Rendered pages in this PR's website preview: Versioning and the specification's Versions section.

SnowboardTechie and others added 13 commits November 17, 2026 16:14
### Summary

- Fixes #1159
- Time to review: 30 minutes

### Changes proposed

Adds [ADR
0032](https://github.com/HHS/simpler-grants-protocol/blob/bryan/1159-adr-0032-version-negotiation/website/src/content/docs/governance/adr/0032-api-version-negotiation.md),
which decides how a client asks a CommonGrants API for a protocol
version and what the server tells it back:

- A client selects a version with an optional `CG-Version` request
header. Every response confirms the version served in
`CG-Version-Served`, and a client that sends no version gets the
server's pinned default.
- A server publishes the versions it serves at `GET
/common-grants/versions`, as a baseline plus entries for routes that
differ.
- Version problems get dedicated codes: `version.malformed` and
`version.conflict` (400), and `version.unsupported` and
`version.retired` (406).
- Retirement uses the standard `Deprecation`, `Sunset`, and `Link`
headers. A change of default uses `Link` with `rel="successor-version"`,
and the date is published in discovery.

The ADR is organized as Overview, Evaluation, and Specification, with
client and implementer questions in each area. It also covers how a
client discovers versions and how a server retires one. It also answers
#1372, which is already closed.

### Context for reviewers

Implementation is tracked in the [[Core] v0.6.0
release](https://github.com/HHS/simpler-grants-protocol/milestone/5)
milestone: headers #1386, discovery #1387, version errors #1388, and the
mock API #1393. The specification's versioning section still describes a
patch as adding "new optional functionality", which contradicts this
ADR. #1389 owns that correction, along with documenting the
default-change link.

This PR also adds a "Partly superseded" note to [ADR
0028](https://github.com/HHS/simpler-grants-protocol/blob/bryan/1159-adr-0032-version-negotiation/website/src/content/docs/governance/adr/0028-mock-api-hosting.md),
since this decision replaces its version path prefix while the rest of
0028 stands.

Verified locally: Prettier and cspell pass on the changed files, and the
website builds.

### Additional information

Rendered page: the website preview link on this PR, at
`/governance/adr/0032-api-version-negotiation/`.
Adds GET /common-grants/versions to the 0.6.0 base API, tagged optional,
with the VersionDiscovery, OperationVersions, UpcomingDefault and
VersionRetirement models and a protocolVersion type. The route lets a
server publish its default version, the versions every route serves,
per-route exceptions, an upcoming default and deprecated versions, per
the API version negotiation ADR draft (#1159, #1372).

Versions.v0_6 and Types.protocolVersion are stubs owned by #1386 and
are dropped when that PR lands. The 0.1.0 through 0.5.0 OpenAPI
documents are unchanged.

Refs #1387
Discovery sits outside version selection, so its models tolerate
fields they don't know instead of being versioned per document, as
the route description promises. The baseline fields now say they
describe routes without an operations entry, versions requires at
least one entry, and the deprecated map documents its keys.

Refs #1387
OkT now spreads the version response headers, so discovery would have
advertised CG-Version-Served and Vary. ADR 0032 says discovery carries
neither, because clients call it before they know which version to
request. The route returns a dedicated VersionDiscoveryResponse instead.

Refs #1387
The defaultVersion docs now say a default is one of the listed
versions, which the schema can't express. The route description adds
the ADR's authentication ceiling and narrows "fields are only ever
added" to data, since the response envelope stays closed. The
interface comment says adopters don't type-parameterize the response,
now that the models accept unknown fields.

Refs #1387
Adds the lookup protocol pages will use to show a schema's code without
file paths or line numbers. TypeSpec is read with the compiler's own
parser; TypeScript with the TypeScript parser; Python with a small
scanner that tracks brackets and strings. A name that isn't declared,
or is declared more than once, throws.
Each protocol page now names the schema in <SchemaTable schema=...> and
<SchemaFormatTabs schema=... typeSpec python typescript>, and the code
tabs show the whole declaration found by name. About 100 tabs that were
cut off, shifted or showing other code now show the right declaration,
and a schema or snippet that can't be found fails the build.

The schema-to-page map that links table types to their pages is built
from the pages during the site build, so generate-schema-docs.ts goes,
along with generate-schema-metadata.ts, generate-type-formatting.ts and
SchemaMetadataLoader, whose output nothing read.

Closes #872
… fields

- The dev server re-reads the TypeSpec, Python and TypeScript sources once
  per page render, so a source edit shows on reload; a production build
  still reads them once.
- Declarations shown together keep the blank lines the source has between
  them, so Python classes sit two blank lines apart.
- The Python tabs for the pagination and sorting models show their base
  class (PaginatedBase, SortBase), which holds the inherited fields.
- Drop code with no reader: the example file branch, the cache-clearing
  helper and an export; use the TypeSpec parser's line lookup and one
  shared recursive file listing.
…-docs

# Conflicts:
#	website/public/openapi/openapi.0.6.0.yaml
Move the specification page to v0.6.0, correct the patch rule, and add
the version negotiation rules from ADR 0032, including the
successor-version link that announces a change of default. Add the
discovery route to the routes tables, v0.6.0 migration notes, and a
Versioning page that explains the model with the ADR's examples.
@SnowboardTechie SnowboardTechie self-assigned this Nov 20, 2026
@github-actions github-actions Bot added website Issues related to the website core Issues related to @common-grants/core library dependencies Pull requests that update a dependency file typescript Issue or PR related to TypeScript tooling labels Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Website Preview Deployed!

Preview your changes at: https://pr-1423-common-grants.agile6.workers.dev

Built from commit 67fe607

@SnowboardTechie SnowboardTechie linked an issue Nov 20, 2026 that may be closed by this pull request
3 tasks
Adds GET /common-grants/versions to the 0.6.0 base API, tagged optional,
with the VersionDiscovery, OperationVersions, UpcomingDefault and
VersionRetirement models and a protocolVersion type. The route lets a
server publish its default version, the versions every route serves,
per-route exceptions, an upcoming default and deprecated versions, per
the API version negotiation ADR draft (#1159, #1372).

Versions.v0_6 and Types.protocolVersion are stubs owned by #1386 and
are dropped when that PR lands. The 0.1.0 through 0.5.0 OpenAPI
documents are unchanged.

Refs #1387
Discovery sits outside version selection, so its models tolerate
fields they don't know instead of being versioned per document, as
the route description promises. The baseline fields now say they
describe routes without an operations entry, versions requires at
least one entry, and the deprecated map documents its keys.

Refs #1387
OkT now spreads the version response headers, so discovery would have
advertised CG-Version-Served and Vary. ADR 0032 says discovery carries
neither, because clients call it before they know which version to
request. The route returns a dedicated VersionDiscoveryResponse instead.

Refs #1387
The defaultVersion docs now say a default is one of the listed
versions, which the schema can't express. The route description adds
the ADR's authentication ceiling and narrows "fields are only ever
added" to data, since the response envelope stays closed. The
interface comment says adopters don't type-parameterize the response,
now that the models accept unknown fields.

Refs #1387
Validate each key of `deprecated` against the protocol version format in the
JSON Schema files, and say that an upcoming default is one of `versions`, as
ADR 0032 requires of every default.
A key is written exactly as its version appears in `versions`. Matching on
major and minor is how a client finds the entry for the version it requested,
so say that separately, with an example.
…nto bryan/1389-versioning-docs

# Conflicts:
#	lib/core/lib/core/models/version-discovery.tsp
#	website/public/openapi/openapi.0.6.0.yaml
#	website/public/schemas/yaml/OperationVersions.yaml
#	website/public/schemas/yaml/VersionDiscovery.yaml
…sioning-docs

# Conflicts:
#	website/src/content/docs/governance/adr/0028-mock-api-hosting.md

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues related to @common-grants/core library dependencies Pull requests that update a dependency file typescript Issue or PR related to TypeScript tooling website Issues related to the website

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Core] Update the protocol docs for versioning

1 participant