Nomearod Claude Opus 4.7 (1M context) commited on
Commit
a48afb9
·
1 Parent(s): 8ef480a

feat(goldens): add source_snippets to 8 FastAPI calibration items

Browse files

Hand-snippeted verbatim spans from data/tech_docs/ for the 8
FastAPI items in calibration_v1. OOS items get source_snippets:[]
(no source to ground against). Scope discipline: only the 8
calibration items, not the full 27-item FastAPI golden — the
remaining 19 backfill in v1.1.

Required by GroundednessJudge (reference-based on source_snippets).
K8s items already had this field from the multi-corpus refactor.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

agent_bench/evaluation/datasets/tech_docs_golden.json CHANGED
@@ -2,8 +2,15 @@
2
  {
3
  "id": "q001",
4
  "question": "How do you define a path parameter in FastAPI?",
5
- "expected_answer_keywords": ["curly braces", "path", "function parameter", "URL"],
6
- "expected_sources": ["fastapi_path_params.md"],
 
 
 
 
 
 
 
7
  "category": "retrieval",
8
  "difficulty": "easy",
9
  "requires_calculator": false,
@@ -12,8 +19,15 @@
12
  {
13
  "id": "q002",
14
  "question": "What is the default page size for pagination in FastAPI and what is the maximum allowed?",
15
- "expected_answer_keywords": ["20", "100", "default", "maximum"],
16
- "expected_sources": ["fastapi_pagination.md"],
 
 
 
 
 
 
 
17
  "category": "retrieval",
18
  "difficulty": "easy",
19
  "requires_calculator": false,
@@ -22,8 +36,15 @@
22
  {
23
  "id": "q003",
24
  "question": "How does FastAPI handle CORS and what is the default max_age for preflight caching?",
25
- "expected_answer_keywords": ["CORSMiddleware", "600", "seconds", "preflight"],
26
- "expected_sources": ["fastapi_middleware.md"],
 
 
 
 
 
 
 
27
  "category": "retrieval",
28
  "difficulty": "easy",
29
  "requires_calculator": false,
@@ -32,8 +53,14 @@
32
  {
33
  "id": "q004",
34
  "question": "What algorithm and expiry time does the FastAPI security example use for JWT tokens?",
35
- "expected_answer_keywords": ["HS256", "30", "minutes"],
36
- "expected_sources": ["fastapi_security.md"],
 
 
 
 
 
 
37
  "category": "retrieval",
38
  "difficulty": "medium",
39
  "requires_calculator": false,
@@ -42,8 +69,15 @@
42
  {
43
  "id": "q005",
44
  "question": "What is the recommended formula for calculating the number of Gunicorn workers for a FastAPI deployment?",
45
- "expected_answer_keywords": ["2", "CPU", "cores", "1"],
46
- "expected_sources": ["fastapi_deployment.md"],
 
 
 
 
 
 
 
47
  "category": "retrieval",
48
  "difficulty": "medium",
49
  "requires_calculator": false,
@@ -52,18 +86,35 @@
52
  {
53
  "id": "q006",
54
  "question": "How does dependency caching work in FastAPI, and how can you disable it?",
55
- "expected_answer_keywords": ["cache", "once", "use_cache", "False"],
56
- "expected_sources": ["fastapi_dependencies.md"],
 
 
 
 
 
 
 
57
  "category": "retrieval",
58
  "difficulty": "medium",
59
  "requires_calculator": false,
60
- "reference_answer": "FastAPI caches dependency results so each dependency is called only once per request. Caching can be disabled by setting use_cache=False in the Depends() call."
 
 
 
61
  },
62
  {
63
  "id": "q007",
64
  "question": "If a paginated endpoint returns 20 items per page and there are 10,000 items total, how many total pages are there? And if the page size is changed to 30, how many pages would there be?",
65
- "expected_answer_keywords": ["500", "334", "ceil", "pages"],
66
- "expected_sources": ["fastapi_pagination.md"],
 
 
 
 
 
 
 
67
  "category": "calculation",
68
  "difficulty": "medium",
69
  "requires_calculator": true,
@@ -72,7 +123,11 @@
72
  {
73
  "id": "q008",
74
  "question": "Does FastAPI support automatic Kubernetes deployment?",
75
- "expected_answer_keywords": ["not", "does not contain", "no information"],
 
 
 
 
76
  "expected_sources": [],
77
  "category": "out_of_scope",
78
  "difficulty": "easy",
@@ -82,7 +137,11 @@
82
  {
83
  "id": "q009",
84
  "question": "How does FastAPI integrate with Apache Kafka for event streaming?",
85
- "expected_answer_keywords": ["not", "does not contain", "no information"],
 
 
 
 
86
  "expected_sources": [],
87
  "category": "out_of_scope",
88
  "difficulty": "easy",
@@ -92,38 +151,69 @@
92
  {
93
  "id": "q010",
94
  "question": "Can FastAPI generate GraphQL schemas natively?",
95
- "expected_answer_keywords": ["not", "does not contain", "no information"],
 
 
 
 
96
  "expected_sources": [],
97
  "category": "out_of_scope",
98
  "difficulty": "easy",
99
  "requires_calculator": false,
100
- "reference_answer": ""
 
101
  },
102
  {
103
  "id": "q011",
104
  "question": "What is the default Swagger UI endpoint in FastAPI?",
105
- "expected_answer_keywords": ["/docs", "Swagger", "interactive"],
106
- "expected_sources": ["fastapi_openapi.md"],
 
 
 
 
 
 
107
  "category": "retrieval",
108
  "difficulty": "easy",
109
  "requires_calculator": false,
110
- "reference_answer": "The default Swagger UI endpoint in FastAPI is /docs, which provides an interactive API documentation interface."
 
 
 
 
111
  },
112
  {
113
  "id": "q012",
114
  "question": "How do you raise an HTTP error in a FastAPI route handler?",
115
- "expected_answer_keywords": ["HTTPException", "status_code", "detail"],
116
- "expected_sources": ["fastapi_error_handling.md"],
 
 
 
 
 
 
117
  "category": "retrieval",
118
  "difficulty": "easy",
119
  "requires_calculator": false,
120
- "reference_answer": "You raise an HTTP error in FastAPI by raising an HTTPException with a status_code and a detail message describing the error."
 
 
 
 
121
  },
122
  {
123
  "id": "q013",
124
  "question": "How do you define a request body in FastAPI?",
125
- "expected_answer_keywords": ["Pydantic", "BaseModel", "JSON"],
126
- "expected_sources": ["fastapi_request_body.md"],
 
 
 
 
 
 
127
  "category": "retrieval",
128
  "difficulty": "easy",
129
  "requires_calculator": false,
@@ -132,8 +222,14 @@
132
  {
133
  "id": "q014",
134
  "question": "What testing tools does FastAPI use, and what class provides the test client?",
135
- "expected_answer_keywords": ["TestClient", "pytest", "Starlette"],
136
- "expected_sources": ["fastapi_testing.md"],
 
 
 
 
 
 
137
  "category": "retrieval",
138
  "difficulty": "easy",
139
  "requires_calculator": false,
@@ -142,8 +238,15 @@
142
  {
143
  "id": "q015",
144
  "question": "How does FastAPI manage application configuration and environment variables?",
145
- "expected_answer_keywords": ["BaseSettings", "pydantic", "env", "environment"],
146
- "expected_sources": ["fastapi_configuration.md"],
 
 
 
 
 
 
 
147
  "category": "retrieval",
148
  "difficulty": "medium",
149
  "requires_calculator": false,
@@ -152,8 +255,15 @@
152
  {
153
  "id": "q016",
154
  "question": "What is the minimum response size for GZip compression middleware in FastAPI, and how do you enable it?",
155
- "expected_answer_keywords": ["500", "bytes", "GZipMiddleware", "minimum_size"],
156
- "expected_sources": ["fastapi_middleware.md"],
 
 
 
 
 
 
 
157
  "category": "retrieval",
158
  "difficulty": "medium",
159
  "requires_calculator": false,
@@ -162,8 +272,15 @@
162
  {
163
  "id": "q017",
164
  "question": "How do yield dependencies work in FastAPI and what is the maximum number supported per request?",
165
- "expected_answer_keywords": ["yield", "cleanup", "finally", "32"],
166
- "expected_sources": ["fastapi_dependencies.md"],
 
 
 
 
 
 
 
167
  "category": "retrieval",
168
  "difficulty": "medium",
169
  "requires_calculator": false,
@@ -172,8 +289,15 @@
172
  {
173
  "id": "q018",
174
  "question": "What are the three documentation endpoints FastAPI exposes by default and what OpenAPI version does it use?",
175
- "expected_answer_keywords": ["/docs", "/redoc", "/openapi.json", "3.1"],
176
- "expected_sources": ["fastapi_openapi.md"],
 
 
 
 
 
 
 
177
  "category": "retrieval",
178
  "difficulty": "medium",
179
  "requires_calculator": false,
@@ -182,8 +306,15 @@
182
  {
183
  "id": "q019",
184
  "question": "How does FastAPI handle WebSocket connections, and what must be called before sending data?",
185
- "expected_answer_keywords": ["accept", "WebSocket", "send", "receive"],
186
- "expected_sources": ["fastapi_websockets.md"],
 
 
 
 
 
 
 
187
  "category": "retrieval",
188
  "difficulty": "medium",
189
  "requires_calculator": false,
@@ -192,8 +323,16 @@
192
  {
193
  "id": "q020",
194
  "question": "For a server with 4 CPU cores, how many Gunicorn workers should be configured using the recommended formula?",
195
- "expected_answer_keywords": ["9", "workers", "2", "CPU", "1"],
196
- "expected_sources": ["fastapi_deployment.md"],
 
 
 
 
 
 
 
 
197
  "category": "calculation",
198
  "difficulty": "medium",
199
  "requires_calculator": true,
@@ -202,18 +341,35 @@
202
  {
203
  "id": "q021",
204
  "question": "If the CORS max_age is 600 seconds, how many minutes does the browser cache preflight results?",
205
- "expected_answer_keywords": ["10", "minutes"],
206
- "expected_sources": ["fastapi_middleware.md"],
 
 
 
 
 
207
  "category": "calculation",
208
  "difficulty": "easy",
209
  "requires_calculator": true,
210
- "reference_answer": "With a CORS max_age of 600 seconds, the browser caches preflight results for 10 minutes (600 / 60 = 10)."
 
 
 
211
  },
212
  {
213
  "id": "q022",
214
  "question": "How do route ordering and dependency injection interact when building a secure FastAPI application with scoped endpoints?",
215
- "expected_answer_keywords": ["order", "Depends", "Security", "scopes"],
216
- "expected_sources": ["fastapi_path_params.md", "fastapi_dependencies.md", "fastapi_security.md"],
 
 
 
 
 
 
 
 
 
217
  "category": "retrieval",
218
  "difficulty": "hard",
219
  "requires_calculator": false,
@@ -222,18 +378,40 @@
222
  {
223
  "id": "q023",
224
  "question": "How would you set up a FastAPI application with custom error handling, CORS middleware, and structured testing including dependency overrides?",
225
- "expected_answer_keywords": ["HTTPException", "CORSMiddleware", "TestClient", "override"],
226
- "expected_sources": ["fastapi_error_handling.md", "fastapi_middleware.md", "fastapi_testing.md"],
 
 
 
 
 
 
 
 
 
227
  "category": "retrieval",
228
  "difficulty": "hard",
229
  "requires_calculator": false,
230
- "reference_answer": "Custom error handling is set up by raising HTTPException or registering exception handlers, CORS is configured by adding CORSMiddleware with allowed origins, and testing uses TestClient with app.dependency_overrides to replace dependencies during tests."
 
 
 
 
231
  },
232
  {
233
  "id": "q024",
234
  "question": "Explain how to deploy a FastAPI app with Docker using Gunicorn workers, health checks, and environment-based configuration via Pydantic Settings.",
235
- "expected_answer_keywords": ["Docker", "Gunicorn", "health", "BaseSettings", "env"],
236
- "expected_sources": ["fastapi_deployment.md", "fastapi_configuration.md"],
 
 
 
 
 
 
 
 
 
237
  "category": "retrieval",
238
  "difficulty": "hard",
239
  "requires_calculator": false,
@@ -242,17 +420,32 @@
242
  {
243
  "id": "q025",
244
  "question": "How would you build a paginated API with cursor-based navigation, response model validation, and background task processing for analytics logging?",
245
- "expected_answer_keywords": ["cursor", "response_model", "BackgroundTasks"],
246
- "expected_sources": ["fastapi_pagination.md", "fastapi_response_model.md", "fastapi_background_tasks.md"],
 
 
 
 
 
 
 
 
247
  "category": "retrieval",
248
  "difficulty": "hard",
249
  "requires_calculator": false,
250
- "reference_answer": "Cursor-based pagination uses an opaque cursor token for navigation instead of page numbers. Response models are validated using the response_model parameter on route decorators, and analytics logging is handled asynchronously via FastAPI's BackgroundTasks dependency."
 
 
 
251
  },
252
  {
253
  "id": "q026",
254
  "question": "Does FastAPI have built-in support for database migrations like Alembic?",
255
- "expected_answer_keywords": ["not", "does not contain", "no information"],
 
 
 
 
256
  "expected_sources": [],
257
  "category": "out_of_scope",
258
  "difficulty": "easy",
@@ -262,11 +455,16 @@
262
  {
263
  "id": "q027",
264
  "question": "How does FastAPI handle automatic load balancing across multiple servers?",
265
- "expected_answer_keywords": ["not", "does not contain", "no information"],
 
 
 
 
266
  "expected_sources": [],
267
  "category": "out_of_scope",
268
  "difficulty": "easy",
269
  "requires_calculator": false,
270
- "reference_answer": ""
 
271
  }
272
  ]
 
2
  {
3
  "id": "q001",
4
  "question": "How do you define a path parameter in FastAPI?",
5
+ "expected_answer_keywords": [
6
+ "curly braces",
7
+ "path",
8
+ "function parameter",
9
+ "URL"
10
+ ],
11
+ "expected_sources": [
12
+ "fastapi_path_params.md"
13
+ ],
14
  "category": "retrieval",
15
  "difficulty": "easy",
16
  "requires_calculator": false,
 
19
  {
20
  "id": "q002",
21
  "question": "What is the default page size for pagination in FastAPI and what is the maximum allowed?",
22
+ "expected_answer_keywords": [
23
+ "20",
24
+ "100",
25
+ "default",
26
+ "maximum"
27
+ ],
28
+ "expected_sources": [
29
+ "fastapi_pagination.md"
30
+ ],
31
  "category": "retrieval",
32
  "difficulty": "easy",
33
  "requires_calculator": false,
 
36
  {
37
  "id": "q003",
38
  "question": "How does FastAPI handle CORS and what is the default max_age for preflight caching?",
39
+ "expected_answer_keywords": [
40
+ "CORSMiddleware",
41
+ "600",
42
+ "seconds",
43
+ "preflight"
44
+ ],
45
+ "expected_sources": [
46
+ "fastapi_middleware.md"
47
+ ],
48
  "category": "retrieval",
49
  "difficulty": "easy",
50
  "requires_calculator": false,
 
53
  {
54
  "id": "q004",
55
  "question": "What algorithm and expiry time does the FastAPI security example use for JWT tokens?",
56
+ "expected_answer_keywords": [
57
+ "HS256",
58
+ "30",
59
+ "minutes"
60
+ ],
61
+ "expected_sources": [
62
+ "fastapi_security.md"
63
+ ],
64
  "category": "retrieval",
65
  "difficulty": "medium",
66
  "requires_calculator": false,
 
69
  {
70
  "id": "q005",
71
  "question": "What is the recommended formula for calculating the number of Gunicorn workers for a FastAPI deployment?",
72
+ "expected_answer_keywords": [
73
+ "2",
74
+ "CPU",
75
+ "cores",
76
+ "1"
77
+ ],
78
+ "expected_sources": [
79
+ "fastapi_deployment.md"
80
+ ],
81
  "category": "retrieval",
82
  "difficulty": "medium",
83
  "requires_calculator": false,
 
86
  {
87
  "id": "q006",
88
  "question": "How does dependency caching work in FastAPI, and how can you disable it?",
89
+ "expected_answer_keywords": [
90
+ "cache",
91
+ "once",
92
+ "use_cache",
93
+ "False"
94
+ ],
95
+ "expected_sources": [
96
+ "fastapi_dependencies.md"
97
+ ],
98
  "category": "retrieval",
99
  "difficulty": "medium",
100
  "requires_calculator": false,
101
+ "reference_answer": "FastAPI caches dependency results so each dependency is called only once per request. Caching can be disabled by setting use_cache=False in the Depends() call.",
102
+ "source_snippets": [
103
+ "By default, if the same dependency is used multiple times within a single request (e.g., both a route and a sub-dependency use `Depends(get_db)`), FastAPI caches the result and calls the dependency only once. To disable caching and force a fresh call each time, use `Depends(get_db, use_cache=False)`."
104
+ ]
105
  },
106
  {
107
  "id": "q007",
108
  "question": "If a paginated endpoint returns 20 items per page and there are 10,000 items total, how many total pages are there? And if the page size is changed to 30, how many pages would there be?",
109
+ "expected_answer_keywords": [
110
+ "500",
111
+ "334",
112
+ "ceil",
113
+ "pages"
114
+ ],
115
+ "expected_sources": [
116
+ "fastapi_pagination.md"
117
+ ],
118
  "category": "calculation",
119
  "difficulty": "medium",
120
  "requires_calculator": true,
 
123
  {
124
  "id": "q008",
125
  "question": "Does FastAPI support automatic Kubernetes deployment?",
126
+ "expected_answer_keywords": [
127
+ "not",
128
+ "does not contain",
129
+ "no information"
130
+ ],
131
  "expected_sources": [],
132
  "category": "out_of_scope",
133
  "difficulty": "easy",
 
137
  {
138
  "id": "q009",
139
  "question": "How does FastAPI integrate with Apache Kafka for event streaming?",
140
+ "expected_answer_keywords": [
141
+ "not",
142
+ "does not contain",
143
+ "no information"
144
+ ],
145
  "expected_sources": [],
146
  "category": "out_of_scope",
147
  "difficulty": "easy",
 
151
  {
152
  "id": "q010",
153
  "question": "Can FastAPI generate GraphQL schemas natively?",
154
+ "expected_answer_keywords": [
155
+ "not",
156
+ "does not contain",
157
+ "no information"
158
+ ],
159
  "expected_sources": [],
160
  "category": "out_of_scope",
161
  "difficulty": "easy",
162
  "requires_calculator": false,
163
+ "reference_answer": "",
164
+ "source_snippets": []
165
  },
166
  {
167
  "id": "q011",
168
  "question": "What is the default Swagger UI endpoint in FastAPI?",
169
+ "expected_answer_keywords": [
170
+ "/docs",
171
+ "Swagger",
172
+ "interactive"
173
+ ],
174
+ "expected_sources": [
175
+ "fastapi_openapi.md"
176
+ ],
177
  "category": "retrieval",
178
  "difficulty": "easy",
179
  "requires_calculator": false,
180
+ "reference_answer": "The default Swagger UI endpoint in FastAPI is /docs, which provides an interactive API documentation interface.",
181
+ "source_snippets": [
182
+ "| `/docs` | Swagger UI -- interactive API explorer |",
183
+ "Every FastAPI application exposes three documentation-related endpoints by default:"
184
+ ]
185
  },
186
  {
187
  "id": "q012",
188
  "question": "How do you raise an HTTP error in a FastAPI route handler?",
189
+ "expected_answer_keywords": [
190
+ "HTTPException",
191
+ "status_code",
192
+ "detail"
193
+ ],
194
+ "expected_sources": [
195
+ "fastapi_error_handling.md"
196
+ ],
197
  "category": "retrieval",
198
  "difficulty": "easy",
199
  "requires_calculator": false,
200
+ "reference_answer": "You raise an HTTP error in FastAPI by raising an HTTPException with a status_code and a detail message describing the error.",
201
+ "source_snippets": [
202
+ "The `HTTPException` class is the primary way to return error responses from route handlers:",
203
+ "When raised, `HTTPException` immediately terminates request processing and returns the specified status code and detail message. The `detail` parameter can be a string, list, or dictionary -- FastAPI serializes it to JSON automatically."
204
+ ]
205
  },
206
  {
207
  "id": "q013",
208
  "question": "How do you define a request body in FastAPI?",
209
+ "expected_answer_keywords": [
210
+ "Pydantic",
211
+ "BaseModel",
212
+ "JSON"
213
+ ],
214
+ "expected_sources": [
215
+ "fastapi_request_body.md"
216
+ ],
217
  "category": "retrieval",
218
  "difficulty": "easy",
219
  "requires_calculator": false,
 
222
  {
223
  "id": "q014",
224
  "question": "What testing tools does FastAPI use, and what class provides the test client?",
225
+ "expected_answer_keywords": [
226
+ "TestClient",
227
+ "pytest",
228
+ "Starlette"
229
+ ],
230
+ "expected_sources": [
231
+ "fastapi_testing.md"
232
+ ],
233
  "category": "retrieval",
234
  "difficulty": "easy",
235
  "requires_calculator": false,
 
238
  {
239
  "id": "q015",
240
  "question": "How does FastAPI manage application configuration and environment variables?",
241
+ "expected_answer_keywords": [
242
+ "BaseSettings",
243
+ "pydantic",
244
+ "env",
245
+ "environment"
246
+ ],
247
+ "expected_sources": [
248
+ "fastapi_configuration.md"
249
+ ],
250
  "category": "retrieval",
251
  "difficulty": "medium",
252
  "requires_calculator": false,
 
255
  {
256
  "id": "q016",
257
  "question": "What is the minimum response size for GZip compression middleware in FastAPI, and how do you enable it?",
258
+ "expected_answer_keywords": [
259
+ "500",
260
+ "bytes",
261
+ "GZipMiddleware",
262
+ "minimum_size"
263
+ ],
264
+ "expected_sources": [
265
+ "fastapi_middleware.md"
266
+ ],
267
  "category": "retrieval",
268
  "difficulty": "medium",
269
  "requires_calculator": false,
 
272
  {
273
  "id": "q017",
274
  "question": "How do yield dependencies work in FastAPI and what is the maximum number supported per request?",
275
+ "expected_answer_keywords": [
276
+ "yield",
277
+ "cleanup",
278
+ "finally",
279
+ "32"
280
+ ],
281
+ "expected_sources": [
282
+ "fastapi_dependencies.md"
283
+ ],
284
  "category": "retrieval",
285
  "difficulty": "medium",
286
  "requires_calculator": false,
 
289
  {
290
  "id": "q018",
291
  "question": "What are the three documentation endpoints FastAPI exposes by default and what OpenAPI version does it use?",
292
+ "expected_answer_keywords": [
293
+ "/docs",
294
+ "/redoc",
295
+ "/openapi.json",
296
+ "3.1"
297
+ ],
298
+ "expected_sources": [
299
+ "fastapi_openapi.md"
300
+ ],
301
  "category": "retrieval",
302
  "difficulty": "medium",
303
  "requires_calculator": false,
 
306
  {
307
  "id": "q019",
308
  "question": "How does FastAPI handle WebSocket connections, and what must be called before sending data?",
309
+ "expected_answer_keywords": [
310
+ "accept",
311
+ "WebSocket",
312
+ "send",
313
+ "receive"
314
+ ],
315
+ "expected_sources": [
316
+ "fastapi_websockets.md"
317
+ ],
318
  "category": "retrieval",
319
  "difficulty": "medium",
320
  "requires_calculator": false,
 
323
  {
324
  "id": "q020",
325
  "question": "For a server with 4 CPU cores, how many Gunicorn workers should be configured using the recommended formula?",
326
+ "expected_answer_keywords": [
327
+ "9",
328
+ "workers",
329
+ "2",
330
+ "CPU",
331
+ "1"
332
+ ],
333
+ "expected_sources": [
334
+ "fastapi_deployment.md"
335
+ ],
336
  "category": "calculation",
337
  "difficulty": "medium",
338
  "requires_calculator": true,
 
341
  {
342
  "id": "q021",
343
  "question": "If the CORS max_age is 600 seconds, how many minutes does the browser cache preflight results?",
344
+ "expected_answer_keywords": [
345
+ "10",
346
+ "minutes"
347
+ ],
348
+ "expected_sources": [
349
+ "fastapi_middleware.md"
350
+ ],
351
  "category": "calculation",
352
  "difficulty": "easy",
353
  "requires_calculator": true,
354
+ "reference_answer": "With a CORS max_age of 600 seconds, the browser caches preflight results for 10 minutes (600 / 60 = 10).",
355
+ "source_snippets": [
356
+ "| `max_age` | `600` | Seconds the browser caches preflight results |"
357
+ ]
358
  },
359
  {
360
  "id": "q022",
361
  "question": "How do route ordering and dependency injection interact when building a secure FastAPI application with scoped endpoints?",
362
+ "expected_answer_keywords": [
363
+ "order",
364
+ "Depends",
365
+ "Security",
366
+ "scopes"
367
+ ],
368
+ "expected_sources": [
369
+ "fastapi_path_params.md",
370
+ "fastapi_dependencies.md",
371
+ "fastapi_security.md"
372
+ ],
373
  "category": "retrieval",
374
  "difficulty": "hard",
375
  "requires_calculator": false,
 
378
  {
379
  "id": "q023",
380
  "question": "How would you set up a FastAPI application with custom error handling, CORS middleware, and structured testing including dependency overrides?",
381
+ "expected_answer_keywords": [
382
+ "HTTPException",
383
+ "CORSMiddleware",
384
+ "TestClient",
385
+ "override"
386
+ ],
387
+ "expected_sources": [
388
+ "fastapi_error_handling.md",
389
+ "fastapi_middleware.md",
390
+ "fastapi_testing.md"
391
+ ],
392
  "category": "retrieval",
393
  "difficulty": "hard",
394
  "requires_calculator": false,
395
+ "reference_answer": "Custom error handling is set up by raising HTTPException or registering exception handlers, CORS is configured by adding CORSMiddleware with allowed origins, and testing uses TestClient with app.dependency_overrides to replace dependencies during tests.",
396
+ "source_snippets": [
397
+ "The `HTTPException` class is the primary way to return error responses from route handlers:",
398
+ "Cross-Origin Resource Sharing (CORS) is configured using `CORSMiddleware` from Starlette:"
399
+ ]
400
  },
401
  {
402
  "id": "q024",
403
  "question": "Explain how to deploy a FastAPI app with Docker using Gunicorn workers, health checks, and environment-based configuration via Pydantic Settings.",
404
+ "expected_answer_keywords": [
405
+ "Docker",
406
+ "Gunicorn",
407
+ "health",
408
+ "BaseSettings",
409
+ "env"
410
+ ],
411
+ "expected_sources": [
412
+ "fastapi_deployment.md",
413
+ "fastapi_configuration.md"
414
+ ],
415
  "category": "retrieval",
416
  "difficulty": "hard",
417
  "requires_calculator": false,
 
420
  {
421
  "id": "q025",
422
  "question": "How would you build a paginated API with cursor-based navigation, response model validation, and background task processing for analytics logging?",
423
+ "expected_answer_keywords": [
424
+ "cursor",
425
+ "response_model",
426
+ "BackgroundTasks"
427
+ ],
428
+ "expected_sources": [
429
+ "fastapi_pagination.md",
430
+ "fastapi_response_model.md",
431
+ "fastapi_background_tasks.md"
432
+ ],
433
  "category": "retrieval",
434
  "difficulty": "hard",
435
  "requires_calculator": false,
436
+ "reference_answer": "Cursor-based pagination uses an opaque cursor token for navigation instead of page numbers. Response models are validated using the response_model parameter on route decorators, and analytics logging is handled asynchronously via FastAPI's BackgroundTasks dependency.",
437
+ "source_snippets": [
438
+ "Cursor-based pagination uses an opaque token (cursor) pointing to the last item in the previous page. This avoids the performance degradation of large offsets:"
439
+ ]
440
  },
441
  {
442
  "id": "q026",
443
  "question": "Does FastAPI have built-in support for database migrations like Alembic?",
444
+ "expected_answer_keywords": [
445
+ "not",
446
+ "does not contain",
447
+ "no information"
448
+ ],
449
  "expected_sources": [],
450
  "category": "out_of_scope",
451
  "difficulty": "easy",
 
455
  {
456
  "id": "q027",
457
  "question": "How does FastAPI handle automatic load balancing across multiple servers?",
458
+ "expected_answer_keywords": [
459
+ "not",
460
+ "does not contain",
461
+ "no information"
462
+ ],
463
  "expected_sources": [],
464
  "category": "out_of_scope",
465
  "difficulty": "easy",
466
  "requires_calculator": false,
467
+ "reference_answer": "",
468
+ "source_snippets": []
469
  }
470
  ]