dojo.md 0.1.0 → 0.2.0

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 (243) hide show
  1. package/courses/GENERATION_LOG.md +27 -0
  2. package/courses/api-error-handling/course.yaml +16 -0
  3. package/courses/api-error-handling/scenarios/level-1/error-response-format.yaml +131 -0
  4. package/courses/api-error-handling/scenarios/level-1/http-status-codes-basics.yaml +90 -0
  5. package/courses/api-error-handling/scenarios/level-1/rate-limiting-basics.yaml +135 -0
  6. package/courses/api-error-handling/scenarios/level-1/request-validation-errors.yaml +208 -0
  7. package/courses/api-error-handling/scenarios/level-2/circuit-breaker-pattern.yaml +189 -0
  8. package/courses/api-error-handling/scenarios/level-2/idempotency-retry-logic.yaml +159 -0
  9. package/courses/api-error-handling/scenarios/level-2/rfc-7807-problem-details.yaml +178 -0
  10. package/courses/api-error-handling/scenarios/level-2/webhook-error-handling.yaml +211 -0
  11. package/courses/api-error-handling/scenarios/level-3/distributed-tracing-errors.yaml +275 -0
  12. package/courses/github-actions-cicd/course.yaml +10 -0
  13. package/courses/github-actions-cicd/scenarios/level-1/actions-and-runners.yaml +58 -0
  14. package/courses/github-actions-cicd/scenarios/level-1/basic-workflow-syntax.yaml +52 -0
  15. package/courses/github-actions-cicd/scenarios/level-1/branch-protection-checks.yaml +63 -0
  16. package/courses/github-actions-cicd/scenarios/level-1/environment-variables-secrets.yaml +65 -0
  17. package/courses/github-actions-cicd/scenarios/level-1/first-cicd-shift.yaml +62 -0
  18. package/courses/github-actions-cicd/scenarios/level-1/job-dependencies-outputs.yaml +62 -0
  19. package/courses/github-actions-cicd/scenarios/level-1/simple-ci-pipeline.yaml +57 -0
  20. package/courses/github-actions-cicd/scenarios/level-1/workflow-debugging.yaml +90 -0
  21. package/courses/github-actions-cicd/scenarios/level-1/workflow-status-notifications.yaml +59 -0
  22. package/courses/github-actions-cicd/scenarios/level-1/workflow-triggers.yaml +56 -0
  23. package/courses/github-actions-cicd/scenarios/level-2/concurrency-control.yaml +58 -0
  24. package/courses/github-actions-cicd/scenarios/level-2/conditional-execution.yaml +60 -0
  25. package/courses/github-actions-cicd/scenarios/level-2/custom-actions-development.yaml +55 -0
  26. package/courses/github-actions-cicd/scenarios/level-2/dependency-caching.yaml +58 -0
  27. package/courses/github-actions-cicd/scenarios/level-2/deployment-workflows.yaml +61 -0
  28. package/courses/github-actions-cicd/scenarios/level-2/github-packages-publishing.yaml +59 -0
  29. package/courses/github-actions-cicd/scenarios/level-2/intermediate-cicd-shift.yaml +68 -0
  30. package/courses/github-actions-cicd/scenarios/level-2/matrix-builds.yaml +59 -0
  31. package/courses/github-actions-cicd/scenarios/level-2/reusable-workflows.yaml +61 -0
  32. package/courses/github-actions-cicd/scenarios/level-2/workflow-cost-optimization.yaml +61 -0
  33. package/courses/github-actions-cicd/scenarios/level-3/advanced-cicd-shift.yaml +64 -0
  34. package/courses/github-actions-cicd/scenarios/level-3/compliance-automation.yaml +68 -0
  35. package/courses/github-actions-cicd/scenarios/level-3/docker-action-development.yaml +65 -0
  36. package/courses/github-actions-cicd/scenarios/level-3/github-environments.yaml +65 -0
  37. package/courses/github-actions-cicd/scenarios/level-3/monorepo-ci.yaml +68 -0
  38. package/courses/github-actions-cicd/scenarios/level-3/oidc-cloud-deployments.yaml +55 -0
  39. package/courses/github-actions-cicd/scenarios/level-3/release-automation.yaml +61 -0
  40. package/courses/github-actions-cicd/scenarios/level-3/security-hardening.yaml +63 -0
  41. package/courses/github-actions-cicd/scenarios/level-3/self-hosted-runners.yaml +60 -0
  42. package/courses/github-actions-cicd/scenarios/level-3/workflow-optimization.yaml +59 -0
  43. package/courses/github-actions-cicd/scenarios/level-4/cicd-data-architecture.yaml +63 -0
  44. package/courses/github-actions-cicd/scenarios/level-4/cicd-economics-roi.yaml +63 -0
  45. package/courses/github-actions-cicd/scenarios/level-4/cicd-executive-communication.yaml +58 -0
  46. package/courses/github-actions-cicd/scenarios/level-4/cicd-incident-response.yaml +60 -0
  47. package/courses/github-actions-cicd/scenarios/level-4/cicd-org-design.yaml +59 -0
  48. package/courses/github-actions-cicd/scenarios/level-4/cicd-platform-architecture.yaml +63 -0
  49. package/courses/github-actions-cicd/scenarios/level-4/cicd-training-program.yaml +65 -0
  50. package/courses/github-actions-cicd/scenarios/level-4/cicd-vendor-evaluation.yaml +59 -0
  51. package/courses/github-actions-cicd/scenarios/level-4/enterprise-cicd-governance.yaml +55 -0
  52. package/courses/github-actions-cicd/scenarios/level-4/expert-cicd-shift.yaml +60 -0
  53. package/courses/github-actions-cicd/scenarios/level-5/cicd-ai-future.yaml +63 -0
  54. package/courses/github-actions-cicd/scenarios/level-5/cicd-behavioral-science.yaml +70 -0
  55. package/courses/github-actions-cicd/scenarios/level-5/cicd-board-strategy.yaml +56 -0
  56. package/courses/github-actions-cicd/scenarios/level-5/cicd-consulting-engagement.yaml +61 -0
  57. package/courses/github-actions-cicd/scenarios/level-5/cicd-industry-benchmarks.yaml +63 -0
  58. package/courses/github-actions-cicd/scenarios/level-5/cicd-ma-integration.yaml +73 -0
  59. package/courses/github-actions-cicd/scenarios/level-5/cicd-product-development.yaml +68 -0
  60. package/courses/github-actions-cicd/scenarios/level-5/cicd-regulatory-landscape.yaml +72 -0
  61. package/courses/github-actions-cicd/scenarios/level-5/comprehensive-cicd-system.yaml +66 -0
  62. package/courses/github-actions-cicd/scenarios/level-5/master-cicd-shift.yaml +76 -0
  63. package/courses/github-pr-review/scenarios/level-2/api-change-review.yaml +82 -0
  64. package/courses/github-pr-review/scenarios/level-2/automated-review-tooling.yaml +53 -0
  65. package/courses/github-pr-review/scenarios/level-2/cross-team-review.yaml +61 -0
  66. package/courses/github-pr-review/scenarios/level-2/intermediate-review-shift.yaml +66 -0
  67. package/courses/github-pr-review/scenarios/level-2/performance-review-patterns.yaml +99 -0
  68. package/courses/github-pr-review/scenarios/level-2/review-disagreement-resolution.yaml +64 -0
  69. package/courses/github-pr-review/scenarios/level-2/review-metrics-analysis.yaml +63 -0
  70. package/courses/github-pr-review/scenarios/level-2/review-turnaround-sla.yaml +54 -0
  71. package/courses/github-pr-review/scenarios/level-2/stacked-pr-review.yaml +65 -0
  72. package/courses/github-pr-review/scenarios/level-3/advanced-review-shift.yaml +65 -0
  73. package/courses/github-pr-review/scenarios/level-3/ai-powered-review.yaml +58 -0
  74. package/courses/github-pr-review/scenarios/level-3/compliance-review-process.yaml +64 -0
  75. package/courses/github-pr-review/scenarios/level-3/cross-functional-review.yaml +60 -0
  76. package/courses/github-pr-review/scenarios/level-3/incident-driven-review.yaml +63 -0
  77. package/courses/github-pr-review/scenarios/level-3/large-scale-review-operations.yaml +55 -0
  78. package/courses/github-pr-review/scenarios/level-3/monorepo-review-process.yaml +68 -0
  79. package/courses/github-pr-review/scenarios/level-3/review-automation-platform.yaml +61 -0
  80. package/courses/github-pr-review/scenarios/level-3/review-culture-design.yaml +62 -0
  81. package/courses/github-pr-review/scenarios/level-3/review-data-pipeline.yaml +62 -0
  82. package/courses/github-pr-review/scenarios/level-4/enterprise-review-operations.yaml +61 -0
  83. package/courses/github-pr-review/scenarios/level-4/expert-review-shift.yaml +62 -0
  84. package/courses/github-pr-review/scenarios/level-4/review-data-architecture.yaml +69 -0
  85. package/courses/github-pr-review/scenarios/level-4/review-economics-roi.yaml +63 -0
  86. package/courses/github-pr-review/scenarios/level-4/review-executive-communication.yaml +61 -0
  87. package/courses/github-pr-review/scenarios/level-4/review-incident-postmortem.yaml +69 -0
  88. package/courses/github-pr-review/scenarios/level-4/review-org-design.yaml +62 -0
  89. package/courses/github-pr-review/scenarios/level-4/review-platform-architecture.yaml +64 -0
  90. package/courses/github-pr-review/scenarios/level-4/review-training-program.yaml +66 -0
  91. package/courses/github-pr-review/scenarios/level-4/review-vendor-evaluation.yaml +76 -0
  92. package/courses/github-pr-review/scenarios/level-5/comprehensive-review-system.yaml +68 -0
  93. package/courses/github-pr-review/scenarios/level-5/master-review-shift.yaml +73 -0
  94. package/courses/github-pr-review/scenarios/level-5/review-ai-future.yaml +69 -0
  95. package/courses/github-pr-review/scenarios/level-5/review-behavioral-science.yaml +66 -0
  96. package/courses/github-pr-review/scenarios/level-5/review-board-strategy.yaml +62 -0
  97. package/courses/github-pr-review/scenarios/level-5/review-consulting-engagement.yaml +62 -0
  98. package/courses/github-pr-review/scenarios/level-5/review-devtools-product.yaml +71 -0
  99. package/courses/github-pr-review/scenarios/level-5/review-industry-benchmarks.yaml +64 -0
  100. package/courses/github-pr-review/scenarios/level-5/review-ma-integration.yaml +76 -0
  101. package/courses/github-pr-review/scenarios/level-5/review-regulatory-landscape.yaml +78 -0
  102. package/courses/postgresql-query-optimization/course.yaml +11 -0
  103. package/courses/postgresql-query-optimization/scenarios/level-1/explain-analyze-basics.yaml +80 -0
  104. package/courses/postgresql-query-optimization/scenarios/level-1/first-optimization-shift.yaml +77 -0
  105. package/courses/postgresql-query-optimization/scenarios/level-1/index-fundamentals.yaml +76 -0
  106. package/courses/postgresql-query-optimization/scenarios/level-1/join-basics.yaml +73 -0
  107. package/courses/postgresql-query-optimization/scenarios/level-1/n-plus-one-queries.yaml +62 -0
  108. package/courses/postgresql-query-optimization/scenarios/level-1/query-rewriting-basics.yaml +69 -0
  109. package/courses/postgresql-query-optimization/scenarios/level-1/select-star-problems.yaml +69 -0
  110. package/courses/postgresql-query-optimization/scenarios/level-1/slow-query-diagnosis.yaml +63 -0
  111. package/courses/postgresql-query-optimization/scenarios/level-1/vacuum-and-statistics.yaml +62 -0
  112. package/courses/postgresql-query-optimization/scenarios/level-1/where-clause-optimization.yaml +74 -0
  113. package/courses/postgresql-query-optimization/scenarios/level-2/autovacuum-tuning.yaml +76 -0
  114. package/courses/postgresql-query-optimization/scenarios/level-2/composite-index-design.yaml +81 -0
  115. package/courses/postgresql-query-optimization/scenarios/level-2/covering-indexes.yaml +74 -0
  116. package/courses/postgresql-query-optimization/scenarios/level-2/cte-optimization.yaml +83 -0
  117. package/courses/postgresql-query-optimization/scenarios/level-2/intermediate-optimization-shift.yaml +66 -0
  118. package/courses/postgresql-query-optimization/scenarios/level-2/join-optimization.yaml +72 -0
  119. package/courses/postgresql-query-optimization/scenarios/level-2/partial-and-expression-indexes.yaml +75 -0
  120. package/courses/postgresql-query-optimization/scenarios/level-2/query-planner-settings.yaml +62 -0
  121. package/courses/postgresql-query-optimization/scenarios/level-2/subquery-optimization.yaml +67 -0
  122. package/courses/postgresql-query-optimization/scenarios/level-2/window-function-optimization.yaml +63 -0
  123. package/courses/postgresql-query-optimization/scenarios/level-3/advanced-optimization-shift.yaml +71 -0
  124. package/courses/postgresql-query-optimization/scenarios/level-3/connection-pooling.yaml +60 -0
  125. package/courses/postgresql-query-optimization/scenarios/level-3/full-text-search-optimization.yaml +66 -0
  126. package/courses/postgresql-query-optimization/scenarios/level-3/jsonb-optimization.yaml +88 -0
  127. package/courses/postgresql-query-optimization/scenarios/level-3/lock-contention-analysis.yaml +80 -0
  128. package/courses/postgresql-query-optimization/scenarios/level-3/materialized-view-optimization.yaml +73 -0
  129. package/courses/postgresql-query-optimization/scenarios/level-3/parallel-query-execution.yaml +74 -0
  130. package/courses/postgresql-query-optimization/scenarios/level-3/partitioning-strategies.yaml +71 -0
  131. package/courses/postgresql-query-optimization/scenarios/level-3/specialized-index-types.yaml +67 -0
  132. package/courses/postgresql-query-optimization/scenarios/level-3/write-optimization.yaml +65 -0
  133. package/courses/postgresql-query-optimization/scenarios/level-4/data-architecture-analytics.yaml +64 -0
  134. package/courses/postgresql-query-optimization/scenarios/level-4/database-executive-communication.yaml +64 -0
  135. package/courses/postgresql-query-optimization/scenarios/level-4/database-migration-planning.yaml +57 -0
  136. package/courses/postgresql-query-optimization/scenarios/level-4/enterprise-database-governance.yaml +52 -0
  137. package/courses/postgresql-query-optimization/scenarios/level-4/expert-optimization-shift.yaml +73 -0
  138. package/courses/postgresql-query-optimization/scenarios/level-4/high-availability-architecture.yaml +62 -0
  139. package/courses/postgresql-query-optimization/scenarios/level-4/optimizer-internals.yaml +69 -0
  140. package/courses/postgresql-query-optimization/scenarios/level-4/performance-sla-design.yaml +58 -0
  141. package/courses/postgresql-query-optimization/scenarios/level-4/read-replica-optimization.yaml +62 -0
  142. package/courses/postgresql-query-optimization/scenarios/level-4/vendor-evaluation.yaml +73 -0
  143. package/courses/rest-api-error-handling/course.yaml +11 -0
  144. package/courses/rest-api-error-handling/scenarios/level-1/authentication-errors.yaml +71 -0
  145. package/courses/rest-api-error-handling/scenarios/level-1/content-negotiation-errors.yaml +63 -0
  146. package/courses/rest-api-error-handling/scenarios/level-1/error-logging-basics.yaml +63 -0
  147. package/courses/rest-api-error-handling/scenarios/level-1/error-response-format.yaml +58 -0
  148. package/courses/rest-api-error-handling/scenarios/level-1/first-error-handling-shift.yaml +67 -0
  149. package/courses/rest-api-error-handling/scenarios/level-1/http-status-codes.yaml +46 -0
  150. package/courses/rest-api-error-handling/scenarios/level-1/not-found-errors.yaml +52 -0
  151. package/courses/rest-api-error-handling/scenarios/level-1/rate-limiting-errors.yaml +56 -0
  152. package/courses/rest-api-error-handling/scenarios/level-1/request-validation-errors.yaml +59 -0
  153. package/courses/rest-api-error-handling/scenarios/level-1/server-error-handling.yaml +55 -0
  154. package/courses/rest-api-error-handling/scenarios/level-2/api-versioning-errors.yaml +66 -0
  155. package/courses/rest-api-error-handling/scenarios/level-2/batch-request-errors.yaml +61 -0
  156. package/courses/rest-api-error-handling/scenarios/level-2/circuit-breaker-pattern.yaml +52 -0
  157. package/courses/rest-api-error-handling/scenarios/level-2/error-code-taxonomy.yaml +62 -0
  158. package/courses/rest-api-error-handling/scenarios/level-2/error-monitoring-alerting.yaml +53 -0
  159. package/courses/rest-api-error-handling/scenarios/level-2/intermediate-error-shift.yaml +69 -0
  160. package/courses/rest-api-error-handling/scenarios/level-2/pagination-errors.yaml +66 -0
  161. package/courses/rest-api-error-handling/scenarios/level-2/retry-and-idempotency.yaml +60 -0
  162. package/courses/rest-api-error-handling/scenarios/level-2/rfc7807-problem-details.yaml +60 -0
  163. package/courses/rest-api-error-handling/scenarios/level-2/webhook-error-handling.yaml +55 -0
  164. package/courses/rest-api-error-handling/scenarios/level-3/advanced-error-shift.yaml +72 -0
  165. package/courses/rest-api-error-handling/scenarios/level-3/api-gateway-errors.yaml +71 -0
  166. package/courses/rest-api-error-handling/scenarios/level-3/async-api-errors.yaml +67 -0
  167. package/courses/rest-api-error-handling/scenarios/level-3/caching-error-scenarios.yaml +65 -0
  168. package/courses/rest-api-error-handling/scenarios/level-3/chaos-engineering-apis.yaml +62 -0
  169. package/courses/rest-api-error-handling/scenarios/level-3/database-error-handling.yaml +79 -0
  170. package/courses/rest-api-error-handling/scenarios/level-3/distributed-error-propagation.yaml +63 -0
  171. package/courses/rest-api-error-handling/scenarios/level-3/error-budgets-sre.yaml +61 -0
  172. package/courses/rest-api-error-handling/scenarios/level-3/error-correlation.yaml +58 -0
  173. package/courses/rest-api-error-handling/scenarios/level-3/graphql-vs-rest-errors.yaml +73 -0
  174. package/courses/rest-api-error-handling/scenarios/level-4/compliance-error-handling.yaml +65 -0
  175. package/courses/rest-api-error-handling/scenarios/level-4/enterprise-error-governance.yaml +62 -0
  176. package/courses/rest-api-error-handling/scenarios/level-4/error-analytics-platform.yaml +65 -0
  177. package/courses/rest-api-error-handling/scenarios/level-4/error-cost-optimization.yaml +63 -0
  178. package/courses/rest-api-error-handling/scenarios/level-4/error-executive-communication.yaml +60 -0
  179. package/courses/rest-api-error-handling/scenarios/level-4/error-handling-architecture.yaml +67 -0
  180. package/courses/rest-api-error-handling/scenarios/level-4/error-org-design.yaml +68 -0
  181. package/courses/rest-api-error-handling/scenarios/level-4/error-sla-design.yaml +65 -0
  182. package/courses/rest-api-error-handling/scenarios/level-4/error-training-program.yaml +61 -0
  183. package/courses/rest-api-error-handling/scenarios/level-4/expert-error-shift.yaml +63 -0
  184. package/courses/rest-api-error-handling/scenarios/level-5/comprehensive-error-system.yaml +68 -0
  185. package/courses/rest-api-error-handling/scenarios/level-5/error-ai-future.yaml +75 -0
  186. package/courses/rest-api-error-handling/scenarios/level-5/error-behavioral-science.yaml +73 -0
  187. package/courses/rest-api-error-handling/scenarios/level-5/error-board-strategy.yaml +60 -0
  188. package/courses/rest-api-error-handling/scenarios/level-5/error-consulting-engagement.yaml +58 -0
  189. package/courses/rest-api-error-handling/scenarios/level-5/error-industry-benchmarks.yaml +72 -0
  190. package/courses/rest-api-error-handling/scenarios/level-5/error-ma-integration.yaml +68 -0
  191. package/courses/rest-api-error-handling/scenarios/level-5/error-product-development.yaml +66 -0
  192. package/courses/rest-api-error-handling/scenarios/level-5/error-regulatory-landscape.yaml +80 -0
  193. package/courses/rest-api-error-handling/scenarios/level-5/master-error-shift.yaml +73 -0
  194. package/dist/cli/commands/add.d.ts.map +1 -1
  195. package/dist/cli/commands/add.js +6 -5
  196. package/dist/cli/commands/add.js.map +1 -1
  197. package/dist/cli/commands/generate.d.ts.map +1 -1
  198. package/dist/cli/commands/generate.js +4 -0
  199. package/dist/cli/commands/generate.js.map +1 -1
  200. package/dist/cli/commands/list.d.ts.map +1 -1
  201. package/dist/cli/commands/list.js +6 -18
  202. package/dist/cli/commands/list.js.map +1 -1
  203. package/dist/cli/commands/train.d.ts.map +1 -1
  204. package/dist/cli/commands/train.js +18 -18
  205. package/dist/cli/commands/train.js.map +1 -1
  206. package/dist/cli/index.js +93 -55
  207. package/dist/cli/index.js.map +1 -1
  208. package/dist/cli/run-demo.js +2 -1
  209. package/dist/cli/run-demo.js.map +1 -1
  210. package/dist/cli/setup.d.ts +18 -0
  211. package/dist/cli/setup.d.ts.map +1 -0
  212. package/dist/cli/setup.js +154 -0
  213. package/dist/cli/setup.js.map +1 -0
  214. package/dist/engine/agent-bridge.d.ts +5 -2
  215. package/dist/engine/agent-bridge.d.ts.map +1 -1
  216. package/dist/engine/agent-bridge.js +36 -9
  217. package/dist/engine/agent-bridge.js.map +1 -1
  218. package/dist/engine/loader.d.ts +21 -0
  219. package/dist/engine/loader.d.ts.map +1 -1
  220. package/dist/engine/loader.js +54 -1
  221. package/dist/engine/loader.js.map +1 -1
  222. package/dist/engine/training-loop.d.ts.map +1 -1
  223. package/dist/engine/training-loop.js +1 -0
  224. package/dist/engine/training-loop.js.map +1 -1
  225. package/dist/engine/training.d.ts.map +1 -1
  226. package/dist/engine/training.js +1 -0
  227. package/dist/engine/training.js.map +1 -1
  228. package/dist/generator/skill-generator.d.ts +1 -1
  229. package/dist/generator/skill-generator.d.ts.map +1 -1
  230. package/dist/generator/skill-generator.js +21 -2
  231. package/dist/generator/skill-generator.js.map +1 -1
  232. package/dist/mcp/server.d.ts.map +1 -1
  233. package/dist/mcp/server.js +11 -26
  234. package/dist/mcp/server.js.map +1 -1
  235. package/dist/mcp/session-manager.d.ts +3 -1
  236. package/dist/mcp/session-manager.d.ts.map +1 -1
  237. package/dist/mcp/session-manager.js +44 -22
  238. package/dist/mcp/session-manager.js.map +1 -1
  239. package/dist/types/schemas.d.ts +38 -13
  240. package/dist/types/schemas.d.ts.map +1 -1
  241. package/dist/types/schemas.js +9 -5
  242. package/dist/types/schemas.js.map +1 -1
  243. package/package.json +1 -1
@@ -0,0 +1,189 @@
1
+ name: "Circuit Breaker Pattern for Resilience"
2
+ level: 2
3
+ difficulty: intermediate
4
+ description: "Implement circuit breaker pattern to prevent cascading failures and graceful degradation"
5
+
6
+ context: |
7
+ Your API depends on an external payment provider. Implement a circuit breaker that
8
+ monitors failures. When failure rate exceeds threshold, trip the circuit to stop
9
+ requests for a cool-down period, preventing cascading failures.
10
+
11
+ scenario:
12
+ state:
13
+ circuit_breaker:
14
+ state: "CLOSED"
15
+ failure_count: 0
16
+ success_count: 0
17
+ failure_threshold: 5
18
+ success_threshold: 2
19
+ timeout_seconds: 30
20
+ payment_provider:
21
+ healthy: true
22
+ failure_rate: 0
23
+
24
+ endpoint: "POST /api/v1/charges"
25
+
26
+ test_cases:
27
+ - name: "circuit_closed_request_succeeds"
28
+ request:
29
+ body:
30
+ amount: 100
31
+ card_token: "tok_visa"
32
+ circuit_state: "CLOSED"
33
+ provider_status: "healthy"
34
+ expected_status: 200
35
+ expected_response:
36
+ charge_id: "charge_001"
37
+ status: "succeeded"
38
+
39
+ - name: "circuit_closed_provider_fails_once"
40
+ request:
41
+ body:
42
+ amount: 100
43
+ card_token: "tok_visa"
44
+ circuit_state: "CLOSED"
45
+ provider_status: "failing"
46
+ expected_status: 502
47
+ expected_response:
48
+ error:
49
+ code: "PAYMENT_PROVIDER_ERROR"
50
+
51
+ - name: "circuit_accumulates_failures"
52
+ request:
53
+ body:
54
+ amount: 100
55
+ card_token: "tok_visa"
56
+ circuit_state: "CLOSED"
57
+ provider_status: "failing"
58
+ consecutive_failures: 5
59
+ expected_status: 502
60
+ circuit_state_after: "OPEN"
61
+
62
+ - name: "circuit_open_request_fails_immediately"
63
+ request:
64
+ body:
65
+ amount: 100
66
+ card_token: "tok_visa"
67
+ circuit_state: "OPEN"
68
+ expected_status: 503
69
+ expected_response:
70
+ error:
71
+ code: "SERVICE_UNAVAILABLE"
72
+ message: "Payment service temporarily unavailable. Please retry later."
73
+ response_time_ms: "< 10"
74
+
75
+ - name: "circuit_returns_fallback_response"
76
+ request:
77
+ body:
78
+ amount: 100
79
+ card_token: "tok_visa"
80
+ circuit_state: "OPEN"
81
+ fallback_enabled: true
82
+ expected_status: 202
83
+ expected_response:
84
+ charge_id: "charge_002"
85
+ status: "pending"
86
+ message: "Charge queued for processing when service recovers"
87
+
88
+ - name: "circuit_half_open_test_request"
89
+ request:
90
+ body:
91
+ amount: 100
92
+ card_token: "tok_visa"
93
+ circuit_state: "HALF_OPEN"
94
+ provider_status: "healthy"
95
+ expected_status: 200
96
+ expected_response:
97
+ charge_id: "charge_003"
98
+ status: "succeeded"
99
+ circuit_state_after: "CLOSED"
100
+
101
+ - name: "circuit_half_open_test_fails_reopens"
102
+ request:
103
+ body:
104
+ amount: 100
105
+ card_token: "tok_visa"
106
+ circuit_state: "HALF_OPEN"
107
+ provider_status: "failing"
108
+ expected_status: 502
109
+ circuit_state_after: "OPEN"
110
+
111
+ - name: "circuit_timeout_moves_to_half_open"
112
+ circuit_state: "OPEN"
113
+ timeout_elapsed: 30
114
+ current_request: false
115
+ circuit_state_after: "HALF_OPEN"
116
+
117
+ assertions:
118
+ - type: "api_called"
119
+ description: "Circuit breaker monitors failure rate"
120
+ test: "failure_count increments on provider errors"
121
+
122
+ - type: "outcome"
123
+ description: "Circuit trips when threshold exceeded"
124
+ test: "circuit_accumulates_failures transitions to OPEN state"
125
+
126
+ - type: "api_called"
127
+ description: "Open circuit fails immediately without trying provider"
128
+ test: "circuit_open_request_fails_immediately responds quickly"
129
+
130
+ - type: "api_called"
131
+ description: "Fallback behavior when circuit open"
132
+ test: "circuit_returns_fallback_response provides degraded service"
133
+
134
+ - type: "api_called"
135
+ description: "Circuit half-open allows test request"
136
+ test: "circuit_half_open_test_request sent to provider"
137
+
138
+ - type: "outcome"
139
+ description: "Successful test request closes circuit"
140
+ test: "circuit_half_open_test_fails_reopens transitions correctly"
141
+
142
+ learning_objectives:
143
+ - "Understand circuit breaker states: CLOSED, OPEN, HALF_OPEN"
144
+ - "Monitor failures to detect persistent provider issues"
145
+ - "Trip circuit to prevent cascading failures"
146
+ - "Implement cool-down period for recovery"
147
+ - "Test recovery with half-open state"
148
+ - "Return appropriate status codes for circuit states"
149
+ - "Implement fallback strategies for open circuits"
150
+
151
+ circuit_breaker_states:
152
+ "CLOSED": "Normal operation, requests flow to provider"
153
+ "OPEN": "Too many failures, requests fail immediately, no provider calls"
154
+ "HALF_OPEN": "Cool-down period elapsed, allow test request to check if provider recovered"
155
+
156
+ state_transitions:
157
+ "CLOSED → OPEN": "When failure_count exceeds threshold"
158
+ "OPEN → HALF_OPEN": "When timeout_seconds elapsed"
159
+ "HALF_OPEN → CLOSED": "When test request succeeds"
160
+ "HALF_OPEN → OPEN": "When test request fails"
161
+
162
+ implementation_considerations:
163
+ "failure_detection": "Monitor 5xx errors and timeouts"
164
+ "failure_threshold": "Typically 5-10 consecutive failures"
165
+ "cool_down_period": "30-60 seconds typical"
166
+ "half_open_testing": "Allow single request through to test recovery"
167
+ "fallback_strategy": "Queue requests, return degraded response, or fail fast"
168
+ "metrics": "Track state transitions, time in each state"
169
+
170
+ fallback_strategies:
171
+ "fast_fail": "Return 503 Service Unavailable immediately"
172
+ "queue_requests": "Enqueue for async processing when provider recovers"
173
+ "degraded_mode": "Use cached data or return partial results"
174
+ "alternate_provider": "Failover to backup provider"
175
+
176
+ common_mistakes:
177
+ - "Not implementing circuit breaker for external dependencies"
178
+ - "Allowing too many failures before tripping circuit"
179
+ - "Cool-down period too short (allows rapid retries)"
180
+ - "Not monitoring time spent in OPEN state"
181
+ - "Failing to test recovery in HALF_OPEN state"
182
+ - "Not logging circuit state changes"
183
+ - "Returning ambiguous status codes (500 vs 503)"
184
+
185
+ libraries:
186
+ "hystrix": "Netflix Hystrix - Java circuit breaker library"
187
+ "polly": ".NET resilience and transient-fault-handling library"
188
+ "opossum": "Node.js circuit breaker"
189
+ "pybreaker": "Python implementation"
@@ -0,0 +1,159 @@
1
+ name: "Idempotency and Retry Logic"
2
+ level: 2
3
+ difficulty: intermediate
4
+ description: "Implement idempotent operations and safe retry strategies to prevent duplicate processing"
5
+
6
+ context: |
7
+ Design payment processing APIs that are idempotent. Clients send a unique idempotency
8
+ key with each request. If a retry arrives with the same key, return the same result
9
+ without processing again. This prevents double-charging when networks fail.
10
+
11
+ scenario:
12
+ state:
13
+ payments:
14
+ "pay_001": { customer_id: "cust_1", amount: 100, status: "completed" }
15
+ customers:
16
+ "cust_1": { balance: 1000 }
17
+ "cust_2": { balance: 500 }
18
+ idempotency_keys:
19
+ "idem_key_123": { payment_id: "pay_001", status: "completed", created_at: "2024-01-01T10:00:00Z" }
20
+
21
+ endpoint: "POST /api/v1/payments"
22
+
23
+ test_cases:
24
+ - name: "initial_payment_request"
25
+ request:
26
+ body:
27
+ customer_id: "cust_2"
28
+ amount: 50
29
+ headers:
30
+ Idempotency-Key: "idem_key_456"
31
+ expected_status: 201
32
+ expected_response:
33
+ payment_id: "pay_002"
34
+ customer_id: "cust_2"
35
+ amount: 50
36
+ status: "completed"
37
+
38
+ - name: "retry_same_idempotency_key_returns_same_result"
39
+ request:
40
+ body:
41
+ customer_id: "cust_2"
42
+ amount: 50
43
+ headers:
44
+ Idempotency-Key: "idem_key_456"
45
+ expected_status: 201
46
+ expected_response:
47
+ payment_id: "pay_002"
48
+ customer_id: "cust_2"
49
+ amount: 50
50
+ status: "completed"
51
+
52
+ - name: "duplicate_charge_prevented"
53
+ request:
54
+ body:
55
+ customer_id: "cust_2"
56
+ amount: 50
57
+ headers:
58
+ Idempotency-Key: "idem_key_456"
59
+ expected_effect: "customer balance unchanged (only charged once)"
60
+
61
+ - name: "different_key_different_charge"
62
+ request:
63
+ body:
64
+ customer_id: "cust_2"
65
+ amount: 50
66
+ headers:
67
+ Idempotency-Key: "idem_key_789"
68
+ expected_status: 201
69
+ expected_response:
70
+ payment_id: "pay_003"
71
+
72
+ - name: "missing_idempotency_key_warning"
73
+ request:
74
+ body:
75
+ customer_id: "cust_2"
76
+ amount: 50
77
+ expected_status: 201
78
+ expected_response:
79
+ warning: "Idempotency-Key not provided. Retries may result in duplicate charges."
80
+
81
+ - name: "request_in_progress"
82
+ request:
83
+ body:
84
+ customer_id: "cust_2"
85
+ amount: 50
86
+ headers:
87
+ Idempotency-Key: "idem_key_processing"
88
+ concurrent_request: true
89
+ expected_status: 409
90
+ expected_response:
91
+ error:
92
+ code: "REQUEST_IN_PROGRESS"
93
+ message: "Request with this Idempotency-Key is currently being processed"
94
+
95
+ assertions:
96
+ - type: "api_called"
97
+ description: "Idempotency-Key header required for non-idempotent operations"
98
+ test: "POST /payments accepts Idempotency-Key header"
99
+
100
+ - type: "api_called"
101
+ description: "Same idempotency key returns same result"
102
+ test: "retry_same_idempotency_key_returns_same_result succeeds"
103
+
104
+ - type: "outcome"
105
+ description: "Duplicate processing prevented"
106
+ test: "duplicate_charge_prevented prevents second charge"
107
+
108
+ - type: "api_called"
109
+ description: "Different keys processed as different requests"
110
+ test: "different_key_different_charge creates separate payment"
111
+
112
+ - type: "api_called"
113
+ description: "Concurrent requests with same key handled"
114
+ test: "request_in_progress returns 409 for concurrent calls"
115
+
116
+ learning_objectives:
117
+ - "Understand idempotency and why it's critical for financial operations"
118
+ - "Implement idempotency key tracking and storage"
119
+ - "Return consistent results for duplicate idempotent requests"
120
+ - "Prevent double-processing with idempotent operations"
121
+ - "Handle request-in-progress scenarios"
122
+ - "Design safe retry strategies with exponential backoff"
123
+ - "Distinguish between idempotent and non-idempotent operations"
124
+
125
+ idempotency_implementation:
126
+ "storage": "Idempotency keys stored with request ID, status, and result"
127
+ "cache_ttl": "Keep entries for 24 hours minimum for safety"
128
+ "duplicate_detection": "Check key before processing, return stored result if found"
129
+ "status_tracking": "Track PENDING, COMPLETED, FAILED states"
130
+
131
+ retry_strategy:
132
+ "idempotent_operations": "GET, PUT, DELETE - safe to retry with backoff"
133
+ "non_idempotent_operations": "POST typically requires idempotency key"
134
+ "backoff_pattern": "exponential: 1s, 2s, 4s, 8s, 16s"
135
+ "max_retries": "Typically 5-10 depending on SLA"
136
+
137
+ headers:
138
+ "Idempotency-Key": "Unique identifier for the logical operation (required for POST/PATCH)"
139
+ "Idempotency-Replay": "Boolean indicating if this is a replay of previous request"
140
+
141
+ common_mistakes:
142
+ - "Not implementing idempotency for payment operations"
143
+ - "Charging twice due to missing idempotency checks"
144
+ - "Not persisting idempotency keys long enough"
145
+ - "Retrying non-idempotent operations blindly"
146
+ - "Not informing clients of idempotency requirements"
147
+ - "Failing to handle requests in progress"
148
+
149
+ example_idempotent_operations: |
150
+ POST /api/v1/payments (with Idempotency-Key header)
151
+ POST /api/v1/orders (with Idempotency-Key header)
152
+ POST /api/v1/subscriptions (with Idempotency-Key header)
153
+
154
+ These modify state and must be idempotent to prevent duplicates.
155
+
156
+ Safe to retry without idempotency key:
157
+ GET /api/v1/users (read-only)
158
+ DELETE /api/v1/users/{id} (idempotent - deleting twice = same result)
159
+ PUT /api/v1/users/{id} (idempotent - updating twice with same data = same result)
@@ -0,0 +1,178 @@
1
+ name: "RFC 7807 Problem Details Standard"
2
+ level: 2
3
+ difficulty: intermediate
4
+ description: "Implement standardized error responses using RFC 7807 Problem Details format"
5
+
6
+ context: |
7
+ Migrate your API error responses to the RFC 7807 standard. This standardized format
8
+ improves interoperability across tools and clients. Implement problem details with
9
+ type URI, title, status, detail, and instance fields.
10
+
11
+ scenario:
12
+ state:
13
+ bank_accounts:
14
+ "acc_001": { balance: 5000, account_holder: "John Doe" }
15
+ "acc_002": { balance: 100, account_holder: "Jane Smith" }
16
+
17
+ endpoint: "POST /api/v1/accounts/{accountId}/transfer"
18
+
19
+ test_cases:
20
+ - name: "successful_transfer"
21
+ request:
22
+ path: "/api/v1/accounts/acc_001/transfer"
23
+ body:
24
+ to_account: "acc_002"
25
+ amount: 100
26
+ expected_status: 200
27
+ expected_response:
28
+ transaction_id: "txn_123"
29
+ status: "completed"
30
+
31
+ - name: "insufficient_funds_rfc7807"
32
+ request:
33
+ path: "/api/v1/accounts/acc_002/transfer"
34
+ body:
35
+ to_account: "acc_001"
36
+ amount: 500
37
+ expected_status: 422
38
+ expected_response:
39
+ type: "https://api.example.com/errors/insufficient-funds"
40
+ title: "Insufficient Funds"
41
+ status: 422
42
+ detail: "Account acc_002 has balance of 100 but requires 500 for this transfer"
43
+ instance: "/api/v1/accounts/acc_002/transfer"
44
+ balance: 100
45
+ required_amount: 500
46
+
47
+ - name: "account_not_found_rfc7807"
48
+ request:
49
+ path: "/api/v1/accounts/acc_999/transfer"
50
+ body:
51
+ to_account: "acc_001"
52
+ amount: 100
53
+ expected_status: 404
54
+ expected_response:
55
+ type: "https://api.example.com/errors/account-not-found"
56
+ title: "Account Not Found"
57
+ status: 404
58
+ detail: "The account acc_999 does not exist in the system"
59
+ instance: "/api/v1/accounts/acc_999/transfer"
60
+
61
+ - name: "invalid_amount_validation"
62
+ request:
63
+ path: "/api/v1/accounts/acc_001/transfer"
64
+ body:
65
+ to_account: "acc_002"
66
+ amount: -50
67
+ expected_status: 400
68
+ expected_response:
69
+ type: "https://api.example.com/errors/validation-error"
70
+ title: "Validation Error"
71
+ status: 400
72
+ detail: "The request body contains invalid values"
73
+ instance: "/api/v1/accounts/acc_001/transfer"
74
+ validation_errors:
75
+ - field: "amount"
76
+ message: "Amount must be positive"
77
+ rejected_value: -50
78
+
79
+ - name: "self_transfer_error"
80
+ request:
81
+ path: "/api/v1/accounts/acc_001/transfer"
82
+ body:
83
+ to_account: "acc_001"
84
+ amount: 100
85
+ expected_status: 409
86
+ expected_response:
87
+ type: "https://api.example.com/errors/invalid-operation"
88
+ title: "Invalid Operation"
89
+ status: 409
90
+ detail: "Cannot transfer funds to the same account"
91
+ instance: "/api/v1/accounts/acc_001/transfer"
92
+
93
+ assertions:
94
+ - type: "api_called"
95
+ description: "type field contains URI identifying problem"
96
+ test: "error response includes type field with URI"
97
+
98
+ - type: "api_called"
99
+ description: "title field is human-readable problem type"
100
+ test: "title field is constant for same error type"
101
+
102
+ - type: "api_called"
103
+ description: "status field echoes HTTP status code"
104
+ test: "status field matches HTTP response status"
105
+
106
+ - type: "api_called"
107
+ description: "detail field explains specific instance"
108
+ test: "detail contains instance-specific information"
109
+
110
+ - type: "api_called"
111
+ description: "instance field identifies affected resource"
112
+ test: "instance field contains request path"
113
+
114
+ - type: "api_called"
115
+ description: "Extensions included for domain-specific details"
116
+ test: "error response includes custom fields as extensions"
117
+
118
+ - type: "outcome"
119
+ description: "RFC 7807 enables standard error tooling"
120
+ test: "error responses conform to standard specification"
121
+
122
+ learning_objectives:
123
+ - "Understand RFC 7807 Problem Details specification"
124
+ - "Map problem types to type URIs"
125
+ - "Distinguish between title (constant) and detail (instance-specific)"
126
+ - "Include appropriate HTTP status codes in problem details"
127
+ - "Extend RFC 7807 with domain-specific fields"
128
+ - "Communicate problem details to generic HTTP clients"
129
+
130
+ rfc7807_fields:
131
+ "type": "URI identifying problem type (required, should dereference to documentation)"
132
+ "title": "Short human-readable summary of problem type (required, same for same type)"
133
+ "status": "HTTP status code (optional, but recommended)"
134
+ "detail": "Human-readable explanation of specific problem instance (optional, instance-specific)"
135
+ "instance": "URI identifying specific problem occurrence (optional, usually request path)"
136
+
137
+ example_error_responses: |
138
+ Example 1: Insufficient Funds
139
+ {
140
+ "type": "https://api.example.com/errors/insufficient-funds",
141
+ "title": "Insufficient Funds",
142
+ "status": 422,
143
+ "detail": "Account acc_002 has balance of 100 but requires 500 for this transfer",
144
+ "instance": "/api/v1/accounts/acc_002/transfer",
145
+ "balance": 100,
146
+ "required_amount": 500
147
+ }
148
+
149
+ Example 2: Validation Error
150
+ {
151
+ "type": "https://api.example.com/errors/validation-error",
152
+ "title": "Validation Error",
153
+ "status": 400,
154
+ "detail": "The request body contains invalid values",
155
+ "instance": "/api/v1/accounts/acc_001/transfer",
156
+ "validation_errors": [
157
+ {
158
+ "field": "amount",
159
+ "message": "Amount must be positive",
160
+ "rejected_value": -50
161
+ }
162
+ ]
163
+ }
164
+
165
+ advantages:
166
+ - "Standard format recognized by HTTP tools and libraries"
167
+ - "Generic clients can handle errors without API-specific code"
168
+ - "Clear semantics: type vs title vs detail"
169
+ - "Extensibility through custom fields"
170
+ - "Easier debugging and error tracking"
171
+ - "Better integration with API gateways and monitoring"
172
+
173
+ content_type:
174
+ "application/problem+json": "Standard MIME type for RFC 7807 responses"
175
+
176
+ references:
177
+ - "https://datatracker.ietf.org/doc/html/rfc7807"
178
+ - "https://datatracker.ietf.org/doc/html/rfc9457 (RFC 9457 - Problem Details for HTTP APIs)"