@radicaltools/cli 0.3.0 → 0.3.2

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 +332 -44
  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 +449 -210
  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 +287 -131
  9. package/dist/hub-catalogue/concern/concern-audit-trail.radical +1096 -0
  10. package/dist/hub-catalogue/concern/concern-authentication.radical +247 -37
  11. package/dist/hub-catalogue/concern/concern-authorization.radical +311 -89
  12. package/dist/hub-catalogue/concern/concern-availability.radical +287 -63
  13. package/dist/hub-catalogue/concern/concern-backend-stack.radical +300 -381
  14. package/dist/hub-catalogue/concern/concern-backup-recovery.radical +385 -129
  15. package/dist/hub-catalogue/concern/concern-caching.radical +1294 -0
  16. package/dist/hub-catalogue/concern/concern-capacity.radical +194 -81
  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 +473 -167
  22. package/dist/hub-catalogue/concern/concern-data-classification.radical +970 -0
  23. package/dist/hub-catalogue/concern/concern-data-consistency.radical +339 -308
  24. package/dist/hub-catalogue/concern/concern-data-store.radical +480 -158
  25. package/dist/hub-catalogue/concern/concern-decomposition.radical +260 -85
  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 +343 -92
  30. package/dist/hub-catalogue/concern/concern-encryption.radical +339 -76
  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 +467 -160
  34. package/dist/hub-catalogue/concern/concern-incident-management.radical +1204 -0
  35. package/dist/hub-catalogue/concern/concern-infrastructure.radical +1300 -268
  36. package/dist/hub-catalogue/concern/concern-integration-resilience.radical +88 -51
  37. package/dist/hub-catalogue/concern/concern-messaging.radical +173 -140
  38. package/dist/hub-catalogue/concern/concern-module-boundaries.radical +162 -159
  39. package/dist/hub-catalogue/concern/concern-observability.radical +224 -275
  40. package/dist/hub-catalogue/concern/concern-operational-readiness.radical +1249 -0
  41. package/dist/hub-catalogue/concern/concern-personal-data.radical +637 -122
  42. package/dist/hub-catalogue/concern/concern-quality-priorities.radical +1091 -0
  43. package/dist/hub-catalogue/concern/concern-rate-limiting.radical +433 -141
  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 +332 -74
  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 +257 -183
  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 +271 -137
  54. package/dist/hub-catalogue/concern/concern-test-strategy.radical +243 -224
  55. package/dist/hub-catalogue/concern/concern-threat-modelling.radical +1143 -0
  56. package/dist/index.js +10608 -6579
  57. package/package.json +1 -1
@@ -21,7 +21,7 @@
21
21
  "trigger": "LIST RELATIONS WHERE source.external != true AND target.external = true AND (source.type = \"system\" OR source.type = \"container\" OR source.type = \"webapp\" OR source.type = \"component\")",
22
22
  "applyTo": "source",
23
23
  "why": "these elements call systems outside your control, so what happens when those are slow, down or answer twice has to be decided.",
24
- "group": "integration"
24
+ "group": "architecture"
25
25
  },
26
26
  "sources": [
27
27
  {
@@ -47,6 +47,10 @@
47
47
  {
48
48
  "title": "Azure Architecture Center, Circuit Breaker pattern",
49
49
  "url": "https://learn.microsoft.com/en-us/azure/architecture/patterns/circuit-breaker"
50
+ },
51
+ {
52
+ "title": "Enterprise Integration Patterns, Dead Letter Channel",
53
+ "url": "https://www.enterpriseintegrationpatterns.com/patterns/messaging/DeadLetterChannel.html"
50
54
  }
51
55
  ],
52
56
  "templateParams": [
@@ -70,7 +74,7 @@
70
74
  {
71
75
  "value": "defer",
72
76
  "label": "it is accepted and completed later",
73
- "description": "The action is stored and the call is made from a queue, so the user does not wait for the outside system; it completes once the system is back and the user is told. Pick it for actions that must not be lost but need not finish now: sending to a partner, booking, e-mail, invoicing."
77
+ "description": "The action is stored and the call is made from a queue, so the user does not wait for the outside system; it completes once the system is back and the user is told. Pick it for actions that must not be lost but need not finish now: sending to a partner, booking, e-mail, invoicing. Not with only reads: a deferred action changes something outside."
74
78
  }
75
79
  ]
76
80
  },
@@ -113,7 +117,7 @@
113
117
  {
114
118
  "value": "readonly",
115
119
  "label": "only reads, nothing to repeat",
116
- "description": "The element only reads from outside systems (GET and other safe methods), so every call may be retried. Pick it when no call changes anything outside; a call that does needs this decision revisited."
120
+ "description": "The element only reads from outside systems (GET and other safe methods), so every call may be retried. Pick it when no call changes anything outside; a call that does needs this decision revisited. Not with deferred actions, which change something outside."
117
121
  }
118
122
  ]
119
123
  },
@@ -189,8 +193,8 @@
189
193
  "x": 260,
190
194
  "y": 130,
191
195
  "ears_type": "unwanted-behaviour",
192
- "unwanted_condition": "a call to an outside system times out, has its connection refused or reset, or is answered 429, 502, 503 or 504",
193
- "action": "retry it at most {{RETRIES}} times with exponential backoff and full jitter starting at {{BACKOFF_MS}} ms, wait at least as long as a Retry-After header asks, and never retry any other 4xx answer",
196
+ "unwanted_condition": "a call to an outside system times out, has its connection refused or reset, or is answered 408, 429, 502, 503 or 504",
197
+ "action": "retry it at most {{RETRIES}} times with exponential backoff and full jitter starting at {{BACKOFF_MS}} ms, wait at least as long as a Retry-After header asks, never start a retry that could not finish within the action's deadline, and never retry any other 4xx answer",
194
198
  "rationale": "Most failures are brief, so a retry often succeeds; jitter keeps every instance from retrying at the same moment, and a 4xx other than 408 and 429 will fail the same way again (AWS Builders' Library; RFC 9110 10.2.3)."
195
199
  },
196
200
  {
@@ -201,7 +205,7 @@
201
205
  "y": 260,
202
206
  "ears_type": "unwanted-behaviour",
203
207
  "unwanted_condition": "more than {{BREAKER_PERCENT}} % of at least 20 calls to one outside system within 30 seconds fail or time out",
204
- "action": "stop calling it for 30 seconds (open the circuit), treat each call in that time as if the system were down, then let 3 trial calls through and resume only when they succeed",
208
+ "action": "stop calling it for 30 seconds (open the circuit), treat each call in that time as if the system were down, then let at most 3 trial calls through and resume only when they succeed",
205
209
  "rationale": "Calling a system that is down wastes the caller's time and keeps the other side down; the breaker fails at once and probes for recovery (microservices.io, Circuit Breaker; Azure Architecture Center)."
206
210
  },
207
211
  {
@@ -352,7 +356,7 @@
352
356
  "x": 260,
353
357
  "y": 1560,
354
358
  "ears_type": "ubiquitous",
355
- "action": "route every call to an outside system through the mesh, with a timeout, retries and outlier detection configured for its host in the repository, and allow no egress to a host without them",
359
+ "action": "route every call to an outside system through the mesh, with a timeout of {{TIMEOUT_MS}} ms, at most {{RETRIES}} retries and outlier detection configured for its host in the repository, and allow no egress to a host without them",
356
360
  "rationale": "In the mesh, the rules are the same for every language and visible in one place; a host without them is an unguarded call.",
357
361
  "hubWhen": {
358
362
  "PROTECTION": [
@@ -378,7 +382,7 @@
378
382
  "y": 130,
379
383
  "given": "an outside system that answers 503 once and then 200",
380
384
  "when": "it is called, and then a system that always answers 503, and one that answers 400",
381
- "then": "the first call succeeds on its first retry; the second gives up after {{RETRIES}} retries with unequal delays; the third is not retried"
385
+ "then": "the first call succeeds on its first retry; the second gives up after {{RETRIES}} retries whose delays differ between two runs; the third is not retried"
382
386
  },
383
387
  {
384
388
  "id": "sc-breaker",
@@ -388,7 +392,7 @@
388
392
  "y": 260,
389
393
  "given": "an outside system that fails every call",
390
394
  "when": "20 calls have failed within 30 seconds and more are made",
391
- "then": "the further calls fail at once without reaching it, and after 30 seconds 3 trial calls do"
395
+ "then": "the further calls fail at once without reaching it, after 30 seconds at most 3 trial calls reach it, and calls resume once trial calls succeed"
392
396
  },
393
397
  {
394
398
  "id": "sc-fail",
@@ -532,7 +536,7 @@
532
536
  "x": 520,
533
537
  "y": 1560,
534
538
  "given": "the mesh configuration in the repository",
535
- "when": "an outside host is added without a timeout, retries or outlier detection",
539
+ "when": "an outside host is added without a timeout, retries or outlier detection, or egress to undeclared hosts is opened",
536
540
  "then": "the configuration check fails the pull request",
537
541
  "hubWhen": {
538
542
  "PROTECTION": [
@@ -549,9 +553,9 @@
549
553
  "concern": "integration-resilience",
550
554
  "status": "accepted",
551
555
  "date": "",
552
- "context": "This element calls systems it does not run: payment, e-mail, maps, partners. The forces: they are slow or down at times, and a call without a timeout holds a thread or a connection until everything behind it stops; most failures are brief, so a retry often succeeds, but retries sent at once by every instance turn a hiccup into an overload (the thundering herd); a timeout does not say whether the other side did the work, so retrying a call that changes something can do it twice; calling a system that is down wastes time and keeps it down; and the user has to be told something true and useful while it is down.",
553
- "decision": "Calls to outside systems are made while the user waits. Each gives up after {{TIMEOUT_MS}} ms; transient failures are retried at most {{RETRIES}} times with exponential backoff and full jitter from {{BACKOFF_MS}} ms, within a deadline of {{DEADLINE_MS}} ms for the whole action; a circuit breaker per outside system opens above {{BREAKER_PERCENT}} % failures. Repeated calls: {{IDEMPOTENCY}}. While a system is down or its circuit open, an action that needs it is refused at once as temporary (503 with Retry-After), with nothing half done. Choose it over degrading when the action is worthless without the answer.",
554
- "consequences": "• Outages are short and visible to the user; nothing is left half done.\n• The user has to come back and try again; some will not.\n• The deadline bounds how long anyone waits, so retries are few by design.",
556
+ "context": "This element calls systems it does not run: payment, e-mail, maps, partners. The forces: they are slow or down at times, and a call without a timeout holds a thread or a connection until everything behind it stops; most failures are brief, so a retry often succeeds, but retries sent at once by every instance turn a hiccup into an overload (the thundering herd); a timeout does not say whether the other side did the work, so retrying a call that changes something can do it twice; calling a system that is down wastes time and keeps it down; and the user has to be told something true and useful while it is down. Snippets assume one client per outside system under src/integrations/<system>/ (package ..integration.. with classes named *Client on the JVM) and the mesh manifests under mesh/.",
557
+ "decision": "Calls to outside systems are made while the user waits. Each gives up after {{TIMEOUT_MS}} ms; transient failures are retried at most {{RETRIES}} times with exponential backoff and full jitter from {{BACKOFF_MS}} ms, within a deadline of {{DEADLINE_MS}} ms for the whole action: the deadline wins, so a retry that could not finish in time is not started. A circuit breaker per outside system opens above {{BREAKER_PERCENT}} % failures. Repeated calls: {{IDEMPOTENCY}}. While a system is down or its circuit open, an action that needs it is refused at once as temporary (503 with Retry-After), with nothing half done. Choose it over degrading when the action is worthless without the answer.",
558
+ "consequences": "• Outages are short and visible to the user; nothing is left half done.\n• The user has to come back and try again; some will not.\n• The deadline bounds how long anyone waits, so with a slow partner fewer than {{RETRIES}} retries happen by design.",
555
559
  "alternatives": "1. Go on with less from a cache or defaults: more available for reads, more code, stale data.\n2. Accept and complete later from a queue: nothing refused, but the user waits for the result.\n3. No timeouts or breakers: simplest, until one slow partner stops everything.",
556
560
  "hubWhen": {
557
561
  "FAILURE": [
@@ -568,8 +572,8 @@
568
572
  "concern": "integration-resilience",
569
573
  "status": "accepted",
570
574
  "date": "",
571
- "context": "This element calls systems it does not run: payment, e-mail, maps, partners. The forces: they are slow or down at times, and a call without a timeout holds a thread or a connection until everything behind it stops; most failures are brief, so a retry often succeeds, but retries sent at once by every instance turn a hiccup into an overload (the thundering herd); a timeout does not say whether the other side did the work, so retrying a call that changes something can do it twice; calling a system that is down wastes time and keeps it down; and the user has to be told something true and useful while it is down.",
572
- "decision": "Calls to outside systems are made while the user waits. Each gives up after {{TIMEOUT_MS}} ms; transient failures are retried at most {{RETRIES}} times with exponential backoff and full jitter from {{BACKOFF_MS}} ms, within a deadline of {{DEADLINE_MS}} ms; a circuit breaker per outside system opens above {{BREAKER_PERCENT}} % failures. Repeated calls: {{IDEMPOTENCY}}. Every read has a fallback: the last good answer, cached for up to {{STALE_MINUTES}} minutes (Redis, Caffeine, or the HTTP cache with stale-if-error), or a default; the answer is marked incomplete. Changes that need the outside system are refused as temporary. Choose it for reads whose outside part is nice to have or changes slowly.",
575
+ "context": "This element calls systems it does not run: payment, e-mail, maps, partners. The forces: they are slow or down at times, and a call without a timeout holds a thread or a connection until everything behind it stops; most failures are brief, so a retry often succeeds, but retries sent at once by every instance turn a hiccup into an overload (the thundering herd); a timeout does not say whether the other side did the work, so retrying a call that changes something can do it twice; calling a system that is down wastes time and keeps it down; and the user has to be told something true and useful while it is down. Snippets assume one client per outside system under src/integrations/<system>/ (package ..integration.. with classes named *Client on the JVM) and the mesh manifests under mesh/.",
576
+ "decision": "Calls to outside systems are made while the user waits. Each gives up after {{TIMEOUT_MS}} ms; transient failures are retried at most {{RETRIES}} times with exponential backoff and full jitter from {{BACKOFF_MS}} ms, within a deadline of {{DEADLINE_MS}} ms: the deadline wins, so a retry that could not finish in time is not started. A circuit breaker per outside system opens above {{BREAKER_PERCENT}} % failures. Repeated calls: {{IDEMPOTENCY}}. Every read has a fallback: the last good answer, cached for up to {{STALE_MINUTES}} minutes (Redis, Caffeine, or the HTTP cache with stale-if-error), or a default; the answer is marked incomplete. Changes that need the outside system are refused as temporary. Choose it for reads whose outside part is nice to have or changes slowly.",
573
577
  "consequences": "• Users keep working through outages, with a visible note that part of the answer is not current.\n• Every read call needs a fallback, written and tested; a cache to size and expire.\n• Stale data must be safe to show for {{STALE_MINUTES}} minutes; prices and stock rarely are.",
574
578
  "alternatives": "1. Fail fast: simpler, less available.\n2. Accept and complete later: for actions rather than reads.\n3. Prefetch everything into our own store: always available, but a copy to keep in sync.",
575
579
  "hubWhen": {
@@ -587,7 +591,7 @@
587
591
  "concern": "integration-resilience",
588
592
  "status": "accepted",
589
593
  "date": "",
590
- "context": "This element calls systems it does not run: payment, e-mail, maps, partners. The forces: they are slow or down at times, and a call without a timeout holds a thread or a connection until everything behind it stops; most failures are brief, so a retry often succeeds, but retries sent at once by every instance turn a hiccup into an overload (the thundering herd); a timeout does not say whether the other side did the work, so retrying a call that changes something can do it twice; calling a system that is down wastes time and keeps it down; and the user has to be told something true and useful while it is down.",
594
+ "context": "This element calls systems it does not run: payment, e-mail, maps, partners. The forces: they are slow or down at times, and a call without a timeout holds a thread or a connection until everything behind it stops; most failures are brief, so a retry often succeeds, but retries sent at once by every instance turn a hiccup into an overload (the thundering herd); a timeout does not say whether the other side did the work, so retrying a call that changes something can do it twice; calling a system that is down wastes time and keeps it down; and the user has to be told something true and useful while it is down. Snippets assume one client per outside system under src/integrations/<system>/ (package ..integration.. with classes named *Client on the JVM) and the mesh manifests under mesh/.",
591
595
  "decision": "Actions that need an outside system are stored durably (an outbox or a job table in the same transaction as the action) and answered at once with a reference; a worker makes the call from a queue (the broker in use, or a job runner such as Hangfire, Sidekiq, BullMQ or Temporal). Each call gives up after {{TIMEOUT_MS}} ms; transient failures are retried at once at most {{RETRIES}} times with exponential backoff and full jitter from {{BACKOFF_MS}} ms, then again with backoff capped at 15 minutes until {{DEFER_HOURS}} hours have passed, when the action goes to a dead-letter queue, the user is told and the owner alerted. A circuit breaker per outside system opens above {{BREAKER_PERCENT}} % failures and pauses the worker. Repeated calls: {{IDEMPOTENCY}}.",
592
596
  "consequences": "• No action is lost to an outage, and the user never waits on the outside system.\n• The user learns the outcome later: the interface must show work in progress and notify.\n• A queue and workers to run and watch, with a dead-letter path and an owner for it.",
593
597
  "alternatives": "1. Fail fast while the user waits: simpler, but the action is lost when the system is down.\n2. Go on with less: for reads, not for actions that must happen.\n3. A workflow engine (Temporal, AWS Step Functions) for multi-step integrations: durable retries and timers built in, one more platform.",
@@ -606,7 +610,7 @@
606
610
  "concern": "integration-resilience",
607
611
  "status": "accepted",
608
612
  "date": "",
609
- "context": "This element calls systems it does not run: payment, e-mail, maps, partners. The forces: they are slow or down at times, and a call without a timeout holds a thread or a connection until everything behind it stops; most failures are brief, so a retry often succeeds, but retries sent at once by every instance turn a hiccup into an overload (the thundering herd); a timeout does not say whether the other side did the work, so retrying a call that changes something can do it twice; calling a system that is down wastes time and keeps it down; and the user has to be told something true and useful while it is down.",
613
+ "context": "This element calls systems it does not run: payment, e-mail, maps, partners. The forces: they are slow or down at times, and a call without a timeout holds a thread or a connection until everything behind it stops; most failures are brief, so a retry often succeeds, but retries sent at once by every instance turn a hiccup into an overload (the thundering herd); a timeout does not say whether the other side did the work, so retrying a call that changes something can do it twice; calling a system that is down wastes time and keeps it down; and the user has to be told something true and useful while it is down. Snippets assume one client per outside system under src/integrations/<system>/ (package ..integration.. with classes named *Client on the JVM) and the mesh manifests under mesh/.",
610
614
  "decision": "Each outside system has one client in the code, the only code that calls it, and every call goes through the resilience pipeline of the stack's library: Resilience4j (TimeLimiter, Retry with exponential random backoff, CircuitBreaker, Bulkhead) on the JVM, Microsoft.Extensions.Http.Resilience (Polly v8) in .NET, cockatiel in Node.js, failsafe-go in Go. Settings come from configuration per outside system: timeout {{TIMEOUT_MS}} ms, at most {{RETRIES}} retries from {{BACKOFF_MS}} ms, circuit open above {{BREAKER_PERCENT}} %. The client knows which calls are safe to repeat and holds the fallback. The library's metrics (calls, retries, breaker state) are exported. Choose a library when calls need fallbacks or idempotency logic, or there is no mesh.",
611
615
  "consequences": "• The rules sit next to the call, which knows whether it may be repeated and what to do instead.\n• One library per language: each stack configures and tests it on its own.\n• A client per outside system is code to keep; an architecture rule keeps others from bypassing it.",
612
616
  "alternatives": "1. The service mesh: the same rules for every language in configuration, but blind to idempotency and fallbacks.\n2. An API gateway for outgoing calls: one place for all, one more hop and owner.\n3. Hand-written retry loops: no dependency, and every one slightly different.",
@@ -625,7 +629,7 @@
625
629
  "concern": "integration-resilience",
626
630
  "status": "accepted",
627
631
  "date": "",
628
- "context": "This element calls systems it does not run: payment, e-mail, maps, partners. The forces: they are slow or down at times, and a call without a timeout holds a thread or a connection until everything behind it stops; most failures are brief, so a retry often succeeds, but retries sent at once by every instance turn a hiccup into an overload (the thundering herd); a timeout does not say whether the other side did the work, so retrying a call that changes something can do it twice; calling a system that is down wastes time and keeps it down; and the user has to be told something true and useful while it is down.",
632
+ "context": "This element calls systems it does not run: payment, e-mail, maps, partners. The forces: they are slow or down at times, and a call without a timeout holds a thread or a connection until everything behind it stops; most failures are brief, so a retry often succeeds, but retries sent at once by every instance turn a hiccup into an overload (the thundering herd); a timeout does not say whether the other side did the work, so retrying a call that changes something can do it twice; calling a system that is down wastes time and keeps it down; and the user has to be told something true and useful while it is down. Snippets assume one client per outside system under src/integrations/<system>/ (package ..integration.. with classes named *Client on the JVM) and the mesh manifests under mesh/.",
629
633
  "decision": "Every outside host is declared to the mesh (Istio ServiceEntry, or Linkerd with an egress policy) and gets, in configuration kept in the repository: a timeout of {{TIMEOUT_MS}} ms, at most {{RETRIES}} retries on connect-failure, refused-stream, reset and 503 (and on other failures only for safe methods), and outlier detection that ejects the host for 30 seconds after consecutive 5xx (the mesh's circuit breaker). Egress to hosts not declared is blocked (outboundTrafficPolicy REGISTRY_ONLY). The code keeps what the mesh cannot know: idempotency ({{IDEMPOTENCY}}) and fallbacks. Choose the mesh when it already carries all traffic and many services in several languages call the same outside systems.",
630
634
  "consequences": "• The same rules for every service and language, changed without a release.\n• The mesh retries without knowing whether a call is safe to repeat: retries on other failures stay limited to safe methods, and the code still sends idempotency protection.\n• Jitter and retry budgets are the mesh's (Envoy), not tuned per call.\n• Debugging spans the application and the sidecar.",
631
635
  "alternatives": "1. A resilience library in each client: aware of idempotency and fallbacks, one per language.\n2. An egress gateway only: one place to watch, but a shared bottleneck.",
@@ -641,9 +645,12 @@
641
645
  "label": "Slow calls cut off",
642
646
  "x": 1040,
643
647
  "y": 0,
644
- "category": "operational",
645
- "threshold": "With 10 s of latency injected on each outside system, every call gives up within {{TIMEOUT_MS}} ms + 10 % per try, and no user action waits longer than {{DEADLINE_MS}} ms",
646
- "description": "An integration test puts a Toxiproxy proxy in front of each outside system (or its sandbox stub), adds a latency toxic far above the timeout, and measures how long each call and each user action takes.\n\nTool: Toxiproxy (Testcontainers module) with Vitest\n\n```ts\nimport { ToxiProxyContainer } from '@testcontainers/toxiproxy'\n\nit('gives up on a slow partner in time', async () => {\n const toxiproxy = await new ToxiProxyContainer('ghcr.io/shopify/toxiproxy:2.9.0').start()\n const proxy = await toxiproxy.createProxy({ name: 'partner', upstream: 'partner-stub:8080' })\n await proxy.instance.addToxic({ type: 'latency', name: 'slow', stream: 'downstream', toxicity: 1, attributes: { latency: 10_000 } })\n const client = partnerClient('http://' + proxy.host + ':' + proxy.port) // the production client and settings\n\n const started = Date.now()\n await expect(client.getQuote(SAMPLE)).rejects.toThrow()\n expect(Date.now() - started).toBeLessThan({{DEADLINE_MS}})\n})\n```"
648
+ "characteristic": "reliability",
649
+ "scope": "atomic",
650
+ "cadence": "triggered",
651
+ "trigger": "pull-request",
652
+ "invocation": "automated",
653
+ "description": "An integration test puts a Toxiproxy proxy in front of each outside system (or its sandbox stub), adds a latency toxic far above the timeout, and measures one attempt with retries turned off and then a whole action with the production settings.\n\nThreshold: With 10 s of latency injected on each outside system, a single attempt gives up within {{TIMEOUT_MS}} ms + 10 %, and no user action waits longer than {{DEADLINE_MS}} ms\n\nTool: Toxiproxy (Testcontainers module) with Vitest (or the test runner of your stack)\n\n```ts\nimport { ToxiProxyContainer } from '@testcontainers/toxiproxy'\n\nconst slowPartner = async () => {\n const toxiproxy = await new ToxiProxyContainer('ghcr.io/shopify/toxiproxy:2.9.0').start()\n const proxy = await toxiproxy.createProxy({ name: 'partner', upstream: 'partner-stub:8080' })\n await proxy.instance.addToxic({ type: 'latency', name: 'slow', stream: 'downstream', toxicity: 1, attributes: { latency: 10_000 } })\n return 'http://' + proxy.host + ':' + proxy.port\n}\n\nit('one attempt gives up at the timeout', async () => {\n const client = partnerClient(await slowPartner(), { retries: 0 }) // production settings, retries off\n const started = Date.now()\n await expect(client.getQuote(SAMPLE)).rejects.toThrow()\n expect(Date.now() - started).toBeLessThan({{TIMEOUT_MS}} * 1.1)\n})\n\nit('a whole action stays within the deadline', async () => {\n const client = partnerClient(await slowPartner()) // production settings\n const started = Date.now()\n await expect(client.getQuote(SAMPLE)).rejects.toThrow()\n expect(Date.now() - started).toBeLessThan({{DEADLINE_MS}})\n})\n```"
647
654
  },
648
655
  {
649
656
  "id": "ff-retry",
@@ -651,9 +658,12 @@
651
658
  "label": "Retries bounded and jittered",
652
659
  "x": 1040,
653
660
  "y": 130,
654
- "category": "structural",
655
- "threshold": "Against a stub that always answers 503: exactly {{RETRIES}} + 1 attempts, delays not all equal; against 400: exactly 1 attempt",
656
- "description": "A test points the production client at a WireMock stub that always fails, counts the requests it received and their spacing, and repeats with an answer that must not be retried.\n\nTool: WireMock (JUnit 5 extension; WireMock.Net or the WireMock container for other stacks)\n\n```java\n@WireMockTest\nclass PartnerRetryTest {\n static final int RETRIES = {{RETRIES}};\n\n @Test\n void retriesTransientFailuresAFewTimesWithJitter(WireMockRuntimeInfo wm) {\n stubFor(get(urlPathEqualTo(\"/quotes\")).willReturn(serviceUnavailable()));\n var client = PartnerClient.create(wm.getHttpBaseUrl()); // production settings\n assertThrows(PartnerUnavailableException.class, () -> client.quote(SAMPLE));\n var requests = findAll(getRequestedFor(urlPathEqualTo(\"/quotes\")));\n assertEquals(RETRIES + 1, requests.size());\n var gaps = IntStream.range(1, requests.size())\n .mapToObj(i -> requests.get(i).getLoggedDate().getTime() - requests.get(i - 1).getLoggedDate().getTime())\n .distinct().count();\n assertTrue(gaps > 1, \"delays are jittered\");\n }\n\n @Test\n void doesNotRetryAClientError(WireMockRuntimeInfo wm) {\n stubFor(get(urlPathEqualTo(\"/quotes\")).willReturn(badRequest()));\n assertThrows(PartnerRejectedException.class, () -> PartnerClient.create(wm.getHttpBaseUrl()).quote(SAMPLE));\n verify(exactly(1), getRequestedFor(urlPathEqualTo(\"/quotes\")));\n }\n}\n```"
661
+ "characteristic": "reliability",
662
+ "scope": "atomic",
663
+ "cadence": "triggered",
664
+ "trigger": "pull-request",
665
+ "invocation": "automated",
666
+ "description": "A test points the production client at a WireMock stub that always fails, counts the requests it received and their spacing over two runs (jitter makes the two sequences differ; plain exponential backoff repeats them), and repeats with an answer that must not be retried.\n\nThreshold: Against a stub that always answers 503: exactly {{RETRIES}} + 1 attempts per run, and the delays of two runs differ; against 400: exactly 1 attempt\n\nTool: WireMock (JUnit 5 extension; WireMock.Net, the WireMock container, or the stub server of your stack)\n\n```java\n@WireMockTest\nclass PartnerRetryTest {\n static final int RETRIES = {{RETRIES}};\n\n List<Long> gapsOfOneRun(WireMockRuntimeInfo wm) {\n resetAllRequests();\n assertThrows(PartnerUnavailableException.class, () -> PartnerClient.create(wm.getHttpBaseUrl()).quote(SAMPLE)); // production settings\n var requests = findAll(getRequestedFor(urlPathEqualTo(\"/quotes\")));\n assertEquals(RETRIES + 1, requests.size());\n return IntStream.range(1, requests.size())\n .mapToObj(i -> requests.get(i).getLoggedDate().getTime() - requests.get(i - 1).getLoggedDate().getTime())\n .toList();\n }\n\n @Test\n void retriesTransientFailuresAFewTimesWithJitter(WireMockRuntimeInfo wm) {\n stubFor(get(urlPathEqualTo(\"/quotes\")).willReturn(serviceUnavailable()));\n var first = gapsOfOneRun(wm);\n var second = gapsOfOneRun(wm);\n assertNotEquals(first, second, \"delays are jittered: two runs never wait the same\");\n }\n\n @Test\n void doesNotRetryAClientError(WireMockRuntimeInfo wm) {\n stubFor(get(urlPathEqualTo(\"/quotes\")).willReturn(badRequest()));\n assertThrows(PartnerRejectedException.class, () -> PartnerClient.create(wm.getHttpBaseUrl()).quote(SAMPLE));\n verify(exactly(1), getRequestedFor(urlPathEqualTo(\"/quotes\")));\n }\n}\n```"
657
667
  },
658
668
  {
659
669
  "id": "ff-breaker",
@@ -661,9 +671,12 @@
661
671
  "label": "Circuit opens and recovers",
662
672
  "x": 1040,
663
673
  "y": 260,
664
- "category": "operational",
665
- "threshold": "After 20 failing calls within 30 s, 0 of the next 50 calls reach the outside system; after 30 s at most 3 trial calls do, and calls resume when they succeed",
666
- "description": "A black-box test against a running instance (with its library or its sidecar) points the outside host at a WireMock stub that fails, drives calls through the instance, and counts what reaches the stub before, during and after the open period.\n\nTool: WireMock container with Testcontainers (JUnit 5)\n\n```java\n@Test\nvoid circuitOpensThenProbes() throws Exception {\n wiremock.stubFor(get(anyUrl()).willReturn(serviceUnavailable()));\n for (int i = 0; i < 20; i++) app.get(\"/quote\"); // calls through the instance under test\n wiremock.resetRequests();\n for (int i = 0; i < 50; i++) app.get(\"/quote\");\n assertEquals(0, wiremock.findAll(getRequestedFor(anyUrl())).size(), \"circuit is open\");\n\n wiremock.stubFor(get(anyUrl()).willReturn(ok(\"{}\")));\n Thread.sleep(30_000);\n app.get(\"/quote\");\n assertEquals(200, app.get(\"/quote\").statusCode(), \"circuit closed after successful trials\");\n}\n```"
674
+ "characteristic": "reliability",
675
+ "scope": "atomic",
676
+ "cadence": "triggered",
677
+ "trigger": "pull-request",
678
+ "invocation": "automated",
679
+ "description": "A black-box test against a running instance (with its library or its sidecar) points the outside host at a WireMockServer started by the test, drives calls through the instance, and counts what reaches the stub before, during and after the open period.\n\nThreshold: With every call failing (above {{BREAKER_PERCENT}} %), after 20 calls within 30 s 0 of the next 50 calls reach the outside system; after 30 s at most 3 of 10 calls reach it while it still fails; once it answers, calls resume\n\nTool: WireMockServer (JUnit 5; or the stub server of your stack) against the running instance\n\n```java\n// wiremock: new WireMockServer(options().port(8089)), the instance under test points its outside host at it\n@Test\nvoid circuitOpensThenProbes() throws Exception {\n wiremock.stubFor(get(anyUrl()).willReturn(serviceUnavailable()));\n for (int i = 0; i < 20; i++) app.get(\"/quote\"); // calls through the instance under test\n wiremock.resetRequests();\n for (int i = 0; i < 50; i++) app.get(\"/quote\");\n assertEquals(0, wiremock.findAll(getRequestedFor(anyUrl())).size(), \"circuit is open\");\n\n Thread.sleep(30_000);\n wiremock.resetRequests();\n for (int i = 0; i < 10; i++) app.get(\"/quote\"); // half-open: only trial calls reach the stub\n assertTrue(wiremock.findAll(getRequestedFor(anyUrl())).size() <= 3, \"at most 3 trial calls\");\n\n wiremock.stubFor(get(anyUrl()).willReturn(ok(\"{}\")));\n Thread.sleep(30_000);\n for (int i = 0; i < 3; i++) app.get(\"/quote\"); // trial calls succeed\n assertEquals(200, app.get(\"/quote\").statusCode(), \"circuit closed after successful trials\");\n}\n```"
667
680
  },
668
681
  {
669
682
  "id": "ff-fail",
@@ -671,9 +684,12 @@
671
684
  "label": "Outage drill: refused cleanly",
672
685
  "x": 1040,
673
686
  "y": 390,
674
- "category": "operational",
675
- "threshold": "With each outside system down, every user action that needs it answers 503 with Retry-After within {{DEADLINE_MS}} ms, and 0 records are changed",
676
- "description": "An integration test cuts each outside system off with Toxiproxy, runs the actions that need it, and checks the answer, its time and that the database is unchanged.\n\nTool: Toxiproxy (Testcontainers module) with Vitest and supertest\n\n```ts\nit('refuses an action cleanly while the partner is down', async () => {\n await partnerProxy.setEnabled(false) // Toxiproxy: the partner is unreachable\n const before = await snapshot(db)\n const started = Date.now()\n const res = await request(app).post('/orders').send(SAMPLE_ORDER)\n expect(res.status).toBe(503)\n expect(res.headers['retry-after']).toBeDefined()\n expect(Date.now() - started).toBeLessThan({{DEADLINE_MS}})\n expect(await snapshot(db)).toEqual(before)\n})\n```",
687
+ "characteristic": "reliability",
688
+ "scope": "atomic",
689
+ "cadence": "triggered",
690
+ "trigger": "pull-request",
691
+ "invocation": "automated",
692
+ "description": "An integration test cuts each outside system off with Toxiproxy, runs the actions that need it, and checks the answer, its time and that the database is unchanged.\n\nThreshold: With each outside system down, every user action that needs it answers 503 with Retry-After within {{DEADLINE_MS}} ms, and 0 records are changed\n\nTool: Toxiproxy (Testcontainers module) with Vitest and supertest (or the test runner and HTTP client of your stack)\n\n```ts\nit('refuses an action cleanly while the partner is down', async () => {\n await partnerProxy.setEnabled(false) // Toxiproxy: the partner is unreachable\n const before = await snapshot(db)\n const started = Date.now()\n const res = await request(app).post('/orders').send(SAMPLE_ORDER)\n expect(res.status).toBe(503)\n expect(res.headers['retry-after']).toBeDefined()\n expect(Date.now() - started).toBeLessThan({{DEADLINE_MS}})\n expect(await snapshot(db)).toEqual(before)\n})\n```",
677
693
  "hubWhen": {
678
694
  "FAILURE": [
679
695
  "fail"
@@ -686,9 +702,12 @@
686
702
  "label": "Outage drill: answers with less",
687
703
  "x": 1040,
688
704
  "y": 520,
689
- "category": "operational",
690
- "threshold": "With each outside system down, every read that uses it answers within {{DEADLINE_MS}} ms from data at most {{STALE_MINUTES}} minutes old or a default, marked incomplete; 0 errors",
691
- "description": "An integration test warms the cache, cuts the outside system off with Toxiproxy, and checks that reads still answer, in time and marked incomplete, while changes are refused.\n\nTool: Toxiproxy (Testcontainers module) with Vitest and supertest\n\n```ts\nit('answers from the cache, marked, while the partner is down', async () => {\n await request(app).get('/products/42').expect(200) // warms the cache\n await partnerProxy.setEnabled(false)\n const started = Date.now()\n const res = await request(app).get('/products/42').expect(200)\n expect(Date.now() - started).toBeLessThan({{DEADLINE_MS}})\n expect(res.body.incomplete).toEqual(['shippingEstimate'])\n expect(res.body.shippingEstimate.asOfMinutesAgo).toBeLessThanOrEqual({{STALE_MINUTES}})\n await request(app).post('/products/42/reserve').expect(503)\n})\n```",
705
+ "characteristic": "reliability",
706
+ "scope": "atomic",
707
+ "cadence": "triggered",
708
+ "trigger": "pull-request",
709
+ "invocation": "automated",
710
+ "description": "An integration test warms the cache, cuts the outside system off with Toxiproxy, and checks that reads still answer, in time and marked incomplete, while changes are refused in time and leave the database as it was.\n\nThreshold: With each outside system down, every read that uses it answers within {{DEADLINE_MS}} ms from data at most {{STALE_MINUTES}} minutes old or a default, marked incomplete; every change that needs it answers 503 within {{DEADLINE_MS}} ms with nothing changed\n\nTool: Toxiproxy (Testcontainers module) with Vitest and supertest (or the test runner and HTTP client of your stack)\n\n```ts\nit('answers from the cache, marked, while the partner is down', async () => {\n await request(app).get('/products/42').expect(200) // warms the cache\n await partnerProxy.setEnabled(false)\n const started = Date.now()\n const res = await request(app).get('/products/42').expect(200)\n expect(Date.now() - started).toBeLessThan({{DEADLINE_MS}})\n expect(res.body.incomplete).toEqual(['shippingEstimate'])\n expect(res.body.shippingEstimate.asOfMinutesAgo).toBeLessThanOrEqual({{STALE_MINUTES}})\n})\n\nit('refuses a change in time, with nothing changed', async () => {\n await partnerProxy.setEnabled(false)\n const before = await snapshot(db)\n const started = Date.now()\n await request(app).post('/products/42/reserve').expect(503)\n expect(Date.now() - started).toBeLessThan({{DEADLINE_MS}})\n expect(await snapshot(db)).toEqual(before)\n})\n```",
692
711
  "hubWhen": {
693
712
  "FAILURE": [
694
713
  "degrade"
@@ -701,9 +720,12 @@
701
720
  "label": "Outage drill: completed later",
702
721
  "x": 1040,
703
722
  "y": 650,
704
- "category": "operational",
705
- "threshold": "With the outside system down, every action is accepted with 202 within {{DEADLINE_MS}} ms and completes after it is back; 0 actions lost; an action older than {{DEFER_HOURS}} h is in the dead-letter queue",
706
- "description": "An integration test cuts the outside system off, starts actions, restarts the worker, brings the system back and waits for completion; a second test advances the clock past the deadline and expects the dead letter and the notices.\n\nTool: Toxiproxy (Testcontainers module) with Vitest (fake timers for the deadline)\n\n```ts\nit('keeps the action and completes it once the partner is back', async () => {\n await partnerProxy.setEnabled(false)\n const res = await request(app).post('/bookings').send(SAMPLE_BOOKING).expect(202)\n await restartWorker()\n await partnerProxy.setEnabled(true)\n await waitFor(async () => (await request(app).get(res.body.statusUrl)).body.state === 'completed')\n expect(await partnerStub.bookings()).toHaveLength(1)\n})\n```",
723
+ "characteristic": "reliability",
724
+ "scope": "atomic",
725
+ "cadence": "triggered",
726
+ "trigger": "pull-request",
727
+ "invocation": "automated",
728
+ "description": "An integration test cuts the outside system off, starts actions, restarts the worker, brings the system back and waits for completion; a second test advances the clock past the deadline and expects the dead letter and the notices.\n\nThreshold: With the outside system down, every action is accepted with 202 within {{DEADLINE_MS}} ms and completes after it is back, 0 actions lost; an action still waiting after {{DEFER_HOURS}} h is in the dead-letter queue with the user and the owner told\n\nTool: Toxiproxy (Testcontainers module) with Vitest (fake timers for the deadline; or the test runner of your stack)\n\n```ts\nit('keeps the action and completes it once the partner is back', async () => {\n await partnerProxy.setEnabled(false)\n const started = Date.now()\n const res = await request(app).post('/bookings').send(SAMPLE_BOOKING).expect(202)\n expect(Date.now() - started).toBeLessThan({{DEADLINE_MS}})\n await restartWorker()\n await partnerProxy.setEnabled(true)\n await waitFor(async () => (await request(app).get(res.body.statusUrl)).body.state === 'completed')\n expect(await partnerStub.bookings()).toHaveLength(1)\n})\n\nit('gives up visibly after the deadline', async () => {\n vi.useFakeTimers()\n await partnerProxy.setEnabled(false)\n const res = await request(app).post('/bookings').send(SAMPLE_BOOKING).expect(202)\n await vi.advanceTimersByTimeAsync({{DEFER_HOURS}} * 3_600_000 + 60_000)\n expect(await deadLetters()).toContainEqual(expect.objectContaining({ reference: res.body.reference }))\n expect((await request(app).get(res.body.statusUrl)).body.state).toBe('failed')\n expect(await alertsSent()).toContainEqual(expect.objectContaining({ to: 'integration-owner' }))\n})\n```",
707
729
  "hubWhen": {
708
730
  "FAILURE": [
709
731
  "defer"
@@ -716,9 +738,12 @@
716
738
  "label": "Retries reuse the key",
717
739
  "x": 1040,
718
740
  "y": 780,
719
- "category": "structural",
720
- "threshold": "Every retried call that changes something carries the same Idempotency-Key as its first attempt; 0 changing calls without a key",
721
- "description": "A test makes the stub time out on the first attempt of each changing call and checks that all attempts carry one and the same Idempotency-Key.\n\nTool: WireMock (JUnit 5 extension)\n\n```java\n@Test\nvoid retriesCarryTheSameKey(WireMockRuntimeInfo wm) {\n stubFor(post(\"/payments\").inScenario(\"lost\").whenScenarioStateIs(STARTED)\n .willReturn(ok().withFixedDelay({{TIMEOUT_MS}} * 2)).willSetStateTo(\"answered\"));\n stubFor(post(\"/payments\").inScenario(\"lost\").whenScenarioStateIs(\"answered\").willReturn(ok(\"{}\")));\n PartnerClient.create(wm.getHttpBaseUrl()).pay(SAMPLE_PAYMENT);\n var keys = findAll(postRequestedFor(urlEqualTo(\"/payments\"))).stream()\n .map(r -> r.getHeader(\"Idempotency-Key\")).distinct().toList();\n assertEquals(1, keys.size());\n assertNotNull(keys.get(0));\n}\n```",
741
+ "characteristic": "reliability",
742
+ "scope": "atomic",
743
+ "cadence": "triggered",
744
+ "trigger": "pull-request",
745
+ "invocation": "automated",
746
+ "description": "A test makes the stub time out on the first attempt of each changing call and checks that all attempts carry one and the same Idempotency-Key.\n\nThreshold: Every retried call that changes something carries the same Idempotency-Key as its first attempt; 0 changing calls without a key\n\nTool: WireMock (JUnit 5 extension; or the stub server of your stack)\n\n```java\n@Test\nvoid retriesCarryTheSameKey(WireMockRuntimeInfo wm) {\n stubFor(post(\"/payments\").inScenario(\"lost\").whenScenarioStateIs(STARTED)\n .willReturn(ok().withFixedDelay({{TIMEOUT_MS}} * 2)).willSetStateTo(\"answered\"));\n stubFor(post(\"/payments\").inScenario(\"lost\").whenScenarioStateIs(\"answered\").willReturn(ok(\"{}\")));\n PartnerClient.create(wm.getHttpBaseUrl()).pay(SAMPLE_PAYMENT);\n var keys = findAll(postRequestedFor(urlEqualTo(\"/payments\"))).stream()\n .map(r -> r.getHeader(\"Idempotency-Key\")).distinct().toList();\n assertEquals(1, keys.size());\n assertNotNull(keys.get(0));\n}\n```",
722
747
  "hubWhen": {
723
748
  "IDEMPOTENCY": [
724
749
  "keys"
@@ -731,9 +756,12 @@
731
756
  "label": "Lookup before repeat",
732
757
  "x": 1040,
733
758
  "y": 910,
734
- "category": "structural",
735
- "threshold": "After a lost answer to a changing call, the client looks the change up by its reference and repeats it 0 times when it exists",
736
- "description": "A test makes the stub take the change but time out, and checks that the client asks for the reference and sends the change only once.\n\nTool: WireMock (JUnit 5 extension)\n\n```java\n@Test\nvoid looksUpInsteadOfRepeating(WireMockRuntimeInfo wm) {\n stubFor(post(\"/bookings\").willReturn(created().withFixedDelay({{TIMEOUT_MS}} * 2)));\n stubFor(get(urlPathEqualTo(\"/bookings\")).withQueryParam(\"reference\", matching(\".+\"))\n .willReturn(okJson(\"[{\\\"id\\\":\\\"b-1\\\"}]\")));\n var booking = PartnerClient.create(wm.getHttpBaseUrl()).book(SAMPLE_BOOKING);\n assertEquals(\"b-1\", booking.id());\n verify(exactly(1), postRequestedFor(urlEqualTo(\"/bookings\")));\n verify(exactly(1), getRequestedFor(urlPathEqualTo(\"/bookings\")));\n}\n```",
759
+ "characteristic": "reliability",
760
+ "scope": "atomic",
761
+ "cadence": "triggered",
762
+ "trigger": "pull-request",
763
+ "invocation": "automated",
764
+ "description": "A test makes the stub take the change but time out, and checks that the client asks for the reference and sends the change only once.\n\nThreshold: After a lost answer to a changing call, the client looks the change up by its reference and repeats it 0 times when it exists\n\nTool: WireMock (JUnit 5 extension; or the stub server of your stack)\n\n```java\n@Test\nvoid looksUpInsteadOfRepeating(WireMockRuntimeInfo wm) {\n stubFor(post(\"/bookings\").willReturn(created().withFixedDelay({{TIMEOUT_MS}} * 2)));\n stubFor(get(urlPathEqualTo(\"/bookings\")).withQueryParam(\"reference\", matching(\".+\"))\n .willReturn(okJson(\"[{\\\"id\\\":\\\"b-1\\\"}]\")));\n var booking = PartnerClient.create(wm.getHttpBaseUrl()).book(SAMPLE_BOOKING);\n assertEquals(\"b-1\", booking.id());\n verify(exactly(1), postRequestedFor(urlEqualTo(\"/bookings\")));\n verify(exactly(1), getRequestedFor(urlPathEqualTo(\"/bookings\")));\n}\n```",
737
765
  "hubWhen": {
738
766
  "IDEMPOTENCY": [
739
767
  "lookup"
@@ -746,9 +774,12 @@
746
774
  "label": "Clients only read",
747
775
  "x": 1040,
748
776
  "y": 1040,
749
- "category": "structural",
750
- "threshold": "0 calls with POST, PUT, PATCH or DELETE in the clients of outside systems",
751
- "description": "A Semgrep rule over the integration clients fails the build on a call with a method that changes something, which would mean this decision has to be revisited.\n\nTool: Semgrep\n\n```yaml\nrules:\n- id: outside-clients-only-read\n message: Outside systems are only read (ADR on integration resilience); a changing call needs idempotency protection first\n severity: ERROR\n languages: [typescript]\n paths: { include: ['src/integrations/'] }\n pattern-either:\n - pattern: $HTTP.post(...)\n - pattern: $HTTP.put(...)\n - pattern: $HTTP.patch(...)\n - pattern: $HTTP.delete(...)\n - pattern: 'fetch($URL, { ..., method: \"$M\", ... })'\n```",
777
+ "characteristic": "reliability",
778
+ "scope": "atomic",
779
+ "cadence": "triggered",
780
+ "trigger": "pull-request",
781
+ "invocation": "automated",
782
+ "description": "A Semgrep rule over the integration clients fails the build on a call with a method that changes something, which would mean this decision has to be revisited; an explicit GET passes.\n\nThreshold: 0 calls with POST, PUT, PATCH or DELETE in the clients of outside systems\n\nTool: Semgrep (the rule is for TypeScript; for Java or C#, the same patterns on the HTTP client of your stack)\n\n```yaml\nrules:\n- id: outside-clients-only-read\n message: Outside systems are only read (ADR on integration resilience); a changing call needs idempotency protection first\n severity: ERROR\n languages: [typescript]\n paths: { include: ['src/integrations/'] }\n pattern-either:\n - pattern: $HTTP.post(...)\n - pattern: $HTTP.put(...)\n - pattern: $HTTP.patch(...)\n - pattern: $HTTP.delete(...)\n - patterns:\n - pattern: 'fetch($URL, { ..., method: \"$M\", ... })'\n - metavariable-regex:\n metavariable: $M\n regex: (?i)^\"?(post|put|patch|delete)\"?$\n```",
752
783
  "hubWhen": {
753
784
  "IDEMPOTENCY": [
754
785
  "readonly"
@@ -761,9 +792,12 @@
761
792
  "label": "No unguarded outside calls",
762
793
  "x": 1040,
763
794
  "y": 1170,
764
- "category": "structural",
765
- "threshold": "0 classes outside the integration clients use an HTTP client; every client method is guarded by a retry and a circuit breaker",
766
- "description": "ArchUnit rules fail the build when code outside the integration package uses an HTTP client, or when a public method of an integration client lacks the Resilience4j annotations (NetArchTest does the same in .NET, dependency-cruiser in TypeScript).\n\nTool: ArchUnit\n\n```java\n@AnalyzeClasses(packages = \"com.acme.shop\")\nclass OutsideCallsArchTest {\n @ArchTest\n static final ArchRule onlyClientsCallOut = noClasses()\n .that().resideOutsideOfPackage(\"..integration..\")\n .should().dependOnClassesThat().resideInAnyPackage(\"org.springframework.web.client..\", \"java.net.http..\", \"okhttp3..\");\n\n @ArchTest\n static final ArchRule clientsAreGuarded = methods()\n .that().areDeclaredInClassesThat().resideInAPackage(\"..integration..\")\n .and().arePublic()\n .should().beAnnotatedWith(io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker.class)\n .andShould().beAnnotatedWith(io.github.resilience4j.retry.annotation.Retry.class);\n}\n```",
795
+ "characteristic": "reliability",
796
+ "scope": "atomic",
797
+ "cadence": "triggered",
798
+ "trigger": "pull-request",
799
+ "invocation": "automated",
800
+ "description": "ArchUnit rules fail the build when code outside the integration package uses an HTTP client, or when a public method of an integration client class lacks the Resilience4j annotations (NetArchTest does the same in .NET, dependency-cruiser in TypeScript).\n\nThreshold: 0 classes outside the integration clients use an HTTP client; every public method of a *Client class in the integration package is guarded by a time limiter, a retry and a circuit breaker\n\nTool: ArchUnit (JVM; NetArchTest for .NET, dependency-cruiser for TypeScript)\n\n```java\n@AnalyzeClasses(packages = \"com.acme.shop\")\nclass OutsideCallsArchTest {\n @ArchTest\n static final ArchRule onlyClientsCallOut = noClasses()\n .that().resideOutsideOfPackage(\"..integration..\")\n .should().dependOnClassesThat().resideInAnyPackage(\"org.springframework.web.client..\", \"java.net.http..\", \"okhttp3..\");\n\n @ArchTest\n static final ArchRule clientsAreGuarded = methods()\n .that().areDeclaredInClassesThat().resideInAPackage(\"..integration..\")\n .and().areDeclaredInClassesThat().haveSimpleNameEndingWith(\"Client\")\n .and().arePublic()\n .should().beAnnotatedWith(io.github.resilience4j.timelimiter.annotation.TimeLimiter.class)\n .andShould().beAnnotatedWith(io.github.resilience4j.retry.annotation.Retry.class)\n .andShould().beAnnotatedWith(io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker.class);\n}\n```",
767
801
  "hubWhen": {
768
802
  "PROTECTION": [
769
803
  "library"
@@ -776,9 +810,12 @@
776
810
  "label": "Every outside host guarded",
777
811
  "x": 1040,
778
812
  "y": 1300,
779
- "category": "structural",
780
- "threshold": "Every ServiceEntry host has a VirtualService with a timeout and at most {{RETRIES}} retry attempts, and a DestinationRule with outlier detection; 0 hosts without",
781
- "description": "A Conftest policy runs over the mesh manifests in the repository in each pull request and fails on an outside host that lacks any of the three.\n\nTool: Conftest (Open Policy Agent)\n\n```rego\n# conftest test --combine mesh/\npackage mesh.egress\n\nimport rego.v1\n\ndocs := [f.contents | some f in input]\n\nhosts contains h if { some e in docs; e.kind == \"ServiceEntry\"; some h in e.spec.hosts }\n\nguarded_vs(h) if {\n some v in docs; v.kind == \"VirtualService\"; h in v.spec.hosts\n some r in v.spec.http; r.timeout; r.retries.attempts <= {{RETRIES}}\n}\n\nguarded_dr(h) if {\n some d in docs; d.kind == \"DestinationRule\"; d.spec.host == h\n d.spec.trafficPolicy.outlierDetection\n}\n\ndeny contains msg if { some h in hosts; not guarded_vs(h); msg := sprintf(\"%s: no VirtualService with a timeout and bounded retries\", [h]) }\ndeny contains msg if { some h in hosts; not guarded_dr(h); msg := sprintf(\"%s: no DestinationRule with outlierDetection\", [h]) }\n```",
813
+ "characteristic": "reliability",
814
+ "scope": "atomic",
815
+ "cadence": "triggered",
816
+ "trigger": "pull-request",
817
+ "invocation": "automated",
818
+ "description": "A Conftest policy runs over the mesh manifests in the repository in each pull request and fails on an outside host that lacks any of the three, or when egress to undeclared hosts is not blocked in the IstioOperator mesh config.\n\nThreshold: Every ServiceEntry host has a VirtualService with a timeout of at most {{TIMEOUT_MS}} ms and at most {{RETRIES}} retry attempts, and a DestinationRule with outlier detection; the mesh config sets outboundTrafficPolicy REGISTRY_ONLY; 0 hosts without\n\nTool: Conftest (Open Policy Agent)\n\n```rego\n# conftest test --combine mesh/\npackage main\n\nimport rego.v1\n\n# every document of every file, multi-document YAML flattened\ndocs contains d if { some f in input; is_array(f.contents); some d in f.contents }\ndocs contains d if { some f in input; not is_array(f.contents); d := f.contents }\n\nhosts contains h if { some e in docs; e.kind == \"ServiceEntry\"; some h in e.spec.hosts }\n\nguarded_vs(h) if {\n some v in docs; v.kind == \"VirtualService\"; h in v.spec.hosts\n some r in v.spec.http\n time.parse_duration_ns(r.timeout) <= {{TIMEOUT_MS}} * 1000000\n r.retries.attempts <= {{RETRIES}}\n}\n\nguarded_dr(h) if {\n some d in docs; d.kind == \"DestinationRule\"; d.spec.host == h\n d.spec.trafficPolicy.outlierDetection\n}\n\nregistry_only if {\n some o in docs; o.kind == \"IstioOperator\"\n o.spec.meshConfig.outboundTrafficPolicy.mode == \"REGISTRY_ONLY\"\n}\n\ndeny contains msg if { some h in hosts; not guarded_vs(h); msg := sprintf(\"%s: no VirtualService with a timeout of at most {{TIMEOUT_MS}} ms and at most {{RETRIES}} retries\", [h]) }\ndeny contains msg if { some h in hosts; not guarded_dr(h); msg := sprintf(\"%s: no DestinationRule with outlierDetection\", [h]) }\ndeny contains msg if { not registry_only; msg := \"mesh config: outboundTrafficPolicy must be REGISTRY_ONLY, or undeclared hosts are reachable unguarded\" }\n```",
782
819
  "hubWhen": {
783
820
  "PROTECTION": [
784
821
  "mesh"