@radicaltools/cli 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +353 -33
  2. package/dist/hub-catalogue/concern/concern-api-collections.radical +1136 -0
  3. package/dist/hub-catalogue/concern/concern-api-errors.radical +1180 -0
  4. package/dist/hub-catalogue/concern/concern-api-evolution.radical +1174 -0
  5. package/dist/hub-catalogue/concern/concern-api-idempotency.radical +1218 -0
  6. package/dist/hub-catalogue/concern/concern-api-resource-design.radical +1102 -0
  7. package/dist/hub-catalogue/concern/concern-api-style-guide.radical +1210 -0
  8. package/dist/hub-catalogue/concern/concern-architecture-style.radical +1268 -0
  9. package/dist/hub-catalogue/concern/concern-audit-trail.radical +1096 -0
  10. package/dist/hub-catalogue/concern/concern-authentication.radical +895 -0
  11. package/dist/hub-catalogue/concern/concern-authorization.radical +1686 -0
  12. package/dist/hub-catalogue/concern/concern-availability.radical +1028 -0
  13. package/dist/hub-catalogue/concern/concern-backend-stack.radical +1037 -0
  14. package/dist/hub-catalogue/concern/concern-backup-recovery.radical +1560 -0
  15. package/dist/hub-catalogue/concern/concern-caching.radical +1294 -0
  16. package/dist/hub-catalogue/concern/concern-capacity.radical +915 -0
  17. package/dist/hub-catalogue/concern/concern-code-documentation.radical +1397 -0
  18. package/dist/hub-catalogue/concern/concern-code-quality-gate.radical +1409 -0
  19. package/dist/hub-catalogue/concern/concern-code-review-branching.radical +1416 -0
  20. package/dist/hub-catalogue/concern/concern-code-style.radical +1058 -0
  21. package/dist/hub-catalogue/concern/concern-communication-style.radical +1508 -0
  22. package/dist/hub-catalogue/concern/concern-data-classification.radical +970 -0
  23. package/dist/hub-catalogue/concern/concern-data-consistency.radical +1112 -0
  24. package/dist/hub-catalogue/concern/concern-data-store.radical +1282 -0
  25. package/dist/hub-catalogue/concern/concern-decomposition.radical +1318 -0
  26. package/dist/hub-catalogue/concern/concern-definition-of-done.radical +1214 -0
  27. package/dist/hub-catalogue/concern/concern-delivery-metrics.radical +966 -0
  28. package/dist/hub-catalogue/concern/concern-dependency-hygiene.radical +1345 -0
  29. package/dist/hub-catalogue/concern/concern-deployment.radical +1203 -0
  30. package/dist/hub-catalogue/concern/concern-encryption.radical +1318 -0
  31. package/dist/hub-catalogue/concern/concern-error-handling-logging.radical +1197 -0
  32. package/dist/hub-catalogue/concern/concern-eu-dora.radical +1321 -0
  33. package/dist/hub-catalogue/concern/concern-frontend-stack.radical +1647 -0
  34. package/dist/hub-catalogue/concern/concern-incident-management.radical +1204 -0
  35. package/dist/hub-catalogue/concern/concern-infrastructure.radical +2183 -0
  36. package/dist/hub-catalogue/concern/concern-integration-resilience.radical +1116 -0
  37. package/dist/hub-catalogue/concern/concern-messaging.radical +973 -0
  38. package/dist/hub-catalogue/concern/concern-module-boundaries.radical +867 -0
  39. package/dist/hub-catalogue/concern/concern-observability.radical +997 -0
  40. package/dist/hub-catalogue/concern/concern-operational-readiness.radical +1249 -0
  41. package/dist/hub-catalogue/concern/concern-personal-data.radical +1949 -0
  42. package/dist/hub-catalogue/concern/concern-quality-priorities.radical +1091 -0
  43. package/dist/hub-catalogue/concern/concern-rate-limiting.radical +1445 -0
  44. package/dist/hub-catalogue/concern/concern-release-versioning.radical +1358 -0
  45. package/dist/hub-catalogue/concern/concern-retention.radical +1399 -0
  46. package/dist/hub-catalogue/concern/concern-secrets.radical +1284 -0
  47. package/dist/hub-catalogue/concern/concern-secure-coding.radical +1379 -0
  48. package/dist/hub-catalogue/concern/concern-secure-development.radical +1245 -0
  49. package/dist/hub-catalogue/concern/concern-security-detection.radical +1153 -0
  50. package/dist/hub-catalogue/concern/concern-supply-chain.radical +1386 -0
  51. package/dist/hub-catalogue/concern/concern-technical-debt.radical +1450 -0
  52. package/dist/hub-catalogue/concern/concern-technology-lifecycle.radical +1145 -0
  53. package/dist/hub-catalogue/concern/concern-tenant-isolation.radical +1440 -0
  54. package/dist/hub-catalogue/concern/concern-test-strategy.radical +1212 -0
  55. package/dist/hub-catalogue/concern/concern-threat-modelling.radical +1143 -0
  56. package/dist/index.js +12712 -7144
  57. package/package.json +5 -3
@@ -0,0 +1,1174 @@
1
+ {
2
+ "hub": {
3
+ "id": "concern-api-evolution",
4
+ "category": "concern",
5
+ "name": "API evolution",
6
+ "description": "An API that systems outside yours call: how its contract is written, how it may change without breaking its callers, how versions are named, and how long an old one lives. Contracts between your own parts are decided in the Communication style pack.",
7
+ "tags": [
8
+ "api",
9
+ "versioning",
10
+ "compatibility",
11
+ "contracts",
12
+ "deprecation",
13
+ "contract-testing"
14
+ ],
15
+ "requiredMetamodel": "c4-ddd-governance-builtin",
16
+ "concern": {
17
+ "id": "api-evolution",
18
+ "trigger": "LIST RELATIONS WHERE source.external = true AND target.external != true AND (target.type = \"system\" OR target.type = \"container\" OR target.type = \"webapp\" OR target.type = \"component\")",
19
+ "applyTo": "target",
20
+ "why": "systems outside yours call these elements, so how their API may change without breaking them has to be decided.",
21
+ "group": "api"
22
+ },
23
+ "sources": [
24
+ {
25
+ "title": "OpenAPI Specification (latest)",
26
+ "url": "https://spec.openapis.org/oas/latest.html"
27
+ },
28
+ {
29
+ "title": "GraphQL Specification (October 2021), @deprecated",
30
+ "url": "https://spec.graphql.org/October2021/#sec--deprecated"
31
+ },
32
+ {
33
+ "title": "RFC 8594, The Sunset HTTP Header Field",
34
+ "url": "https://www.rfc-editor.org/rfc/rfc8594"
35
+ },
36
+ {
37
+ "title": "RFC 9745, The Deprecation HTTP Response Header Field",
38
+ "url": "https://www.rfc-editor.org/rfc/rfc9745"
39
+ },
40
+ {
41
+ "title": "Google AIP-180, Backwards compatibility",
42
+ "url": "https://google.aip.dev/180"
43
+ },
44
+ {
45
+ "title": "Google AIP-185, API Versioning",
46
+ "url": "https://google.aip.dev/185"
47
+ },
48
+ {
49
+ "title": "Microsoft REST API Guidelines",
50
+ "url": "https://github.com/microsoft/api-guidelines"
51
+ },
52
+ {
53
+ "title": "microservices.io, Service Integration Contract Test",
54
+ "url": "https://microservices.io/patterns/testing/service-integration-contract-test.html"
55
+ },
56
+ {
57
+ "title": "Pact documentation",
58
+ "url": "https://docs.pact.io/"
59
+ }
60
+ ],
61
+ "templateParams": [
62
+ {
63
+ "key": "FORMAT",
64
+ "title": "Contract",
65
+ "label": "How is the API described?",
66
+ "hint": "A machine-readable contract is what callers generate clients from and what every change is checked against for breaks.",
67
+ "defaultValue": "openapi",
68
+ "options": [
69
+ {
70
+ "value": "openapi",
71
+ "label": "OpenAPI 3.1",
72
+ "description": "REST over HTTP, described in an OpenAPI document; breaking changes are found with oasdiff. Pick it for resource-style HTTP APIs and for public or partner APIs, where callers expect plain HTTP and JSON."
73
+ },
74
+ {
75
+ "value": "graphql",
76
+ "label": "a GraphQL schema",
77
+ "description": "One endpoint where callers choose the fields they read; it evolves by adding fields and marking old ones @deprecated, checked with graphql-inspector. Pick it when many clients need different shapes of the same data, usually front ends; it goes with no versions, deprecation field by field."
78
+ },
79
+ {
80
+ "value": "protobuf",
81
+ "label": "Protocol Buffers (gRPC)",
82
+ "description": "Binary contracts in .proto files whose field numbers are never reused, checked with buf breaking. Pick it for service-to-service calls with high volume or streaming, where both sides use generated code."
83
+ }
84
+ ]
85
+ },
86
+ {
87
+ "key": "VERSIONING",
88
+ "title": "Versions",
89
+ "label": "How does a caller name the version it wants?",
90
+ "hint": "Released versions only ever add; this decides where a breaking change goes: a new version beside the old one, or a deprecation of the old element in the only version.",
91
+ "defaultValue": "path",
92
+ "options": [
93
+ {
94
+ "value": "path",
95
+ "label": "a major version in the path",
96
+ "description": "/v1/, /v2/ in the URL; for Protocol Buffers the package suffix .v1 (AIP-185). Pick it for public and partner REST or gRPC APIs: the version shows in every log line and is easy to route and to cache. Unusual with a GraphQL schema, which has one endpoint: pick no versions there."
97
+ },
98
+ {
99
+ "value": "header",
100
+ "label": "a version header",
101
+ "description": "Callers name the version in an Api-Version header (gRPC metadata api-version for Protocol Buffers), often a date as Stripe does. Pick it when URLs must stay the same across versions (stored links, hypermedia) or versions are frequent and small. Unusual with a GraphQL schema: pick no versions there."
102
+ },
103
+ {
104
+ "value": "none",
105
+ "label": "no versions, deprecation field by field",
106
+ "description": "There is only ever one version: an element is removed only after it has been deprecated for the sunset period and nobody uses it. Pick it for GraphQL, or for any API where you can see each caller's usage."
107
+ }
108
+ ]
109
+ },
110
+ {
111
+ "key": "CONTRACT_TESTS",
112
+ "title": "Contract tests",
113
+ "label": "How is it checked that the API keeps its promises?",
114
+ "hint": "A contract diff finds a break in the document; a test against the running API finds a break in what it really serves.",
115
+ "defaultValue": "pact",
116
+ "options": [
117
+ {
118
+ "value": "pact",
119
+ "label": "consumer-driven contract tests (Pact)",
120
+ "description": "Each caller records the interactions it relies on and publishes them to a Pact Broker; every build of the API verifies them all, and can-i-deploy blocks a release that would break one. Pick it when the callers are known teams who can run Pact in their builds."
121
+ },
122
+ {
123
+ "value": "conformance",
124
+ "label": "conformance tests against the contract",
125
+ "description": "Tests generated from the published contract (Schemathesis for OpenAPI and GraphQL; for gRPC, the server's reflection compared with the contract and every RPC probed) call the running API and fail on any answer the contract does not describe. Pick it when callers are unknown or outside (a public API, many partners) and cannot give you tests."
126
+ }
127
+ ]
128
+ },
129
+ {
130
+ "key": "SUNSET_MONTHS",
131
+ "label": "For how many months is a deprecated version or field still served?",
132
+ "defaultValue": "6",
133
+ "type": "number"
134
+ },
135
+ {
136
+ "key": "USAGE_DAYS",
137
+ "label": "For how many days must nobody use a deprecated element before it is removed?",
138
+ "defaultValue": "30",
139
+ "type": "number"
140
+ }
141
+ ]
142
+ },
143
+ "nodes": [
144
+ {
145
+ "id": "need",
146
+ "type": "need",
147
+ "label": "Callers not broken",
148
+ "x": 0,
149
+ "y": 0,
150
+ "kind": "brief",
151
+ "source": "Hub concern pack: API evolution",
152
+ "description": "Other systems call this API, and they are released on their own schedule by people who do not see our code. A renamed field, a new required parameter, a narrower type or a changed error breaks them without warning; without a contract nobody can tell which change breaks what, and without notice and a date a caller cannot plan its move off an old version. The API also has to keep changing, so the rules must make safe changes cheap and unsafe ones visible."
153
+ },
154
+ {
155
+ "id": "req-contract",
156
+ "type": "requirement",
157
+ "label": "Contract published",
158
+ "x": 260,
159
+ "y": 0,
160
+ "ears_type": "ubiquitous",
161
+ "action": "publish its interface as {{FORMAT}}, kept in the repository with the code, tagged with every release, and served at a stable URL that holds the document of the release deployed",
162
+ "rationale": "The contract is what callers build against and what every change is checked against; a published copy that is not the deployed release's is worse than none (OpenAPI Specification; Google AIP-180)."
163
+ },
164
+ {
165
+ "id": "req-compat",
166
+ "type": "requirement",
167
+ "label": "Breaking changes versioned",
168
+ "x": 260,
169
+ "y": 130,
170
+ "ears_type": "unwanted-behaviour",
171
+ "unwanted_condition": "a pull request removes or renames a field, operation, enum value or error code, makes an optional input required, narrows a type, or changes what a field means",
172
+ "action": "refuse it unless the change goes into a new version served beside the old one, so that 0 breaking changes reach a released version",
173
+ "rationale": "Adding is safe; anything else breaks a caller that has not changed (Google AIP-180 lists the changes that break source, wire and semantic compatibility).",
174
+ "hubWhen": {
175
+ "VERSIONING": [
176
+ "path",
177
+ "header"
178
+ ]
179
+ }
180
+ },
181
+ {
182
+ "id": "req-path",
183
+ "type": "requirement",
184
+ "label": "Major version in path",
185
+ "x": 260,
186
+ "y": 260,
187
+ "ears_type": "ubiquitous",
188
+ "action": "serve each major version under its own path prefix (/v1/, /v2/; the package suffix .v1 for Protocol Buffers), serve at most two major versions at once, and change a released major version only by adding",
189
+ "rationale": "A version in the path is visible in every log and easy to route; two at a time bounds the cost of keeping old ones (Google AIP-185, Microsoft REST API Guidelines).",
190
+ "hubWhen": {
191
+ "VERSIONING": [
192
+ "path"
193
+ ]
194
+ }
195
+ },
196
+ {
197
+ "id": "req-header",
198
+ "type": "requirement",
199
+ "label": "Version named per request",
200
+ "x": 260,
201
+ "y": 390,
202
+ "ears_type": "unwanted-behaviour",
203
+ "unwanted_condition": "a request carries no Api-Version header, or names a version that is not served",
204
+ "action": "answer 400 with the list of versions served",
205
+ "rationale": "A caller that does not name a version gets whatever is newest and breaks on the next release; requiring it makes the dependency explicit (Microsoft REST API Guidelines require an explicit api-version).",
206
+ "hubWhen": {
207
+ "VERSIONING": [
208
+ "header"
209
+ ]
210
+ }
211
+ },
212
+ {
213
+ "id": "req-header-echo",
214
+ "type": "requirement",
215
+ "label": "Version echoed, two at most",
216
+ "x": 260,
217
+ "y": 520,
218
+ "ears_type": "ubiquitous",
219
+ "action": "answer every request in the version its Api-Version header names, echo that version in the Api-Version response header, and serve at most two versions at once",
220
+ "rationale": "The echo lets a caller and a log line prove which version answered; two at a time bounds the cost of keeping old ones (Microsoft REST API Guidelines).",
221
+ "hubWhen": {
222
+ "VERSIONING": [
223
+ "header"
224
+ ]
225
+ }
226
+ },
227
+ {
228
+ "id": "req-versionless",
229
+ "type": "requirement",
230
+ "label": "Removal only after disuse",
231
+ "x": 260,
232
+ "y": 650,
233
+ "ears_type": "unwanted-behaviour",
234
+ "unwanted_condition": "a pull request removes, renames or changes the meaning of an element of the contract",
235
+ "action": "refuse it unless the element has been deprecated for at least {{SUNSET_MONTHS}} months and no caller has used it for {{USAGE_DAYS}} days",
236
+ "rationale": "With a single version nothing may break in place; usage data is what makes a removal safe (GraphQL Specification, @deprecated; Google AIP-180).",
237
+ "hubWhen": {
238
+ "VERSIONING": [
239
+ "none"
240
+ ]
241
+ }
242
+ },
243
+ {
244
+ "id": "req-sunset",
245
+ "type": "requirement",
246
+ "label": "Deprecation announced",
247
+ "x": 260,
248
+ "y": 780,
249
+ "ears_type": "event-driven",
250
+ "trigger": "a version or operation is deprecated",
251
+ "action": "mark it deprecated: true with an x-sunset date at least {{SUNSET_MONTHS}} months away in the contract, add a Deprecation header (RFC 9745) and a Sunset header (RFC 8594) with that date to every answer that uses it, tell every known caller, and keep serving it until that date",
252
+ "rationale": "Callers need notice they can read in code and a date they can plan for; the headers make both machine-readable (RFC 9745, RFC 8594).",
253
+ "hubWhen": {
254
+ "FORMAT": [
255
+ "openapi"
256
+ ]
257
+ }
258
+ },
259
+ {
260
+ "id": "req-sunset-graphql",
261
+ "type": "requirement",
262
+ "label": "Deprecation announced per field",
263
+ "x": 260,
264
+ "y": 910,
265
+ "ears_type": "event-driven",
266
+ "trigger": "a field, argument or enum value is deprecated",
267
+ "action": "mark it @deprecated with a reason that ends in \"deprecated YYYY-MM-DD, sunset YYYY-MM-DD\", the sunset at least {{SUNSET_MONTHS}} months after the deprecation, tell every known caller, and keep serving it until that date",
268
+ "rationale": "One endpoint answers many fields at once, so a per-answer header cannot name a field; the reason in the schema is what every client and tool reads (GraphQL Specification, @deprecated).",
269
+ "hubWhen": {
270
+ "FORMAT": [
271
+ "graphql"
272
+ ]
273
+ }
274
+ },
275
+ {
276
+ "id": "req-sunset-protobuf",
277
+ "type": "requirement",
278
+ "label": "Deprecation announced per field",
279
+ "x": 260,
280
+ "y": 1040,
281
+ "ears_type": "event-driven",
282
+ "trigger": "a field, RPC or enum value is deprecated",
283
+ "action": "mark it [deprecated = true] with a comment above it \"Deprecated: YYYY-MM-DD, sunset: YYYY-MM-DD\", the sunset at least {{SUNSET_MONTHS}} months after the deprecation, tell every known caller, keep serving it until that date, and reserve its number and name when it is removed",
284
+ "rationale": "Generated code warns on a deprecated field, and the dates in the contract are what callers plan by; reserving keeps the number from ever meaning something else (Google AIP-180).",
285
+ "hubWhen": {
286
+ "FORMAT": [
287
+ "protobuf"
288
+ ]
289
+ }
290
+ },
291
+ {
292
+ "id": "req-usage",
293
+ "type": "requirement",
294
+ "label": "Usage of deprecated counted",
295
+ "x": 260,
296
+ "y": 1170,
297
+ "ears_type": "ubiquitous",
298
+ "action": "count the calls to every deprecated version, operation and field per calling system and day, export the counts and each sunset date as metrics, and alert the API's owner when an element is called within 30 days of its sunset",
299
+ "rationale": "Without usage per caller, a sunset date is a guess and the callers still on an old version are found by breaking them."
300
+ },
301
+ {
302
+ "id": "req-pact",
303
+ "type": "requirement",
304
+ "label": "Caller contracts verified",
305
+ "x": 260,
306
+ "y": 1300,
307
+ "ears_type": "event-driven",
308
+ "trigger": "the API or one of its callers is built",
309
+ "action": "verify every caller's published contract against the API, and block the deployment of either side while one verification fails",
310
+ "rationale": "A caller's contract states what it really relies on, which a contract diff cannot know (microservices.io, Service Integration Contract Test; Pact documentation).",
311
+ "hubWhen": {
312
+ "CONTRACT_TESTS": [
313
+ "pact"
314
+ ]
315
+ }
316
+ },
317
+ {
318
+ "id": "req-conformance",
319
+ "type": "requirement",
320
+ "label": "Running API conforms",
321
+ "x": 260,
322
+ "y": 1430,
323
+ "ears_type": "event-driven",
324
+ "trigger": "the API is built",
325
+ "action": "run tests generated from its contract against every operation of a running instance, and fail the build on any answer whose status code or body the contract does not describe",
326
+ "rationale": "Callers you cannot ask for tests rely on the contract alone, so the contract must be true of the running API (OpenAPI Specification).",
327
+ "hubWhen": {
328
+ "CONTRACT_TESTS": [
329
+ "conformance"
330
+ ],
331
+ "FORMAT": [
332
+ "openapi",
333
+ "graphql"
334
+ ]
335
+ }
336
+ },
337
+ {
338
+ "id": "req-conformance-grpc",
339
+ "type": "requirement",
340
+ "label": "Running server conforms",
341
+ "x": 260,
342
+ "y": 1560,
343
+ "ears_type": "event-driven",
344
+ "trigger": "the API is built",
345
+ "action": "compare the services a running instance reflects with the services of the contract, call every RPC with an empty request, and fail the build on a service missing or extra or on an RPC answering Unknown or Internal",
346
+ "rationale": "Generated stubs make the shapes match; what they cannot show is a service left unregistered or an RPC that crashes on input the contract allows (Google AIP-180).",
347
+ "hubWhen": {
348
+ "CONTRACT_TESTS": [
349
+ "conformance"
350
+ ],
351
+ "FORMAT": [
352
+ "protobuf"
353
+ ]
354
+ }
355
+ },
356
+ {
357
+ "id": "sc-contract",
358
+ "type": "scenario",
359
+ "label": "Published contract is the release's",
360
+ "x": 520,
361
+ "y": 0,
362
+ "given": "a deployed release of the API",
363
+ "when": "the contract is fetched from the stable URL and compared with the document at the release tag",
364
+ "then": "the two are the same, operation by operation and field by field"
365
+ },
366
+ {
367
+ "id": "sc-compat",
368
+ "type": "scenario",
369
+ "label": "Breaking change refused",
370
+ "x": 520,
371
+ "y": 130,
372
+ "given": "a pull request that renames a response field of a released version",
373
+ "when": "the contract check compares it with the last release",
374
+ "then": "the check fails, and passes once the rename is in a new version",
375
+ "hubWhen": {
376
+ "VERSIONING": [
377
+ "path",
378
+ "header"
379
+ ]
380
+ }
381
+ },
382
+ {
383
+ "id": "sc-path",
384
+ "type": "scenario",
385
+ "label": "Two versions side by side",
386
+ "x": 520,
387
+ "y": 260,
388
+ "given": "major versions 1 and 2 served",
389
+ "when": "a caller calls the same operation under /v1/ and /v2/, and the served prefixes are listed from the router",
390
+ "then": "each answers in its own shape, and the list holds no more than two prefixes",
391
+ "hubWhen": {
392
+ "VERSIONING": [
393
+ "path"
394
+ ]
395
+ }
396
+ },
397
+ {
398
+ "id": "sc-header",
399
+ "type": "scenario",
400
+ "label": "Missing version refused",
401
+ "x": 520,
402
+ "y": 390,
403
+ "given": "versions 2025-01-01 and 2026-01-01 served",
404
+ "when": "a request comes without Api-Version and one with 2024-01-01",
405
+ "then": "both get 400 with a body that lists 2025-01-01 and 2026-01-01",
406
+ "hubWhen": {
407
+ "VERSIONING": [
408
+ "header"
409
+ ]
410
+ }
411
+ },
412
+ {
413
+ "id": "sc-header-echo",
414
+ "type": "scenario",
415
+ "label": "Version echoed",
416
+ "x": 520,
417
+ "y": 520,
418
+ "given": "versions 2025-01-01 and 2026-01-01 served",
419
+ "when": "a request names 2026-01-01, and the served versions are listed",
420
+ "then": "the answer carries Api-Version: 2026-01-01 and the list holds no more than two versions",
421
+ "hubWhen": {
422
+ "VERSIONING": [
423
+ "header"
424
+ ]
425
+ }
426
+ },
427
+ {
428
+ "id": "sc-versionless",
429
+ "type": "scenario",
430
+ "label": "Used field kept",
431
+ "x": 520,
432
+ "y": 650,
433
+ "given": "a field deprecated {{SUNSET_MONTHS}} months ago that one caller used yesterday",
434
+ "when": "a pull request removes it",
435
+ "then": "the check fails and names the caller; with {{USAGE_DAYS}} days without a call it passes",
436
+ "hubWhen": {
437
+ "VERSIONING": [
438
+ "none"
439
+ ]
440
+ }
441
+ },
442
+ {
443
+ "id": "sc-sunset",
444
+ "type": "scenario",
445
+ "label": "Deprecation carries a date",
446
+ "x": 520,
447
+ "y": 780,
448
+ "given": "an operation deprecated today",
449
+ "when": "a caller calls it",
450
+ "then": "the answer carries Deprecation with today's date and Sunset at least {{SUNSET_MONTHS}} months later, equal to the contract's x-sunset, and the operation still works",
451
+ "hubWhen": {
452
+ "FORMAT": [
453
+ "openapi"
454
+ ]
455
+ }
456
+ },
457
+ {
458
+ "id": "sc-sunset-graphql",
459
+ "type": "scenario",
460
+ "label": "Field carries its dates",
461
+ "x": 520,
462
+ "y": 910,
463
+ "given": "a field deprecated today",
464
+ "when": "the schema is introspected",
465
+ "then": "its deprecation reason ends in today's date and a sunset at least {{SUNSET_MONTHS}} months later, and the field still resolves",
466
+ "hubWhen": {
467
+ "FORMAT": [
468
+ "graphql"
469
+ ]
470
+ }
471
+ },
472
+ {
473
+ "id": "sc-sunset-protobuf",
474
+ "type": "scenario",
475
+ "label": "Field carries its dates",
476
+ "x": 520,
477
+ "y": 1040,
478
+ "given": "a field deprecated today",
479
+ "when": "the .proto files are checked",
480
+ "then": "the field is marked deprecated with today's date and a sunset at least {{SUNSET_MONTHS}} months later",
481
+ "hubWhen": {
482
+ "FORMAT": [
483
+ "protobuf"
484
+ ]
485
+ }
486
+ },
487
+ {
488
+ "id": "sc-usage",
489
+ "type": "scenario",
490
+ "label": "Laggards identified",
491
+ "x": 520,
492
+ "y": 1170,
493
+ "given": "a deprecated operation called by two systems, its sunset 20 days away",
494
+ "when": "the usage metrics are read",
495
+ "then": "they list both systems with their call counts, and the owner is alerted"
496
+ },
497
+ {
498
+ "id": "sc-pact",
499
+ "type": "scenario",
500
+ "label": "Break caught before deploy",
501
+ "x": 520,
502
+ "y": 1300,
503
+ "given": "a caller whose contract reads the field \"total\"",
504
+ "when": "a build of the API drops \"total\" and asks to deploy",
505
+ "then": "the verification fails and the deployment is blocked",
506
+ "hubWhen": {
507
+ "CONTRACT_TESTS": [
508
+ "pact"
509
+ ]
510
+ }
511
+ },
512
+ {
513
+ "id": "sc-conformance",
514
+ "type": "scenario",
515
+ "label": "Undocumented answer caught",
516
+ "x": 520,
517
+ "y": 1430,
518
+ "given": "an operation that answers 500 for an empty name, not described in the contract",
519
+ "when": "the conformance tests run on the build",
520
+ "then": "they fail and name the operation and the input",
521
+ "hubWhen": {
522
+ "CONTRACT_TESTS": [
523
+ "conformance"
524
+ ],
525
+ "FORMAT": [
526
+ "openapi",
527
+ "graphql"
528
+ ]
529
+ }
530
+ },
531
+ {
532
+ "id": "sc-conformance-grpc",
533
+ "type": "scenario",
534
+ "label": "Unregistered service caught",
535
+ "x": 520,
536
+ "y": 1560,
537
+ "given": "a service in the contract the server does not register",
538
+ "when": "the conformance step runs on the build",
539
+ "then": "it fails and names the service",
540
+ "hubWhen": {
541
+ "CONTRACT_TESTS": [
542
+ "conformance"
543
+ ],
544
+ "FORMAT": [
545
+ "protobuf"
546
+ ]
547
+ }
548
+ },
549
+ {
550
+ "id": "adr-version-path",
551
+ "type": "adr",
552
+ "label": "Additive changes, major version in the path",
553
+ "x": 780,
554
+ "y": 0,
555
+ "concern": "api-evolution",
556
+ "status": "accepted",
557
+ "date": "",
558
+ "context": "Other systems call this element through its API, and they are built and released by other people on their own schedule. The forces: a renamed field, a new required input, a narrowed type or a changed error code breaks a caller that cannot change on the same day; without a machine-readable contract nobody can tell which change breaks what, so breaks are found in production; every version kept alive costs code, tests and attention; callers have to hear that something is going away early enough to move, and with a date they can plan for; and the contract callers read must be what the API really serves. Snippets assume one contract document per served version under api/ (api/v1.yaml, api/v2.yaml; schema.graphql for GraphQL; .proto files under api/ for Protocol Buffers), the router's table in src/app and the released contract reachable at $API_URL.",
559
+ "decision": "The API is described in {{FORMAT}}, kept with the code, one contract document per served version. Released versions change only by adding; a breaking change goes into a new major version under its own path prefix (/v2/, or the package suffix .v2 for Protocol Buffers; for a GraphQL schema the endpoint /v2/graphql), served beside the previous one. At most two major versions are served at once. A deprecated version is marked in its contract with its sunset date, announced to callers (Deprecation and Sunset headers over HTTP) and served for {{SUNSET_MONTHS}} months; calls to it are counted per caller and alerted near the sunset. Every pull request diffs each version's document against the last release's (oasdiff for OpenAPI, graphql-inspector for GraphQL, buf breaking for Protocol Buffers) and fails on a break; a new version has nothing to diff against. Promises to callers are checked by {{CONTRACT_TESTS}}. Choosing what counts as breaking: Google AIP-180 (source, wire and semantic compatibility).",
560
+ "consequences": "• Callers upgrade when they choose, within {{SUNSET_MONTHS}} months of a deprecation.\n• Two major versions run side by side for a while: twice the routes, tests and documentation.\n• A breaking change costs a whole new major version, so teams batch them and design for adding.\n• Fields and field numbers are never reused for something else.",
561
+ "alternatives": "1. A version header: stable URLs, but the version is hidden from logs and caches.\n2. No versions, field-by-field deprecation: cheaper, but needs usage data for every caller.\n3. Releasing with the callers: only for callers inside our own release, which the Communication style pack decides.",
562
+ "hubWhen": {
563
+ "VERSIONING": [
564
+ "path"
565
+ ]
566
+ }
567
+ },
568
+ {
569
+ "id": "adr-version-header",
570
+ "type": "adr",
571
+ "label": "Additive changes, version named in a header",
572
+ "x": 780,
573
+ "y": 130,
574
+ "concern": "api-evolution",
575
+ "status": "accepted",
576
+ "date": "",
577
+ "context": "Other systems call this element through its API, and they are built and released by other people on their own schedule. The forces: a renamed field, a new required input, a narrowed type or a changed error code breaks a caller that cannot change on the same day; without a machine-readable contract nobody can tell which change breaks what, so breaks are found in production; every version kept alive costs code, tests and attention; callers have to hear that something is going away early enough to move, and with a date they can plan for; and the contract callers read must be what the API really serves. Snippets assume one contract document per served version under api/ (api/v1.yaml, api/v2.yaml; schema.graphql for GraphQL; .proto files under api/ for Protocol Buffers), the router's table in src/app and the released contract reachable at $API_URL.",
578
+ "decision": "The API is described in {{FORMAT}}, kept with the code, one contract document per served version (api/2026-01-01.yaml). Released versions change only by adding; a breaking change goes into a new version that callers ask for in the Api-Version header (gRPC metadata api-version for Protocol Buffers; for a GraphQL schema the same header on the one endpoint). A request without a served version is answered 400 with the versions served; the version served is echoed in the response. At most two versions are served at once, each translated from one implementation by a version layer at the edge (as Stripe does with dated versions). A deprecated version is marked in its contract with its sunset date, announced to callers (Deprecation and Sunset headers over HTTP) and served for {{SUNSET_MONTHS}} months; calls to it are counted per caller and alerted near the sunset. Every pull request diffs each version's document against the last release's and fails on a break; a new version has nothing to diff against. Promises to callers are checked by {{CONTRACT_TESTS}}.",
579
+ "consequences": "• URLs and links stay the same across versions.\n• Every caller must send the header; clients that do not are refused, which surfaces them early.\n• Caches and gateways must vary on Api-Version.\n• The version layer is code of its own that has to be tested per version.",
580
+ "alternatives": "1. A major version in the path: visible and easy to route, but URLs change with every major version.\n2. A query parameter (api-version, as Azure does): visible in logs, but easy to drop when links are copied.\n3. No versions, field-by-field deprecation.",
581
+ "hubWhen": {
582
+ "VERSIONING": [
583
+ "header"
584
+ ]
585
+ }
586
+ },
587
+ {
588
+ "id": "adr-versionless",
589
+ "type": "adr",
590
+ "label": "One version, deprecated field by field",
591
+ "x": 780,
592
+ "y": 260,
593
+ "concern": "api-evolution",
594
+ "status": "accepted",
595
+ "date": "",
596
+ "context": "Other systems call this element through its API, and they are built and released by other people on their own schedule. The forces: a renamed field, a new required input, a narrowed type or a changed error code breaks a caller that cannot change on the same day; without a machine-readable contract nobody can tell which change breaks what, so breaks are found in production; every version kept alive costs code, tests and attention; callers have to hear that something is going away early enough to move, and with a date they can plan for; and the contract callers read must be what the API really serves. Snippets assume one contract document per served version under api/ (api/v1.yaml, api/v2.yaml; schema.graphql for GraphQL; .proto files under api/ for Protocol Buffers), the router's table in src/app and the released contract reachable at $API_URL.",
597
+ "decision": "The API is described in {{FORMAT}}, kept with the code, and has a single version. It changes only by adding; an element to go is marked deprecated in the contract with its dates (@deprecated with the sunset in its reason in GraphQL, deprecated: true with x-sunset in OpenAPI, [deprecated = true] with a dated comment in Protocol Buffers), announced to callers (Deprecation and Sunset headers over HTTP), and is removed only after {{SUNSET_MONTHS}} months and {{USAGE_DAYS}} days without a call, as the usage counts per caller show. Every pull request is diffed against the last release's contract (oasdiff with its deprecation grace period, graphql-inspector with the usage rule, buf breaking with reserved numbers and names) and fails on a removal the dates and the usage data do not allow. Promises to callers are checked by {{CONTRACT_TESTS}}. Choose it over versions when the API is GraphQL or you can see every caller's usage; prefer versions for public APIs whose callers you cannot see.",
598
+ "consequences": "• Callers never migrate between versions; they only stop using what is deprecated.\n• Usage per caller and field has to be collected and kept, or nothing can ever be removed.\n• A change of meaning cannot be made in place: it needs a new field with a new name.",
599
+ "alternatives": "1. A major version in the path or a header: lets breaking changes happen in bulk, at the cost of running versions side by side.\n2. Releasing with the callers: only for callers inside our own release, which the Communication style pack decides.",
600
+ "hubWhen": {
601
+ "VERSIONING": [
602
+ "none"
603
+ ]
604
+ }
605
+ },
606
+ {
607
+ "id": "ff-oasdiff",
608
+ "type": "fitness-fn",
609
+ "label": "OpenAPI break check",
610
+ "x": 1040,
611
+ "y": 0,
612
+ "characteristic": "compatibility",
613
+ "scope": "atomic",
614
+ "cadence": "triggered",
615
+ "trigger": "pull-request",
616
+ "invocation": "automated",
617
+ "description": "In every pull request, oasdiff compares each contract document with the same document at the last release tag and fails on any change it rates as breaking (removed or renamed operations and fields, new required inputs, narrowed types, removed enum values); a deprecated operation must carry x-sunset at least {{SUNSET_MONTHS}} months away, and once that date has passed its removal is not breaking (whether anybody still calls it is checked by the usage alert). A new version is a new document with nothing to diff against. After each deployment the same tool compares the stable URL with the release's document.\n\nThreshold: 0 breaking changes (oasdiff level ERR) between each version's document at the last release tag and the pull request, a removal after its x-sunset date and {{SUNSET_MONTHS}} months of deprecation not counting; after a deployment, 0 differences between the stable URL and the release's document\n\nTool: oasdiff\n\n```yaml\n# .github/workflows/api-contract.yml (job steps; actions/checkout@v4.2.2 with fetch-depth: 0 — pin by commit SHA in your repository)\n- name: No breaking API changes outside a new version\n run: |\n last=$(git describe --tags --abbrev=0)\n for doc in api/*.yaml; do # one document per served version\n git show \"$last:$doc\" > /tmp/base.yaml 2>/dev/null || continue # a new version: nothing to diff against\n docker run --rm -v /tmp:/base -v \"$PWD\":/rev tufin/oasdiff:stable \\\n breaking /base/base.yaml \"/rev/$doc\" --fail-on ERR \\\n --deprecation-days-stable $(( {{SUNSET_MONTHS}} * 30 )) # x-sunset required this far away; removal after it is not breaking\n done\n# after each deployment:\n- name: The stable URL serves the release's contract\n run: |\n for doc in api/*.yaml; do\n docker run --rm -v \"$PWD\":/rev tufin/oasdiff:stable \\\n diff \"/rev/$doc\" \"$API_URL/openapi/$(basename \"$doc\" .yaml).json\" --fail-on-diff\n done\n```",
618
+ "hubWhen": {
619
+ "FORMAT": [
620
+ "openapi"
621
+ ]
622
+ }
623
+ },
624
+ {
625
+ "id": "ff-graphql-inspector",
626
+ "type": "fitness-fn",
627
+ "label": "GraphQL break check",
628
+ "x": 1040,
629
+ "y": 130,
630
+ "characteristic": "compatibility",
631
+ "scope": "atomic",
632
+ "cadence": "triggered",
633
+ "trigger": "pull-request",
634
+ "invocation": "automated",
635
+ "description": "In every pull request, graphql-inspector diffs the schema with the one at the last release tag and fails on a breaking change (a removed field or type, a changed argument, a nullable field made non-null on input). Removing a deprecated field is allowed when the usage module, asked per field, reports no call in the last {{USAGE_DAYS}} days (the dates in the reason are checked by the sunset test). After each deployment the served schema is introspected and must equal the release's.\n\nThreshold: 0 breaking changes between the schema at the last release tag and the pull request, the removal of a deprecated field unused for {{USAGE_DAYS}} days not counting; after a deployment, 0 differences between the served schema and the release's\n\nTool: graphql-inspector\n\n```yaml\n# .github/workflows/api-contract.yml (job steps; actions/checkout@v4.2.2 with fetch-depth: 0 — pin by commit SHA in your repository)\n- name: No breaking schema changes\n run: |\n git show \"$(git describe --tags --abbrev=0)\":schema.graphql > /tmp/base.graphql\n npx @graphql-inspector/cli diff /tmp/base.graphql schema.graphql \\\n --rule suppressRemovalOfDeprecatedField \\\n --rule considerUsage --onUsage ./usage.js\n # usage.js: export default (fields) => Promise<boolean[]>, true when the field had 0 calls in the last {{USAGE_DAYS}} days\n# after each deployment:\n- name: The endpoint serves the release's schema\n run: |\n npx @graphql-inspector/cli introspect \"$API_URL/graphql\" --write /tmp/served.graphql\n npx @graphql-inspector/cli diff schema.graphql /tmp/served.graphql | grep -q 'No changes detected'\n```",
636
+ "hubWhen": {
637
+ "FORMAT": [
638
+ "graphql"
639
+ ]
640
+ }
641
+ },
642
+ {
643
+ "id": "ff-buf",
644
+ "type": "fitness-fn",
645
+ "label": "Protobuf break check",
646
+ "x": 1040,
647
+ "y": 260,
648
+ "characteristic": "compatibility",
649
+ "scope": "atomic",
650
+ "cadence": "triggered",
651
+ "trigger": "pull-request",
652
+ "invocation": "automated",
653
+ "description": "buf lint requires a version suffix on every package, and buf breaking compares the .proto files with the last release tag, failing on a renumbered field, a changed type, a removed RPC, or a field deleted without reserving its number and name (which is how a field past its sunset goes). After each deployment the services the server reflects are compared with the services of the release's descriptors.\n\nThreshold: 0 breaking changes against the last release tag, a deleted field whose number and name are reserved not counting; 0 lint findings, PACKAGE_VERSION_SUFFIX included; after a deployment, the services the server reflects equal the contract's\n\nTool: buf breaking, grpcurl\n\n```yaml\n# buf.yaml\nversion: v2\nlint:\n use: [STANDARD] # includes PACKAGE_VERSION_SUFFIX: acme.orders.v1\nbreaking:\n use: [FILE, FIELD_NO_DELETE_UNLESS_NUMBER_RESERVED, FIELD_NO_DELETE_UNLESS_NAME_RESERVED]\n except: [FIELD_NO_DELETE] # a field may go once its number and name are reserved\n# CI step (checkout with fetch-depth: 0); with a version header, each version is its own module directory, diffed with subdir=:\n# buf lint && buf breaking --against \".git#tag=$(git describe --tags --abbrev=0)\"\n# after each deployment: the server reflects the services of the release\n# buf build -o /tmp/release.binpb\n# diff <(grpcurl -protoset /tmp/release.binpb list | sort) <(grpcurl -plaintext \"$GRPC_ADDRESS\" list | grep -v '^grpc\\.' | sort)\n```",
654
+ "hubWhen": {
655
+ "FORMAT": [
656
+ "protobuf"
657
+ ]
658
+ }
659
+ },
660
+ {
661
+ "id": "ff-sunset",
662
+ "type": "fitness-fn",
663
+ "label": "Deprecations carry a sunset",
664
+ "x": 1040,
665
+ "y": 390,
666
+ "characteristic": "compatibility",
667
+ "scope": "atomic",
668
+ "cadence": "triggered",
669
+ "trigger": "pull-request",
670
+ "invocation": "automated",
671
+ "description": "A test reads the operations marked deprecated from the contract documents (not from a list kept by hand), calls each and checks the Deprecation (RFC 9745) and Sunset (RFC 8594) headers against the contract's x-sunset.\n\nThreshold: Every operation marked deprecated in the contract carries x-sunset and answers with a Deprecation header and a Sunset date equal to it and at least {{SUNSET_MONTHS}} months after the deprecation; 0 without\n\nTool: Vitest with supertest (or the test runner and HTTP client of your stack)\n\n```ts\nimport { readFileSync, readdirSync } from 'node:fs'\nimport { parse } from 'yaml'\nimport request from 'supertest'\nimport { app } from '../src/app'\n\nconst SUNSET_MONTHS = {{SUNSET_MONTHS}}\ntype Op = { deprecated?: boolean; 'x-sunset'?: string; 'x-example'?: string }\nconst deprecated = readdirSync('api').filter((f) => f.endsWith('.yaml')).flatMap((file) => {\n const spec = parse(readFileSync(`api/${file}`, 'utf8'))\n return Object.entries(spec.paths as Record<string, Record<string, Op>>).flatMap(([path, ops]) =>\n Object.entries(ops).filter(([, op]) => op.deprecated).map(([method, op]) => ({ method, path: op['x-example'] ?? path, sunset: op['x-sunset'] })))\n})\n\ndescribe.each(deprecated)('$method $path', ({ method, path, sunset }) => {\n it('announces its deprecation and a sunset far enough away', async () => {\n expect(sunset).toMatch(/^\\d{4}-\\d{2}-\\d{2}/) // x-sunset in the contract\n const res = await request(app)[method](path)\n expect(res.headers.deprecation).toMatch(/^@\\d+$/) // RFC 9745: @<epoch seconds>\n const from = new Date(Number(res.headers.deprecation.slice(1)) * 1000)\n from.setMonth(from.getMonth() + SUNSET_MONTHS)\n expect(Date.parse(res.headers.sunset)).toBe(Date.parse(sunset!)) // RFC 8594, the contract's date\n expect(Date.parse(res.headers.sunset)).toBeGreaterThanOrEqual(from.getTime())\n })\n})\n```",
672
+ "hubWhen": {
673
+ "FORMAT": [
674
+ "openapi"
675
+ ]
676
+ }
677
+ },
678
+ {
679
+ "id": "ff-sunset-graphql",
680
+ "type": "fitness-fn",
681
+ "label": "Deprecated fields carry their dates",
682
+ "x": 1040,
683
+ "y": 520,
684
+ "characteristic": "compatibility",
685
+ "scope": "atomic",
686
+ "cadence": "triggered",
687
+ "trigger": "pull-request",
688
+ "invocation": "automated",
689
+ "description": "A test builds the schema from schema.graphql, walks every type for deprecated fields, arguments and enum values, and checks the two dates in each reason.\n\nThreshold: Every @deprecated field, argument and enum value has a reason ending in \"deprecated YYYY-MM-DD, sunset YYYY-MM-DD\" with the sunset at least {{SUNSET_MONTHS}} months after the deprecation; 0 without\n\nTool: Vitest with the graphql package (or the test runner of your stack)\n\n```ts\nimport { readFileSync } from 'node:fs'\nimport { buildSchema, isObjectType, isInputObjectType, isEnumType, isInterfaceType } from 'graphql'\n\nconst SUNSET_MONTHS = {{SUNSET_MONTHS}}\nconst DATES = /deprecated (\\d{4}-\\d{2}-\\d{2}), sunset (\\d{4}-\\d{2}-\\d{2})$/\nconst schema = buildSchema(readFileSync('schema.graphql', 'utf8'))\nconst deprecated: Array<{ where: string; reason: string | null | undefined }> = []\nfor (const type of Object.values(schema.getTypeMap())) {\n if (type.name.startsWith('__')) continue\n if (isEnumType(type)) for (const v of type.getValues()) if (v.deprecationReason != null) deprecated.push({ where: `${type.name}.${v.name}`, reason: v.deprecationReason })\n if (isObjectType(type) || isInterfaceType(type) || isInputObjectType(type)) for (const f of Object.values(type.getFields())) {\n if (f.deprecationReason != null) deprecated.push({ where: `${type.name}.${f.name}`, reason: f.deprecationReason })\n if ('args' in f) for (const a of f.args) if (a.deprecationReason != null) deprecated.push({ where: `${type.name}.${f.name}(${a.name})`, reason: a.deprecationReason })\n }\n}\n\ndescribe.each(deprecated)('$where', ({ reason }) => {\n it('names its deprecation and sunset dates, far enough apart', () => {\n const m = DATES.exec(reason ?? '')\n expect(m, 'reason ends in \"deprecated YYYY-MM-DD, sunset YYYY-MM-DD\"').not.toBeNull()\n const from = new Date(m![1])\n from.setMonth(from.getMonth() + SUNSET_MONTHS)\n expect(Date.parse(m![2])).toBeGreaterThanOrEqual(from.getTime())\n })\n})\n```",
690
+ "hubWhen": {
691
+ "FORMAT": [
692
+ "graphql"
693
+ ]
694
+ }
695
+ },
696
+ {
697
+ "id": "ff-sunset-protobuf",
698
+ "type": "fitness-fn",
699
+ "label": "Deprecated fields carry their dates",
700
+ "x": 1040,
701
+ "y": 650,
702
+ "characteristic": "compatibility",
703
+ "scope": "atomic",
704
+ "cadence": "triggered",
705
+ "trigger": "pull-request",
706
+ "invocation": "automated",
707
+ "description": "A CI step greps the .proto files for deprecated elements and checks the dated comment above each; reserving the number and name on removal is checked by buf breaking.\n\nThreshold: Every [deprecated = true] field, RPC and enum value has a comment \"Deprecated: YYYY-MM-DD, sunset: YYYY-MM-DD\" on the line above with the sunset at least {{SUNSET_MONTHS}} months after the deprecation; 0 without\n\nTool: grep and GNU date in the CI job\n\n```bash\n#!/usr/bin/env bash\n# every deprecated field, RPC or enum value: the line above reads \"// Deprecated: 2026-01-01, sunset: 2026-07-01\"\nset -uo pipefail\nfail=0\nwhile IFS=: read -r file line _; do\n dates=$(sed -n \"$((line - 1))p\" \"$file\" | grep -Eo 'Deprecated: [0-9]{4}-[0-9]{2}-[0-9]{2}, sunset: [0-9]{4}-[0-9]{2}-[0-9]{2}' || true)\n if [ -z \"$dates\" ]; then echo \"$file:$line: deprecated without its dates\"; fail=1; continue; fi\n from=$(date -d \"$(echo \"$dates\" | cut -d' ' -f2 | tr -d ,)\" +%s)\n to=$(date -d \"$(echo \"$dates\" | cut -d' ' -f4)\" +%s)\n if [ $(( (to - from) / 86400 )) -lt $(( {{SUNSET_MONTHS}} * 30 )) ]; then echo \"$file:$line: sunset under {{SUNSET_MONTHS}} months after deprecation\"; fail=1; fi\ndone < <(grep -rn 'deprecated = true' api/ --include='*.proto')\nexit $fail\n```",
708
+ "hubWhen": {
709
+ "FORMAT": [
710
+ "protobuf"
711
+ ]
712
+ }
713
+ },
714
+ {
715
+ "id": "ff-usage",
716
+ "type": "fitness-fn",
717
+ "label": "Deprecated usage counted and alerted",
718
+ "x": 1040,
719
+ "y": 780,
720
+ "characteristic": "compatibility",
721
+ "scope": "atomic",
722
+ "cadence": "continual",
723
+ "invocation": "automated",
724
+ "description": "The element exports api_deprecated_calls_total{caller, operation} and api_sunset_timestamp_seconds{operation} (from the dates in the contract); Prometheus rules alert when the counter is missing and when a deprecated element close to its sunset is still called.\n\nThreshold: The counter api_deprecated_calls_total{caller, operation} is scraped (an alert fires while it is absent); an alert names every caller that called an element whose sunset is under 30 days away in the last 7 days\n\nTool: Prometheus alerting rules\n\n```yaml\ngroups:\n- name: api-deprecations\n rules:\n - alert: DeprecatedUsageNotCounted\n expr: absent(api_deprecated_calls_total)\n for: 1h\n labels: { severity: ticket }\n annotations: { summary: \"the API exports no usage counter for deprecated elements\" }\n - alert: SunsetNearWithCallers\n expr: |\n sum by (operation, caller) (increase(api_deprecated_calls_total[7d])) > 0\n and on (operation) (api_sunset_timestamp_seconds - time()) < 30 * 86400\n labels: { severity: ticket }\n annotations: { summary: \"{{ $labels.caller }} still calls {{ $labels.operation }}, whose sunset is under 30 days away\" }\n```"
725
+ },
726
+ {
727
+ "id": "ff-two-paths",
728
+ "type": "fitness-fn",
729
+ "label": "Two major versions at most",
730
+ "x": 1040,
731
+ "y": 910,
732
+ "characteristic": "compatibility",
733
+ "scope": "atomic",
734
+ "cadence": "triggered",
735
+ "trigger": "pull-request",
736
+ "invocation": "automated",
737
+ "description": "A test lists the routes from the router (not from a list kept by hand), collects their /vN/ prefixes (for gRPC, the .vN package suffixes of the registered services) and fails when there are more than two.\n\nThreshold: The router serves at most 2 distinct major version prefixes; a third fails the test\n\nTool: Vitest (or the test runner of your stack)\n\n```ts\nimport { routes } from '../src/app' // the router's table\n\nit('serves at most two major versions', () => {\n const majors = new Set(routes.map((r) => /^\\/v(\\d+)\\//.exec(r.path)?.[1]).filter(Boolean))\n expect([...majors].length, `major versions served: ${[...majors].join(', ')}`).toBeLessThanOrEqual(2)\n})\n```",
738
+ "hubWhen": {
739
+ "VERSIONING": [
740
+ "path"
741
+ ]
742
+ }
743
+ },
744
+ {
745
+ "id": "ff-header-versions",
746
+ "type": "fitness-fn",
747
+ "label": "Version header required and echoed",
748
+ "x": 1040,
749
+ "y": 1040,
750
+ "characteristic": "compatibility",
751
+ "scope": "atomic",
752
+ "cadence": "triggered",
753
+ "trigger": "pull-request",
754
+ "invocation": "automated",
755
+ "description": "A test calls the API without the header, with an unknown version and with each served version, and checks the status, the list in the 400 body and the echoed header.\n\nThreshold: A request without Api-Version, and one naming an unserved version, get 400 with the served versions; a request naming a served version is answered with that version echoed; at most 2 versions are served\n\nTool: Vitest with supertest (or the test runner and HTTP client of your stack)\n\n```ts\nimport request from 'supertest'\nimport { app } from '../src/app'\n\nit('requires the version header, echoes it, and serves two versions at most', async () => {\n const missing = await request(app).get('/orders').expect(400)\n const served: string[] = missing.body.versions\n expect(served.length).toBeLessThanOrEqual(2)\n const unknown = await request(app).get('/orders').set('Api-Version', '2000-01-01').expect(400)\n expect(unknown.body.versions).toEqual(served)\n for (const v of served) {\n const res = await request(app).get('/orders').set('Api-Version', v).expect(200)\n expect(res.headers['api-version']).toBe(v)\n }\n})\n```",
756
+ "hubWhen": {
757
+ "VERSIONING": [
758
+ "header"
759
+ ]
760
+ }
761
+ },
762
+ {
763
+ "id": "ff-pact",
764
+ "type": "fitness-fn",
765
+ "label": "Caller contracts verified",
766
+ "x": 1040,
767
+ "y": 1170,
768
+ "characteristic": "compatibility",
769
+ "scope": "holistic",
770
+ "cadence": "triggered",
771
+ "trigger": "pull-request",
772
+ "invocation": "automated",
773
+ "description": "Every build of the API fetches the pacts of its callers from the Pact Broker and replays them against the running API, publishing the result; the deployment step asks can-i-deploy and stops on no.\n\nThreshold: 100 % of the callers' pacts for the main branch and every deployed version verify on each build; can-i-deploy answers yes before every deployment\n\nTool: Pact (pact-js Verifier, Pact Broker can-i-deploy)\n\n```ts\nimport { Verifier } from '@pact-foundation/pact'\n\nit('honours every caller\\'s pact', () =>\n new Verifier({\n provider: 'order-api',\n providerBaseUrl: 'http://localhost:8080',\n pactBrokerUrl: process.env.PACT_BROKER_BASE_URL,\n consumerVersionSelectors: [{ mainBranch: true }, { deployedOrReleased: true }],\n publishVerificationResult: true,\n providerVersion: process.env.GIT_SHA,\n }).verifyProvider())\n\n// before deploying:\n// npx --package=@pact-foundation/pact-cli pact-broker can-i-deploy --pacticipant order-api --version \"$GIT_SHA\" --to-environment production\n```",
774
+ "hubWhen": {
775
+ "CONTRACT_TESTS": [
776
+ "pact"
777
+ ]
778
+ }
779
+ },
780
+ {
781
+ "id": "ff-conformance",
782
+ "type": "fitness-fn",
783
+ "label": "API conforms to contract",
784
+ "x": 1040,
785
+ "y": 1300,
786
+ "characteristic": "compatibility",
787
+ "scope": "atomic",
788
+ "cadence": "triggered",
789
+ "trigger": "pull-request",
790
+ "invocation": "automated",
791
+ "description": "On every build, Schemathesis generates calls for each operation of the published contract (OpenAPI or GraphQL), runs them against a running instance and fails on an answer the contract does not allow or on a server error.\n\nThreshold: 0 answers whose status code, headers or body the contract does not describe, and 0 server errors, over every operation, on each build\n\nTool: Schemathesis\n\n```bash\n# CI step, after the API is started\npip install 'schemathesis>=4'\nst run \"$API_URL/openapi.json\" --checks all # for a GraphQL schema: st run \"$API_URL/graphql\" --checks all\n```",
792
+ "hubWhen": {
793
+ "CONTRACT_TESTS": [
794
+ "conformance"
795
+ ],
796
+ "FORMAT": [
797
+ "openapi",
798
+ "graphql"
799
+ ]
800
+ }
801
+ },
802
+ {
803
+ "id": "ff-conformance-grpc",
804
+ "type": "fitness-fn",
805
+ "label": "Server conforms to contract",
806
+ "x": 1040,
807
+ "y": 1430,
808
+ "characteristic": "compatibility",
809
+ "scope": "atomic",
810
+ "cadence": "triggered",
811
+ "trigger": "pull-request",
812
+ "invocation": "automated",
813
+ "description": "On every build, the services the server reflects are compared with those of the contract's descriptors, and every RPC is called with an empty request; a crash (Unknown, Internal) fails the build, an InvalidArgument does not.\n\nThreshold: The services the running server reflects equal the services of the contract; 0 RPCs answer Unknown or Internal to an empty request\n\nTool: buf and grpcurl\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\nbuf build -o /tmp/contract.binpb\ndiff <(grpcurl -protoset /tmp/contract.binpb list | sort) <(grpcurl -plaintext \"$GRPC_ADDRESS\" list | grep -v '^grpc\\.' | sort)\nfail=0\nfor svc in $(grpcurl -protoset /tmp/contract.binpb list); do\n for rpc in $(grpcurl -protoset /tmp/contract.binpb list \"$svc\"); do\n out=$(grpcurl -plaintext -d '{}' \"$GRPC_ADDRESS\" \"$rpc\" 2>&1 || true)\n if echo \"$out\" | grep -qE 'Code: (Unknown|Internal)'; then echo \"$rpc crashes on an empty request\"; fail=1; fi\n done\ndone\nexit $fail\n```",
814
+ "hubWhen": {
815
+ "CONTRACT_TESTS": [
816
+ "conformance"
817
+ ],
818
+ "FORMAT": [
819
+ "protobuf"
820
+ ]
821
+ }
822
+ }
823
+ ],
824
+ "relations": [
825
+ {
826
+ "id": "req-contract--derives--need",
827
+ "sourceId": "req-contract",
828
+ "targetId": "need",
829
+ "relationType": "derives"
830
+ },
831
+ {
832
+ "id": "req-compat--derives--need",
833
+ "sourceId": "req-compat",
834
+ "targetId": "need",
835
+ "relationType": "derives"
836
+ },
837
+ {
838
+ "id": "req-path--derives--need",
839
+ "sourceId": "req-path",
840
+ "targetId": "need",
841
+ "relationType": "derives"
842
+ },
843
+ {
844
+ "id": "req-header--derives--need",
845
+ "sourceId": "req-header",
846
+ "targetId": "need",
847
+ "relationType": "derives"
848
+ },
849
+ {
850
+ "id": "req-header-echo--derives--need",
851
+ "sourceId": "req-header-echo",
852
+ "targetId": "need",
853
+ "relationType": "derives"
854
+ },
855
+ {
856
+ "id": "req-versionless--derives--need",
857
+ "sourceId": "req-versionless",
858
+ "targetId": "need",
859
+ "relationType": "derives"
860
+ },
861
+ {
862
+ "id": "req-sunset--derives--need",
863
+ "sourceId": "req-sunset",
864
+ "targetId": "need",
865
+ "relationType": "derives"
866
+ },
867
+ {
868
+ "id": "req-sunset-graphql--derives--need",
869
+ "sourceId": "req-sunset-graphql",
870
+ "targetId": "need",
871
+ "relationType": "derives"
872
+ },
873
+ {
874
+ "id": "req-sunset-protobuf--derives--need",
875
+ "sourceId": "req-sunset-protobuf",
876
+ "targetId": "need",
877
+ "relationType": "derives"
878
+ },
879
+ {
880
+ "id": "req-usage--derives--need",
881
+ "sourceId": "req-usage",
882
+ "targetId": "need",
883
+ "relationType": "derives"
884
+ },
885
+ {
886
+ "id": "req-pact--derives--need",
887
+ "sourceId": "req-pact",
888
+ "targetId": "need",
889
+ "relationType": "derives"
890
+ },
891
+ {
892
+ "id": "req-conformance--derives--need",
893
+ "sourceId": "req-conformance",
894
+ "targetId": "need",
895
+ "relationType": "derives"
896
+ },
897
+ {
898
+ "id": "req-conformance-grpc--derives--need",
899
+ "sourceId": "req-conformance-grpc",
900
+ "targetId": "need",
901
+ "relationType": "derives"
902
+ },
903
+ {
904
+ "id": "sc-contract--verifies--req-contract",
905
+ "sourceId": "sc-contract",
906
+ "targetId": "req-contract",
907
+ "relationType": "verifies"
908
+ },
909
+ {
910
+ "id": "sc-compat--verifies--req-compat",
911
+ "sourceId": "sc-compat",
912
+ "targetId": "req-compat",
913
+ "relationType": "verifies"
914
+ },
915
+ {
916
+ "id": "sc-path--verifies--req-path",
917
+ "sourceId": "sc-path",
918
+ "targetId": "req-path",
919
+ "relationType": "verifies"
920
+ },
921
+ {
922
+ "id": "sc-header--verifies--req-header",
923
+ "sourceId": "sc-header",
924
+ "targetId": "req-header",
925
+ "relationType": "verifies"
926
+ },
927
+ {
928
+ "id": "sc-header-echo--verifies--req-header-echo",
929
+ "sourceId": "sc-header-echo",
930
+ "targetId": "req-header-echo",
931
+ "relationType": "verifies"
932
+ },
933
+ {
934
+ "id": "sc-versionless--verifies--req-versionless",
935
+ "sourceId": "sc-versionless",
936
+ "targetId": "req-versionless",
937
+ "relationType": "verifies"
938
+ },
939
+ {
940
+ "id": "sc-sunset--verifies--req-sunset",
941
+ "sourceId": "sc-sunset",
942
+ "targetId": "req-sunset",
943
+ "relationType": "verifies"
944
+ },
945
+ {
946
+ "id": "sc-sunset-graphql--verifies--req-sunset-graphql",
947
+ "sourceId": "sc-sunset-graphql",
948
+ "targetId": "req-sunset-graphql",
949
+ "relationType": "verifies"
950
+ },
951
+ {
952
+ "id": "sc-sunset-protobuf--verifies--req-sunset-protobuf",
953
+ "sourceId": "sc-sunset-protobuf",
954
+ "targetId": "req-sunset-protobuf",
955
+ "relationType": "verifies"
956
+ },
957
+ {
958
+ "id": "sc-usage--verifies--req-usage",
959
+ "sourceId": "sc-usage",
960
+ "targetId": "req-usage",
961
+ "relationType": "verifies"
962
+ },
963
+ {
964
+ "id": "sc-pact--verifies--req-pact",
965
+ "sourceId": "sc-pact",
966
+ "targetId": "req-pact",
967
+ "relationType": "verifies"
968
+ },
969
+ {
970
+ "id": "sc-conformance--verifies--req-conformance",
971
+ "sourceId": "sc-conformance",
972
+ "targetId": "req-conformance",
973
+ "relationType": "verifies"
974
+ },
975
+ {
976
+ "id": "sc-conformance-grpc--verifies--req-conformance-grpc",
977
+ "sourceId": "sc-conformance-grpc",
978
+ "targetId": "req-conformance-grpc",
979
+ "relationType": "verifies"
980
+ },
981
+ {
982
+ "id": "ff-oasdiff--implements--adr-version-path",
983
+ "sourceId": "ff-oasdiff",
984
+ "targetId": "adr-version-path",
985
+ "relationType": "implements"
986
+ },
987
+ {
988
+ "id": "ff-oasdiff--implements--adr-version-header",
989
+ "sourceId": "ff-oasdiff",
990
+ "targetId": "adr-version-header",
991
+ "relationType": "implements"
992
+ },
993
+ {
994
+ "id": "ff-oasdiff--implements--adr-versionless",
995
+ "sourceId": "ff-oasdiff",
996
+ "targetId": "adr-versionless",
997
+ "relationType": "implements"
998
+ },
999
+ {
1000
+ "id": "ff-graphql-inspector--implements--adr-version-path",
1001
+ "sourceId": "ff-graphql-inspector",
1002
+ "targetId": "adr-version-path",
1003
+ "relationType": "implements"
1004
+ },
1005
+ {
1006
+ "id": "ff-graphql-inspector--implements--adr-version-header",
1007
+ "sourceId": "ff-graphql-inspector",
1008
+ "targetId": "adr-version-header",
1009
+ "relationType": "implements"
1010
+ },
1011
+ {
1012
+ "id": "ff-graphql-inspector--implements--adr-versionless",
1013
+ "sourceId": "ff-graphql-inspector",
1014
+ "targetId": "adr-versionless",
1015
+ "relationType": "implements"
1016
+ },
1017
+ {
1018
+ "id": "ff-buf--implements--adr-version-path",
1019
+ "sourceId": "ff-buf",
1020
+ "targetId": "adr-version-path",
1021
+ "relationType": "implements"
1022
+ },
1023
+ {
1024
+ "id": "ff-buf--implements--adr-version-header",
1025
+ "sourceId": "ff-buf",
1026
+ "targetId": "adr-version-header",
1027
+ "relationType": "implements"
1028
+ },
1029
+ {
1030
+ "id": "ff-buf--implements--adr-versionless",
1031
+ "sourceId": "ff-buf",
1032
+ "targetId": "adr-versionless",
1033
+ "relationType": "implements"
1034
+ },
1035
+ {
1036
+ "id": "ff-sunset--implements--adr-version-path",
1037
+ "sourceId": "ff-sunset",
1038
+ "targetId": "adr-version-path",
1039
+ "relationType": "implements"
1040
+ },
1041
+ {
1042
+ "id": "ff-sunset--implements--adr-version-header",
1043
+ "sourceId": "ff-sunset",
1044
+ "targetId": "adr-version-header",
1045
+ "relationType": "implements"
1046
+ },
1047
+ {
1048
+ "id": "ff-sunset--implements--adr-versionless",
1049
+ "sourceId": "ff-sunset",
1050
+ "targetId": "adr-versionless",
1051
+ "relationType": "implements"
1052
+ },
1053
+ {
1054
+ "id": "ff-sunset-graphql--implements--adr-version-path",
1055
+ "sourceId": "ff-sunset-graphql",
1056
+ "targetId": "adr-version-path",
1057
+ "relationType": "implements"
1058
+ },
1059
+ {
1060
+ "id": "ff-sunset-graphql--implements--adr-version-header",
1061
+ "sourceId": "ff-sunset-graphql",
1062
+ "targetId": "adr-version-header",
1063
+ "relationType": "implements"
1064
+ },
1065
+ {
1066
+ "id": "ff-sunset-graphql--implements--adr-versionless",
1067
+ "sourceId": "ff-sunset-graphql",
1068
+ "targetId": "adr-versionless",
1069
+ "relationType": "implements"
1070
+ },
1071
+ {
1072
+ "id": "ff-sunset-protobuf--implements--adr-version-path",
1073
+ "sourceId": "ff-sunset-protobuf",
1074
+ "targetId": "adr-version-path",
1075
+ "relationType": "implements"
1076
+ },
1077
+ {
1078
+ "id": "ff-sunset-protobuf--implements--adr-version-header",
1079
+ "sourceId": "ff-sunset-protobuf",
1080
+ "targetId": "adr-version-header",
1081
+ "relationType": "implements"
1082
+ },
1083
+ {
1084
+ "id": "ff-sunset-protobuf--implements--adr-versionless",
1085
+ "sourceId": "ff-sunset-protobuf",
1086
+ "targetId": "adr-versionless",
1087
+ "relationType": "implements"
1088
+ },
1089
+ {
1090
+ "id": "ff-usage--implements--adr-version-path",
1091
+ "sourceId": "ff-usage",
1092
+ "targetId": "adr-version-path",
1093
+ "relationType": "implements"
1094
+ },
1095
+ {
1096
+ "id": "ff-usage--implements--adr-version-header",
1097
+ "sourceId": "ff-usage",
1098
+ "targetId": "adr-version-header",
1099
+ "relationType": "implements"
1100
+ },
1101
+ {
1102
+ "id": "ff-usage--implements--adr-versionless",
1103
+ "sourceId": "ff-usage",
1104
+ "targetId": "adr-versionless",
1105
+ "relationType": "implements"
1106
+ },
1107
+ {
1108
+ "id": "ff-two-paths--implements--adr-version-path",
1109
+ "sourceId": "ff-two-paths",
1110
+ "targetId": "adr-version-path",
1111
+ "relationType": "implements"
1112
+ },
1113
+ {
1114
+ "id": "ff-header-versions--implements--adr-version-header",
1115
+ "sourceId": "ff-header-versions",
1116
+ "targetId": "adr-version-header",
1117
+ "relationType": "implements"
1118
+ },
1119
+ {
1120
+ "id": "ff-pact--implements--adr-version-path",
1121
+ "sourceId": "ff-pact",
1122
+ "targetId": "adr-version-path",
1123
+ "relationType": "implements"
1124
+ },
1125
+ {
1126
+ "id": "ff-pact--implements--adr-version-header",
1127
+ "sourceId": "ff-pact",
1128
+ "targetId": "adr-version-header",
1129
+ "relationType": "implements"
1130
+ },
1131
+ {
1132
+ "id": "ff-pact--implements--adr-versionless",
1133
+ "sourceId": "ff-pact",
1134
+ "targetId": "adr-versionless",
1135
+ "relationType": "implements"
1136
+ },
1137
+ {
1138
+ "id": "ff-conformance--implements--adr-version-path",
1139
+ "sourceId": "ff-conformance",
1140
+ "targetId": "adr-version-path",
1141
+ "relationType": "implements"
1142
+ },
1143
+ {
1144
+ "id": "ff-conformance--implements--adr-version-header",
1145
+ "sourceId": "ff-conformance",
1146
+ "targetId": "adr-version-header",
1147
+ "relationType": "implements"
1148
+ },
1149
+ {
1150
+ "id": "ff-conformance--implements--adr-versionless",
1151
+ "sourceId": "ff-conformance",
1152
+ "targetId": "adr-versionless",
1153
+ "relationType": "implements"
1154
+ },
1155
+ {
1156
+ "id": "ff-conformance-grpc--implements--adr-version-path",
1157
+ "sourceId": "ff-conformance-grpc",
1158
+ "targetId": "adr-version-path",
1159
+ "relationType": "implements"
1160
+ },
1161
+ {
1162
+ "id": "ff-conformance-grpc--implements--adr-version-header",
1163
+ "sourceId": "ff-conformance-grpc",
1164
+ "targetId": "adr-version-header",
1165
+ "relationType": "implements"
1166
+ },
1167
+ {
1168
+ "id": "ff-conformance-grpc--implements--adr-versionless",
1169
+ "sourceId": "ff-conformance-grpc",
1170
+ "targetId": "adr-versionless",
1171
+ "relationType": "implements"
1172
+ }
1173
+ ]
1174
+ }