SamuelChien821 commited on
Commit
db04965
·
verified ·
1 Parent(s): 37690b6

Publish devopsbench-100 v2 realism release

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. README.md +12 -1
  2. data/tasks.jsonl +0 -0
  3. reports/build.json +30 -3
  4. reports/qualification.json +243 -174
  5. task_files/dob100-001-rca-analytics-egress-blocked/01-work-ticket.md +151 -0
  6. task_files/dob100-001-rca-analytics-egress-blocked/02-service-catalog.csv +14 -0
  7. task_files/dob100-001-rca-analytics-egress-blocked/03-observability.log +12 -0
  8. task_files/dob100-001-rca-analytics-egress-blocked/04-incident-room.json +202 -0
  9. task_files/dob100-001-rca-analytics-egress-blocked/05-deployment-state.json +175 -0
  10. task_files/dob100-001-rca-analytics-egress-blocked/06-repository-context.txt +39 -0
  11. task_files/dob100-001-rca-analytics-egress-blocked/07-ci-and-tests.csv +33 -0
  12. task_files/dob100-001-rca-analytics-egress-blocked/08-data-change-controls.sql +13 -0
  13. task_files/dob100-001-rca-analytics-egress-blocked/09-feature-and-security.yaml +181 -0
  14. task_files/dob100-001-rca-analytics-egress-blocked/10-vendor-trackers.json +194 -0
  15. task_files/dob100-001-rca-analytics-egress-blocked/11-knowledge-base.md +164 -0
  16. task_files/dob100-001-rca-analytics-egress-blocked/12-chat-and-status.json +126 -0
  17. task_files/dob100-001-rca-analytics-egress-blocked/13-approval-and-ownership.md +76 -0
  18. task_files/dob100-001-rca-analytics-egress-blocked/14-tool-contracts.json +460 -0
  19. task_files/dob100-002-rca-analytics-revoked-grant/01-work-ticket.md +151 -0
  20. task_files/dob100-002-rca-analytics-revoked-grant/02-service-catalog.csv +13 -0
  21. task_files/dob100-002-rca-analytics-revoked-grant/03-observability.log +12 -0
  22. task_files/dob100-002-rca-analytics-revoked-grant/04-incident-room.json +202 -0
  23. task_files/dob100-002-rca-analytics-revoked-grant/05-deployment-state.json +175 -0
  24. task_files/dob100-002-rca-analytics-revoked-grant/06-repository-context.txt +39 -0
  25. task_files/dob100-002-rca-analytics-revoked-grant/07-ci-and-tests.csv +33 -0
  26. task_files/dob100-002-rca-analytics-revoked-grant/08-data-change-controls.sql +10 -0
  27. task_files/dob100-002-rca-analytics-revoked-grant/09-feature-and-security.yaml +181 -0
  28. task_files/dob100-002-rca-analytics-revoked-grant/10-vendor-trackers.json +194 -0
  29. task_files/dob100-002-rca-analytics-revoked-grant/11-knowledge-base.md +164 -0
  30. task_files/dob100-002-rca-analytics-revoked-grant/12-chat-and-status.json +126 -0
  31. task_files/dob100-002-rca-analytics-revoked-grant/13-approval-and-ownership.md +76 -0
  32. task_files/dob100-002-rca-analytics-revoked-grant/14-tool-contracts.json +492 -0
  33. task_files/dob100-003-rca-checkout-unschedulable-replicas/01-work-ticket.md +228 -0
  34. task_files/dob100-003-rca-checkout-unschedulable-replicas/02-service-catalog.csv +27 -0
  35. task_files/dob100-003-rca-checkout-unschedulable-replicas/03-observability.log +16 -0
  36. task_files/dob100-003-rca-checkout-unschedulable-replicas/04-incident-room.json +156 -0
  37. task_files/dob100-003-rca-checkout-unschedulable-replicas/05-deployment-state.json +235 -0
  38. task_files/dob100-003-rca-checkout-unschedulable-replicas/06-repository-context.txt +42 -0
  39. task_files/dob100-003-rca-checkout-unschedulable-replicas/07-ci-and-tests.csv +31 -0
  40. task_files/dob100-003-rca-checkout-unschedulable-replicas/08-data-change-controls.sql +5 -0
  41. task_files/dob100-003-rca-checkout-unschedulable-replicas/09-feature-and-security.yaml +127 -0
  42. task_files/dob100-003-rca-checkout-unschedulable-replicas/10-vendor-trackers.json +143 -0
  43. task_files/dob100-003-rca-checkout-unschedulable-replicas/11-knowledge-base.md +203 -0
  44. task_files/dob100-003-rca-checkout-unschedulable-replicas/12-chat-and-status.json +98 -0
  45. task_files/dob100-003-rca-checkout-unschedulable-replicas/13-approval-and-ownership.md +52 -0
  46. task_files/dob100-003-rca-checkout-unschedulable-replicas/14-tool-contracts.json +550 -0
  47. task_files/dob100-004-rca-media-disk-pressure/01-work-ticket.md +129 -0
  48. task_files/dob100-004-rca-media-disk-pressure/02-service-catalog.csv +15 -0
  49. task_files/dob100-004-rca-media-disk-pressure/03-observability.log +15 -0
  50. task_files/dob100-004-rca-media-disk-pressure/04-incident-room.json +202 -0
README.md CHANGED
@@ -31,7 +31,11 @@ PagerDuty, Confluence, spreadsheets) and Kubernetes.
31
 
32
  Tasks are outcome-only tickets (symptom + definition of done; company policy
33
  lives in the world's knowledge base, not the prompt). Reference trajectories
34
- run 4-34 tool calls (median 13).
 
 
 
 
35
  Acceptance is fully deterministic: each task ships an executable vcode
36
  verifier that checks the final world state and the append-only audit log,
37
  with anti-forgery table pins - no LLM judge, no network, no clock in the
@@ -43,6 +47,9 @@ reward path.
43
  `prompt`, `context_files`, `rubric`, `gold_output`, `metadata`).
44
  - `tasks/`: one readable JSON record per task (includes the guided
45
  instruction variant).
 
 
 
46
  - `world/`: the offline world source - stdlib MCP server, tool implementations,
47
  seeded SQLite database, schema and seed SQL.
48
  - `verifiers/`: 100 standalone verifier scripts
@@ -79,6 +86,10 @@ reward path.
79
  | Gate | Required | Measured |
80
  |---|---:|---:|
81
  | Tasks | 100 | 100 |
 
 
 
 
82
  | Oracle replays at reward 1.0 | 100/100 | see `reports/qualification.json` |
83
  | Deterministic verifier replays | 100/100 | see `reports/qualification.json` |
84
  | Negative-control false accepts | 0 | see `reports/qualification.json` |
 
31
 
32
  Tasks are outcome-only tickets (symptom + definition of done; company policy
33
  lives in the world's knowledge base, not the prompt). Reference trajectories
34
+ run 4-35 tool calls (median 13), with
35
+ 100/100 distinct tool-name sequences. Every task publishes 14 task-scoped
36
+ initial-state views, three operational alternatives, and
37
+ 59-86 explicit
38
+ vcode/evidence/containment criteria.
39
  Acceptance is fully deterministic: each task ships an executable vcode
40
  verifier that checks the final world state and the append-only audit log,
41
  with anti-forgery table pins - no LLM judge, no network, no clock in the
 
47
  `prompt`, `context_files`, `rubric`, `gold_output`, `metadata`).
48
  - `tasks/`: one readable JSON record per task (includes the guided
49
  instruction variant).
50
+ - `task_files/`: 14 inspectable views per task spanning tickets, services,
51
+ observability, incidents, deployments, code, CI, migrations, vendor trackers,
52
+ knowledge, chat, approvals, and exact tool contracts.
53
  - `world/`: the offline world source - stdlib MCP server, tool implementations,
54
  seeded SQLite database, schema and seed SQL.
55
  - `verifiers/`: 100 standalone verifier scripts
 
86
  | Gate | Required | Measured |
87
  |---|---:|---:|
88
  | Tasks | 100 | 100 |
89
+ | High-level unique employee requests | 100 | 100 |
90
+ | Unique reference tool sequences | 100 | 100 |
91
+ | Inspectable assets per task | >=12 | 14 |
92
+ | Public criteria per task | >=40 | 59-86 |
93
  | Oracle replays at reward 1.0 | 100/100 | see `reports/qualification.json` |
94
  | Deterministic verifier replays | 100/100 | see `reports/qualification.json` |
95
  | Negative-control false accepts | 0 | see `reports/qualification.json` |
data/tasks.jsonl CHANGED
The diff for this file is too large to render. See raw diff
 
reports/build.json CHANGED
@@ -1,4 +1,9 @@
1
  {
 
 
 
 
 
2
  "benchmark": "DevOpsBench-100",
3
  "categories": {
4
  "aiops_analysis": 6,
@@ -22,6 +27,12 @@
22
  "workspace": 1
23
  },
24
  "category_count": 19,
 
 
 
 
 
 
25
  "difficulties": {
26
  "easy": 2,
27
  "expert": 38,
@@ -29,14 +40,30 @@
29
  "medium": 29
30
  },
31
  "exact_duplicate_prompts": 0,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  "reference_tool_calls": {
33
- "max": 34,
34
  "median": 13,
35
  "min": 4,
36
- "total": 1318
37
  },
 
38
  "schema_version": "1.0",
39
  "task_count": 100,
 
40
  "verifier": {
41
  "deterministic": true,
42
  "model_calls": 0,
@@ -44,7 +71,7 @@
44
  "random_calls": 0,
45
  "wall_clock_reads": 0
46
  },
47
- "version": "1.0.0",
48
  "world_commits": 417,
49
  "world_documents": 30,
50
  "world_seeded_rows": 1451,
 
1
  {
2
+ "assets_per_task": {
3
+ "max": 14,
4
+ "median": 14,
5
+ "min": 14
6
+ },
7
  "benchmark": "DevOpsBench-100",
8
  "categories": {
9
  "aiops_analysis": 6,
 
27
  "workspace": 1
28
  },
29
  "category_count": 19,
30
+ "criteria_per_task": {
31
+ "max": 86,
32
+ "median": 72,
33
+ "min": 59
34
+ },
35
+ "decision_options_per_task": 3,
36
  "difficulties": {
37
  "easy": 2,
38
  "expert": 38,
 
40
  "medium": 29
41
  },
42
  "exact_duplicate_prompts": 0,
43
+ "prompt_words": {
44
+ "max": 180,
45
+ "median": 76,
46
+ "min": 45
47
+ },
48
+ "quality_gates": {
49
+ "deep_task_assets": true,
50
+ "high_level_prompt_length": true,
51
+ "high_level_prompts_unique": true,
52
+ "one_hundred_tasks": true,
53
+ "specific_public_criteria": true,
54
+ "three_options_one_selected": true,
55
+ "unique_reference_tool_sequences": true
56
+ },
57
  "reference_tool_calls": {
58
+ "max": 35,
59
  "median": 13,
60
  "min": 4,
61
+ "total": 1346
62
  },
63
+ "release_passed": true,
64
  "schema_version": "1.0",
65
  "task_count": 100,
66
+ "unique_reference_tool_name_sequences": 100,
67
  "verifier": {
68
  "deterministic": true,
69
  "model_calls": 0,
 
71
  "random_calls": 0,
72
  "wall_clock_reads": 0
73
  },
74
+ "version": "2.0.0",
75
  "world_commits": 417,
76
  "world_documents": 30,
77
  "world_seeded_rows": 1451,
reports/qualification.json CHANGED
@@ -5,11 +5,11 @@
5
  "mismatches": 0,
6
  "replays": 100
7
  },
8
- "executions": 371,
9
  "negative_controls": {
10
  "naive": {
11
- "applicable_executions": 53,
12
- "correct_rejections": 53,
13
  "false_accepts": 0
14
  },
15
  "pristine": {
@@ -164,11 +164,11 @@
164
  }
165
  },
166
  "oracle_passed": true,
167
- "oracle_report_sha256": "12886c588d86cd644e08f207f7137fb94b4bcd4b953fb965cb82a6e4b2688d2d",
168
  "oracle_reward": 1.0,
169
  "oracle_score": 1.0,
170
- "oracle_successful_tool_calls": 10,
171
- "second_oracle_report_sha256": "12886c588d86cd644e08f207f7137fb94b4bcd4b953fb965cb82a6e4b2688d2d",
172
  "source_task_id": "tsk_rca_notifications_node_deadlock",
173
  "wrong_token_rejected": true
174
  },
@@ -241,11 +241,11 @@
241
  }
242
  },
243
  "oracle_passed": true,
244
- "oracle_report_sha256": "67a5340a6981980ffe239d31b426e42824c1746deb8b434fd980071a19fbbe4e",
245
  "oracle_reward": 1.0,
246
  "oracle_score": 1.0,
247
- "oracle_successful_tool_calls": 6,
248
- "second_oracle_report_sha256": "67a5340a6981980ffe239d31b426e42824c1746deb8b434fd980071a19fbbe4e",
249
  "source_task_id": "tsk_detect_inventory",
250
  "wrong_token_rejected": true
251
  },
@@ -266,11 +266,11 @@
266
  }
267
  },
268
  "oracle_passed": true,
269
- "oracle_report_sha256": "11c04b295d9f2407457dcbc7e9923f71539278d260d472f045569e63bbbbce83",
270
  "oracle_reward": 1.0,
271
  "oracle_score": 1.0,
272
- "oracle_successful_tool_calls": 6,
273
- "second_oracle_report_sha256": "11c04b295d9f2407457dcbc7e9923f71539278d260d472f045569e63bbbbce83",
274
  "source_task_id": "tsk_detect_payments",
275
  "wrong_token_rejected": true
276
  },
@@ -317,11 +317,11 @@
317
  }
318
  },
319
  "oracle_passed": true,
320
- "oracle_report_sha256": "bfb3c55833a77055243605f38bb0855a2f5eb3b55be2295a8b98170046cdea65",
321
  "oracle_reward": 1.0,
322
  "oracle_score": 1.0,
323
- "oracle_successful_tool_calls": 6,
324
- "second_oracle_report_sha256": "bfb3c55833a77055243605f38bb0855a2f5eb3b55be2295a8b98170046cdea65",
325
  "source_task_id": "tsk_detect_storefront_healthy",
326
  "wrong_token_rejected": true
327
  },
@@ -369,11 +369,11 @@
369
  }
370
  },
371
  "oracle_passed": true,
372
- "oracle_report_sha256": "06d2dee8a73f5a037a57d0447b89a2a46d679b686c10a58acc35a45264a91f58",
373
  "oracle_reward": 1.0,
374
  "oracle_score": 1.0,
375
- "oracle_successful_tool_calls": 7,
376
- "second_oracle_report_sha256": "06d2dee8a73f5a037a57d0447b89a2a46d679b686c10a58acc35a45264a91f58",
377
  "source_task_id": "tsk_localize_analytics_errors",
378
  "wrong_token_rejected": true
379
  },
@@ -401,11 +401,11 @@
401
  }
402
  },
403
  "oracle_passed": true,
404
- "oracle_report_sha256": "503f9bfdfe1034d74502307d0a4305e3724a5464f974436a7191d94eb3a88eb9",
405
  "oracle_reward": 1.0,
406
  "oracle_score": 1.0,
407
- "oracle_successful_tool_calls": 7,
408
- "second_oracle_report_sha256": "503f9bfdfe1034d74502307d0a4305e3724a5464f974436a7191d94eb3a88eb9",
409
  "source_task_id": "tsk_localize_checkout_latency",
410
  "wrong_token_rejected": true
411
  },
@@ -427,11 +427,11 @@
427
  }
428
  },
429
  "oracle_passed": true,
430
- "oracle_report_sha256": "d7f440fd47b0ff2afabe9ebb84f6983e0fefe70558bb70e7ed793ec543f33be6",
431
  "oracle_reward": 1.0,
432
  "oracle_score": 1.0,
433
- "oracle_successful_tool_calls": 7,
434
- "second_oracle_report_sha256": "d7f440fd47b0ff2afabe9ebb84f6983e0fefe70558bb70e7ed793ec543f33be6",
435
  "source_task_id": "tsk_localize_gateway_latency",
436
  "wrong_token_rejected": true
437
  },
@@ -453,11 +453,11 @@
453
  }
454
  },
455
  "oracle_passed": true,
456
- "oracle_report_sha256": "49e74d7c502cd08095dc9f2634894e131bd9a36b9de4c7d76269af8187ca968b",
457
  "oracle_reward": 1.0,
458
  "oracle_score": 1.0,
459
- "oracle_successful_tool_calls": 7,
460
- "second_oracle_report_sha256": "49e74d7c502cd08095dc9f2634894e131bd9a36b9de4c7d76269af8187ca968b",
461
  "source_task_id": "tsk_localize_media_latency",
462
  "wrong_token_rejected": true
463
  },
@@ -496,11 +496,11 @@
496
  }
497
  },
498
  "oracle_passed": true,
499
- "oracle_report_sha256": "2ba99258d5843ca3dded22e5f4895f4fdf4eabd4bd0ddd248a33a1d6c69a8ce5",
500
  "oracle_reward": 1.0,
501
  "oracle_score": 1.0,
502
  "oracle_successful_tool_calls": 34,
503
- "second_oracle_report_sha256": "2ba99258d5843ca3dded22e5f4895f4fdf4eabd4bd0ddd248a33a1d6c69a8ce5",
504
  "source_task_id": "tsk_auth_v1_to_v2",
505
  "wrong_token_rejected": true
506
  },
@@ -539,11 +539,11 @@
539
  }
540
  },
541
  "oracle_passed": true,
542
- "oracle_report_sha256": "8096fa1a8e21d07f5c26bc4f73e36390de657eac7a46633c6f72f2f7fc883622",
543
  "oracle_reward": 1.0,
544
  "oracle_score": 1.0,
545
- "oracle_successful_tool_calls": 34,
546
- "second_oracle_report_sha256": "8096fa1a8e21d07f5c26bc4f73e36390de657eac7a46633c6f72f2f7fc883622",
547
  "source_task_id": "tsk_checkout_v1_to_v2",
548
  "wrong_token_rejected": true
549
  },
@@ -577,11 +577,11 @@
577
  }
578
  },
579
  "oracle_passed": true,
580
- "oracle_report_sha256": "c0a99abf3f2cc5f2172b653b91f41fa6da5dfcc23e4cc2f646d08fe8fe503bf0",
581
  "oracle_reward": 1.0,
582
  "oracle_score": 1.0,
583
  "oracle_successful_tool_calls": 27,
584
- "second_oracle_report_sha256": "c0a99abf3f2cc5f2172b653b91f41fa6da5dfcc23e4cc2f646d08fe8fe503bf0",
585
  "source_task_id": "tsk_inventory_v1_to_v2",
586
  "wrong_token_rejected": true
587
  },
@@ -615,11 +615,11 @@
615
  }
616
  },
617
  "oracle_passed": true,
618
- "oracle_report_sha256": "dbfb11a661bab236ec8374427256aaee09247e39fdd33774228d64d570eb2d72",
619
  "oracle_reward": 1.0,
620
  "oracle_score": 1.0,
621
- "oracle_successful_tool_calls": 27,
622
- "second_oracle_report_sha256": "dbfb11a661bab236ec8374427256aaee09247e39fdd33774228d64d570eb2d72",
623
  "source_task_id": "tsk_media_v1_to_v2",
624
  "wrong_token_rejected": true
625
  },
@@ -653,11 +653,11 @@
653
  }
654
  },
655
  "oracle_passed": true,
656
- "oracle_report_sha256": "753aff0992b48a9fca99912040f6f8fc4144892474d9e44578de0b9a3785b5e2",
657
  "oracle_reward": 1.0,
658
  "oracle_score": 1.0,
659
- "oracle_successful_tool_calls": 27,
660
- "second_oracle_report_sha256": "753aff0992b48a9fca99912040f6f8fc4144892474d9e44578de0b9a3785b5e2",
661
  "source_task_id": "tsk_notify_v1_to_v2",
662
  "wrong_token_rejected": true
663
  },
@@ -696,11 +696,11 @@
696
  }
697
  },
698
  "oracle_passed": true,
699
- "oracle_report_sha256": "9adab49ecdd13ac75cedf82b87f9b36871360d1cb39cd6a2f7aae00dc767a75f",
700
  "oracle_reward": 1.0,
701
  "oracle_score": 1.0,
702
- "oracle_successful_tool_calls": 34,
703
- "second_oracle_report_sha256": "9adab49ecdd13ac75cedf82b87f9b36871360d1cb39cd6a2f7aae00dc767a75f",
704
  "source_task_id": "tsk_orders_v1_to_v2",
705
  "wrong_token_rejected": true
706
  },
@@ -734,11 +734,11 @@
734
  }
735
  },
736
  "oracle_passed": true,
737
- "oracle_report_sha256": "fb7b091f555ff02bdfe1cb0b52995c8a27e5810fc441e6309d11b4653ee526c8",
738
  "oracle_reward": 1.0,
739
  "oracle_score": 1.0,
740
- "oracle_successful_tool_calls": 27,
741
- "second_oracle_report_sha256": "fb7b091f555ff02bdfe1cb0b52995c8a27e5810fc441e6309d11b4653ee526c8",
742
  "source_task_id": "tsk_search_v1_to_v2",
743
  "wrong_token_rejected": true
744
  },
@@ -970,11 +970,11 @@
970
  }
971
  },
972
  "oracle_passed": true,
973
- "oracle_report_sha256": "ff6503ea46ee1dbc76b1ff7614fb62e27fce7067ddaa97c262547eb3d17514a8",
974
  "oracle_reward": 1.0,
975
  "oracle_score": 1.0,
976
  "oracle_successful_tool_calls": 5,
977
- "second_oracle_report_sha256": "ff6503ea46ee1dbc76b1ff7614fb62e27fce7067ddaa97c262547eb3d17514a8",
978
  "source_task_id": "tsk_impl_backoff",
979
  "wrong_token_rejected": true
980
  },
@@ -1003,11 +1003,11 @@
1003
  }
1004
  },
1005
  "oracle_passed": true,
1006
- "oracle_report_sha256": "ad8d88d4b75e254811f4947e2e0138c7cbdbff5ad55a7fd51e6ee63811195f71",
1007
  "oracle_reward": 1.0,
1008
  "oracle_score": 1.0,
1009
- "oracle_successful_tool_calls": 5,
1010
- "second_oracle_report_sha256": "ad8d88d4b75e254811f4947e2e0138c7cbdbff5ad55a7fd51e6ee63811195f71",
1011
  "source_task_id": "tsk_impl_cachekey",
1012
  "wrong_token_rejected": true
1013
  },
@@ -1036,11 +1036,11 @@
1036
  }
1037
  },
1038
  "oracle_passed": true,
1039
- "oracle_report_sha256": "b0ceb2209196df9afd9bc3a25a0d1fde21e92732d1e3323e64918592e94a6229",
1040
  "oracle_reward": 1.0,
1041
  "oracle_score": 1.0,
1042
- "oracle_successful_tool_calls": 5,
1043
- "second_oracle_report_sha256": "b0ceb2209196df9afd9bc3a25a0d1fde21e92732d1e3323e64918592e94a6229",
1044
  "source_task_id": "tsk_impl_chunk",
1045
  "wrong_token_rejected": true
1046
  },
@@ -1069,11 +1069,11 @@
1069
  }
1070
  },
1071
  "oracle_passed": true,
1072
- "oracle_report_sha256": "d8cb816ae8bbbb3f36601aa2394d8dd342044c3fd6df551d3d4531300929ae4d",
1073
  "oracle_reward": 1.0,
1074
  "oracle_score": 1.0,
1075
- "oracle_successful_tool_calls": 5,
1076
- "second_oracle_report_sha256": "d8cb816ae8bbbb3f36601aa2394d8dd342044c3fd6df551d3d4531300929ae4d",
1077
  "source_task_id": "tsk_impl_ratelimit",
1078
  "wrong_token_rejected": true
1079
  },
@@ -1165,11 +1165,11 @@
1165
  }
1166
  },
1167
  "oracle_passed": true,
1168
- "oracle_report_sha256": "ea56009f4a4d06f7d4e750f7ef59313986cee00d95cdeeb190ebdaf47b1af2ad",
1169
  "oracle_reward": 1.0,
1170
  "oracle_score": 1.0,
1171
  "oracle_successful_tool_calls": 10,
1172
- "second_oracle_report_sha256": "ea56009f4a4d06f7d4e750f7ef59313986cee00d95cdeeb190ebdaf47b1af2ad",
1173
  "source_task_id": "tsk_port_copy_priority_issues",
1174
  "wrong_token_rejected": true
1175
  },
@@ -1223,11 +1223,11 @@
1223
  }
1224
  },
1225
  "oracle_passed": true,
1226
- "oracle_report_sha256": "2232e59132094e3af61408d2dfe9391eba23a04495521f6da6e63788e912ff87",
1227
  "oracle_reward": 1.0,
1228
  "oracle_score": 1.0,
1229
- "oracle_successful_tool_calls": 4,
1230
- "second_oracle_report_sha256": "2232e59132094e3af61408d2dfe9391eba23a04495521f6da6e63788e912ff87",
1231
  "source_task_id": "tsk_port_count_unowned_work",
1232
  "wrong_token_rejected": true
1233
  },
@@ -1317,11 +1317,11 @@
1317
  }
1318
  },
1319
  "oracle_passed": true,
1320
- "oracle_report_sha256": "74446a3797c60ab2b79c29c206d9609122f5e0bc6adf2d2a3994e3c39b11d6eb",
1321
  "oracle_reward": 1.0,
1322
  "oracle_score": 1.0,
1323
  "oracle_successful_tool_calls": 4,
1324
- "second_oracle_report_sha256": "74446a3797c60ab2b79c29c206d9609122f5e0bc6adf2d2a3994e3c39b11d6eb",
1325
  "source_task_id": "tsk_port_high_priority_since",
1326
  "wrong_token_rejected": true
1327
  },
@@ -1348,11 +1348,11 @@
1348
  }
1349
  },
1350
  "oracle_passed": true,
1351
- "oracle_report_sha256": "31eb47e8c6107884d91f75b8fab5c472be690e2db1c88a4b1ea7c1423d7913ef",
1352
  "oracle_reward": 1.0,
1353
  "oracle_score": 1.0,
1354
  "oracle_successful_tool_calls": 14,
1355
- "second_oracle_report_sha256": "31eb47e8c6107884d91f75b8fab5c472be690e2db1c88a4b1ea7c1423d7913ef",
1356
  "source_task_id": "tsk_analytics_batch_size",
1357
  "wrong_token_rejected": true
1358
  },
@@ -1384,11 +1384,11 @@
1384
  }
1385
  },
1386
  "oracle_passed": true,
1387
- "oracle_report_sha256": "9bf909e7264bf62a94db1d8c7cc91e2cef0b38741ffd5f51289a51600222babf",
1388
  "oracle_reward": 1.0,
1389
  "oracle_score": 1.0,
1390
  "oracle_successful_tool_calls": 18,
1391
- "second_oracle_report_sha256": "9bf909e7264bf62a94db1d8c7cc91e2cef0b38741ffd5f51289a51600222babf",
1392
  "source_task_id": "tsk_analytics_prefetch",
1393
  "wrong_token_rejected": true
1394
  },
@@ -1417,11 +1417,11 @@
1417
  }
1418
  },
1419
  "oracle_passed": true,
1420
- "oracle_report_sha256": "5697f8cd79ad4f5bf0cda72e6168762383cae5378c957f727e61cc2cce90c2ea",
1421
  "oracle_reward": 1.0,
1422
  "oracle_score": 1.0,
1423
  "oracle_successful_tool_calls": 16,
1424
- "second_oracle_report_sha256": "5697f8cd79ad4f5bf0cda72e6168762383cae5378c957f727e61cc2cce90c2ea",
1425
  "source_task_id": "tsk_checkout_payments_timeout",
1426
  "wrong_token_rejected": true
1427
  },
@@ -1454,11 +1454,11 @@
1454
  }
1455
  },
1456
  "oracle_passed": true,
1457
- "oracle_report_sha256": "8f9ccb3a37d60dd0318d64f602b230f19a9c5ce0b49622f35de5d8eba25e3d51",
1458
  "oracle_reward": 1.0,
1459
  "oracle_score": 1.0,
1460
  "oracle_successful_tool_calls": 19,
1461
- "second_oracle_report_sha256": "8f9ccb3a37d60dd0318d64f602b230f19a9c5ce0b49622f35de5d8eba25e3d51",
1462
  "source_task_id": "tsk_inventory_pool",
1463
  "wrong_token_rejected": true
1464
  },
@@ -1490,11 +1490,11 @@
1490
  }
1491
  },
1492
  "oracle_passed": true,
1493
- "oracle_report_sha256": "7791aefd2ef3b385e6e0898e76fbbd53bfc03a137e2bf63a2633e3dce8833b3c",
1494
  "oracle_reward": 1.0,
1495
  "oracle_score": 1.0,
1496
  "oracle_successful_tool_calls": 17,
1497
- "second_oracle_report_sha256": "7791aefd2ef3b385e6e0898e76fbbd53bfc03a137e2bf63a2633e3dce8833b3c",
1498
  "source_task_id": "tsk_notifications_timeout",
1499
  "wrong_token_rejected": true
1500
  },
@@ -1523,11 +1523,11 @@
1523
  }
1524
  },
1525
  "oracle_passed": true,
1526
- "oracle_report_sha256": "bf338ed8f7409f7e9db9d7ec9d435c5c7b06ef4b59386a79a30c8e5272e7353f",
1527
  "oracle_reward": 1.0,
1528
  "oracle_score": 1.0,
1529
  "oracle_successful_tool_calls": 15,
1530
- "second_oracle_report_sha256": "bf338ed8f7409f7e9db9d7ec9d435c5c7b06ef4b59386a79a30c8e5272e7353f",
1531
  "source_task_id": "tsk_payments_notify_timeout",
1532
  "wrong_token_rejected": true
1533
  },
@@ -1561,11 +1561,11 @@
1561
  }
1562
  },
1563
  "oracle_passed": true,
1564
- "oracle_report_sha256": "965dc21de873f908dabd6b9d00147d41b0e845b64e6c363369409cf1cd15098d",
1565
  "oracle_reward": 1.0,
1566
  "oracle_score": 1.0,
1567
  "oracle_successful_tool_calls": 19,
1568
- "second_oracle_report_sha256": "965dc21de873f908dabd6b9d00147d41b0e845b64e6c363369409cf1cd15098d",
1569
  "source_task_id": "tsk_payments_retry",
1570
  "wrong_token_rejected": true
1571
  },
@@ -1599,11 +1599,11 @@
1599
  }
1600
  },
1601
  "oracle_passed": true,
1602
- "oracle_report_sha256": "11525100e6fe0dde4f8a09c834865ef375477160b46256a542a45c0d143911be",
1603
  "oracle_reward": 1.0,
1604
  "oracle_score": 1.0,
1605
  "oracle_successful_tool_calls": 19,
1606
- "second_oracle_report_sha256": "11525100e6fe0dde4f8a09c834865ef375477160b46256a542a45c0d143911be",
1607
  "source_task_id": "tsk_payments_retry_from_code",
1608
  "wrong_token_rejected": true
1609
  },
@@ -1633,11 +1633,11 @@
1633
  }
1634
  },
1635
  "oracle_passed": true,
1636
- "oracle_report_sha256": "e521b3d1836381803dfda3b3dabde5e258a118b81ba42fb7f873947577746742",
1637
  "oracle_reward": 1.0,
1638
  "oracle_score": 1.0,
1639
  "oracle_successful_tool_calls": 15,
1640
- "second_oracle_report_sha256": "e521b3d1836381803dfda3b3dabde5e258a118b81ba42fb7f873947577746742",
1641
  "source_task_id": "tsk_checkout_v2_layout_cleanup",
1642
  "wrong_token_rejected": true
1643
  },
@@ -1669,11 +1669,11 @@
1669
  }
1670
  },
1671
  "oracle_passed": true,
1672
- "oracle_report_sha256": "e5539105fd21888474745ce599ac5f21b79c71e648bf38dd87b4dd139c75e679",
1673
  "oracle_reward": 1.0,
1674
  "oracle_score": 1.0,
1675
  "oracle_successful_tool_calls": 15,
1676
- "second_oracle_report_sha256": "e5539105fd21888474745ce599ac5f21b79c71e648bf38dd87b4dd139c75e679",
1677
  "source_task_id": "tsk_express_checkout",
1678
  "wrong_token_rejected": true
1679
  },
@@ -1705,11 +1705,11 @@
1705
  }
1706
  },
1707
  "oracle_passed": true,
1708
- "oracle_report_sha256": "b1d61d2b4342b3d0ff6ab256006e055e88e46512798cc66e93bfcb87591c2c9e",
1709
  "oracle_reward": 1.0,
1710
  "oracle_score": 1.0,
1711
  "oracle_successful_tool_calls": 12,
1712
- "second_oracle_report_sha256": "b1d61d2b4342b3d0ff6ab256006e055e88e46512798cc66e93bfcb87591c2c9e",
1713
  "source_task_id": "tsk_instant_refunds_killswitch",
1714
  "wrong_token_rejected": true
1715
  },
@@ -1737,11 +1737,11 @@
1737
  }
1738
  },
1739
  "oracle_passed": true,
1740
- "oracle_report_sha256": "89773d4a202a2cad0c6cddf66d132f901a3aeed45b1d96825dbd58800108fe38",
1741
  "oracle_reward": 1.0,
1742
  "oracle_score": 1.0,
1743
  "oracle_successful_tool_calls": 13,
1744
- "second_oracle_report_sha256": "89773d4a202a2cad0c6cddf66d132f901a3aeed45b1d96825dbd58800108fe38",
1745
  "source_task_id": "tsk_legacy_price_rounding_cleanup",
1746
  "wrong_token_rejected": true
1747
  },
@@ -1771,11 +1771,11 @@
1771
  }
1772
  },
1773
  "oracle_passed": true,
1774
- "oracle_report_sha256": "4504adfedad5be03b3fc64082c004981778e10eecf3e4bf70801c30f30553c89",
1775
  "oracle_reward": 1.0,
1776
  "oracle_score": 1.0,
1777
  "oracle_successful_tool_calls": 12,
1778
- "second_oracle_report_sha256": "4504adfedad5be03b3fc64082c004981778e10eecf3e4bf70801c30f30553c89",
1779
  "source_task_id": "tsk_media_webp",
1780
  "wrong_token_rejected": true
1781
  },
@@ -1809,11 +1809,11 @@
1809
  }
1810
  },
1811
  "oracle_passed": true,
1812
- "oracle_report_sha256": "20d858f7eefb61efac82e5356527ecbd27bf98d707fab31f54a1fea4e3e6b73d",
1813
  "oracle_reward": 1.0,
1814
  "oracle_score": 1.0,
1815
  "oracle_successful_tool_calls": 20,
1816
- "second_oracle_report_sha256": "20d858f7eefb61efac82e5356527ecbd27bf98d707fab31f54a1fea4e3e6b73d",
1817
  "source_task_id": "tsk_saved_carts",
1818
  "wrong_token_rejected": true
1819
  },
@@ -1843,11 +1843,11 @@
1843
  }
1844
  },
1845
  "oracle_passed": true,
1846
- "oracle_report_sha256": "16aa352e78de65014435fa588b9a4efd2f328b6569079c839504707a82b2b0eb",
1847
  "oracle_reward": 1.0,
1848
  "oracle_score": 1.0,
1849
  "oracle_successful_tool_calls": 13,
1850
- "second_oracle_report_sha256": "16aa352e78de65014435fa588b9a4efd2f328b6569079c839504707a82b2b0eb",
1851
  "source_task_id": "tsk_search_autocomplete",
1852
  "wrong_token_rejected": true
1853
  },
@@ -1855,6 +1855,14 @@
1855
  "bench_id": "dob100-058-flaky-analytics-rollup",
1856
  "deterministic_replay_match": true,
1857
  "negative_executions": {
 
 
 
 
 
 
 
 
1858
  "pristine": {
1859
  "failed_checks": [
1860
  "ci_all_stages_green",
@@ -1876,11 +1884,11 @@
1876
  }
1877
  },
1878
  "oracle_passed": true,
1879
- "oracle_report_sha256": "b8d4ef2ff703cdcde4de5e9507748334860c5aeb2ee512f2824c7ddde7d1c91f",
1880
  "oracle_reward": 1.0,
1881
  "oracle_score": 1.0,
1882
  "oracle_successful_tool_calls": 14,
1883
- "second_oracle_report_sha256": "b8d4ef2ff703cdcde4de5e9507748334860c5aeb2ee512f2824c7ddde7d1c91f",
1884
  "source_task_id": "tsk_flaky_analytics_rollup",
1885
  "wrong_token_rejected": true
1886
  },
@@ -1888,6 +1896,14 @@
1888
  "bench_id": "dob100-059-flaky-catalog-rounding",
1889
  "deterministic_replay_match": true,
1890
  "negative_executions": {
 
 
 
 
 
 
 
 
1891
  "pristine": {
1892
  "failed_checks": [
1893
  "ci_all_stages_green",
@@ -1909,11 +1925,11 @@
1909
  }
1910
  },
1911
  "oracle_passed": true,
1912
- "oracle_report_sha256": "36a4d782a5b3fbd21bc97d724d3878258f1e81d14687cad8d69814b5bfe1c1d1",
1913
  "oracle_reward": 1.0,
1914
  "oracle_score": 1.0,
1915
- "oracle_successful_tool_calls": 14,
1916
- "second_oracle_report_sha256": "36a4d782a5b3fbd21bc97d724d3878258f1e81d14687cad8d69814b5bfe1c1d1",
1917
  "source_task_id": "tsk_flaky_catalog_rounding",
1918
  "wrong_token_rejected": true
1919
  },
@@ -1921,6 +1937,14 @@
1921
  "bench_id": "dob100-060-flaky-checkout-idempotency",
1922
  "deterministic_replay_match": true,
1923
  "negative_executions": {
 
 
 
 
 
 
 
 
1924
  "pristine": {
1925
  "failed_checks": [
1926
  "ci_all_stages_green",
@@ -1942,11 +1966,11 @@
1942
  }
1943
  },
1944
  "oracle_passed": true,
1945
- "oracle_report_sha256": "075bb14e192f66120d200c24b9fcb3dcb99b2a19d67902e86646b4d89af481fe",
1946
  "oracle_reward": 1.0,
1947
  "oracle_score": 1.0,
1948
- "oracle_successful_tool_calls": 14,
1949
- "second_oracle_report_sha256": "075bb14e192f66120d200c24b9fcb3dcb99b2a19d67902e86646b4d89af481fe",
1950
  "source_task_id": "tsk_flaky_checkout_idempotency",
1951
  "wrong_token_rejected": true
1952
  },
@@ -1954,6 +1978,14 @@
1954
  "bench_id": "dob100-061-flaky-gateway-timeout",
1955
  "deterministic_replay_match": true,
1956
  "negative_executions": {
 
 
 
 
 
 
 
 
1957
  "pristine": {
1958
  "failed_checks": [
1959
  "ci_all_stages_green",
@@ -1975,11 +2007,11 @@
1975
  }
1976
  },
1977
  "oracle_passed": true,
1978
- "oracle_report_sha256": "27f1a8dddb51823c9640eda5f40f26784566b2d3f0861e4a1fe804e42ad1099c",
1979
  "oracle_reward": 1.0,
1980
  "oracle_score": 1.0,
1981
- "oracle_successful_tool_calls": 14,
1982
- "second_oracle_report_sha256": "27f1a8dddb51823c9640eda5f40f26784566b2d3f0861e4a1fe804e42ad1099c",
1983
  "source_task_id": "tsk_flaky_gateway_timeout",
1984
  "wrong_token_rejected": true
1985
  },
@@ -1987,6 +2019,14 @@
1987
  "bench_id": "dob100-062-flaky-inventory-race",
1988
  "deterministic_replay_match": true,
1989
  "negative_executions": {
 
 
 
 
 
 
 
 
1990
  "pristine": {
1991
  "failed_checks": [
1992
  "ci_all_stages_green",
@@ -2008,11 +2048,11 @@
2008
  }
2009
  },
2010
  "oracle_passed": true,
2011
- "oracle_report_sha256": "09f853817142b852f1ad0136ebd7a56c7b5960e723e812015197f0c06f2d89db",
2012
  "oracle_reward": 1.0,
2013
  "oracle_score": 1.0,
2014
- "oracle_successful_tool_calls": 14,
2015
- "second_oracle_report_sha256": "09f853817142b852f1ad0136ebd7a56c7b5960e723e812015197f0c06f2d89db",
2016
  "source_task_id": "tsk_flaky_inventory_race",
2017
  "wrong_token_rejected": true
2018
  },
@@ -2020,6 +2060,14 @@
2020
  "bench_id": "dob100-063-flaky-search-index",
2021
  "deterministic_replay_match": true,
2022
  "negative_executions": {
 
 
 
 
 
 
 
 
2023
  "pristine": {
2024
  "failed_checks": [
2025
  "ci_all_stages_green",
@@ -2041,11 +2089,11 @@
2041
  }
2042
  },
2043
  "oracle_passed": true,
2044
- "oracle_report_sha256": "525e40223a0dada071475eb7abae063e928a5840f970d688819726206701046a",
2045
  "oracle_reward": 1.0,
2046
  "oracle_score": 1.0,
2047
- "oracle_successful_tool_calls": 14,
2048
- "second_oracle_report_sha256": "525e40223a0dada071475eb7abae063e928a5840f970d688819726206701046a",
2049
  "source_task_id": "tsk_flaky_search_index",
2050
  "wrong_token_rejected": true
2051
  },
@@ -2125,11 +2173,11 @@
2125
  }
2126
  },
2127
  "oracle_passed": true,
2128
- "oracle_report_sha256": "1db72df78f56dac5550ecdebdf76ad05dd8cc0d5b7c4a9dea5468940a7de02fc",
2129
  "oracle_reward": 1.0,
2130
  "oracle_score": 1.0,
2131
  "oracle_successful_tool_calls": 7,
2132
- "second_oracle_report_sha256": "1db72df78f56dac5550ecdebdf76ad05dd8cc0d5b7c4a9dea5468940a7de02fc",
2133
  "source_task_id": "tsk_hz_checkout_flag_kill",
2134
  "wrong_token_rejected": true
2135
  },
@@ -2157,11 +2205,11 @@
2157
  }
2158
  },
2159
  "oracle_passed": true,
2160
- "oracle_report_sha256": "ca01aeb31707bafbfc48c203b87150ff2936a92a1f358839154f2c4c968a8384",
2161
  "oracle_reward": 1.0,
2162
  "oracle_score": 1.0,
2163
  "oracle_successful_tool_calls": 7,
2164
- "second_oracle_report_sha256": "ca01aeb31707bafbfc48c203b87150ff2936a92a1f358839154f2c4c968a8384",
2165
  "source_task_id": "tsk_hz_gateway_leak_rollback",
2166
  "wrong_token_rejected": true
2167
  },
@@ -2191,11 +2239,11 @@
2191
  }
2192
  },
2193
  "oracle_passed": true,
2194
- "oracle_report_sha256": "2a38ce45966b8060cf67d3df0c10561e2a9f6a13e7eef9335989d8cad83adcff",
2195
  "oracle_reward": 1.0,
2196
  "oracle_score": 1.0,
2197
  "oracle_successful_tool_calls": 18,
2198
- "second_oracle_report_sha256": "2a38ce45966b8060cf67d3df0c10561e2a9f6a13e7eef9335989d8cad83adcff",
2199
  "source_task_id": "tsk_gated_rotate_partner_credential",
2200
  "wrong_token_rejected": true
2201
  },
@@ -2203,6 +2251,13 @@
2203
  "bench_id": "dob100-069-judge-analytics-oom",
2204
  "deterministic_replay_match": true,
2205
  "negative_executions": {
 
 
 
 
 
 
 
2206
  "pristine": {
2207
  "failed_checks": [
2208
  "chose_the_root_cause_fix",
@@ -2216,11 +2271,11 @@
2216
  }
2217
  },
2218
  "oracle_passed": true,
2219
- "oracle_report_sha256": "debadca737ef3995247beb5e10f57d17a490a9b872cfcd6288e5935e79f685a2",
2220
  "oracle_reward": 1.0,
2221
  "oracle_score": 1.0,
2222
  "oracle_successful_tool_calls": 8,
2223
- "second_oracle_report_sha256": "debadca737ef3995247beb5e10f57d17a490a9b872cfcd6288e5935e79f685a2",
2224
  "source_task_id": "tsk_judge_analytics_oom",
2225
  "wrong_token_rejected": true
2226
  },
@@ -2228,6 +2283,13 @@
2228
  "bench_id": "dob100-070-judge-checkout-flag",
2229
  "deterministic_replay_match": true,
2230
  "negative_executions": {
 
 
 
 
 
 
 
2231
  "pristine": {
2232
  "failed_checks": [
2233
  "chose_the_root_cause_fix",
@@ -2241,11 +2303,11 @@
2241
  }
2242
  },
2243
  "oracle_passed": true,
2244
- "oracle_report_sha256": "ffce3a1d4ec8ea7951a4d328131ac269dfd4efa1d042748b6af500cd68b50344",
2245
  "oracle_reward": 1.0,
2246
  "oracle_score": 1.0,
2247
  "oracle_successful_tool_calls": 8,
2248
- "second_oracle_report_sha256": "ffce3a1d4ec8ea7951a4d328131ac269dfd4efa1d042748b6af500cd68b50344",
2249
  "source_task_id": "tsk_judge_checkout_flag",
2250
  "wrong_token_rejected": true
2251
  },
@@ -2278,6 +2340,13 @@
2278
  "bench_id": "dob100-072-judge-payments-retry",
2279
  "deterministic_replay_match": true,
2280
  "negative_executions": {
 
 
 
 
 
 
 
2281
  "pristine": {
2282
  "failed_checks": [
2283
  "chose_the_root_cause_fix",
@@ -2291,11 +2360,11 @@
2291
  }
2292
  },
2293
  "oracle_passed": true,
2294
- "oracle_report_sha256": "2ec2358c54c0c7e70ef6066d56e7f033218c4d4504ccf065897fd7b4871080bd",
2295
  "oracle_reward": 1.0,
2296
  "oracle_score": 1.0,
2297
  "oracle_successful_tool_calls": 7,
2298
- "second_oracle_report_sha256": "2ec2358c54c0c7e70ef6066d56e7f033218c4d4504ccf065897fd7b4871080bd",
2299
  "source_task_id": "tsk_judge_payments_retry",
2300
  "wrong_token_rejected": true
2301
  },
@@ -2327,11 +2396,11 @@
2327
  }
2328
  },
2329
  "oracle_passed": true,
2330
- "oracle_report_sha256": "a760de20c08912753aa589e72797c954cb2739eb7999519149a1e11946d3d294",
2331
  "oracle_reward": 1.0,
2332
  "oracle_score": 1.0,
2333
  "oracle_successful_tool_calls": 19,
2334
- "second_oracle_report_sha256": "a760de20c08912753aa589e72797c954cb2739eb7999519149a1e11946d3d294",
2335
  "source_task_id": "tsk_catalog_batch_pricing",
2336
  "wrong_token_rejected": true
2337
  },
@@ -2358,11 +2427,11 @@
2358
  }
2359
  },
2360
  "oracle_passed": true,
2361
- "oracle_report_sha256": "9f2bd66a092f5c1d0d1ee8ffded57e49d49e0e5ba5c018a9069dbd76f430177c",
2362
  "oracle_reward": 1.0,
2363
  "oracle_score": 1.0,
2364
- "oracle_successful_tool_calls": 14,
2365
- "second_oracle_report_sha256": "9f2bd66a092f5c1d0d1ee8ffded57e49d49e0e5ba5c018a9069dbd76f430177c",
2366
  "source_task_id": "tsk_catalog_cache_ttl",
2367
  "wrong_token_rejected": true
2368
  },
@@ -2393,11 +2462,11 @@
2393
  }
2394
  },
2395
  "oracle_passed": true,
2396
- "oracle_report_sha256": "c331c786a737f3fe1150ed7a65dadad1d98c3819a9ee778ab2cf1d4862f711d0",
2397
  "oracle_reward": 1.0,
2398
  "oracle_score": 1.0,
2399
  "oracle_successful_tool_calls": 18,
2400
- "second_oracle_report_sha256": "c331c786a737f3fe1150ed7a65dadad1d98c3819a9ee778ab2cf1d4862f711d0",
2401
  "source_task_id": "tsk_catalog_pricing_from_code",
2402
  "wrong_token_rejected": true
2403
  },
@@ -2426,11 +2495,11 @@
2426
  }
2427
  },
2428
  "oracle_passed": true,
2429
- "oracle_report_sha256": "31add1ba94a1578afd495330a83d1d84d524a705f9d8f43c3bde126f4d076039",
2430
  "oracle_reward": 1.0,
2431
  "oracle_score": 1.0,
2432
- "oracle_successful_tool_calls": 16,
2433
- "second_oracle_report_sha256": "31add1ba94a1578afd495330a83d1d84d524a705f9d8f43c3bde126f4d076039",
2434
  "source_task_id": "tsk_gateway_pool_reuse",
2435
  "wrong_token_rejected": true
2436
  },
@@ -2465,11 +2534,11 @@
2465
  }
2466
  },
2467
  "oracle_passed": true,
2468
- "oracle_report_sha256": "50f6ec7d68ac0ff4ad4369c5ee8c1c3d306f4e2490833fac26822a5002f3f415",
2469
  "oracle_reward": 1.0,
2470
  "oracle_score": 1.0,
2471
  "oracle_successful_tool_calls": 15,
2472
- "second_oracle_report_sha256": "50f6ec7d68ac0ff4ad4369c5ee8c1c3d306f4e2490833fac26822a5002f3f415",
2473
  "source_task_id": "tsk_gateway_v510_rollback",
2474
  "wrong_token_rejected": true
2475
  },
@@ -2501,11 +2570,11 @@
2501
  }
2502
  },
2503
  "oracle_passed": true,
2504
- "oracle_report_sha256": "e842ae57e37087f8dd5e1fee160fa5b4814e3cbc35858aac5e2dc2c0c7917d13",
2505
  "oracle_reward": 1.0,
2506
  "oracle_score": 1.0,
2507
  "oracle_successful_tool_calls": 18,
2508
- "second_oracle_report_sha256": "e842ae57e37087f8dd5e1fee160fa5b4814e3cbc35858aac5e2dc2c0c7917d13",
2509
  "source_task_id": "tsk_media_cdn",
2510
  "wrong_token_rejected": true
2511
  },
@@ -2537,11 +2606,11 @@
2537
  }
2538
  },
2539
  "oracle_passed": true,
2540
- "oracle_report_sha256": "96118515de911f2f2d85c903482552fd0df39074e8975be2040dd1a86d26ca67",
2541
  "oracle_reward": 1.0,
2542
  "oracle_score": 1.0,
2543
- "oracle_successful_tool_calls": 19,
2544
- "second_oracle_report_sha256": "96118515de911f2f2d85c903482552fd0df39074e8975be2040dd1a86d26ca67",
2545
  "source_task_id": "tsk_search_cache",
2546
  "wrong_token_rejected": true
2547
  },
@@ -2568,11 +2637,11 @@
2568
  }
2569
  },
2570
  "oracle_passed": true,
2571
- "oracle_report_sha256": "2cc66313618f5825b423c05055711294ff0d7f8db2d623e4bc5bcf20a641b107",
2572
  "oracle_reward": 1.0,
2573
  "oracle_score": 1.0,
2574
- "oracle_successful_tool_calls": 14,
2575
- "second_oracle_report_sha256": "2cc66313618f5825b423c05055711294ff0d7f8db2d623e4bc5bcf20a641b107",
2576
  "source_task_id": "tsk_search_shards",
2577
  "wrong_token_rejected": true
2578
  },
@@ -2612,11 +2681,11 @@
2612
  }
2613
  },
2614
  "oracle_passed": true,
2615
- "oracle_report_sha256": "c2e94a76c5cce7bee57e344b6af687530fb3ba433d511dde15a06ca183d99f42",
2616
  "oracle_reward": 1.0,
2617
  "oracle_score": 1.0,
2618
  "oracle_successful_tool_calls": 31,
2619
- "second_oracle_report_sha256": "c2e94a76c5cce7bee57e344b6af687530fb3ba433d511dde15a06ca183d99f42",
2620
  "source_task_id": "tsk_backorders",
2621
  "wrong_token_rejected": true
2622
  },
@@ -2655,11 +2724,11 @@
2655
  }
2656
  },
2657
  "oracle_passed": true,
2658
- "oracle_report_sha256": "cdbd6a055aacf513f13ac1ca973ebf24d5a6e0d43c12f00d8613a9615ad156ed",
2659
  "oracle_reward": 1.0,
2660
  "oracle_score": 1.0,
2661
  "oracle_successful_tool_calls": 26,
2662
- "second_oracle_report_sha256": "cdbd6a055aacf513f13ac1ca973ebf24d5a6e0d43c12f00d8613a9615ad156ed",
2663
  "source_task_id": "tsk_checkout_upsell",
2664
  "wrong_token_rejected": true
2665
  },
@@ -2700,11 +2769,11 @@
2700
  }
2701
  },
2702
  "oracle_passed": true,
2703
- "oracle_report_sha256": "d650cd3bd0732a7c5b0918b896645e62a71e149facea1e311d1117ab19cd240c",
2704
  "oracle_reward": 1.0,
2705
  "oracle_score": 1.0,
2706
  "oracle_successful_tool_calls": 33,
2707
- "second_oracle_report_sha256": "d650cd3bd0732a7c5b0918b896645e62a71e149facea1e311d1117ab19cd240c",
2708
  "source_task_id": "tsk_loyalty_points",
2709
  "wrong_token_rejected": true
2710
  },
@@ -2741,11 +2810,11 @@
2741
  }
2742
  },
2743
  "oracle_passed": true,
2744
- "oracle_report_sha256": "a48e7619eecad62161b797a80609da555cc5a1b5621be13b72ef62b2ca92d2f1",
2745
  "oracle_reward": 1.0,
2746
  "oracle_score": 1.0,
2747
  "oracle_successful_tool_calls": 23,
2748
- "second_oracle_report_sha256": "a48e7619eecad62161b797a80609da555cc5a1b5621be13b72ef62b2ca92d2f1",
2749
  "source_task_id": "tsk_media_pipeline",
2750
  "wrong_token_rejected": true
2751
  },
@@ -2778,11 +2847,11 @@
2778
  }
2779
  },
2780
  "oracle_passed": true,
2781
- "oracle_report_sha256": "ae2e35dcec0eb2775a4832a9afe48e0e13f3104b0de27715d9f8db923b9ff8e1",
2782
  "oracle_reward": 1.0,
2783
  "oracle_score": 1.0,
2784
  "oracle_successful_tool_calls": 17,
2785
- "second_oracle_report_sha256": "ae2e35dcec0eb2775a4832a9afe48e0e13f3104b0de27715d9f8db923b9ff8e1",
2786
  "source_task_id": "tsk_notification_templates",
2787
  "wrong_token_rejected": true
2788
  },
@@ -2813,11 +2882,11 @@
2813
  }
2814
  },
2815
  "oracle_passed": true,
2816
- "oracle_report_sha256": "e3b8ffc2f6c393f64bde77aad2e41c7a0b4eeb53e425673c922156fe989cbb72",
2817
  "oracle_reward": 1.0,
2818
  "oracle_score": 1.0,
2819
  "oracle_successful_tool_calls": 17,
2820
- "second_oracle_report_sha256": "e3b8ffc2f6c393f64bde77aad2e41c7a0b4eeb53e425673c922156fe989cbb72",
2821
  "source_task_id": "tsk_search_relevance",
2822
  "wrong_token_rejected": true
2823
  },
@@ -2853,11 +2922,11 @@
2853
  }
2854
  },
2855
  "oracle_passed": true,
2856
- "oracle_report_sha256": "ef9082136d9d5386d252ac6e2be336f55bcd3363b3fd47bc5209aab126cc8a48",
2857
  "oracle_reward": 1.0,
2858
  "oracle_score": 1.0,
2859
  "oracle_successful_tool_calls": 25,
2860
- "second_oracle_report_sha256": "ef9082136d9d5386d252ac6e2be336f55bcd3363b3fd47bc5209aab126cc8a48",
2861
  "source_task_id": "tsk_split_settlement",
2862
  "wrong_token_rejected": true
2863
  },
@@ -3038,11 +3107,11 @@
3038
  }
3039
  },
3040
  "oracle_passed": true,
3041
- "oracle_report_sha256": "b81b29c1a3bf42bb1f20b8e5b98f3e2442a8a3a3e05980a110e88d05b940ef4d",
3042
  "oracle_reward": 1.0,
3043
  "oracle_score": 1.0,
3044
  "oracle_successful_tool_calls": 17,
3045
- "second_oracle_report_sha256": "b81b29c1a3bf42bb1f20b8e5b98f3e2442a8a3a3e05980a110e88d05b940ef4d",
3046
  "source_task_id": "tsk_checkout_hardcoded_secret",
3047
  "wrong_token_rejected": true
3048
  },
@@ -3074,11 +3143,11 @@
3074
  }
3075
  },
3076
  "oracle_passed": true,
3077
- "oracle_report_sha256": "b52ded9c28a1471907a9fb0e92ec88edb72517f7844988aee93e4e98c8ca0d7f",
3078
  "oracle_reward": 1.0,
3079
  "oracle_score": 1.0,
3080
  "oracle_successful_tool_calls": 16,
3081
- "second_oracle_report_sha256": "b52ded9c28a1471907a9fb0e92ec88edb72517f7844988aee93e4e98c8ca0d7f",
3082
  "source_task_id": "tsk_cve_libpayproc",
3083
  "wrong_token_rejected": true
3084
  },
@@ -3107,11 +3176,11 @@
3107
  }
3108
  },
3109
  "oracle_passed": true,
3110
- "oracle_report_sha256": "1b9b266617f18367af2f81c12fb3b89b4cd67acf911e6c0b3116d1eb56f3ab2f",
3111
  "oracle_reward": 1.0,
3112
  "oracle_score": 1.0,
3113
  "oracle_successful_tool_calls": 15,
3114
- "second_oracle_report_sha256": "1b9b266617f18367af2f81c12fb3b89b4cd67acf911e6c0b3116d1eb56f3ab2f",
3115
  "source_task_id": "tsk_cve_pydantic",
3116
  "wrong_token_rejected": true
3117
  },
@@ -3143,11 +3212,11 @@
3143
  }
3144
  },
3145
  "oracle_passed": true,
3146
- "oracle_report_sha256": "32981d4d924752e19adeec8749dbb2b5a797d86e54568a813d1ba69974c29465",
3147
  "oracle_reward": 1.0,
3148
  "oracle_score": 1.0,
3149
- "oracle_successful_tool_calls": 16,
3150
- "second_oracle_report_sha256": "32981d4d924752e19adeec8749dbb2b5a797d86e54568a813d1ba69974c29465",
3151
  "source_task_id": "tsk_cve_requests",
3152
  "wrong_token_rejected": true
3153
  },
@@ -3179,11 +3248,11 @@
3179
  }
3180
  },
3181
  "oracle_passed": true,
3182
- "oracle_report_sha256": "e8e1079137aacf45fc71da21cac9a76cb0c7592421fd3632b40788d0cc866e8b",
3183
  "oracle_reward": 1.0,
3184
  "oracle_score": 1.0,
3185
  "oracle_successful_tool_calls": 17,
3186
- "second_oracle_report_sha256": "e8e1079137aacf45fc71da21cac9a76cb0c7592421fd3632b40788d0cc866e8b",
3187
  "source_task_id": "tsk_cve_stripe_sdk",
3188
  "wrong_token_rejected": true
3189
  },
@@ -3212,11 +3281,11 @@
3212
  }
3213
  },
3214
  "oracle_passed": true,
3215
- "oracle_report_sha256": "a16e73f4204a634a0588c70e8dab08e54a044337be25b23410432fc8aea03edf",
3216
  "oracle_reward": 1.0,
3217
  "oracle_score": 1.0,
3218
  "oracle_successful_tool_calls": 13,
3219
- "second_oracle_report_sha256": "a16e73f4204a634a0588c70e8dab08e54a044337be25b23410432fc8aea03edf",
3220
  "source_task_id": "tsk_retire_debug_endpoint",
3221
  "wrong_token_rejected": true
3222
  },
@@ -3245,11 +3314,11 @@
3245
  }
3246
  },
3247
  "oracle_passed": true,
3248
- "oracle_report_sha256": "a8e6b8e290ce974bde340cc2868bb0d07eeb1ab7dd128749a6edb69548352c01",
3249
  "oracle_reward": 1.0,
3250
  "oracle_score": 1.0,
3251
- "oracle_successful_tool_calls": 13,
3252
- "second_oracle_report_sha256": "a8e6b8e290ce974bde340cc2868bb0d07eeb1ab7dd128749a6edb69548352c01",
3253
  "source_task_id": "tsk_retire_metrics_endpoint",
3254
  "wrong_token_rejected": true
3255
  },
@@ -3282,5 +3351,5 @@
3282
  "failures": 0,
3283
  "wrong_token_rejections": 100
3284
  },
3285
- "version": "1.0.0"
3286
  }
 
5
  "mismatches": 0,
6
  "replays": 100
7
  },
8
+ "executions": 380,
9
  "negative_controls": {
10
  "naive": {
11
+ "applicable_executions": 62,
12
+ "correct_rejections": 62,
13
  "false_accepts": 0
14
  },
15
  "pristine": {
 
164
  }
165
  },
166
  "oracle_passed": true,
167
+ "oracle_report_sha256": "8a788c7028a7e9b73d2e64c689a9f564d6573ab7ee3852694d7679dc7b853fdf",
168
  "oracle_reward": 1.0,
169
  "oracle_score": 1.0,
170
+ "oracle_successful_tool_calls": 11,
171
+ "second_oracle_report_sha256": "8a788c7028a7e9b73d2e64c689a9f564d6573ab7ee3852694d7679dc7b853fdf",
172
  "source_task_id": "tsk_rca_notifications_node_deadlock",
173
  "wrong_token_rejected": true
174
  },
 
241
  }
242
  },
243
  "oracle_passed": true,
244
+ "oracle_report_sha256": "312ea2a8e31457cf5d7d763fd22b97501907f6ad83dc83e9f0d7c8eadd871768",
245
  "oracle_reward": 1.0,
246
  "oracle_score": 1.0,
247
+ "oracle_successful_tool_calls": 7,
248
+ "second_oracle_report_sha256": "312ea2a8e31457cf5d7d763fd22b97501907f6ad83dc83e9f0d7c8eadd871768",
249
  "source_task_id": "tsk_detect_inventory",
250
  "wrong_token_rejected": true
251
  },
 
266
  }
267
  },
268
  "oracle_passed": true,
269
+ "oracle_report_sha256": "e2efebc50b1d45839be917a2e4dbefad3c8967411da8ba0958e9a881b9bbc2fc",
270
  "oracle_reward": 1.0,
271
  "oracle_score": 1.0,
272
+ "oracle_successful_tool_calls": 7,
273
+ "second_oracle_report_sha256": "e2efebc50b1d45839be917a2e4dbefad3c8967411da8ba0958e9a881b9bbc2fc",
274
  "source_task_id": "tsk_detect_payments",
275
  "wrong_token_rejected": true
276
  },
 
317
  }
318
  },
319
  "oracle_passed": true,
320
+ "oracle_report_sha256": "37820634c3f63e2a26b9edd2adddfb0b257f568b32ef6ad68b75fae97cc2c87e",
321
  "oracle_reward": 1.0,
322
  "oracle_score": 1.0,
323
+ "oracle_successful_tool_calls": 7,
324
+ "second_oracle_report_sha256": "37820634c3f63e2a26b9edd2adddfb0b257f568b32ef6ad68b75fae97cc2c87e",
325
  "source_task_id": "tsk_detect_storefront_healthy",
326
  "wrong_token_rejected": true
327
  },
 
369
  }
370
  },
371
  "oracle_passed": true,
372
+ "oracle_report_sha256": "5a709f24688a7ef85e2436dbc7113dd69d54b65fe659addc2bc2f9a370974c5e",
373
  "oracle_reward": 1.0,
374
  "oracle_score": 1.0,
375
+ "oracle_successful_tool_calls": 8,
376
+ "second_oracle_report_sha256": "5a709f24688a7ef85e2436dbc7113dd69d54b65fe659addc2bc2f9a370974c5e",
377
  "source_task_id": "tsk_localize_analytics_errors",
378
  "wrong_token_rejected": true
379
  },
 
401
  }
402
  },
403
  "oracle_passed": true,
404
+ "oracle_report_sha256": "d8b38418f460d95bbbbf8fb323eeb95039e776411812a1dfcd520c7498a57ba8",
405
  "oracle_reward": 1.0,
406
  "oracle_score": 1.0,
407
+ "oracle_successful_tool_calls": 8,
408
+ "second_oracle_report_sha256": "d8b38418f460d95bbbbf8fb323eeb95039e776411812a1dfcd520c7498a57ba8",
409
  "source_task_id": "tsk_localize_checkout_latency",
410
  "wrong_token_rejected": true
411
  },
 
427
  }
428
  },
429
  "oracle_passed": true,
430
+ "oracle_report_sha256": "4af277a47858df341257dc42c482aba7889e324ef8e0266c98a559ab7d8abca3",
431
  "oracle_reward": 1.0,
432
  "oracle_score": 1.0,
433
+ "oracle_successful_tool_calls": 8,
434
+ "second_oracle_report_sha256": "4af277a47858df341257dc42c482aba7889e324ef8e0266c98a559ab7d8abca3",
435
  "source_task_id": "tsk_localize_gateway_latency",
436
  "wrong_token_rejected": true
437
  },
 
453
  }
454
  },
455
  "oracle_passed": true,
456
+ "oracle_report_sha256": "8ed9c9c0915786bdab6814c9bccb527cf6061320dc8b336d90812e4eac3336cd",
457
  "oracle_reward": 1.0,
458
  "oracle_score": 1.0,
459
+ "oracle_successful_tool_calls": 8,
460
+ "second_oracle_report_sha256": "8ed9c9c0915786bdab6814c9bccb527cf6061320dc8b336d90812e4eac3336cd",
461
  "source_task_id": "tsk_localize_media_latency",
462
  "wrong_token_rejected": true
463
  },
 
496
  }
497
  },
498
  "oracle_passed": true,
499
+ "oracle_report_sha256": "bc351de872347d1d019b45c97b7c685273c0ee775b8e06842e73f96f75df53f6",
500
  "oracle_reward": 1.0,
501
  "oracle_score": 1.0,
502
  "oracle_successful_tool_calls": 34,
503
+ "second_oracle_report_sha256": "bc351de872347d1d019b45c97b7c685273c0ee775b8e06842e73f96f75df53f6",
504
  "source_task_id": "tsk_auth_v1_to_v2",
505
  "wrong_token_rejected": true
506
  },
 
539
  }
540
  },
541
  "oracle_passed": true,
542
+ "oracle_report_sha256": "171fac4a175c08578f818a7b33002552d641bd6fe6222f330f063f51e2c06a0c",
543
  "oracle_reward": 1.0,
544
  "oracle_score": 1.0,
545
+ "oracle_successful_tool_calls": 35,
546
+ "second_oracle_report_sha256": "171fac4a175c08578f818a7b33002552d641bd6fe6222f330f063f51e2c06a0c",
547
  "source_task_id": "tsk_checkout_v1_to_v2",
548
  "wrong_token_rejected": true
549
  },
 
577
  }
578
  },
579
  "oracle_passed": true,
580
+ "oracle_report_sha256": "dce310f3720890d0324ac2cf5969ab272c71d9082f2c7098d7a260f08b3c93d1",
581
  "oracle_reward": 1.0,
582
  "oracle_score": 1.0,
583
  "oracle_successful_tool_calls": 27,
584
+ "second_oracle_report_sha256": "dce310f3720890d0324ac2cf5969ab272c71d9082f2c7098d7a260f08b3c93d1",
585
  "source_task_id": "tsk_inventory_v1_to_v2",
586
  "wrong_token_rejected": true
587
  },
 
615
  }
616
  },
617
  "oracle_passed": true,
618
+ "oracle_report_sha256": "95fd61966f6cbca47cb275da050200dbe906abe7afb5d2f5b71c3543d4956627",
619
  "oracle_reward": 1.0,
620
  "oracle_score": 1.0,
621
+ "oracle_successful_tool_calls": 28,
622
+ "second_oracle_report_sha256": "95fd61966f6cbca47cb275da050200dbe906abe7afb5d2f5b71c3543d4956627",
623
  "source_task_id": "tsk_media_v1_to_v2",
624
  "wrong_token_rejected": true
625
  },
 
653
  }
654
  },
655
  "oracle_passed": true,
656
+ "oracle_report_sha256": "c73f46f6265de9c245cd403b34855216d652c169e4314d7dd5a26d0e34e90297",
657
  "oracle_reward": 1.0,
658
  "oracle_score": 1.0,
659
+ "oracle_successful_tool_calls": 28,
660
+ "second_oracle_report_sha256": "c73f46f6265de9c245cd403b34855216d652c169e4314d7dd5a26d0e34e90297",
661
  "source_task_id": "tsk_notify_v1_to_v2",
662
  "wrong_token_rejected": true
663
  },
 
696
  }
697
  },
698
  "oracle_passed": true,
699
+ "oracle_report_sha256": "38a7f2fe345fad9894b750878380d07aa52271b3ae9e66392ed15d2ba9155f73",
700
  "oracle_reward": 1.0,
701
  "oracle_score": 1.0,
702
+ "oracle_successful_tool_calls": 35,
703
+ "second_oracle_report_sha256": "38a7f2fe345fad9894b750878380d07aa52271b3ae9e66392ed15d2ba9155f73",
704
  "source_task_id": "tsk_orders_v1_to_v2",
705
  "wrong_token_rejected": true
706
  },
 
734
  }
735
  },
736
  "oracle_passed": true,
737
+ "oracle_report_sha256": "93c093991feaea927935cfaefd13e9cc391d6d9f7c3cc1ae147dce1488852a74",
738
  "oracle_reward": 1.0,
739
  "oracle_score": 1.0,
740
+ "oracle_successful_tool_calls": 28,
741
+ "second_oracle_report_sha256": "93c093991feaea927935cfaefd13e9cc391d6d9f7c3cc1ae147dce1488852a74",
742
  "source_task_id": "tsk_search_v1_to_v2",
743
  "wrong_token_rejected": true
744
  },
 
970
  }
971
  },
972
  "oracle_passed": true,
973
+ "oracle_report_sha256": "e644dc588103dddd12e69289d83cb1eba05b1c63b7d6025112bdc3401ba2fef8",
974
  "oracle_reward": 1.0,
975
  "oracle_score": 1.0,
976
  "oracle_successful_tool_calls": 5,
977
+ "second_oracle_report_sha256": "e644dc588103dddd12e69289d83cb1eba05b1c63b7d6025112bdc3401ba2fef8",
978
  "source_task_id": "tsk_impl_backoff",
979
  "wrong_token_rejected": true
980
  },
 
1003
  }
1004
  },
1005
  "oracle_passed": true,
1006
+ "oracle_report_sha256": "5ff5adb321540fdb8d08eda677bedfd2c492dfe0744bd22389c5d0214e3aac85",
1007
  "oracle_reward": 1.0,
1008
  "oracle_score": 1.0,
1009
+ "oracle_successful_tool_calls": 6,
1010
+ "second_oracle_report_sha256": "5ff5adb321540fdb8d08eda677bedfd2c492dfe0744bd22389c5d0214e3aac85",
1011
  "source_task_id": "tsk_impl_cachekey",
1012
  "wrong_token_rejected": true
1013
  },
 
1036
  }
1037
  },
1038
  "oracle_passed": true,
1039
+ "oracle_report_sha256": "e905dcb46245f004a9a1fa68a1bda71eb8c13e45f18791cd232cabe5f288fb83",
1040
  "oracle_reward": 1.0,
1041
  "oracle_score": 1.0,
1042
+ "oracle_successful_tool_calls": 6,
1043
+ "second_oracle_report_sha256": "e905dcb46245f004a9a1fa68a1bda71eb8c13e45f18791cd232cabe5f288fb83",
1044
  "source_task_id": "tsk_impl_chunk",
1045
  "wrong_token_rejected": true
1046
  },
 
1069
  }
1070
  },
1071
  "oracle_passed": true,
1072
+ "oracle_report_sha256": "2f8c7f5169fc1108a4a970f83f94cd9d6aa3a562480b34319a042c16cec93f10",
1073
  "oracle_reward": 1.0,
1074
  "oracle_score": 1.0,
1075
+ "oracle_successful_tool_calls": 6,
1076
+ "second_oracle_report_sha256": "2f8c7f5169fc1108a4a970f83f94cd9d6aa3a562480b34319a042c16cec93f10",
1077
  "source_task_id": "tsk_impl_ratelimit",
1078
  "wrong_token_rejected": true
1079
  },
 
1165
  }
1166
  },
1167
  "oracle_passed": true,
1168
+ "oracle_report_sha256": "4f5a97b5390aa92f99807d6f46bc5ee480e01a014844e18e621d4a5f603cfef0",
1169
  "oracle_reward": 1.0,
1170
  "oracle_score": 1.0,
1171
  "oracle_successful_tool_calls": 10,
1172
+ "second_oracle_report_sha256": "4f5a97b5390aa92f99807d6f46bc5ee480e01a014844e18e621d4a5f603cfef0",
1173
  "source_task_id": "tsk_port_copy_priority_issues",
1174
  "wrong_token_rejected": true
1175
  },
 
1223
  }
1224
  },
1225
  "oracle_passed": true,
1226
+ "oracle_report_sha256": "fed850bb7adb314771e05b5c21266c7ac65ec6414a6d3557855c343a8fd3e4cb",
1227
  "oracle_reward": 1.0,
1228
  "oracle_score": 1.0,
1229
+ "oracle_successful_tool_calls": 5,
1230
+ "second_oracle_report_sha256": "fed850bb7adb314771e05b5c21266c7ac65ec6414a6d3557855c343a8fd3e4cb",
1231
  "source_task_id": "tsk_port_count_unowned_work",
1232
  "wrong_token_rejected": true
1233
  },
 
1317
  }
1318
  },
1319
  "oracle_passed": true,
1320
+ "oracle_report_sha256": "85fd24b62a5e62753bf2185d95f5c099ef81c694f1155826e1c6c116f37a26e0",
1321
  "oracle_reward": 1.0,
1322
  "oracle_score": 1.0,
1323
  "oracle_successful_tool_calls": 4,
1324
+ "second_oracle_report_sha256": "85fd24b62a5e62753bf2185d95f5c099ef81c694f1155826e1c6c116f37a26e0",
1325
  "source_task_id": "tsk_port_high_priority_since",
1326
  "wrong_token_rejected": true
1327
  },
 
1348
  }
1349
  },
1350
  "oracle_passed": true,
1351
+ "oracle_report_sha256": "2e2e620ebbfaff07823021e2da68ec7185ba2536c7858f7cd32441f10d29eebd",
1352
  "oracle_reward": 1.0,
1353
  "oracle_score": 1.0,
1354
  "oracle_successful_tool_calls": 14,
1355
+ "second_oracle_report_sha256": "2e2e620ebbfaff07823021e2da68ec7185ba2536c7858f7cd32441f10d29eebd",
1356
  "source_task_id": "tsk_analytics_batch_size",
1357
  "wrong_token_rejected": true
1358
  },
 
1384
  }
1385
  },
1386
  "oracle_passed": true,
1387
+ "oracle_report_sha256": "dcd13ccae875eabfdde8646452e37972a3b80f33428e7dc6196749ce91c5365f",
1388
  "oracle_reward": 1.0,
1389
  "oracle_score": 1.0,
1390
  "oracle_successful_tool_calls": 18,
1391
+ "second_oracle_report_sha256": "dcd13ccae875eabfdde8646452e37972a3b80f33428e7dc6196749ce91c5365f",
1392
  "source_task_id": "tsk_analytics_prefetch",
1393
  "wrong_token_rejected": true
1394
  },
 
1417
  }
1418
  },
1419
  "oracle_passed": true,
1420
+ "oracle_report_sha256": "1d326ef3ee2bded15e4def51d95838220a4d0874299b05ccfee2282d1e4399db",
1421
  "oracle_reward": 1.0,
1422
  "oracle_score": 1.0,
1423
  "oracle_successful_tool_calls": 16,
1424
+ "second_oracle_report_sha256": "1d326ef3ee2bded15e4def51d95838220a4d0874299b05ccfee2282d1e4399db",
1425
  "source_task_id": "tsk_checkout_payments_timeout",
1426
  "wrong_token_rejected": true
1427
  },
 
1454
  }
1455
  },
1456
  "oracle_passed": true,
1457
+ "oracle_report_sha256": "6d9ce536309622ac1ea9d5b5fdaf45b82729008b67232f4f3952ab7a783f169a",
1458
  "oracle_reward": 1.0,
1459
  "oracle_score": 1.0,
1460
  "oracle_successful_tool_calls": 19,
1461
+ "second_oracle_report_sha256": "6d9ce536309622ac1ea9d5b5fdaf45b82729008b67232f4f3952ab7a783f169a",
1462
  "source_task_id": "tsk_inventory_pool",
1463
  "wrong_token_rejected": true
1464
  },
 
1490
  }
1491
  },
1492
  "oracle_passed": true,
1493
+ "oracle_report_sha256": "00314d0a03c16a0b3cff1bdf601578c2f9ca9211f9756d44eb166a7cfbe5db9b",
1494
  "oracle_reward": 1.0,
1495
  "oracle_score": 1.0,
1496
  "oracle_successful_tool_calls": 17,
1497
+ "second_oracle_report_sha256": "00314d0a03c16a0b3cff1bdf601578c2f9ca9211f9756d44eb166a7cfbe5db9b",
1498
  "source_task_id": "tsk_notifications_timeout",
1499
  "wrong_token_rejected": true
1500
  },
 
1523
  }
1524
  },
1525
  "oracle_passed": true,
1526
+ "oracle_report_sha256": "48e9fb4bb9d3dc91b52ae276f394bd10f61cbcce7a313d417f14a3d4c1f6c5d8",
1527
  "oracle_reward": 1.0,
1528
  "oracle_score": 1.0,
1529
  "oracle_successful_tool_calls": 15,
1530
+ "second_oracle_report_sha256": "48e9fb4bb9d3dc91b52ae276f394bd10f61cbcce7a313d417f14a3d4c1f6c5d8",
1531
  "source_task_id": "tsk_payments_notify_timeout",
1532
  "wrong_token_rejected": true
1533
  },
 
1561
  }
1562
  },
1563
  "oracle_passed": true,
1564
+ "oracle_report_sha256": "3cdf15001d3fb2611a963347c0f3a66f1856ee759d4f88013acc1c729aa8ab38",
1565
  "oracle_reward": 1.0,
1566
  "oracle_score": 1.0,
1567
  "oracle_successful_tool_calls": 19,
1568
+ "second_oracle_report_sha256": "3cdf15001d3fb2611a963347c0f3a66f1856ee759d4f88013acc1c729aa8ab38",
1569
  "source_task_id": "tsk_payments_retry",
1570
  "wrong_token_rejected": true
1571
  },
 
1599
  }
1600
  },
1601
  "oracle_passed": true,
1602
+ "oracle_report_sha256": "f23edd34a817391fcaa0cd89c8ed6ed0729f087a7e344dfa193bd974533c381c",
1603
  "oracle_reward": 1.0,
1604
  "oracle_score": 1.0,
1605
  "oracle_successful_tool_calls": 19,
1606
+ "second_oracle_report_sha256": "f23edd34a817391fcaa0cd89c8ed6ed0729f087a7e344dfa193bd974533c381c",
1607
  "source_task_id": "tsk_payments_retry_from_code",
1608
  "wrong_token_rejected": true
1609
  },
 
1633
  }
1634
  },
1635
  "oracle_passed": true,
1636
+ "oracle_report_sha256": "d7504d48002225bb44d572e01b31b22867bc241083313e56c65f0931a655b9e8",
1637
  "oracle_reward": 1.0,
1638
  "oracle_score": 1.0,
1639
  "oracle_successful_tool_calls": 15,
1640
+ "second_oracle_report_sha256": "d7504d48002225bb44d572e01b31b22867bc241083313e56c65f0931a655b9e8",
1641
  "source_task_id": "tsk_checkout_v2_layout_cleanup",
1642
  "wrong_token_rejected": true
1643
  },
 
1669
  }
1670
  },
1671
  "oracle_passed": true,
1672
+ "oracle_report_sha256": "8229f46894874d7e1e0f5ee85807e194371b06c2cd5ac15bcedfd53b11bcf942",
1673
  "oracle_reward": 1.0,
1674
  "oracle_score": 1.0,
1675
  "oracle_successful_tool_calls": 15,
1676
+ "second_oracle_report_sha256": "8229f46894874d7e1e0f5ee85807e194371b06c2cd5ac15bcedfd53b11bcf942",
1677
  "source_task_id": "tsk_express_checkout",
1678
  "wrong_token_rejected": true
1679
  },
 
1705
  }
1706
  },
1707
  "oracle_passed": true,
1708
+ "oracle_report_sha256": "9857298cac0f34c8aada7d14d2ce38ed5b3c1876514adc871ab5c4467c05718c",
1709
  "oracle_reward": 1.0,
1710
  "oracle_score": 1.0,
1711
  "oracle_successful_tool_calls": 12,
1712
+ "second_oracle_report_sha256": "9857298cac0f34c8aada7d14d2ce38ed5b3c1876514adc871ab5c4467c05718c",
1713
  "source_task_id": "tsk_instant_refunds_killswitch",
1714
  "wrong_token_rejected": true
1715
  },
 
1737
  }
1738
  },
1739
  "oracle_passed": true,
1740
+ "oracle_report_sha256": "12114c50799b1ba16c4b611b61ff755ce72135b0c72f7b20e796384a6d55b824",
1741
  "oracle_reward": 1.0,
1742
  "oracle_score": 1.0,
1743
  "oracle_successful_tool_calls": 13,
1744
+ "second_oracle_report_sha256": "12114c50799b1ba16c4b611b61ff755ce72135b0c72f7b20e796384a6d55b824",
1745
  "source_task_id": "tsk_legacy_price_rounding_cleanup",
1746
  "wrong_token_rejected": true
1747
  },
 
1771
  }
1772
  },
1773
  "oracle_passed": true,
1774
+ "oracle_report_sha256": "bac5b22a910aa74ff152b4873187a9ac6edea9c82325f1373852cc2fe95f71ff",
1775
  "oracle_reward": 1.0,
1776
  "oracle_score": 1.0,
1777
  "oracle_successful_tool_calls": 12,
1778
+ "second_oracle_report_sha256": "bac5b22a910aa74ff152b4873187a9ac6edea9c82325f1373852cc2fe95f71ff",
1779
  "source_task_id": "tsk_media_webp",
1780
  "wrong_token_rejected": true
1781
  },
 
1809
  }
1810
  },
1811
  "oracle_passed": true,
1812
+ "oracle_report_sha256": "c48f52e1a1080ff80955b08703b200ac005db8f918e84d48d51ba495ebfbc6c9",
1813
  "oracle_reward": 1.0,
1814
  "oracle_score": 1.0,
1815
  "oracle_successful_tool_calls": 20,
1816
+ "second_oracle_report_sha256": "c48f52e1a1080ff80955b08703b200ac005db8f918e84d48d51ba495ebfbc6c9",
1817
  "source_task_id": "tsk_saved_carts",
1818
  "wrong_token_rejected": true
1819
  },
 
1843
  }
1844
  },
1845
  "oracle_passed": true,
1846
+ "oracle_report_sha256": "88b5186251f762ab0efdea4068e6a087a62a539b2b98cb15b330ac54e32b2f1e",
1847
  "oracle_reward": 1.0,
1848
  "oracle_score": 1.0,
1849
  "oracle_successful_tool_calls": 13,
1850
+ "second_oracle_report_sha256": "88b5186251f762ab0efdea4068e6a087a62a539b2b98cb15b330ac54e32b2f1e",
1851
  "source_task_id": "tsk_search_autocomplete",
1852
  "wrong_token_rejected": true
1853
  },
 
1855
  "bench_id": "dob100-058-flaky-analytics-rollup",
1856
  "deterministic_replay_match": true,
1857
  "negative_executions": {
1858
+ "naive": {
1859
+ "failed_checks": [
1860
+ "required_tool_get_ci_run",
1861
+ "required_tool_get_document",
1862
+ "required_tool_search_docs"
1863
+ ],
1864
+ "passed": false
1865
+ },
1866
  "pristine": {
1867
  "failed_checks": [
1868
  "ci_all_stages_green",
 
1884
  }
1885
  },
1886
  "oracle_passed": true,
1887
+ "oracle_report_sha256": "283590adea2872ebfbd7c360359e7d7fad53e53a77a6102aa4c8090ba47436ac",
1888
  "oracle_reward": 1.0,
1889
  "oracle_score": 1.0,
1890
  "oracle_successful_tool_calls": 14,
1891
+ "second_oracle_report_sha256": "283590adea2872ebfbd7c360359e7d7fad53e53a77a6102aa4c8090ba47436ac",
1892
  "source_task_id": "tsk_flaky_analytics_rollup",
1893
  "wrong_token_rejected": true
1894
  },
 
1896
  "bench_id": "dob100-059-flaky-catalog-rounding",
1897
  "deterministic_replay_match": true,
1898
  "negative_executions": {
1899
+ "naive": {
1900
+ "failed_checks": [
1901
+ "required_tool_get_ci_run",
1902
+ "required_tool_get_document",
1903
+ "required_tool_search_docs"
1904
+ ],
1905
+ "passed": false
1906
+ },
1907
  "pristine": {
1908
  "failed_checks": [
1909
  "ci_all_stages_green",
 
1925
  }
1926
  },
1927
  "oracle_passed": true,
1928
+ "oracle_report_sha256": "6558d48631af9a2b67a3bfa643ee79f1fa4276f6ed732d8c06baee3383d2fdcb",
1929
  "oracle_reward": 1.0,
1930
  "oracle_score": 1.0,
1931
+ "oracle_successful_tool_calls": 15,
1932
+ "second_oracle_report_sha256": "6558d48631af9a2b67a3bfa643ee79f1fa4276f6ed732d8c06baee3383d2fdcb",
1933
  "source_task_id": "tsk_flaky_catalog_rounding",
1934
  "wrong_token_rejected": true
1935
  },
 
1937
  "bench_id": "dob100-060-flaky-checkout-idempotency",
1938
  "deterministic_replay_match": true,
1939
  "negative_executions": {
1940
+ "naive": {
1941
+ "failed_checks": [
1942
+ "required_tool_get_ci_run",
1943
+ "required_tool_get_document",
1944
+ "required_tool_search_docs"
1945
+ ],
1946
+ "passed": false
1947
+ },
1948
  "pristine": {
1949
  "failed_checks": [
1950
  "ci_all_stages_green",
 
1966
  }
1967
  },
1968
  "oracle_passed": true,
1969
+ "oracle_report_sha256": "7cde88330181f8a64d43982b5fa80e221a24ad6c18cb0663bc4e4bb6094b5639",
1970
  "oracle_reward": 1.0,
1971
  "oracle_score": 1.0,
1972
+ "oracle_successful_tool_calls": 15,
1973
+ "second_oracle_report_sha256": "7cde88330181f8a64d43982b5fa80e221a24ad6c18cb0663bc4e4bb6094b5639",
1974
  "source_task_id": "tsk_flaky_checkout_idempotency",
1975
  "wrong_token_rejected": true
1976
  },
 
1978
  "bench_id": "dob100-061-flaky-gateway-timeout",
1979
  "deterministic_replay_match": true,
1980
  "negative_executions": {
1981
+ "naive": {
1982
+ "failed_checks": [
1983
+ "required_tool_get_ci_run",
1984
+ "required_tool_get_document",
1985
+ "required_tool_search_docs"
1986
+ ],
1987
+ "passed": false
1988
+ },
1989
  "pristine": {
1990
  "failed_checks": [
1991
  "ci_all_stages_green",
 
2007
  }
2008
  },
2009
  "oracle_passed": true,
2010
+ "oracle_report_sha256": "46b559a39a76476e25c574ef9d444cce4ee80a76768a4a17cbada33286f296a5",
2011
  "oracle_reward": 1.0,
2012
  "oracle_score": 1.0,
2013
+ "oracle_successful_tool_calls": 15,
2014
+ "second_oracle_report_sha256": "46b559a39a76476e25c574ef9d444cce4ee80a76768a4a17cbada33286f296a5",
2015
  "source_task_id": "tsk_flaky_gateway_timeout",
2016
  "wrong_token_rejected": true
2017
  },
 
2019
  "bench_id": "dob100-062-flaky-inventory-race",
2020
  "deterministic_replay_match": true,
2021
  "negative_executions": {
2022
+ "naive": {
2023
+ "failed_checks": [
2024
+ "required_tool_get_ci_run",
2025
+ "required_tool_get_document",
2026
+ "required_tool_search_docs"
2027
+ ],
2028
+ "passed": false
2029
+ },
2030
  "pristine": {
2031
  "failed_checks": [
2032
  "ci_all_stages_green",
 
2048
  }
2049
  },
2050
  "oracle_passed": true,
2051
+ "oracle_report_sha256": "3a8663c2f1cddf59a534a5a3e0fe16a3a403ae94a22c62989b23dc3b8e155efe",
2052
  "oracle_reward": 1.0,
2053
  "oracle_score": 1.0,
2054
+ "oracle_successful_tool_calls": 15,
2055
+ "second_oracle_report_sha256": "3a8663c2f1cddf59a534a5a3e0fe16a3a403ae94a22c62989b23dc3b8e155efe",
2056
  "source_task_id": "tsk_flaky_inventory_race",
2057
  "wrong_token_rejected": true
2058
  },
 
2060
  "bench_id": "dob100-063-flaky-search-index",
2061
  "deterministic_replay_match": true,
2062
  "negative_executions": {
2063
+ "naive": {
2064
+ "failed_checks": [
2065
+ "required_tool_get_ci_run",
2066
+ "required_tool_get_document",
2067
+ "required_tool_search_docs"
2068
+ ],
2069
+ "passed": false
2070
+ },
2071
  "pristine": {
2072
  "failed_checks": [
2073
  "ci_all_stages_green",
 
2089
  }
2090
  },
2091
  "oracle_passed": true,
2092
+ "oracle_report_sha256": "309e07b85989ad7173884f409f16447d9597031c30e2f38807a24bbdbda83725",
2093
  "oracle_reward": 1.0,
2094
  "oracle_score": 1.0,
2095
+ "oracle_successful_tool_calls": 15,
2096
+ "second_oracle_report_sha256": "309e07b85989ad7173884f409f16447d9597031c30e2f38807a24bbdbda83725",
2097
  "source_task_id": "tsk_flaky_search_index",
2098
  "wrong_token_rejected": true
2099
  },
 
2173
  }
2174
  },
2175
  "oracle_passed": true,
2176
+ "oracle_report_sha256": "82cf512bd394f1891dad7ab6c20b709a668ca49b6e308e6cdb06cad14e540981",
2177
  "oracle_reward": 1.0,
2178
  "oracle_score": 1.0,
2179
  "oracle_successful_tool_calls": 7,
2180
+ "second_oracle_report_sha256": "82cf512bd394f1891dad7ab6c20b709a668ca49b6e308e6cdb06cad14e540981",
2181
  "source_task_id": "tsk_hz_checkout_flag_kill",
2182
  "wrong_token_rejected": true
2183
  },
 
2205
  }
2206
  },
2207
  "oracle_passed": true,
2208
+ "oracle_report_sha256": "7ded21f8dd6ca96c24ee55abf13050f789067c4c9af35adc10f9a58e327606f9",
2209
  "oracle_reward": 1.0,
2210
  "oracle_score": 1.0,
2211
  "oracle_successful_tool_calls": 7,
2212
+ "second_oracle_report_sha256": "7ded21f8dd6ca96c24ee55abf13050f789067c4c9af35adc10f9a58e327606f9",
2213
  "source_task_id": "tsk_hz_gateway_leak_rollback",
2214
  "wrong_token_rejected": true
2215
  },
 
2239
  }
2240
  },
2241
  "oracle_passed": true,
2242
+ "oracle_report_sha256": "fcfa3337fee72970d260c29430a39014140718925de09bed0ded74d908a26acc",
2243
  "oracle_reward": 1.0,
2244
  "oracle_score": 1.0,
2245
  "oracle_successful_tool_calls": 18,
2246
+ "second_oracle_report_sha256": "fcfa3337fee72970d260c29430a39014140718925de09bed0ded74d908a26acc",
2247
  "source_task_id": "tsk_gated_rotate_partner_credential",
2248
  "wrong_token_rejected": true
2249
  },
 
2251
  "bench_id": "dob100-069-judge-analytics-oom",
2252
  "deterministic_replay_match": true,
2253
  "negative_executions": {
2254
+ "naive": {
2255
+ "failed_checks": [
2256
+ "required_tool_get_document",
2257
+ "required_tool_search_docs"
2258
+ ],
2259
+ "passed": false
2260
+ },
2261
  "pristine": {
2262
  "failed_checks": [
2263
  "chose_the_root_cause_fix",
 
2271
  }
2272
  },
2273
  "oracle_passed": true,
2274
+ "oracle_report_sha256": "36552582e3707ef515cacdd569a6bf62ec4a233e1823cf7cb3ccf58da2f3feb8",
2275
  "oracle_reward": 1.0,
2276
  "oracle_score": 1.0,
2277
  "oracle_successful_tool_calls": 8,
2278
+ "second_oracle_report_sha256": "36552582e3707ef515cacdd569a6bf62ec4a233e1823cf7cb3ccf58da2f3feb8",
2279
  "source_task_id": "tsk_judge_analytics_oom",
2280
  "wrong_token_rejected": true
2281
  },
 
2283
  "bench_id": "dob100-070-judge-checkout-flag",
2284
  "deterministic_replay_match": true,
2285
  "negative_executions": {
2286
+ "naive": {
2287
+ "failed_checks": [
2288
+ "required_tool_get_document",
2289
+ "required_tool_search_docs"
2290
+ ],
2291
+ "passed": false
2292
+ },
2293
  "pristine": {
2294
  "failed_checks": [
2295
  "chose_the_root_cause_fix",
 
2303
  }
2304
  },
2305
  "oracle_passed": true,
2306
+ "oracle_report_sha256": "7160f641ddc9f7084af5e5ebf24f9c52f12f23bd5f03dd14e04b3451cb76c873",
2307
  "oracle_reward": 1.0,
2308
  "oracle_score": 1.0,
2309
  "oracle_successful_tool_calls": 8,
2310
+ "second_oracle_report_sha256": "7160f641ddc9f7084af5e5ebf24f9c52f12f23bd5f03dd14e04b3451cb76c873",
2311
  "source_task_id": "tsk_judge_checkout_flag",
2312
  "wrong_token_rejected": true
2313
  },
 
2340
  "bench_id": "dob100-072-judge-payments-retry",
2341
  "deterministic_replay_match": true,
2342
  "negative_executions": {
2343
+ "naive": {
2344
+ "failed_checks": [
2345
+ "required_tool_get_document",
2346
+ "required_tool_search_docs"
2347
+ ],
2348
+ "passed": false
2349
+ },
2350
  "pristine": {
2351
  "failed_checks": [
2352
  "chose_the_root_cause_fix",
 
2360
  }
2361
  },
2362
  "oracle_passed": true,
2363
+ "oracle_report_sha256": "0b5742605ebefd55fbf612bd961c256c540473e672fd50eee8371b466a7e7b04",
2364
  "oracle_reward": 1.0,
2365
  "oracle_score": 1.0,
2366
  "oracle_successful_tool_calls": 7,
2367
+ "second_oracle_report_sha256": "0b5742605ebefd55fbf612bd961c256c540473e672fd50eee8371b466a7e7b04",
2368
  "source_task_id": "tsk_judge_payments_retry",
2369
  "wrong_token_rejected": true
2370
  },
 
2396
  }
2397
  },
2398
  "oracle_passed": true,
2399
+ "oracle_report_sha256": "1945fbd35698559031d228a035f6e525f51347484355aa5b9ae214afc1627ff4",
2400
  "oracle_reward": 1.0,
2401
  "oracle_score": 1.0,
2402
  "oracle_successful_tool_calls": 19,
2403
+ "second_oracle_report_sha256": "1945fbd35698559031d228a035f6e525f51347484355aa5b9ae214afc1627ff4",
2404
  "source_task_id": "tsk_catalog_batch_pricing",
2405
  "wrong_token_rejected": true
2406
  },
 
2427
  }
2428
  },
2429
  "oracle_passed": true,
2430
+ "oracle_report_sha256": "edbf51f2ff7265d2fae43cc8f59744b4915c7f8bdc217baf764ec4278fe45330",
2431
  "oracle_reward": 1.0,
2432
  "oracle_score": 1.0,
2433
+ "oracle_successful_tool_calls": 15,
2434
+ "second_oracle_report_sha256": "edbf51f2ff7265d2fae43cc8f59744b4915c7f8bdc217baf764ec4278fe45330",
2435
  "source_task_id": "tsk_catalog_cache_ttl",
2436
  "wrong_token_rejected": true
2437
  },
 
2462
  }
2463
  },
2464
  "oracle_passed": true,
2465
+ "oracle_report_sha256": "a15925a2cc6fb02c08ceef8f3b61b474d17e537a3c3611285a595d355cb13e47",
2466
  "oracle_reward": 1.0,
2467
  "oracle_score": 1.0,
2468
  "oracle_successful_tool_calls": 18,
2469
+ "second_oracle_report_sha256": "a15925a2cc6fb02c08ceef8f3b61b474d17e537a3c3611285a595d355cb13e47",
2470
  "source_task_id": "tsk_catalog_pricing_from_code",
2471
  "wrong_token_rejected": true
2472
  },
 
2495
  }
2496
  },
2497
  "oracle_passed": true,
2498
+ "oracle_report_sha256": "ba15e0c48dbea4c39969901b0ab8208936a0a76200b4d85e27b7e398d8c6fc3e",
2499
  "oracle_reward": 1.0,
2500
  "oracle_score": 1.0,
2501
+ "oracle_successful_tool_calls": 17,
2502
+ "second_oracle_report_sha256": "ba15e0c48dbea4c39969901b0ab8208936a0a76200b4d85e27b7e398d8c6fc3e",
2503
  "source_task_id": "tsk_gateway_pool_reuse",
2504
  "wrong_token_rejected": true
2505
  },
 
2534
  }
2535
  },
2536
  "oracle_passed": true,
2537
+ "oracle_report_sha256": "73468546bdd3a1e2eb526218de190df7bfb1cfa7b0c8270d9db60fa58d714211",
2538
  "oracle_reward": 1.0,
2539
  "oracle_score": 1.0,
2540
  "oracle_successful_tool_calls": 15,
2541
+ "second_oracle_report_sha256": "73468546bdd3a1e2eb526218de190df7bfb1cfa7b0c8270d9db60fa58d714211",
2542
  "source_task_id": "tsk_gateway_v510_rollback",
2543
  "wrong_token_rejected": true
2544
  },
 
2570
  }
2571
  },
2572
  "oracle_passed": true,
2573
+ "oracle_report_sha256": "24b968ba1a19994f7d015a5b9ec8e05d682faf5dddd8731b0b2911876f42130b",
2574
  "oracle_reward": 1.0,
2575
  "oracle_score": 1.0,
2576
  "oracle_successful_tool_calls": 18,
2577
+ "second_oracle_report_sha256": "24b968ba1a19994f7d015a5b9ec8e05d682faf5dddd8731b0b2911876f42130b",
2578
  "source_task_id": "tsk_media_cdn",
2579
  "wrong_token_rejected": true
2580
  },
 
2606
  }
2607
  },
2608
  "oracle_passed": true,
2609
+ "oracle_report_sha256": "1fbf72516e230df482a499fa6d18f059de0bdd2712ff21944dbd2e1cb6c82da3",
2610
  "oracle_reward": 1.0,
2611
  "oracle_score": 1.0,
2612
+ "oracle_successful_tool_calls": 20,
2613
+ "second_oracle_report_sha256": "1fbf72516e230df482a499fa6d18f059de0bdd2712ff21944dbd2e1cb6c82da3",
2614
  "source_task_id": "tsk_search_cache",
2615
  "wrong_token_rejected": true
2616
  },
 
2637
  }
2638
  },
2639
  "oracle_passed": true,
2640
+ "oracle_report_sha256": "34563a9d352d7a4f8e7698e5f2efb9cc20f33685603b1f337f1163f65e3eb233",
2641
  "oracle_reward": 1.0,
2642
  "oracle_score": 1.0,
2643
+ "oracle_successful_tool_calls": 15,
2644
+ "second_oracle_report_sha256": "34563a9d352d7a4f8e7698e5f2efb9cc20f33685603b1f337f1163f65e3eb233",
2645
  "source_task_id": "tsk_search_shards",
2646
  "wrong_token_rejected": true
2647
  },
 
2681
  }
2682
  },
2683
  "oracle_passed": true,
2684
+ "oracle_report_sha256": "70c1b369df326cfa5edfb0432e0941925859702f89628ebcba2aeabfba9f47c4",
2685
  "oracle_reward": 1.0,
2686
  "oracle_score": 1.0,
2687
  "oracle_successful_tool_calls": 31,
2688
+ "second_oracle_report_sha256": "70c1b369df326cfa5edfb0432e0941925859702f89628ebcba2aeabfba9f47c4",
2689
  "source_task_id": "tsk_backorders",
2690
  "wrong_token_rejected": true
2691
  },
 
2724
  }
2725
  },
2726
  "oracle_passed": true,
2727
+ "oracle_report_sha256": "9515995f528a66b0e0fbb001d9a7cc42e5d64f58d9517bd29e4e479157566852",
2728
  "oracle_reward": 1.0,
2729
  "oracle_score": 1.0,
2730
  "oracle_successful_tool_calls": 26,
2731
+ "second_oracle_report_sha256": "9515995f528a66b0e0fbb001d9a7cc42e5d64f58d9517bd29e4e479157566852",
2732
  "source_task_id": "tsk_checkout_upsell",
2733
  "wrong_token_rejected": true
2734
  },
 
2769
  }
2770
  },
2771
  "oracle_passed": true,
2772
+ "oracle_report_sha256": "fcf85df3312f3693d18142555693395f71e7b2b2f33cfb769d0bc54652244637",
2773
  "oracle_reward": 1.0,
2774
  "oracle_score": 1.0,
2775
  "oracle_successful_tool_calls": 33,
2776
+ "second_oracle_report_sha256": "fcf85df3312f3693d18142555693395f71e7b2b2f33cfb769d0bc54652244637",
2777
  "source_task_id": "tsk_loyalty_points",
2778
  "wrong_token_rejected": true
2779
  },
 
2810
  }
2811
  },
2812
  "oracle_passed": true,
2813
+ "oracle_report_sha256": "6ed872dd23750100a2b29526833c7ed29902008fea2b181dcf593bc98f8516f7",
2814
  "oracle_reward": 1.0,
2815
  "oracle_score": 1.0,
2816
  "oracle_successful_tool_calls": 23,
2817
+ "second_oracle_report_sha256": "6ed872dd23750100a2b29526833c7ed29902008fea2b181dcf593bc98f8516f7",
2818
  "source_task_id": "tsk_media_pipeline",
2819
  "wrong_token_rejected": true
2820
  },
 
2847
  }
2848
  },
2849
  "oracle_passed": true,
2850
+ "oracle_report_sha256": "d09972a0dbdb677cf76d232158a1302fdcc610054eb04d456ba04bbbc688064b",
2851
  "oracle_reward": 1.0,
2852
  "oracle_score": 1.0,
2853
  "oracle_successful_tool_calls": 17,
2854
+ "second_oracle_report_sha256": "d09972a0dbdb677cf76d232158a1302fdcc610054eb04d456ba04bbbc688064b",
2855
  "source_task_id": "tsk_notification_templates",
2856
  "wrong_token_rejected": true
2857
  },
 
2882
  }
2883
  },
2884
  "oracle_passed": true,
2885
+ "oracle_report_sha256": "18fda88889243131f4d91c8f43095740610a0753434626dfc3ab573e40f46109",
2886
  "oracle_reward": 1.0,
2887
  "oracle_score": 1.0,
2888
  "oracle_successful_tool_calls": 17,
2889
+ "second_oracle_report_sha256": "18fda88889243131f4d91c8f43095740610a0753434626dfc3ab573e40f46109",
2890
  "source_task_id": "tsk_search_relevance",
2891
  "wrong_token_rejected": true
2892
  },
 
2922
  }
2923
  },
2924
  "oracle_passed": true,
2925
+ "oracle_report_sha256": "81eb9cbbbf257a5a0ca0804c73515c60af47d031f65ac1648c163b11e526ef04",
2926
  "oracle_reward": 1.0,
2927
  "oracle_score": 1.0,
2928
  "oracle_successful_tool_calls": 25,
2929
+ "second_oracle_report_sha256": "81eb9cbbbf257a5a0ca0804c73515c60af47d031f65ac1648c163b11e526ef04",
2930
  "source_task_id": "tsk_split_settlement",
2931
  "wrong_token_rejected": true
2932
  },
 
3107
  }
3108
  },
3109
  "oracle_passed": true,
3110
+ "oracle_report_sha256": "d865715c471f756cb2cbeb070a5869d83cdc7a760db5ebc02b53d6e29c4cd39c",
3111
  "oracle_reward": 1.0,
3112
  "oracle_score": 1.0,
3113
  "oracle_successful_tool_calls": 17,
3114
+ "second_oracle_report_sha256": "d865715c471f756cb2cbeb070a5869d83cdc7a760db5ebc02b53d6e29c4cd39c",
3115
  "source_task_id": "tsk_checkout_hardcoded_secret",
3116
  "wrong_token_rejected": true
3117
  },
 
3143
  }
3144
  },
3145
  "oracle_passed": true,
3146
+ "oracle_report_sha256": "25f11cdc3dc618d4f786edb1a9dedc0a1a10725e7736103c372dcbfb19b872ca",
3147
  "oracle_reward": 1.0,
3148
  "oracle_score": 1.0,
3149
  "oracle_successful_tool_calls": 16,
3150
+ "second_oracle_report_sha256": "25f11cdc3dc618d4f786edb1a9dedc0a1a10725e7736103c372dcbfb19b872ca",
3151
  "source_task_id": "tsk_cve_libpayproc",
3152
  "wrong_token_rejected": true
3153
  },
 
3176
  }
3177
  },
3178
  "oracle_passed": true,
3179
+ "oracle_report_sha256": "1cf6647f6afed2d79706c1c03eb4a978511a94146b637a840ebf0553577a66aa",
3180
  "oracle_reward": 1.0,
3181
  "oracle_score": 1.0,
3182
  "oracle_successful_tool_calls": 15,
3183
+ "second_oracle_report_sha256": "1cf6647f6afed2d79706c1c03eb4a978511a94146b637a840ebf0553577a66aa",
3184
  "source_task_id": "tsk_cve_pydantic",
3185
  "wrong_token_rejected": true
3186
  },
 
3212
  }
3213
  },
3214
  "oracle_passed": true,
3215
+ "oracle_report_sha256": "15b600f552468323d6921a9adbb7f345a9e07b01175ac77726a2bd96c8a61846",
3216
  "oracle_reward": 1.0,
3217
  "oracle_score": 1.0,
3218
+ "oracle_successful_tool_calls": 17,
3219
+ "second_oracle_report_sha256": "15b600f552468323d6921a9adbb7f345a9e07b01175ac77726a2bd96c8a61846",
3220
  "source_task_id": "tsk_cve_requests",
3221
  "wrong_token_rejected": true
3222
  },
 
3248
  }
3249
  },
3250
  "oracle_passed": true,
3251
+ "oracle_report_sha256": "31ff7de21db28df2f10df753466a38c291484612a3d84c4b03774247e0255faf",
3252
  "oracle_reward": 1.0,
3253
  "oracle_score": 1.0,
3254
  "oracle_successful_tool_calls": 17,
3255
+ "second_oracle_report_sha256": "31ff7de21db28df2f10df753466a38c291484612a3d84c4b03774247e0255faf",
3256
  "source_task_id": "tsk_cve_stripe_sdk",
3257
  "wrong_token_rejected": true
3258
  },
 
3281
  }
3282
  },
3283
  "oracle_passed": true,
3284
+ "oracle_report_sha256": "8e444cf729cb6e6893a278db9638f67abc0d12e308f5c4eb450e06a77745c752",
3285
  "oracle_reward": 1.0,
3286
  "oracle_score": 1.0,
3287
  "oracle_successful_tool_calls": 13,
3288
+ "second_oracle_report_sha256": "8e444cf729cb6e6893a278db9638f67abc0d12e308f5c4eb450e06a77745c752",
3289
  "source_task_id": "tsk_retire_debug_endpoint",
3290
  "wrong_token_rejected": true
3291
  },
 
3314
  }
3315
  },
3316
  "oracle_passed": true,
3317
+ "oracle_report_sha256": "c62dbe310789b65b9f690420168ff53dae06905c2b119fe22e6b345fee2f041e",
3318
  "oracle_reward": 1.0,
3319
  "oracle_score": 1.0,
3320
+ "oracle_successful_tool_calls": 14,
3321
+ "second_oracle_report_sha256": "c62dbe310789b65b9f690420168ff53dae06905c2b119fe22e6b345fee2f041e",
3322
  "source_task_id": "tsk_retire_metrics_endpoint",
3323
  "wrong_token_rejected": true
3324
  },
 
3351
  "failures": 0,
3352
  "wrong_token_rejections": 100
3353
  },
3354
+ "version": "2.0.0"
3355
  }
task_files/dob100-001-rca-analytics-egress-blocked/01-work-ticket.md ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 01 Work Ticket
2
+
3
+ ## tickets (187 rows)
4
+
5
+ ```json
6
+ [
7
+ {
8
+ "ticket_id": 9103,
9
+ "key": "ENG-2103",
10
+ "type": "bug",
11
+ "title": "Analytics worker restarting under queue load",
12
+ "description": "analytics-worker error_rate_pct is 6.0% against a 2.0% SLO (alarm 9609) Investigate the root cause, ship the fix through the standard workflow, and follow the deployment policy.",
13
+ "status": "open",
14
+ "priority": "high",
15
+ "assignee": "",
16
+ "service": "analytics-worker"
17
+ },
18
+ {
19
+ "ticket_id": 9108,
20
+ "key": "ENG-2108",
21
+ "type": "bug",
22
+ "title": "Analytics rollups run in batches large enough to amplify memory pressure",
23
+ "description": "large rollup batches amplify memory pressure on the consumer Investigate the root cause, ship the fix through the standard workflow, and follow the deployment policy.",
24
+ "status": "open",
25
+ "priority": "low",
26
+ "assignee": "",
27
+ "service": "analytics-worker"
28
+ },
29
+ {
30
+ "ticket_id": 9143,
31
+ "key": "ENG-2506",
32
+ "type": "bug",
33
+ "title": "Fix flaky test_rollup_window",
34
+ "description": "test_rollup_window fails intermittently in CI: the rollup window boundary is computed from the current clock.",
35
+ "status": "open",
36
+ "priority": "medium",
37
+ "assignee": "",
38
+ "service": "analytics-worker"
39
+ },
40
+ {
41
+ "ticket_id": 9158,
42
+ "key": "OPS-113",
43
+ "type": "incident",
44
+ "title": "Localize alarm 9609 (analytics-worker errors)",
45
+ "description": "Alarm 9609 is firing. Identify the responsible service and report the finding with submit_diagnosis. Read-only investigation.",
46
+ "status": "open",
47
+ "priority": "high",
48
+ "assignee": "",
49
+ "service": "analytics-worker"
50
+ },
51
+ {
52
+ "ticket_id": 9170,
53
+ "key": "OPS-160",
54
+ "type": "incident",
55
+ "title": "Root cause: analytics cannot read the replica since the rotation",
56
+ "description": "Perform a root-cause analysis for analytics-cannot-read-replica and report service, fault type and the offending key with submit_diagnosis. Read-only investigation.",
57
+ "status": "open",
58
+ "priority": "critical",
59
+ "assignee": "",
60
+ "service": "analytics-worker"
61
+ },
62
+ {
63
+ "ticket_id": 9173,
64
+ "key": "OPS-163",
65
+ "type": "incident",
66
+ "title": "Root cause: analytics connections are refused, not slow",
67
+ "description": "Perform a root-cause analysis for analytics-connection-refused and report service, fault type and the offending key with submit_diagnosis. Read-only investigation.",
68
+ "status": "open",
69
+ "priority": "critical",
70
+ "assignee": "",
71
+ "service": "analytics-worker"
72
+ },
73
+ {
74
+ "ticket_id": 9175,
75
+ "key": "OPS-151",
76
+ "type": "incident",
77
+ "title": "Root cause: the nightly reconciliation never runs",
78
+ "description": "Perform a root-cause analysis for analytics-recon-never-runs and report service, fault type and the offending key with submit_diagnosis. Read-only investigation.",
79
+ "status": "open",
80
+ "priority": "high",
81
+ "assignee": "",
82
+ "service": "analytics-worker"
83
+ },
84
+ {
85
+ "ticket_id": 9200,
86
+ "key": "OPS-116",
87
+ "type": "incident",
88
+ "title": "Localize alarm 9609 \u2014 the error tracker shows nothing",
89
+ "description": "Alarm 9609 is firing. Identify the responsible service and report the finding with submit_diagnosis. Read-only investigation.",
90
+ "status": "open",
91
+ "priority": "critical",
92
+ "assignee": "",
93
+ "service": "analytics-worker"
94
+ },
95
+ {
96
+ "ticket_id": 9209,
97
+ "key": "OPS-302",
98
+ "type": "incident",
99
+ "title": "Decide the remediation for the analytics crashloop",
100
+ "description": "analytics-worker is being OOMKilled and is in CrashLoopBackOff. Four remediations have been proposed.",
101
+ "status": "open",
102
+ "priority": "high",
103
+ "assignee": "",
104
+ "service": ""
105
+ },
106
+ {
107
+ "ticket_id": 9212,
108
+ "key": "SEC-908",
109
+ "type": "security",
110
+ "title": "Rotate the exposed partner API credential",
111
+ "description": "The partner API key was committed to the monorepo, so it must be treated as compromised and rotated in production. Rotation invalidates every existing partner session immediately and cannot be undone - a mistake locks partners out of production until a new key is issued.",
112
+ "status": "open",
113
+ "priority": "critical",
114
+ "assignee": "",
115
+ "service": "checkout"
116
+ },
117
+ {
118
+ "ticket_id": 9213,
119
+ "key": "SLO-7100",
120
+ "type": "task",
121
+ "title": "Is analytics-worker meeting its errors objective?",
122
+ "description": "Is analytics-worker meeting its errors objective?",
123
+ "status": "open",
124
+ "priority": "medium",
125
+ "assignee": "",
126
+ "service": "analytics-worker"
127
+ },
128
+ {
129
+ "ticket_id": 9225,
130
+ "key": "QA-7200",
131
+ "type": "task",
132
+ "title": "Is test_rollup_window intermittent, or did it fail for a reason?",
133
+ "description": "Is test_rollup_window intermittent, or did it fail for a reason?",
134
+ "status": "open",
135
+ "priority": "medium",
136
+ "assignee": "",
137
+ "service": "analytics-worker"
138
+ },
139
+ {
140
+ "ticket_id": 9248,
141
+ "key": "SUP-7500",
142
+ "type": "task",
143
+ "title": "Customer report: the numbers in this morning's report do not add up",
144
+ "description": "Customer report: the numbers in this morning's report do not add up",
145
+ "status": "open",
146
+ "priority": "high",
147
+ "assignee": "",
148
+ "service": "analytics-worker"
149
+ }
150
+ ]
151
+ ```
task_files/dob100-001-rca-analytics-egress-blocked/02-service-catalog.csv ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ source_table,depends_on,description,environment,key,kind,language,name,repo_version,service,service_id,team,tier,value
2
+ services,,Consumes the event queue and builds analytics rollups.,,,worker,python,analytics-worker,v2.1.7,,9010,platform,3,
3
+ service_dependencies,pg-replica,,,,database,,,,search,,,,
4
+ service_dependencies,rabbitmq,,,,queue,,,,analytics-worker,,,,
5
+ env_state,,,staging,cdn_enabled,config,,,,catalog,,,,true
6
+ env_state,,,production,cdn_enabled,config,,,,catalog,,,,true
7
+ env_state,,,staging,prefetch_count,config,,,,analytics-worker,,,,0
8
+ env_state,,,production,prefetch_count,config,,,,analytics-worker,,,,0
9
+ env_state,,,staging,batch_size,config,,,,analytics-worker,,,,500
10
+ env_state,,,production,batch_size,config,,,,analytics-worker,,,,500
11
+ env_state,,,staging,rollup_daily,module,,,,analytics-worker,,,,present
12
+ env_state,,,production,rollup_daily,module,,,,analytics-worker,,,,present
13
+ env_state,,,staging,current,version,,,,analytics-worker,,,,v2.1.7
14
+ env_state,,,production,current,version,,,,analytics-worker,,,,v2.1.7
task_files/dob100-001-rca-analytics-egress-blocked/03-observability.log ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"environment": "production", "metric": "error_rate_pct", "service": "analytics-worker", "source_table": "service_metrics", "value": 6.0}
2
+ {"environment": "production", "metric": "latency_p99_ms", "service": "analytics-worker", "source_table": "service_metrics", "value": 300.0}
3
+ {"environment": "production", "level": "ERROR", "log_id": 9021, "message": "consumer restarted after MemoryError; prefetch_count=0 means unlimited prefetch from rabbitmq", "service": "analytics-worker", "source_table": "logs"}
4
+ {"culprit": "src/analytics/consumer.py in run", "event_id": 5, "events": 1180, "fingerprint": "ana-oom", "service": "analytics-worker", "source_table": "error_events", "status": "unresolved", "title": "MemoryError: consumer restarted after OOM"}
5
+ {"counter_reset": 0, "day": 418, "label_env": "production", "label_service": "checkout_service", "metric": "http_requests_total:rate5m", "series_id": 1, "source_table": "prom_series", "value": 138.0}
6
+ {"counter_reset": 0, "day": 419, "label_env": "production", "label_service": "checkout_service", "metric": "http_requests_total:rate5m", "series_id": 2, "source_table": "prom_series", "value": 141.0}
7
+ {"counter_reset": 0, "day": 420, "label_env": "production", "label_service": "checkout_service", "metric": "http_requests_total:rate5m", "series_id": 3, "source_table": "prom_series", "value": 139.0}
8
+ {"counter_reset": 0, "day": 418, "label_env": "production", "label_service": "checkout_service", "metric": "http_errors_total:rate5m", "series_id": 4, "source_table": "prom_series", "value": 7.6}
9
+ {"events": 2317, "first_seen_day": 410, "issue_id": "CHECKOUT-1A", "last_seen_day": 420, "level": "error", "project_slug": "checkout-web", "source_table": "sentry_issues", "status": "unresolved", "title": "TypeError: NoneType has no attribute 'amount'", "users_affected": 890}
10
+ {"events": 1904, "first_seen_day": 409, "issue_id": "CHECKOUT-2B", "last_seen_day": 420, "level": "error", "project_slug": "checkout-web", "source_table": "sentry_issues", "status": "unresolved", "title": "TimeoutError: payments call exceeded 8000ms", "users_affected": 1502}
11
+ {"events": 18422, "first_seen_day": 405, "issue_id": "PAY-9C", "last_seen_day": 420, "level": "error", "project_slug": "payments-backend", "source_table": "sentry_issues", "status": "unresolved", "title": "ConnectionTimeout: notifications call exceeded 30000ms", "users_affected": 6210}
12
+ {"events": 640, "first_seen_day": 414, "issue_id": "SRCH-3D", "last_seen_day": 419, "level": "warning", "project_slug": "search", "source_table": "sentry_issues", "status": "resolved", "title": "IndexRefreshTimeout", "users_affected": 210}
task_files/dob100-001-rca-analytics-egress-blocked/04-incident-room.json ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "sources": [
3
+ {
4
+ "columns": [
5
+ "incident_id",
6
+ "severity",
7
+ "title",
8
+ "service",
9
+ "status",
10
+ "commander"
11
+ ],
12
+ "row_count": 3,
13
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
14
+ "table": "incidents",
15
+ "task_relevant_rows": [
16
+ {
17
+ "commander": "",
18
+ "incident_id": 9701,
19
+ "service": "api-gateway",
20
+ "severity": "sev1",
21
+ "status": "open",
22
+ "title": "API gateway latency surge after v5.1.0 rollout"
23
+ },
24
+ {
25
+ "commander": "",
26
+ "incident_id": 9702,
27
+ "service": "checkout",
28
+ "severity": "sev2",
29
+ "status": "open",
30
+ "title": "Checkout error spike since instant_refunds ramp"
31
+ },
32
+ {
33
+ "commander": "",
34
+ "incident_id": 9703,
35
+ "service": "inventory",
36
+ "severity": "sev2",
37
+ "status": "open",
38
+ "title": "Inventory reservation failures during peak"
39
+ }
40
+ ]
41
+ },
42
+ {
43
+ "columns": [
44
+ "alert_id",
45
+ "service",
46
+ "metric",
47
+ "severity",
48
+ "status",
49
+ "message"
50
+ ],
51
+ "row_count": 10,
52
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
53
+ "table": "alerts",
54
+ "task_relevant_rows": [
55
+ {
56
+ "alert_id": 9609,
57
+ "message": "analytics-worker error_rate_pct 6.0 exceeds SLO 2.0",
58
+ "metric": "error_rate_pct",
59
+ "service": "analytics-worker",
60
+ "severity": "medium",
61
+ "status": "firing"
62
+ }
63
+ ]
64
+ },
65
+ {
66
+ "columns": [
67
+ "incident_number",
68
+ "title",
69
+ "pd_service_id",
70
+ "urgency",
71
+ "priority",
72
+ "status",
73
+ "created_day",
74
+ "resolved_day"
75
+ ],
76
+ "row_count": 7,
77
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
78
+ "table": "pd_incidents",
79
+ "task_relevant_rows": [
80
+ {
81
+ "created_day": 411,
82
+ "incident_number": 5101,
83
+ "pd_service_id": "PSVC001",
84
+ "priority": "P2",
85
+ "resolved_day": 412,
86
+ "status": "resolved",
87
+ "title": "Elevated checkout latency",
88
+ "urgency": "high"
89
+ },
90
+ {
91
+ "created_day": 414,
92
+ "incident_number": 5102,
93
+ "pd_service_id": "PSVC002",
94
+ "priority": "P1",
95
+ "resolved_day": null,
96
+ "status": "triggered",
97
+ "title": "Payments error rate above SLO",
98
+ "urgency": "high"
99
+ },
100
+ {
101
+ "created_day": 416,
102
+ "incident_number": 5103,
103
+ "pd_service_id": "PSVC003",
104
+ "priority": "P1",
105
+ "resolved_day": null,
106
+ "status": "acknowledged",
107
+ "title": "Gateway latency surge after release",
108
+ "urgency": "high"
109
+ },
110
+ {
111
+ "created_day": 414,
112
+ "incident_number": 5104,
113
+ "pd_service_id": "PSVC004",
114
+ "priority": "P4",
115
+ "resolved_day": 415,
116
+ "status": "resolved",
117
+ "title": "Search index refresh lag",
118
+ "urgency": "low"
119
+ }
120
+ ]
121
+ },
122
+ {
123
+ "columns": [
124
+ "pd_service_id",
125
+ "name",
126
+ "escalation_policy",
127
+ "status"
128
+ ],
129
+ "row_count": 5,
130
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
131
+ "table": "pd_services",
132
+ "task_relevant_rows": [
133
+ {
134
+ "escalation_policy": "EP-Commerce",
135
+ "name": "checkout-api",
136
+ "pd_service_id": "PSVC001",
137
+ "status": "active"
138
+ },
139
+ {
140
+ "escalation_policy": "EP-Commerce",
141
+ "name": "payments-api",
142
+ "pd_service_id": "PSVC002",
143
+ "status": "active"
144
+ },
145
+ {
146
+ "escalation_policy": "EP-Platform",
147
+ "name": "edge-gateway",
148
+ "pd_service_id": "PSVC003",
149
+ "status": "active"
150
+ },
151
+ {
152
+ "escalation_policy": "EP-Growth",
153
+ "name": "search-svc",
154
+ "pd_service_id": "PSVC004",
155
+ "status": "active"
156
+ }
157
+ ]
158
+ },
159
+ {
160
+ "columns": [
161
+ "schedule_id",
162
+ "schedule_name",
163
+ "escalation_policy",
164
+ "user_name",
165
+ "day"
166
+ ],
167
+ "row_count": 4,
168
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
169
+ "table": "pd_oncall",
170
+ "task_relevant_rows": [
171
+ {
172
+ "day": 418,
173
+ "escalation_policy": "EP-Commerce",
174
+ "schedule_id": "SCHED-COM",
175
+ "schedule_name": "Commerce primary",
176
+ "user_name": "Diego Ramos"
177
+ },
178
+ {
179
+ "day": 419,
180
+ "escalation_policy": "EP-Commerce",
181
+ "schedule_id": "SCHED-COM",
182
+ "schedule_name": "Commerce primary",
183
+ "user_name": "Diego Ramos"
184
+ },
185
+ {
186
+ "day": 419,
187
+ "escalation_policy": "EP-Platform",
188
+ "schedule_id": "SCHED-PLT",
189
+ "schedule_name": "Platform primary",
190
+ "user_name": "Priya Nair"
191
+ },
192
+ {
193
+ "day": 419,
194
+ "escalation_policy": "EP-Growth",
195
+ "schedule_id": "SCHED-GRW",
196
+ "schedule_name": "Growth primary",
197
+ "user_name": "Mei Tanaka"
198
+ }
199
+ ]
200
+ }
201
+ ]
202
+ }
task_files/dob100-001-rca-analytics-egress-blocked/05-deployment-state.json ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "sources": [
3
+ {
4
+ "columns": [
5
+ "deployment_id",
6
+ "service",
7
+ "environment",
8
+ "version",
9
+ "status",
10
+ "canary_percent"
11
+ ],
12
+ "row_count": 22,
13
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
14
+ "table": "deployments",
15
+ "task_relevant_rows": [
16
+ {
17
+ "canary_percent": 100,
18
+ "deployment_id": 9271,
19
+ "environment": "staging",
20
+ "service": "analytics-worker",
21
+ "status": "succeeded",
22
+ "version": "v2.1.7"
23
+ },
24
+ {
25
+ "canary_percent": 100,
26
+ "deployment_id": 9272,
27
+ "environment": "production",
28
+ "service": "analytics-worker",
29
+ "status": "succeeded",
30
+ "version": "v2.1.7"
31
+ }
32
+ ]
33
+ },
34
+ {
35
+ "columns": [
36
+ "route_id",
37
+ "service",
38
+ "route",
39
+ "rps",
40
+ "share_pct"
41
+ ],
42
+ "row_count": 13,
43
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
44
+ "table": "traffic_profile",
45
+ "task_relevant_rows": [
46
+ {
47
+ "route": "queue:events",
48
+ "route_id": 9213,
49
+ "rps": 900,
50
+ "service": "analytics-worker",
51
+ "share_pct": 100
52
+ }
53
+ ]
54
+ },
55
+ {
56
+ "columns": [
57
+ "service",
58
+ "desired_replicas",
59
+ "ready_replicas",
60
+ "strategy",
61
+ "storage_class"
62
+ ],
63
+ "row_count": 10,
64
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
65
+ "table": "k8s_deployments",
66
+ "task_relevant_rows": [
67
+ {
68
+ "desired_replicas": 2,
69
+ "ready_replicas": 1,
70
+ "service": "analytics-worker",
71
+ "storage_class": "standard",
72
+ "strategy": "RollingUpdate"
73
+ }
74
+ ]
75
+ },
76
+ {
77
+ "columns": [
78
+ "pod",
79
+ "namespace",
80
+ "service",
81
+ "image_tag",
82
+ "phase",
83
+ "restarts",
84
+ "memory_limit_mb",
85
+ "memory_usage_mb",
86
+ "node",
87
+ "pending_reason"
88
+ ],
89
+ "row_count": 14,
90
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
91
+ "table": "k8s_pods",
92
+ "task_relevant_rows": [
93
+ {
94
+ "image_tag": "v2.1.7",
95
+ "memory_limit_mb": 512,
96
+ "memory_usage_mb": 511,
97
+ "namespace": "production",
98
+ "node": "node-a1",
99
+ "pending_reason": "",
100
+ "phase": "CrashLoopBackOff",
101
+ "pod": "analytics-worker-7d9f-x2k1",
102
+ "restarts": 47,
103
+ "service": "analytics-worker"
104
+ },
105
+ {
106
+ "image_tag": "v2.1.7",
107
+ "memory_limit_mb": 512,
108
+ "memory_usage_mb": 498,
109
+ "namespace": "production",
110
+ "node": "node-a1",
111
+ "pending_reason": "",
112
+ "phase": "Running",
113
+ "pod": "analytics-worker-7d9f-m4p8",
114
+ "restarts": 39,
115
+ "service": "analytics-worker"
116
+ },
117
+ {
118
+ "image_tag": "v2.1.7",
119
+ "memory_limit_mb": 512,
120
+ "memory_usage_mb": 0,
121
+ "namespace": "production",
122
+ "node": "",
123
+ "pending_reason": "0/4 nodes are available: 1 node(s) had untolerated taint {workload: batch}, 3 node(s) didn't match Pod's node affinity/selector",
124
+ "phase": "Pending",
125
+ "pod": "analytics-recon-6a1b-jj10",
126
+ "restarts": 0,
127
+ "service": "analytics-worker"
128
+ }
129
+ ]
130
+ },
131
+ {
132
+ "columns": [
133
+ "event_id",
134
+ "namespace",
135
+ "pod",
136
+ "reason",
137
+ "message",
138
+ "count",
139
+ "day"
140
+ ],
141
+ "row_count": 8,
142
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
143
+ "table": "k8s_events",
144
+ "task_relevant_rows": [
145
+ {
146
+ "count": 47,
147
+ "day": 419,
148
+ "event_id": 9001,
149
+ "message": "Container analytics exceeded its memory limit of 512Mi and was killed",
150
+ "namespace": "production",
151
+ "pod": "analytics-worker-7d9f-x2k1",
152
+ "reason": "OOMKilled"
153
+ },
154
+ {
155
+ "count": 47,
156
+ "day": 419,
157
+ "event_id": 9002,
158
+ "message": "Back-off restarting failed container analytics",
159
+ "namespace": "production",
160
+ "pod": "analytics-worker-7d9f-x2k1",
161
+ "reason": "CrashLoopBackOff"
162
+ },
163
+ {
164
+ "count": 39,
165
+ "day": 420,
166
+ "event_id": 9003,
167
+ "message": "Container analytics exceeded its memory limit of 512Mi and was killed",
168
+ "namespace": "production",
169
+ "pod": "analytics-worker-7d9f-m4p8",
170
+ "reason": "OOMKilled"
171
+ }
172
+ ]
173
+ }
174
+ ]
175
+ }
task_files/dob100-001-rca-analytics-egress-blocked/06-repository-context.txt ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"content": "\"\"\"Per-client rate limiting at the API gateway edge.\"\"\"\n\n\nclass TokenBucket:\n def __init__(self, capacity, refill_per_sec):\n raise NotImplementedError\n\n def allow(self, now_ms):\n \"\"\"True if a request may proceed, consuming one token.\"\"\"\n raise NotImplementedError\n", "file_id": 4, "language": "python", "loc": 10, "owner": "", "path": "src/gateway/token_bucket.py", "service": "api-gateway", "source_table": "repo_files"}
2
+ {"content": "\"\"\"Client for the notifications service.\n\npayments calls notifications synchronously after a capture succeeds; a\npermanent failure here fails the payment (see ``payments.capture``).\n\"\"\"\nfrom __future__ import annotations\n\nimport logging\nimport time\nimport uuid\n\nimport requests\n\nfrom payments import settings\n\nlog = logging.getLogger(__name__)\n\nNOTIFICATIONS_BASE_URL = settings.get(\"notifications_base_url\")\nNOTIFICATIONS_TIMEOUT_MS = settings.get(\"notifications_timeout_ms\")\n\n# NOTE(dramos): the tenacity retry wrapper around _post() was removed to hit the\n# Q3 receipt-latency deadline -- backoff sleeps were showing up in payments p99.\n# The knob stayed in config. It is 0 today, so _post() gets exactly one attempt\n# and a single downstream timeout permanently fails the order.\nNOTIFICATIONS_RETRY_MAX_ATTEMPTS = settings.get(\"notifications_retry_max_attempts\")\n\n\nclass PaymentNotificationError(RuntimeError):\n \"\"\"The receipt notification could not be delivered.\"\"\"\n\n\ndef _post(path, payload, correlation_id):\n return requests.post(\n \"%s%s\" % (NOTIFICATIONS_BASE_URL, path),\n json=payload,\n timeout=NOTIFICATIONS_TIMEOUT_MS / 1000.0,\n headers={\"X-Correlation-Id\": correlation_id, \"X-Source\": \"payments\"},\n )\n\n\ndef send_receipt(order_id, customer_email, amount_cents, currency=\"USD\"):\n \"\"\"Deliver a receipt. Raises PaymentNotificationError if it cannot.\"\"\"\n correlation_id = str(uuid.uuid4())\n payload = {\"template\": \"payment_receipt\", \"order_id\": order_id,\n \"to\": customer_email, \"amount_cents\": amount_cents,\n \"currency\": currency}\n\n attempt = 0\n while True:\n attempt += 1\n started = time.monotonic()\n try:\n response = _post(\"/v1/receipts\", payload, correlation_id)\n response.raise_for_status()\n log.info(\"receipt delivered order=%s attempt=%d\", order_id, attempt)\n return response.json()\n except requests.RequestException as exc:\n elapsed_ms = int((time.monotonic() - started) * 1000)\n if attempt > NOTIFICATIONS_RETRY_MAX_ATTEMPTS:\n log.error(\n \"ConnectionTimeout calling notifications after %dms - request \"\n \"failed permanently (retry_max_attempts=%d, no retry attempted); \"\n \"order %s marked failed\", elapsed_ms,\n NOTIFICATIONS_RETRY_MAX_ATTEMPTS, order_id)\n raise PaymentNotificationError(\"receipt undeliverable\") from exc\n backoff = min(0.2 * (2 ** (attempt - 1)), 2.0)\n log.warning(\"notifications call failed (attempt %d of %d) after %dms; \"\n \"retrying in %.1fs\", attempt,\n NOTIFICATIONS_RETRY_MAX_ATTEMPTS, elapsed_ms, backoff)\n time.sleep(backoff)\n", "file_id": 6, "language": "python", "loc": 70, "owner": "Diego Ramos", "path": "src/payments/notify_client.py", "service": "payments", "source_table": "repo_files"}
3
+ {"content": "\"\"\"Payment capture.\n\nMoves an authorized payment to \"captured\" with libpayproc, then emits the buyer\nreceipt. Idempotent on ``idempotency_key``: replaying a key returns the\noriginal capture rather than charging the card twice.\n\"\"\"\nfrom __future__ import annotations\n\nimport logging\nfrom dataclasses import dataclass\n\nimport libpayproc\n\nfrom payments import settings\nfrom payments.notify_client import PaymentNotificationError, send_receipt\nfrom payments.store import captures\n\nlog = logging.getLogger(__name__)\n\nCAPTURE_TIMEOUT_MS = settings.get(\"capture_timeout_ms\")\n\n\nclass CaptureDeclined(Exception):\n \"\"\"The upstream processor refused the capture.\"\"\"\n\n\n@dataclass(frozen=True)\nclass CaptureResult:\n order_id: str\n processor_ref: str\n amount_cents: int\n currency: str\n status: str\n\n\ndef capture_payment(order_id, auth_token, amount_cents, currency, idempotency_key):\n replay = captures.find_by_idempotency_key(idempotency_key)\n if replay is not None:\n log.info(\"capture replay order=%s key=%s\", order_id, idempotency_key)\n return replay\n\n client = libpayproc.Client(timeout_ms=CAPTURE_TIMEOUT_MS)\n try:\n upstream = client.capture(auth_token=auth_token, amount=amount_cents,\n currency=currency)\n except libpayproc.Declined as exc:\n log.warning(\"capture declined order=%s reason=%s\", order_id, exc.reason)\n captures.record_failure(order_id, idempotency_key, reason=exc.reason)\n raise CaptureDeclined(exc.reason) from exc\n except libpayproc.TransportError:\n log.exception(\"processor transport error order=%s\", order_id)\n raise\n\n result = CaptureResult(order_id, upstream.reference, amount_cents, currency,\n \"captured\")\n captures.persist(result, idempotency_key)\n\n # The receipt is part of the payment contract: if we cannot tell the buyer\n # the money moved, we do not treat the payment as complete.\n try:\n send_receipt(order_id, upstream.customer_email, amount_cents, currency)\n except PaymentNotificationError:\n log.error(\"receipt delivery failed order=%s; marking payment failed\", order_id)\n captures.mark_failed(order_id, reason=\"notification_undeliverable\")\n raise\n\n log.info(\"captured order=%s ref=%s amount=%d %s\", order_id, upstream.reference,\n amount_cents, currency)\n return result\n", "file_id": 7, "language": "python", "loc": 69, "owner": "Diego Ramos", "path": "src/payments/capture.py", "service": "payments", "source_table": "repo_files"}
4
+ {"content": "\"\"\"Checkout submit orchestration.\n\nOrder matters and is asserted by the integration suite: reserve inventory ->\ncapture payment -> persist order -> commit hold. If capture fails we release\nthe reservation first, otherwise stock leaks for the length of the hold TTL.\n\"\"\"\nfrom __future__ import annotations\n\nimport logging\nimport uuid\nfrom dataclasses import dataclass\n\nfrom checkout import cart as cart_mod\nfrom checkout import config\nfrom checkout.clients.inventory import InventoryClient\nfrom checkout.clients.payments import PaymentsClient\nfrom checkout.store import order_store\n\nlog = logging.getLogger(__name__)\n\ninventory = InventoryClient(timeout_ms=config.PAYMENT_TIMEOUT_MS)\npayments = PaymentsClient(\n base_url=config.PAYMENTS_BASE_URL, timeout_ms=config.PAYMENT_TIMEOUT_MS\n)\n\n\nclass CheckoutError(RuntimeError):\n pass\n\n\n@dataclass(frozen=True)\nclass SubmitResult:\n order_id: str\n total_cents: int\n replayed: bool\n\n\ndef submit_order(cart, idempotency_key, tax_rate=0.0, shipping_cents=0):\n existing = order_store.find_by_idempotency_key(idempotency_key)\n if existing is not None:\n log.info(\"submit replay cart=%s key=%s\", cart.cart_id, idempotency_key)\n return SubmitResult(existing.order_id, existing.total_cents, True)\n\n computed = cart_mod.totals(cart, tax_rate=tax_rate, shipping_cents=shipping_cents)\n order_id = \"ord_\" + uuid.uuid4().hex[:12]\n\n hold = inventory.reserve(\n order_id=order_id,\n lines=[(item.sku, item.quantity) for item in cart.items],\n )\n try:\n capture = payments.capture(\n order_id=order_id,\n amount_cents=computed[\"total_cents\"],\n currency=computed[\"currency\"],\n idempotency_key=idempotency_key,\n )\n except Exception:\n log.exception(\"capture failed order=%s; releasing hold %s\", order_id, hold.id)\n inventory.release(hold.id)\n raise CheckoutError(\"payment capture failed for order %s\" % order_id)\n\n order_store.persist(order_id=order_id, cart_id=cart.cart_id, totals=computed,\n processor_ref=capture.processor_ref,\n idempotency_key=idempotency_key)\n inventory.commit(hold.id)\n log.info(\"order submitted order=%s total=%d %s\", order_id,\n computed[\"total_cents\"], computed[\"currency\"])\n return SubmitResult(order_id, computed[\"total_cents\"], False)\n", "file_id": 13, "language": "python", "loc": 69, "owner": "Mei Tanaka", "path": "src/checkout/orchestrator.py", "service": "checkout", "source_table": "repo_files"}
5
+ {"content": "\"\"\"Integration coverage for checkout idempotency.\n\nSuite: integration. Tracked as flaky in CI under ENG-2401 -- reruns pass.\n\"\"\"\nfrom __future__ import annotations\n\nimport time\n\nimport pytest\n\nfrom checkout.orchestrator import submit_order\nfrom tests.helpers import make_cart, reset_orders\n\n\ndef build_idempotency_key(prefix=\"test\"):\n # One key per wall-clock second is plenty: the suite never runs two cases\n # inside the same second. (CI shards this suite across four workers, so it\n # very much does, and the workers then generate identical keys.)\n return \"%s-%d\" % (prefix, int(time.time()))\n\n\n@pytest.fixture(autouse=True)\ndef clean_orders():\n reset_orders()\n yield\n reset_orders()\n\n\ndef test_duplicate_submit_returns_same_order():\n key = build_idempotency_key()\n cart = make_cart(items=3, total_cents=4599)\n\n first = submit_order(cart, idempotency_key=key)\n second = submit_order(cart, idempotency_key=key)\n\n assert first.order_id == second.order_id\n assert second.replayed is True\n\n\ndef test_distinct_keys_create_distinct_orders():\n cart = make_cart(items=1, total_cents=1299)\n\n left = submit_order(cart, idempotency_key=build_idempotency_key(\"left\"))\n right = submit_order(cart, idempotency_key=build_idempotency_key(\"right\"))\n\n assert left.order_id != right.order_id\n\n\ndef test_capture_failure_releases_inventory(monkeypatch):\n cart = make_cart(items=2, total_cents=2500)\n released = []\n\n monkeypatch.setattr(\n \"checkout.orchestrator.inventory.release\", lambda hold_id: released.append(hold_id)\n )\n monkeypatch.setattr(\n \"checkout.orchestrator.payments.capture\",\n lambda **kwargs: (_ for _ in ()).throw(RuntimeError(\"upstream down\")),\n )\n\n with pytest.raises(Exception):\n submit_order(cart, idempotency_key=build_idempotency_key(\"fail\"))\n\n assert len(released) == 1\n", "file_id": 14, "language": "python", "loc": 64, "owner": "Mei Tanaka", "path": "tests/test_idempotency.py", "service": "checkout", "source_table": "repo_files"}
6
+ {"content": "\"\"\"Catalog domain models.\n\nPlain dataclasses on purpose: ORM row objects stay inside\n``catalog.repository`` so listing code cannot trigger lazy loading.\n\"\"\"\nfrom __future__ import annotations\n\nfrom dataclasses import dataclass, field\nfrom datetime import datetime\nfrom enum import Enum\n\n\nclass Availability(str, Enum):\n IN_STOCK = \"in_stock\"\n BACKORDER = \"backorder\"\n DISCONTINUED = \"discontinued\"\n\n\n@dataclass(frozen=True)\nclass Money:\n amount_cents: int\n currency: str = \"USD\"\n\n def __post_init__(self):\n if self.amount_cents < 0:\n raise ValueError(\"money cannot be negative: %d\" % self.amount_cents)\n\n\n@dataclass(frozen=True)\nclass Product:\n id: str\n sku: str\n title: str\n category_id: str\n availability: Availability = Availability.IN_STOCK\n attributes: dict = field(default_factory=dict)\n updated_at: datetime = None\n\n @property\n def is_orderable(self):\n return self.availability is not Availability.DISCONTINUED\n\n\n@dataclass(frozen=True)\nclass PriceRow:\n product_id: str\n list_price: Money\n sale_price: Money = None\n price_tier: str = \"standard\"\n\n @property\n def effective(self):\n if self.sale_price is not None and self.sale_price.amount_cents < self.list_price.amount_cents:\n return self.sale_price\n return self.list_price\n\n\n@dataclass(frozen=True)\nclass PricedProduct:\n product: Product\n price: PriceRow\n\n def to_dict(self):\n return {\"id\": self.product.id, \"sku\": self.product.sku,\n \"title\": self.product.title,\n \"availability\": self.product.availability.value,\n \"price_cents\": self.price.effective.amount_cents,\n \"currency\": self.price.effective.currency,\n \"tier\": self.price.price_tier}\n", "file_id": 16, "language": "python", "loc": 69, "owner": "Sam Whitfield", "path": "src/catalog/models.py", "service": "catalog", "source_table": "repo_files"}
7
+ {"content": "\"\"\"Query execution for product search.\n\nparse -> build the index query -> execute -> rank. The query cache sits in front\nof execution and normally absorbs the large majority of index load.\n\"\"\"\nfrom __future__ import annotations\n\nimport hashlib\nimport json\nimport logging\nimport time\n\nfrom search import ranking, settings\nfrom search.cache import RedisCache\nfrom search.index import IndexClient\n\nlog = logging.getLogger(__name__)\n\n# Turned off during the index-rebuild incident so cache writes would stop\n# amplifying load on the Redis cluster while we reshard. Flip back to true once\n# the rebuild lands. (Rebuild landed; this never got flipped back.)\nCACHE_ENABLED = settings.get(\"cache_enabled\", False)\nCACHE_TTL_S = settings.get(\"cache_ttl_s\", 300)\nINDEX_SHARDS = settings.get(\"index_shards\", 4)\n\ncache = RedisCache(namespace=\"search:q\")\nindex = IndexClient(shards=INDEX_SHARDS)\n\n\ndef cache_key(term, filters, page, size):\n document = {\"t\": term.strip().lower(), \"f\": filters or {}, \"p\": page, \"s\": size}\n payload = json.dumps(document, sort_keys=True, separators=(\",\", \":\"))\n return hashlib.sha1(payload.encode(\"utf-8\")).hexdigest()\n\n\ndef search(term, filters=None, page=0, size=24, user_segment=\"anon\"):\n started = time.monotonic()\n key = cache_key(term, filters, page, size)\n\n if CACHE_ENABLED:\n cached = cache.get(key)\n if cached is not None:\n log.debug(\"cache hit term=%r key=%s\", term, key)\n return cached\n else:\n log.warning(\n \"query cache disabled (cache_enabled=false); every request is hitting \"\n \"the primary index\"\n )\n\n hits = index.execute(term=term, filters=filters or {}, offset=page * size, limit=size)\n results = ranking.rank(hits, term=term, user_segment=user_segment)\n payload = {\"term\": term, \"page\": page, \"size\": size, \"total\": hits.total,\n \"results\": [r.to_dict() for r in results]}\n\n if CACHE_ENABLED:\n cache.set(key, payload, ttl_s=CACHE_TTL_S)\n\n elapsed_ms = int((time.monotonic() - started) * 1000)\n log.info(\n \"search term=%r hits=%d elapsed_ms=%d cache_enabled=%s\",\n term, hits.total, elapsed_ms, CACHE_ENABLED,\n )\n return payload\n\n\ndef invalidate(term, filters=None, page=0, size=24):\n cache.delete(cache_key(term, filters, page, size))\n", "file_id": 20, "language": "python", "loc": 68, "owner": "Mei Tanaka", "path": "src/search/query.py", "service": "search", "source_table": "repo_files"}
8
+ {"content": "\"\"\"Incremental indexer.\n\nApplies catalog change events to the index in bulk flushes. Deletes go before\nupserts inside a flush so a delete+recreate of the same SKU ends up present.\n\"\"\"\nfrom __future__ import annotations\n\nimport logging\nimport signal\nimport time\n\nfrom search import settings\nfrom search.index import IndexClient\nfrom search.stream import CatalogChangeStream\n\nlog = logging.getLogger(__name__)\n\nFLUSH_SIZE = settings.get(\"indexer_flush_size\", 500)\nFLUSH_INTERVAL_S = settings.get(\"indexer_flush_interval_s\", 5)\n\nindex = IndexClient(shards=settings.get(\"index_shards\", 4))\n_running = True\n\n\ndef _handle_sigterm(signum, frame):\n global _running\n log.info(\"SIGTERM received; draining indexer buffer\")\n _running = False\n\n\nsignal.signal(signal.SIGTERM, _handle_sigterm)\n\n\ndef _flush(upserts, deletes):\n if deletes:\n index.bulk_delete(deletes)\n if upserts:\n index.bulk_upsert(upserts)\n log.info(\"indexer flush upserts=%d deletes=%d\", len(upserts), len(deletes))\n\n\ndef run(stream=None):\n stream = stream or CatalogChangeStream(group=\"search-indexer\")\n upserts, deletes = [], []\n last_flush = time.monotonic()\n\n for event in stream:\n if event.kind == \"delete\":\n deletes.append(event.product_id)\n else:\n upserts.append(event.document)\n\n buffered = len(upserts) + len(deletes)\n due = (time.monotonic() - last_flush) >= FLUSH_INTERVAL_S\n if buffered >= FLUSH_SIZE or (buffered and due):\n try:\n _flush(upserts, deletes)\n except Exception:\n log.exception(\"flush failed; buffer retained for retry\")\n time.sleep(1.0)\n continue\n stream.commit(event.offset)\n upserts, deletes = [], []\n last_flush = time.monotonic()\n\n if not _running:\n break\n\n _flush(upserts, deletes)\n log.info(\"indexer stopped cleanly\")\n", "file_id": 22, "language": "python", "loc": 70, "owner": "Mei Tanaka", "path": "src/search/indexer.py", "service": "search", "source_table": "repo_files"}
9
+ {"content": "// Package proxy manages upstream connections for the API gateway.\n//\n// Rewritten in v5.1.0: every route now gets its own transport so per-route TLS\n// material and per-route timeouts are honoured.\npackage proxy\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"net\"\n\t\"net/http\"\n\t\"sync/atomic\"\n\t\"time\"\n\n\t\"github.com/novacart/api-gateway/internal/config\"\n\t\"github.com/novacart/api-gateway/internal/log\"\n)\n\nconst (\n\tdialTimeout = 2 * time.Second\n\tidleConnTimeout = 90 * time.Second\n\tmaxIdlePerHost = 64\n\thealthCheckEvery = 15 * time.Second\n)\n\n// Conn wraps a transport dedicated to a single upstream.\ntype Conn struct {\n\tUpstream string\n\tTransport *http.Transport\n\tclient *http.Client\n\tdone chan struct{}\n\tcreatedAt time.Time\n}\n\n// Pool hands out upstream connections.\ntype Pool struct {\n\tcfg *config.Upstreams\n\tinFlight int64\n}\n\nfunc NewPool(cfg *config.Upstreams) *Pool { return &Pool{cfg: cfg} }\n\n// Acquire builds a connection for the given upstream. Building a transport is\n// cheap, so v5.1.0 does it per request rather than keeping long-lived ones.\nfunc (p *Pool) Acquire(ctx context.Context, upstream string) (*Conn, error) {\n\tif upstream == \"\" {\n\t\treturn nil, fmt.Errorf(\"proxy: empty upstream\")\n\t}\n\tatomic.AddInt64(&p.inFlight, 1)\n\n\ttransport := &http.Transport{\n\t\tDialContext: (&net.Dialer{Timeout: dialTimeout}).DialContext,\n\t\tTLSClientConfig: p.cfg.TLSFor(upstream),\n\t\tMaxIdleConnsPerHost: maxIdlePerHost,\n\t\tIdleConnTimeout: idleConnTimeout,\n\t}\n\n\tc := &Conn{Upstream: upstream, Transport: transport, done: make(chan struct{}),\n\t\tclient: &http.Client{Transport: transport}, createdAt: time.Now()}\n\n\t// Watchdog: keep probing this upstream for as long as the connection lives.\n\tgo func() {\n\t\tticker := time.NewTicker(healthCheckEvery)\n\t\tdefer ticker.Stop()\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-ticker.C:\n\t\t\t\tp.probe(c)\n\t\t\tcase <-c.done:\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}()\n\n\tlog.Debugf(\"acquired upstream=%s in_flight=%d\", upstream, atomic.LoadInt64(&p.inFlight))\n\treturn c, nil\n}\n\n// Release closes the transport and stops the watchdog goroutine.\n//\n// NOTE: the v5.1.0 rewrite dropped the call to Release from Do -- the handler\n// returns as soon as it has the response. Nothing else calls it, so every\n// request leaves behind an idle transport plus a live watchdog goroutine.\nfunc (p *Pool) Release(c *Conn) {\n\tclose(c.done)\n\tc.Transport.CloseIdleConnections()\n\tatomic.AddInt64(&p.inFlight, -1)\n\tlog.Debugf(\"released upstream=%s age=%s\", c.Upstream, time.Since(c.createdAt))\n}\n\nfunc (p *Pool) probe(c *Conn) {\n\treq, _ := http.NewRequest(http.MethodHead, \"http://\"+c.Upstream+\"/healthz\", nil)\n\tif resp, err := c.client.Do(req); err == nil {\n\t\t_ = resp.Body.Close()\n\t}\n}\n\n// Do proxies a single request to the named upstream.\nfunc (p *Pool) Do(ctx context.Context, upstream string, req *http.Request) (*http.Response, error) {\n\tc, err := p.Acquire(ctx, upstream)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"acquire %s: %w\", upstream, err)\n\t}\n\n\tresp, err := c.client.Do(req.WithContext(ctx))\n\tif err != nil {\n\t\tlog.Errorf(\"upstream=%s request failed: %v\", upstream, err)\n\t\treturn nil, err\n\t}\n\treturn resp, nil\n}\n", "file_id": 25, "language": "go", "loc": 111, "owner": "Priya Nair", "path": "internal/proxy/pool.go", "service": "api-gateway", "source_table": "repo_files"}
10
+ {"content": "// Package router wires public API routes to their upstream services.\n//\n// Route table is declarative: handlers are generic proxies, and anything\n// route-specific (auth requirement, traffic weight, deprecation) lives in the\n// Route struct so the control plane can reason about it.\npackage router\n\nimport (\n\t\"net/http\"\n\n\t\"github.com/novacart/api-gateway/internal/handlers\"\n\t\"github.com/novacart/api-gateway/internal/middleware\"\n\t\"github.com/novacart/api-gateway/internal/proxy\"\n)\n\n// Route describes one public endpoint.\ntype Route struct {\n\tPath string\n\tMethods []string\n\tUpstream string\n\tAuthRequired bool\n\tDeprecated bool\n\tWeight int // percentage of traffic, resolved by the control plane\n}\n\n// Table is the canonical route list for the edge.\nvar Table = []Route{\n\t{Path: \"/v1/orders\", Methods: []string{\"GET\", \"POST\"}, Upstream: \"checkout.internal:8080\", AuthRequired: true, Weight: 100},\n\t{Path: \"/v2/orders\", Methods: []string{\"GET\", \"POST\", \"PATCH\"}, Upstream: \"checkout.internal:8080\", AuthRequired: true, Weight: 0},\n\t{Path: \"/v1/checkout\", Methods: []string{\"POST\"}, Upstream: \"checkout.internal:8080\", AuthRequired: true, Weight: 100},\n\t{Path: \"/v1/catalog\", Methods: []string{\"GET\"}, Upstream: \"catalog.internal:8080\", Weight: 100},\n\t{Path: \"/v1/search\", Methods: []string{\"GET\"}, Upstream: \"search.internal:8080\", Weight: 100},\n\t{Path: \"/v1/media\", Methods: []string{\"GET\"}, Upstream: \"media-service.internal:8080\", Weight: 100},\n\t{Path: \"/internal/debug\", Methods: []string{\"GET\"}, Upstream: \"\", Weight: 0},\n}\n\n// New builds the edge mux.\nfunc New(pool *proxy.Pool) http.Handler {\n\tmux := http.NewServeMux()\n\n\tfor _, route := range Table {\n\t\tr := route\n\t\tif r.Upstream == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tvar h http.Handler = handlers.NewProxyHandler(pool, r.Upstream, r.Path)\n\t\th = middleware.MethodFilter(r.Methods, h)\n\t\tif r.AuthRequired {\n\t\t\th = middleware.RequireToken(h)\n\t\t}\n\t\tif r.Deprecated {\n\t\t\th = middleware.DeprecationNotice(r.Path, h)\n\t\t}\n\t\th = middleware.RateLimit(h)\n\t\th = middleware.AccessLog(r.Path, h)\n\t\tmux.Handle(r.Path, h)\n\t}\n\n\tmux.Handle(\"/internal/debug\", handlers.Debug())\n\tmux.HandleFunc(\"/healthz\", func(w http.ResponseWriter, _ *http.Request) {\n\t\tw.WriteHeader(http.StatusOK)\n\t\t_, _ = w.Write([]byte(\"ok\"))\n\t})\n\treturn mux\n}\n", "file_id": 26, "language": "go", "loc": 65, "owner": "Tom Becker", "path": "internal/router/routes.go", "service": "api-gateway", "source_table": "repo_files"}
11
+ {"content": "package middleware\n\nimport (\n\t\"net\"\n\t\"net/http\"\n\t\"strconv\"\n\t\"sync\"\n\t\"time\"\n\n\t\"github.com/novacart/api-gateway/internal/config\"\n\t\"github.com/novacart/api-gateway/internal/log\"\n)\n\n// bucket is a token bucket for one client key.\ntype bucket struct {\n\ttokens float64\n\tlastSeen time.Time\n}\n\ntype limiter struct {\n\tmu sync.Mutex\n\tbuckets map[string]*bucket\n\trps float64\n\tburst float64\n}\n\nvar shared = func() *limiter {\n\tcfg, err := config.Load()\n\trps := 500\n\tif err == nil && cfg.RateLimitRPS > 0 {\n\t\trps = cfg.RateLimitRPS\n\t}\n\treturn &limiter{\n\t\tbuckets: make(map[string]*bucket),\n\t\trps: float64(rps),\n\t\tburst: float64(rps) * 1.5,\n\t}\n}()\n\nfunc clientKey(r *http.Request) string {\n\tif token := r.Header.Get(\"X-Api-Client\"); token != \"\" {\n\t\treturn token\n\t}\n\tif host, _, err := net.SplitHostPort(r.RemoteAddr); err == nil {\n\t\treturn host\n\t}\n\treturn r.RemoteAddr\n}\n\nfunc (l *limiter) allow(key string) bool {\n\tnow := time.Now()\n\tl.mu.Lock()\n\tdefer l.mu.Unlock()\n\n\tb, ok := l.buckets[key]\n\tif !ok {\n\t\tl.buckets[key] = &bucket{tokens: l.burst - 1, lastSeen: now}\n\t\treturn true\n\t}\n\tb.tokens += now.Sub(b.lastSeen).Seconds() * l.rps\n\tif b.tokens > l.burst {\n\t\tb.tokens = l.burst\n\t}\n\tb.lastSeen = now\n\tif b.tokens < 1 {\n\t\treturn false\n\t}\n\tb.tokens--\n\treturn true\n}\n\n// RateLimit rejects callers over their per-client budget with a 429.\nfunc RateLimit(next http.Handler) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tkey := clientKey(r)\n\t\tif !shared.allow(key) {\n\t\t\tlog.Warnf(\"rate limited client=%s path=%s\", key, r.URL.Path)\n\t\t\tw.Header().Set(\"Retry-After\", strconv.Itoa(1))\n\t\t\thttp.Error(w, \"rate limit exceeded\", http.StatusTooManyRequests)\n\t\t\treturn\n\t\t}\n\t\tnext.ServeHTTP(w, r)\n\t})\n}\n", "file_id": 28, "language": "go", "loc": 84, "owner": "Priya Nair", "path": "internal/middleware/ratelimit.go", "service": "api-gateway", "source_table": "repo_files"}
12
+ {"content": "\"\"\"Image variant generation.\n\nUploads land as a single original; this module derives the responsive ladder\n(``320w`` through ``1600w``) plus a WebP twin for each rung. Work is idempotent:\nre-running a transcode over an existing variant is a no-op unless the source\netag changed.\n\"\"\"\nfrom __future__ import annotations\n\nimport io\nimport logging\n\nfrom PIL import Image, UnidentifiedImageError\n\nfrom media import settings\nfrom media.store import ObjectStore\n\nlog = logging.getLogger(__name__)\n\nLADDER = (320, 640, 800, 1200, 1600)\nJPEG_QUALITY = settings.get(\"jpeg_quality\", 82)\nWEBP_QUALITY = settings.get(\"webp_quality\", 78)\nMAX_SOURCE_BYTES = settings.get(\"max_source_bytes\", 25 * 1024 * 1024)\n\nstore = ObjectStore(bucket=settings.get(\"origin_bucket\", \"novacart-media-prod\"))\n\n\nclass TranscodeError(RuntimeError):\n pass\n\n\ndef _resize(image, width):\n if image.width <= width:\n return image.copy()\n height = round(image.height * (width / image.width))\n return image.resize((width, height), Image.LANCZOS)\n\n\ndef _encode(image, fmt):\n buffer = io.BytesIO()\n quality = WEBP_QUALITY if fmt == \"WEBP\" else JPEG_QUALITY\n image.convert(\"RGB\").save(buffer, format=fmt, quality=quality, optimize=True)\n return buffer.getvalue()\n\n\ndef transcode(asset_id, source_key, source_etag):\n raw = store.get(source_key)\n if len(raw) > MAX_SOURCE_BYTES:\n raise TranscodeError(\n \"source %s is %d bytes, over the %d limit\" % (source_key, len(raw), MAX_SOURCE_BYTES)\n )\n try:\n original = Image.open(io.BytesIO(raw))\n original.load()\n except UnidentifiedImageError as exc:\n raise TranscodeError(\"unreadable source %s\" % source_key) from exc\n\n written = []\n for width in LADDER:\n resized = _resize(original, width)\n for fmt, ext in ((\"JPEG\", \"jpg\"), (\"WEBP\", \"webp\")):\n key = \"assets/%s/%dw.%s\" % (asset_id, width, ext)\n if store.etag(key) == source_etag:\n log.debug(\"variant %s already current; skipping\", key)\n continue\n store.put(key, _encode(resized, fmt), metadata={\"source_etag\": source_etag})\n written.append(key)\n\n log.info(\"transcoded asset=%s variants=%d source=%s\", asset_id, len(written), source_key)\n return written\n", "file_id": 33, "language": "python", "loc": 70, "owner": "Sam Whitfield", "path": "src/media/transcode.py", "service": "media-service", "source_table": "repo_files"}
13
+ {"content": "\"\"\"Event queue consumer: reads events off RabbitMQ, batches them, and hands\nthe batches to the aggregation pipeline.\"\"\"\nimport logging\nimport signal\nimport time\n\nimport pika\n\nfrom analytics import aggregates, settings\n\nlog = logging.getLogger(__name__)\n\nQUEUE_NAME = settings.get(\"queue_name\", \"analytics.events\")\nAMQP_URL = settings.get(\"amqp_url\", \"amqp://analytics:analytics@rabbit.internal:5672/%2f\")\nBATCH_SIZE = settings.get(\"batch_size\", 500)\nFLUSH_INTERVAL_S = settings.get(\"flush_interval_s\", 10)\n\n# Prefetch is the number of unacked messages the broker will push to us. Raised\n# from 200 to \"no limit\" so a slow flush cannot stall delivery -- but 0 means\n# unlimited in AMQP, so the broker streams the whole backlog into this process.\nPREFETCH_COUNT = settings.get(\"prefetch_count\", 0)\n\n_running = True\n\n\ndef _stop(signum, frame):\n global _running\n log.info(\"signal %s received; draining consumer\", signum)\n _running = False\n\n\nsignal.signal(signal.SIGTERM, _stop)\n\n\ndef run():\n params = pika.URLParameters(AMQP_URL)\n params.heartbeat = 30\n connection = pika.BlockingConnection(params)\n channel = connection.channel()\n channel.queue_declare(queue=QUEUE_NAME, durable=True)\n channel.basic_qos(prefetch_count=PREFETCH_COUNT)\n log.info(\"consumer attached queue=%s prefetch_count=%d batch_size=%d\",\n QUEUE_NAME, PREFETCH_COUNT, BATCH_SIZE)\n\n buffer = []\n last_flush = time.monotonic()\n\n try:\n for method, _props, body in channel.consume(QUEUE_NAME, inactivity_timeout=1.0):\n if method is not None:\n buffer.append((method.delivery_tag, body))\n\n due = buffer and (time.monotonic() - last_flush) >= FLUSH_INTERVAL_S\n if len(buffer) >= BATCH_SIZE or due:\n tag = buffer[-1][0]\n try:\n aggregates.ingest([payload for _, payload in buffer])\n channel.basic_ack(delivery_tag=tag, multiple=True)\n except Exception:\n log.exception(\"aggregation failed; nacking %d\", len(buffer))\n channel.basic_nack(tag, multiple=True, requeue=True)\n buffer = []\n last_flush = time.monotonic()\n\n if not _running:\n break\n finally:\n channel.cancel()\n connection.close()\n log.info(\"consumer stopped; %d messages unflushed\", len(buffer))\n", "file_id": 34, "language": "python", "loc": 70, "owner": "Ravi Shah", "path": "src/analytics/consumer.py", "service": "analytics-worker", "source_table": "repo_files"}
14
+ {"content": "\"\"\"Rollup pipeline.\n\nNormalizes JSON events, folds them into per-minute counters and writes those to\nthe warehouse staging table. Everything is additive, so replaying a batch is\nsafe as long as event ids are unique (the collector guarantees that).\n\"\"\"\nfrom __future__ import annotations\n\nimport collections\nimport json\nimport logging\nfrom datetime import datetime, timezone\n\nfrom analytics import settings\nfrom analytics.warehouse import StagingWriter\n\nlog = logging.getLogger(__name__)\n\nKNOWN_EVENTS = frozenset({\"page_view\", \"product_view\", \"add_to_cart\",\n \"checkout_started\", \"order_placed\", \"search_performed\",\n \"refund_issued\"})\nDROP_UNKNOWN = settings.get(\"drop_unknown_events\", True)\n\nwriter = StagingWriter(table=settings.get(\"staging_table\", \"events_minute\"))\n\n\ndef _minute_bucket(epoch_ms):\n moment = datetime.fromtimestamp(epoch_ms / 1000.0, tz=timezone.utc)\n return moment.replace(second=0, microsecond=0)\n\n\ndef _parse(payload):\n try:\n event = json.loads(payload)\n except (ValueError, TypeError):\n log.warning(\"undecodable event payload of %d bytes\", len(payload or b\"\"))\n return None\n if \"type\" not in event or \"ts_ms\" not in event:\n log.warning(\"event missing required fields: %s\", sorted(event)[:6])\n return None\n if event[\"type\"] not in KNOWN_EVENTS:\n if DROP_UNKNOWN:\n return None\n log.info(\"passing through unknown event type %s\", event[\"type\"])\n return event\n\n\ndef ingest(payloads):\n counters = collections.Counter()\n revenue = collections.Counter()\n dropped = 0\n\n for payload in payloads:\n event = _parse(payload)\n if event is None:\n dropped += 1\n continue\n bucket = _minute_bucket(event[\"ts_ms\"])\n key = (bucket, event[\"type\"], event.get(\"channel\", \"web\"))\n counters[key] += 1\n if event[\"type\"] == \"order_placed\":\n revenue[key] += int(event.get(\"total_cents\", 0))\n\n rows = [{\"minute\": bucket.isoformat(), \"event_type\": event_type,\n \"channel\": channel, \"count\": count,\n \"revenue_cents\": revenue[(bucket, event_type, channel)]}\n for (bucket, event_type, channel), count in sorted(counters.items())]\n writer.write(rows)\n log.info(\"ingested events=%d rows=%d dropped=%d\", len(payloads), len(rows), dropped)\n return len(rows)\n", "file_id": 35, "language": "python", "loc": 70, "owner": "Nina Kowalski", "path": "src/analytics/aggregates.py", "service": "analytics-worker", "source_table": "repo_files"}
15
+ {"content": "\"\"\"Template registry and rendering.\n\nTemplates are Jinja files on disk under ``templates/<name>/``; each directory\nholds ``subject.txt``, ``body.html`` and ``body.txt``. Rendering is strict --\nan undefined variable is an error, not an empty string, because a receipt with\na blank amount is worse than a bounced send.\n\"\"\"\nfrom __future__ import annotations\n\nimport functools\nimport logging\nimport os\n\nfrom jinja2 import Environment, FileSystemLoader, StrictUndefined, TemplateNotFound\n\nfrom notifications import settings\n\nlog = logging.getLogger(__name__)\n\nTEMPLATE_ROOT = settings.get(\"template_root\", \"/srv/notifications/templates\")\nDEFAULT_LOCALE = settings.get(\"default_locale\", \"en-US\")\n\nREQUIRED_FILES = (\"subject.txt\", \"body.html\", \"body.txt\")\n\n\nclass TemplateError(RuntimeError):\n pass\n\n\n@functools.lru_cache(maxsize=1)\ndef _env():\n env = Environment(\n loader=FileSystemLoader(TEMPLATE_ROOT),\n undefined=StrictUndefined,\n autoescape=True,\n trim_blocks=True,\n lstrip_blocks=True,\n )\n env.filters[\"money\"] = lambda cents: \"%d.%02d\" % (cents // 100, cents % 100)\n return env\n\n\ndef available():\n if not os.path.isdir(TEMPLATE_ROOT):\n log.error(\"template root %s does not exist\", TEMPLATE_ROOT)\n return []\n names = []\n for entry in sorted(os.listdir(TEMPLATE_ROOT)):\n path = os.path.join(TEMPLATE_ROOT, entry)\n if all(os.path.exists(os.path.join(path, f)) for f in REQUIRED_FILES):\n names.append(entry)\n else:\n log.warning(\"template %s is incomplete; skipping\", entry)\n return names\n\n\ndef render(name, variables, locale=None):\n locale = locale or DEFAULT_LOCALE\n context = dict(variables, locale=locale)\n try:\n subject = _env().get_template(\"%s/subject.txt\" % name).render(context).strip()\n html = _env().get_template(\"%s/body.html\" % name).render(context)\n text = _env().get_template(\"%s/body.txt\" % name).render(context)\n except TemplateNotFound as exc:\n log.error(\"template %s missing file %s\", name, exc.name)\n raise TemplateError(\"template %s is not installed\" % name) from exc\n\n log.debug(\"rendered template=%s locale=%s subject=%r\", name, locale, subject)\n return subject, html, text\n", "file_id": 37, "language": "python", "loc": 69, "owner": "Alex Osei", "path": "src/notifications/templates.py", "service": "notifications", "source_table": "repo_files"}
16
+ {"content": "\"\"\"Delivery queue.\n\nCallers enqueue; workers pop and hand off to ``sender.send``. Failures retry\nwith exponential backoff up to ``MAX_ATTEMPTS``, then park on the DLQ.\n\"\"\"\nfrom __future__ import annotations\n\nimport json\nimport logging\nimport random\nimport time\n\nimport redis\n\nfrom notifications import settings\nfrom notifications.sender import DeliveryError, send\n\nlog = logging.getLogger(__name__)\n\nQUEUE_KEY = \"notifications:outbound\"\nDLQ_KEY = \"notifications:dead\"\nMAX_ATTEMPTS = settings.get(\"max_attempts\", 5)\nBASE_BACKOFF_S = settings.get(\"base_backoff_s\", 0.5)\n\nclient = redis.Redis.from_url(settings.get(\"redis_url\", \"redis://redis.internal:6379/2\"))\n\n\ndef enqueue(template, to, variables, correlation_id=None):\n message = {\"template\": template, \"to\": to, \"variables\": variables,\n \"correlation_id\": correlation_id, \"attempts\": 0}\n client.lpush(QUEUE_KEY, json.dumps(message))\n log.debug(\"enqueued template=%s to=%s\", template, to)\n\n\ndef _backoff(attempts):\n ceiling = BASE_BACKOFF_S * (2 ** attempts)\n return min(ceiling, 30.0) * (0.5 + random.random() / 2.0)\n\n\ndef _requeue(message):\n message[\"attempts\"] += 1\n if message[\"attempts\"] >= MAX_ATTEMPTS:\n client.lpush(DLQ_KEY, json.dumps(message))\n log.error(\"message parked on DLQ template=%s to=%s attempts=%d\",\n message[\"template\"], message[\"to\"], message[\"attempts\"])\n return\n time.sleep(_backoff(message[\"attempts\"]))\n client.lpush(QUEUE_KEY, json.dumps(message))\n\n\ndef work_once(timeout_s=5):\n popped = client.brpop(QUEUE_KEY, timeout=timeout_s)\n if popped is None:\n return False\n message = json.loads(popped[1])\n try:\n send(message[\"template\"], message[\"to\"], message[\"variables\"],\n correlation_id=message.get(\"correlation_id\"))\n except DeliveryError:\n log.warning(\"delivery failed; requeueing template=%s\", message[\"template\"])\n _requeue(message)\n return True\n\n\ndef run_forever():\n log.info(\"notification worker online queue=%s max_attempts=%d\", QUEUE_KEY, MAX_ATTEMPTS)\n while True:\n work_once()\n", "file_id": 38, "language": "python", "loc": 68, "owner": "Priya Nair", "path": "src/notifications/queue.py", "service": "notifications", "source_table": "repo_files"}
17
+ {"content": "\"use client\";\n\nimport { useMemo } from \"react\";\n\nimport { formatMoney } from \"@/lib/money\";\nimport { useCart } from \"@/lib/hooks/useCart\";\nimport type { CartLine, CartTotals } from \"@/lib/types\";\n\ninterface CartSummaryProps {\n compact?: boolean;\n onCheckout?: () => void;\n}\n\nfunction computeTotals(lines: CartLine[], taxRate: number): CartTotals {\n const subtotalCents = lines.reduce((sum, l) => sum + l.quantity * l.unitPriceCents, 0);\n const discountCents = lines.reduce((sum, l) => sum + (l.discountCents ?? 0), 0);\n const taxableCents = Math.max(subtotalCents - discountCents, 0);\n const taxCents = Math.round(taxableCents * taxRate);\n return { subtotalCents, discountCents, taxCents, totalCents: taxableCents + taxCents };\n}\n\nexport function CartSummary({ compact = false, onCheckout }: CartSummaryProps) {\n const { lines, taxRate, currency, isLoading, error } = useCart();\n\n // Totals are recomputed on every keystroke in the promo field otherwise.\n const totals = useMemo(() => computeTotals(lines, taxRate), [lines, taxRate]);\n\n if (isLoading) return <div className=\"cart-summary--loading\" aria-busy=\"true\" />;\n\n if (error) {\n return (\n <div className=\"cart-summary cart-summary--error\" role=\"alert\">\n We could not load your cart. Refresh the page or try again shortly.\n </div>\n );\n }\n\n return (\n <aside className={compact ? \"cart-summary cart-summary--compact\" : \"cart-summary\"}>\n <h2 className=\"cart-summary__title\">Order summary</h2>\n <dl className=\"cart-summary__rows\">\n <div>\n <dt>Subtotal</dt>\n <dd>{formatMoney(totals.subtotalCents, currency)}</dd>\n </div>\n <div>\n <dt>Estimated tax</dt>\n <dd>{formatMoney(totals.taxCents, currency)}</dd>\n </div>\n </dl>\n <p className=\"cart-summary__total\">\n <span>Total</span>\n <strong>{formatMoney(totals.totalCents, currency)}</strong>\n </p>\n <button\n type=\"button\"\n className=\"cart-summary__cta\"\n onClick={onCheckout}\n disabled={lines.length === 0}\n >\n Checkout\n </button>\n </aside>\n );\n}\n", "file_id": 39, "language": "typescript", "loc": 65, "owner": "Nina Kowalski", "path": "src/components/CartSummary.tsx", "service": "storefront-web", "source_table": "repo_files"}
18
+ {"additions": 104, "author": "Ravi Shah", "commit_id": 41, "day": 43, "deletions": 0, "files": "src/analytics/consumer.py", "message": "analytics-worker: AMQP consumer skeleton", "service": "analytics-worker", "sha": "2db947c", "source_table": "commits"}
19
+ {"additions": 113, "author": "Nina Kowalski", "commit_id": 42, "day": 44, "deletions": 0, "files": "src/analytics/aggregates.py", "message": "analytics-worker: per-minute rollups into warehouse staging", "service": "analytics-worker", "sha": "b6e0851", "source_table": "commits"}
20
+ {"additions": 19, "author": "Ravi Shah", "commit_id": 53, "day": 55, "deletions": 12, "files": "src/analytics/consumer.py", "message": "analytics-worker: ack batches with multiple=true", "service": "analytics-worker", "sha": "b25a9d8", "source_table": "commits"}
21
+ {"additions": 26, "author": "Nina Kowalski", "commit_id": 67, "day": 70, "deletions": 6, "files": "src/analytics/aggregates.py", "message": "analytics-worker: drop unknown event types by default", "service": "analytics-worker", "sha": "b1f6e82", "source_table": "commits"}
22
+ {"additions": 11, "author": "Ravi Shah", "commit_id": 77, "day": 80, "deletions": 3, "files": "src/analytics/consumer.py", "message": "analytics-worker: heartbeat every 30s to survive slow flushes", "service": "analytics-worker", "sha": "f7a2065", "source_table": "commits"}
23
+ {"additions": 23, "author": "Nina Kowalski", "commit_id": 91, "day": 94, "deletions": 7, "files": "src/analytics/aggregates.py", "message": "analytics-worker: revenue counters alongside event counts", "service": "analytics-worker", "sha": "6c05b7f", "source_table": "commits"}
24
+ {"additions": 8, "author": "Ravi Shah", "commit_id": 102, "day": 105, "deletions": 3, "files": "src/analytics/consumer.py", "message": "analytics-worker: prefetch 200 to bound consumer memory", "service": "analytics-worker", "sha": "ec1904b", "source_table": "commits"}
25
+ {"additions": 16, "author": "Nina Kowalski", "commit_id": 113, "day": 116, "deletions": 7, "files": "src/analytics/consumer.py", "message": "analytics-worker: nack the whole batch when aggregation throws", "service": "analytics-worker", "sha": "35a8c92", "source_table": "commits"}
26
+ {"additions": 19, "author": "Ravi Shah", "commit_id": 122, "day": 125, "deletions": 8, "files": "src/analytics/consumer.py", "message": "analytics-worker: flush on a 10s timer as well as on size", "service": "analytics-worker", "sha": "1fc48ab", "source_table": "commits"}
27
+ {"additions": 14, "author": "Nina Kowalski", "commit_id": 133, "day": 136, "deletions": 1, "files": "src/analytics/aggregates.py", "message": "analytics-worker: docs on replay safety", "service": "analytics-worker", "sha": "b6407e9", "source_table": "commits"}
28
+ {"additions": 3, "author": "Ravi Shah", "commit_id": 146, "day": 149, "deletions": 3, "files": "src/analytics/consumer.py", "message": "analytics-worker: bump pika to 1.3.2", "service": "analytics-worker", "sha": "f31de84", "source_table": "commits"}
29
+ {"additions": 22, "author": "Nina Kowalski", "commit_id": 156, "day": 159, "deletions": 11, "files": "src/analytics/aggregates.py", "message": "analytics-worker: channel dimension on rollups", "service": "analytics-worker", "sha": "958ea31", "source_table": "commits"}
30
+ {"additions": 23, "author": "Ravi Shah", "commit_id": 168, "day": 171, "deletions": 6, "files": "src/analytics/consumer.py", "message": "analytics-worker: drain cleanly on SIGTERM", "service": "analytics-worker", "sha": "31ed970", "source_table": "commits"}
31
+ {"additions": 17, "author": "Nina Kowalski", "commit_id": 178, "day": 181, "deletions": 5, "files": "src/analytics/aggregates.py", "message": "analytics-worker: tolerate undecodable payloads", "service": "analytics-worker", "sha": "e5cb241", "source_table": "commits"}
32
+ {"additions": 8, "author": "Ravi Shah", "commit_id": 190, "day": 193, "deletions": 2, "files": "src/analytics/consumer.py", "message": "analytics-worker: log how many messages stay unflushed on exit", "service": "analytics-worker", "sha": "0b7e4c9", "source_table": "commits"}
33
+ {"additions": 9, "author": "Nina Kowalski", "commit_id": 200, "day": 203, "deletions": 4, "files": "src/analytics/aggregates.py", "message": "analytics-worker: sort rollup rows for deterministic writes", "service": "analytics-worker", "sha": "2b05e18", "source_table": "commits"}
34
+ {"additions": 2, "author": "Ravi Shah", "commit_id": 212, "day": 215, "deletions": 2, "files": "src/analytics/consumer.py", "message": "analytics-worker: cut v0.7.0", "service": "analytics-worker", "sha": "1ea6f5c", "source_table": "commits"}
35
+ {"additions": 24, "author": "Nina Kowalski", "commit_id": 222, "day": 225, "deletions": 9, "files": "src/analytics/aggregates.py", "message": "analytics-worker: warehouse staging writer batches by minute", "service": "analytics-worker", "sha": "e51c983", "source_table": "commits"}
36
+ {"additions": 14, "author": "Ravi Shah", "commit_id": 234, "day": 237, "deletions": 3, "files": "src/analytics/consumer.py", "message": "analytics-worker: OPS-241 dashboards for consumer lag", "service": "analytics-worker", "sha": "39d604e", "source_table": "commits"}
37
+ {"additions": 3, "author": "Nina Kowalski", "commit_id": 244, "day": 247, "deletions": 3, "files": "src/analytics/aggregates.py", "message": "analytics-worker: bump warehouse driver to 3.9.1", "service": "analytics-worker", "sha": "40b9e53", "source_table": "commits"}
38
+ {"author": "Priya Nair", "body": "Perf: new upstream pool.", "merged_version": "v5.1.0", "number": 9201, "service": "api-gateway", "source_table": "pull_requests", "status": "merged", "ticket_key": "", "title": "Connection pool rewrite"}
39
+ {"author": "Diego Ramos", "body": "Draft, do not merge yet.", "merged_version": "", "number": 9202, "service": "catalog", "source_table": "pull_requests", "status": "open", "ticket_key": "", "title": "Price rounding cleanup"}
task_files/dob100-001-rca-analytics-egress-blocked/07-ci-and-tests.csv ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ source_table,detail,exercise_id,func,hidden_tests,name,path,pr_number,quarantined,run_id,service,spec,stage,stage_id,starter,status,suite,test_id,visible_tests
2
+ ci_runs,all checks passed,,,,,,,,11,analytics-worker,,,,,passed,,,
3
+ ci_runs,intermittent failure: test_rollup_window (rerun may pass),,,,,,,,12,analytics-worker,,,,,failed,,,
4
+ ci_stages,ok,,,,,,,,1,,,build,1,,passed,,,
5
+ ci_stages,ok,,,,,,,,1,,,unit,2,,passed,,,
6
+ ci_stages,ok,,,,,,,,1,,,integration,3,,passed,,,
7
+ ci_stages,ok,,,,,,,,1,,,regression,4,,passed,,,
8
+ tests_catalog,,,,,test_rollup_window,,,0,,analytics-worker,,,,,flaky,integration,9910,
9
+ code_exercises,,9404,TokenBucket,"[[""partial time is not discarded"", ""b = TokenBucket(1, 1)\nassert b.allow(0)\nassert not b.allow(500)\nassert b.allow(1000)""], [""the bucket never exceeds capacity"", ""b = TokenBucket(2, 100)\nassert b.allow(0) and b.allow(0)\nassert b.allow(10000) and b.allow(10000)\nassert not b.allow(10000)""], [""a backwards clock grants nothing"", ""b = TokenBucket(1, 1)\nassert b.allow(5000)\nassert not b.allow(1000)""], [""a backwards clock does not wedge the bucket"", ""b = TokenBucket(1, 1)\nassert b.allow(5000)\nassert not b.allow(1000)\nassert b.allow(2000)""], [""a refused request consumes nothing"", ""b = TokenBucket(1, 1)\nassert b.allow(0)\nfor _ in range(5):\n assert not b.allow(0)\nassert b.allow(1000)""]]",,src/gateway/token_bucket.py,,,,api-gateway,"Implement class TokenBucket(capacity, refill_per_sec) with one method,
10
+ allow(now_ms), returning True if a request may proceed and False otherwise.
11
+
12
+ A bucket starts full. Each allowed request consumes exactly one token; a
13
+ refused request consumes none. Tokens refill continuously at refill_per_sec
14
+ and the bucket never holds more than capacity.
15
+
16
+ Refill is continuous, not stepwise: two calls 500ms apart at 1 token/sec must
17
+ together restore one whole token, so partial time must not be discarded. The
18
+ first call establishes the clock and refills nothing.
19
+
20
+ now_ms comes from a wall clock that is occasionally stepped backwards by NTP.
21
+ A backwards jump must never grant tokens and must never make the bucket
22
+ permanently unable to refill: treat time as not having advanced, and take the
23
+ new reading as the current clock.",,,"""""""Per-client rate limiting at the API gateway edge.""""""
24
+
25
+
26
+ class TokenBucket:
27
+ def __init__(self, capacity, refill_per_sec):
28
+ raise NotImplementedError
29
+
30
+ def allow(self, now_ms):
31
+ """"""True if a request may proceed, consuming one token.""""""
32
+ raise NotImplementedError
33
+ ",,,,"[[""a full bucket allows up to capacity"", ""b = TokenBucket(2, 1)\nassert b.allow(0) and b.allow(0) and not b.allow(0)""], [""waiting restores a token"", ""b = TokenBucket(1, 1)\nassert b.allow(0)\nassert not b.allow(0)\nassert b.allow(1000)""]]"
task_files/dob100-001-rca-analytics-egress-blocked/08-data-change-controls.sql ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -- migrations: {"environment": "staging", "migration_id": 1, "name": "0041_settlement_batches", "service": "payments", "status": "applied"}
2
+ -- migrations: {"environment": "production", "migration_id": 2, "name": "0041_settlement_batches", "service": "payments", "status": "applied"}
3
+ -- migrations: {"environment": "staging", "migration_id": 3, "name": "0087_cart_line_discounts", "service": "checkout", "status": "applied"}
4
+ -- migrations: {"environment": "production", "migration_id": 4, "name": "0087_cart_line_discounts", "service": "checkout", "status": "applied"}
5
+ -- migration_requirements: {"migration_name": "0088_loyalty_ledger", "module": "loyalty_redeem", "req_id": 9151, "service": "checkout"}
6
+ -- migration_requirements: {"migration_name": "0123_loyalty_points", "module": "loyalty_accrual", "req_id": 9152, "service": "catalog"}
7
+ -- migration_requirements: {"migration_name": "0042_settlement_splits", "module": "split_settlement", "req_id": 9153, "service": "payments"}
8
+ -- migration_requirements: {"migration_name": "0034_backorders", "module": "backorder_queue", "req_id": 9154, "service": "inventory"}
9
+ -- db_grants: {"changed_day": 390, "component": "pg-replica", "grant_id": 9903, "note": "", "role": "catalog_ro", "service": "catalog", "state": "active"}
10
+ -- db_grants: {"changed_day": 390, "component": "pg-replica", "grant_id": 9904, "note": "", "role": "search_ro", "service": "search", "state": "active"}
11
+ -- db_grants: {"changed_day": 418, "component": "pg-replica", "grant_id": 9905, "note": "role dropped during the day-418 credential rotation; the running pods were never restarted and still present the old role", "role": "analytics_ro", "service": "analytics-worker", "state": "revoked"}
12
+ -- db_grants: {"changed_day": 0, "component": "pg-replica", "grant_id": 9906, "note": "no such role on pg-replica; the reporting job has never successfully connected since it was added", "role": "inventory_ro", "service": "inventory", "state": "missing"}
13
+ -- db_grants: {"changed_day": 390, "component": "rabbitmq", "grant_id": 9908, "note": "", "role": "analytics_sub", "service": "analytics-worker", "state": "active"}
task_files/dob100-001-rca-analytics-egress-blocked/09-feature-and-security.yaml ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "sources": [
3
+ {
4
+ "columns": [
5
+ "flag_id",
6
+ "key",
7
+ "service",
8
+ "description",
9
+ "environment",
10
+ "enabled",
11
+ "rollout_percent"
12
+ ],
13
+ "row_count": 8,
14
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
15
+ "table": "feature_flags",
16
+ "task_relevant_rows": [
17
+ {
18
+ "description": "Pilot: refund immediately at checkout instead of async batch.",
19
+ "enabled": 1,
20
+ "environment": "production",
21
+ "flag_id": 9301,
22
+ "key": "instant_refunds",
23
+ "rollout_percent": 100,
24
+ "service": "checkout"
25
+ },
26
+ {
27
+ "description": "Pilot: refund immediately at checkout instead of async batch.",
28
+ "enabled": 1,
29
+ "environment": "staging",
30
+ "flag_id": 9302,
31
+ "key": "instant_refunds",
32
+ "rollout_percent": 100,
33
+ "service": "checkout"
34
+ },
35
+ {
36
+ "description": "Redesigned search results page.",
37
+ "enabled": 0,
38
+ "environment": "production",
39
+ "flag_id": 9303,
40
+ "key": "new_search_ui",
41
+ "rollout_percent": 0,
42
+ "service": "search"
43
+ },
44
+ {
45
+ "description": "Redesigned search results page.",
46
+ "enabled": 1,
47
+ "environment": "staging",
48
+ "flag_id": 9304,
49
+ "key": "new_search_ui",
50
+ "rollout_percent": 100,
51
+ "service": "search"
52
+ }
53
+ ]
54
+ },
55
+ {
56
+ "columns": [
57
+ "vuln_id",
58
+ "cve",
59
+ "package",
60
+ "service",
61
+ "severity",
62
+ "fixed_version",
63
+ "status"
64
+ ],
65
+ "row_count": 4,
66
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
67
+ "table": "vulnerabilities",
68
+ "task_relevant_rows": [
69
+ {
70
+ "cve": "CVE-2026-31337",
71
+ "fixed_version": "2.4.0",
72
+ "package": "libpayproc",
73
+ "service": "payments",
74
+ "severity": "critical",
75
+ "status": "open",
76
+ "vuln_id": 9801
77
+ },
78
+ {
79
+ "cve": "CVE-2026-40881",
80
+ "fixed_version": "11.4.0",
81
+ "package": "stripe-sdk",
82
+ "service": "checkout",
83
+ "severity": "high",
84
+ "status": "open",
85
+ "vuln_id": 9802
86
+ },
87
+ {
88
+ "cve": "CVE-2026-22190",
89
+ "fixed_version": "2.11.0",
90
+ "package": "pydantic",
91
+ "service": "catalog",
92
+ "severity": "medium",
93
+ "status": "remediated",
94
+ "vuln_id": 9803
95
+ },
96
+ {
97
+ "cve": "CVE-2026-51002",
98
+ "fixed_version": "2.33.0",
99
+ "package": "requests",
100
+ "service": "payments",
101
+ "severity": "high",
102
+ "status": "open",
103
+ "vuln_id": 9804
104
+ }
105
+ ]
106
+ },
107
+ {
108
+ "columns": [
109
+ "rule_id",
110
+ "name",
111
+ "service_label",
112
+ "expr",
113
+ "severity",
114
+ "group_by",
115
+ "routes_to"
116
+ ],
117
+ "row_count": 5,
118
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
119
+ "table": "alert_rules",
120
+ "task_relevant_rows": [
121
+ {
122
+ "expr": "histogram_quantile(0.99, gateway_latency) > 250",
123
+ "group_by": "service",
124
+ "name": "GatewayHighLatency",
125
+ "routes_to": "EP-Platform",
126
+ "rule_id": 601,
127
+ "service_label": "gateway_service",
128
+ "severity": "critical"
129
+ },
130
+ {
131
+ "expr": "rate(gateway_errors[5m]) > 0.01",
132
+ "group_by": "service",
133
+ "name": "GatewayErrorRate",
134
+ "routes_to": "EP-Platform",
135
+ "rule_id": 602,
136
+ "service_label": "gateway_service",
137
+ "severity": "high"
138
+ },
139
+ {
140
+ "expr": "avg(latency) by (cluster) > 400",
141
+ "group_by": "cluster",
142
+ "name": "ClusterWideLatency",
143
+ "routes_to": "EP-Platform",
144
+ "rule_id": 603,
145
+ "service_label": "",
146
+ "severity": "critical"
147
+ },
148
+ {
149
+ "expr": "cache_hit_ratio{tier=\"gateway-edge\"} < 0.8",
150
+ "group_by": "service",
151
+ "name": "EdgeCacheHitRate",
152
+ "routes_to": "EP-Platform",
153
+ "rule_id": 604,
154
+ "service_label": "edge_cache_service",
155
+ "severity": "medium"
156
+ }
157
+ ]
158
+ },
159
+ {
160
+ "columns": [
161
+ "silence_id",
162
+ "matcher",
163
+ "created_by",
164
+ "reason",
165
+ "expires_day"
166
+ ],
167
+ "row_count": 1,
168
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
169
+ "table": "alert_silences",
170
+ "task_relevant_rows": [
171
+ {
172
+ "created_by": "Sam Whitfield",
173
+ "expires_day": 402,
174
+ "matcher": "alertname=\"EdgeCacheHitRate\"",
175
+ "reason": "muted during the CDN migration, never lifted",
176
+ "silence_id": 801
177
+ }
178
+ ]
179
+ }
180
+ ]
181
+ }
task_files/dob100-001-rca-analytics-egress-blocked/10-vendor-trackers.json ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "sources": [
3
+ {
4
+ "columns": [
5
+ "key",
6
+ "project",
7
+ "summary",
8
+ "issue_type",
9
+ "status",
10
+ "resolution",
11
+ "priority",
12
+ "component",
13
+ "assignee",
14
+ "created_day",
15
+ "updated_day"
16
+ ],
17
+ "row_count": 11,
18
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
19
+ "table": "jira_issues",
20
+ "task_relevant_rows": [
21
+ {
22
+ "assignee": "Alex Osei",
23
+ "component": "analytics-worker",
24
+ "created_day": 415,
25
+ "issue_type": "Bug",
26
+ "key": "ENG-2103",
27
+ "priority": "High",
28
+ "project": "ENG",
29
+ "resolution": "",
30
+ "status": "In Progress",
31
+ "summary": "Analytics worker restarting under queue load",
32
+ "updated_day": 419
33
+ },
34
+ {
35
+ "assignee": "Diego Ramos",
36
+ "component": "payments",
37
+ "created_day": 402,
38
+ "issue_type": "Bug",
39
+ "key": "ENG-3002",
40
+ "priority": "High",
41
+ "project": "ENG",
42
+ "resolution": "Fixed",
43
+ "status": "Done",
44
+ "summary": "Duplicate charge on retried payment",
45
+ "updated_day": 409
46
+ },
47
+ {
48
+ "assignee": "",
49
+ "component": "checkout",
50
+ "created_day": 396,
51
+ "issue_type": "Bug",
52
+ "key": "ENG-3004",
53
+ "priority": "Low",
54
+ "project": "ENG",
55
+ "resolution": "Won't Do",
56
+ "status": "Done",
57
+ "summary": "Cart total rounds incorrectly for multi-currency",
58
+ "updated_day": 404
59
+ }
60
+ ]
61
+ },
62
+ {
63
+ "columns": [
64
+ "identifier",
65
+ "team",
66
+ "title",
67
+ "state",
68
+ "priority",
69
+ "label",
70
+ "created_day"
71
+ ],
72
+ "row_count": 4,
73
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
74
+ "table": "linear_issues",
75
+ "task_relevant_rows": [
76
+ {
77
+ "created_day": 411,
78
+ "identifier": "GRW-88",
79
+ "label": "bug",
80
+ "priority": 1,
81
+ "state": "In Progress",
82
+ "team": "Growth",
83
+ "title": "Checkout slow at peak \u2014 customers dropping off"
84
+ },
85
+ {
86
+ "created_day": 408,
87
+ "identifier": "GRW-91",
88
+ "label": "bug",
89
+ "priority": 3,
90
+ "state": "Todo",
91
+ "team": "Growth",
92
+ "title": "Search shows stale products after reindex"
93
+ },
94
+ {
95
+ "created_day": 417,
96
+ "identifier": "GRW-95",
97
+ "label": "bug",
98
+ "priority": 4,
99
+ "state": "Todo",
100
+ "team": "Growth",
101
+ "title": "Autocomplete flickers on slow connections"
102
+ },
103
+ {
104
+ "created_day": 416,
105
+ "identifier": "GRW-97",
106
+ "label": "bug,performance",
107
+ "priority": 2,
108
+ "state": "In Progress",
109
+ "team": "Growth",
110
+ "title": "Product images load from origin, not CDN"
111
+ }
112
+ ]
113
+ },
114
+ {
115
+ "columns": [
116
+ "number",
117
+ "repo",
118
+ "title",
119
+ "state",
120
+ "labels",
121
+ "created_day"
122
+ ],
123
+ "row_count": 28,
124
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
125
+ "table": "github_issues",
126
+ "task_relevant_rows": [
127
+ {
128
+ "created_day": 396,
129
+ "labels": "bug",
130
+ "number": 4404,
131
+ "repo": "novacart/storefront",
132
+ "state": "closed",
133
+ "title": "Rate limiter allows bursts above the configured ceiling"
134
+ },
135
+ {
136
+ "created_day": 403,
137
+ "labels": "bug,priority",
138
+ "number": 4407,
139
+ "repo": "novacart/platform",
140
+ "state": "open",
141
+ "title": "Refund webhook retried indefinitely on 4xx"
142
+ },
143
+ {
144
+ "created_day": 410,
145
+ "labels": "bug,customer-report",
146
+ "number": 4409,
147
+ "repo": "novacart/commerce",
148
+ "state": "open",
149
+ "title": "Dark mode toggle resets on navigation"
150
+ },
151
+ {
152
+ "created_day": 417,
153
+ "labels": "enhancement",
154
+ "number": 4411,
155
+ "repo": "novacart/growth",
156
+ "state": "open",
157
+ "title": "Checkout page hangs before redirect"
158
+ }
159
+ ]
160
+ },
161
+ {
162
+ "columns": [
163
+ "source",
164
+ "target",
165
+ "kind"
166
+ ],
167
+ "row_count": 4,
168
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
169
+ "table": "issue_links",
170
+ "task_relevant_rows": [
171
+ {
172
+ "kind": "duplicates",
173
+ "source": "ENG-3001",
174
+ "target": "GRW-88"
175
+ },
176
+ {
177
+ "kind": "duplicates",
178
+ "source": "ENG-3001",
179
+ "target": "4412"
180
+ },
181
+ {
182
+ "kind": "duplicates",
183
+ "source": "ENG-3003",
184
+ "target": "GRW-91"
185
+ },
186
+ {
187
+ "kind": "duplicates",
188
+ "source": "ENG-3003",
189
+ "target": "4402"
190
+ }
191
+ ]
192
+ }
193
+ ]
194
+ }
task_files/dob100-001-rca-analytics-egress-blocked/11-knowledge-base.md ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 11 Knowledge Base
2
+
3
+ ## documents (30 rows)
4
+
5
+ ```json
6
+ [
7
+ {
8
+ "doc_id": 9604,
9
+ "kind": "runbook",
10
+ "title": "Search caching",
11
+ "service": "search",
12
+ "author": "Mei Tanaka",
13
+ "day": 233,
14
+ "body": "# Search caching\n\nOwner: growth. Service: `search` (tier 2, python). SLO:\n`latency_p99_ms < 300`.\n\n## The rule\n\nProduction `search` **requires `cache_enabled=true`**. This is not a tuning\nknob; it is a capacity assumption baked into how the index cluster is sized.\n\n## Why\n\nThe query cache sits in front of the primary index and absorbs roughly **75% of\nindex load**. Search traffic is extremely head-heavy: the top few thousand\nqueries (\"black jeans\", \"usb-c cable\", \"gift card\") are a large majority of all\nrequests, and their result sets change only when the index is rebuilt. Serving\nthose from cache is close to free.\n\nWith `cache_enabled=false` every request goes to the primary index. Observed\neffect in production: `latency_p99_ms` moves from a ~210ms baseline to ~640ms and\nkeeps climbing as concurrency rises, blowing through the 300ms SLO and firing a\n`medium` alert. The service does not error - it just gets slow, which is why this\none is easy to miss until the alert fires. The tell in the logs is:\n\n```\nWARN query cache disabled (cache_enabled=false); every request is hitting the primary index\n```\n\n## Config keys\n\n| Key | Production value | Notes |\n| --------------- | ---------------- | ------------------------------------------ |\n| `cache_enabled` | `true` | Required. Never ship `false` to production. |\n| `cache_ttl_s` | `300` | Standard TTL. Five minutes. |\n| `index_shards` | `4` | Change only with a capacity review. |\n\n`cache_ttl_s=300` is the standard. It is a deliberate compromise: long enough\nthat the hit rate stays above 70%, short enough that a price or availability\nchange is visible within five minutes. Do not lower it below 60 - at that point\nthe stampede risk (below) outweighs the freshness gain. Do not raise it above\n900 without merchandising sign-off, because stale out-of-stock results generate\nsupport tickets.\n\n## Cache stampede\n\nA cold cache is dangerous, not merely slow. When many identical queries miss at\nonce they all reach the index simultaneously. We ship single-flight coalescing\nplus a +/-10% TTL jitter for exactly this reason. If you flush the cache\nmanually, do it during low traffic and expect a latency spike. The full story is\nin \"Postmortem: search cache stampede after index rebuild\".\n\n## Changing cache config\n\n`cache_enabled` and `cache_ttl_s` are repo config, not runtime flags. Changing\nthem means a PR with a `config` change, CI, merge, then a deploy - staging\nfirst, per the \"Deployment policy\". `search` is tier 2, so production deploys go\nstraight to 100%.\n\n## Verification\n\nAfter deploying, confirm `latency_p99_ms` has returned to the ~210ms band before\nresolving any related alert.\n"
15
+ },
16
+ {
17
+ "doc_id": 9605,
18
+ "kind": "runbook",
19
+ "title": "Catalog pricing performance",
20
+ "service": "catalog",
21
+ "author": "Diego Ramos",
22
+ "day": 229,
23
+ "body": "# Catalog pricing performance\n\nOwner: commerce. Service: `catalog` (tier 2, python). Consumed by `search`,\n`checkout`, and `storefront-web` on every product listing render.\n\n## The rule\n\n`batch_pricing_enabled=true` is **required in production**.\n\n## Why\n\n`catalog` resolves a price per product from the pricing rules table, applying\nthe active promotion, the customer's currency, and any tier discount. With\n`batch_pricing_enabled=false`, the listing endpoint loops over the products in\nthe response and issues one pricing query per product. This is a textbook\n**N+1 pattern**: a 48-item category page produces 1 listing query plus 48\npricing queries.\n\nMeasured cost: the per-product loop adds roughly **500ms at p99** on a standard\ncategory page. It also multiplies database connection checkouts by the page\nsize, which is how a catalog slowdown turns into a `db_pool_size` exhaustion\nevent in a service that was nowhere near its own limits (see \"Connection pool\nsizing\").\n\nWith `batch_pricing_enabled=true` the same page issues one listing query and one\nbatched pricing query with an `IN` clause over the product ids, then applies\npromotions in memory. Same results, two round trips.\n\n## Config keys\n\n| Key | Production value | Notes |\n| ------------------------- | ---------------- | -------------------------------------- |\n| `batch_pricing_enabled` | `true` | Required. The N+1 killer. |\n| `cdn_enabled` | `true` | See \"CDN and media delivery\". |\n\n## How to spot it\n\n- p99 on `catalog` listing endpoints scales with page size rather than staying\n flat. If 24 items is 200ms and 96 items is 900ms, it is the loop.\n- Database query counts per request in the hundreds.\n- Log lines of the form `pricing lookup for product_id=... (batch disabled)`\n repeating with the same trace id.\n\n## Fixing it\n\n`batch_pricing_enabled` is repo config. Ship it as a PR with a `config` change,\nrun CI, merge, deploy to staging, then production. `catalog` is tier 2 so the\nproduction deploy is a straight 100% deploy - no canary required, though a\ncanary is never wrong.\n\nAfter the deploy, re-measure p99 on a large category page before closing the\nticket.\n\n## Do not\n\n- Do not \"fix\" this by raising `db_pool_size`. That hides the symptom and moves\n the failure to the database.\n- Do not add a per-product cache in front of the loop. The batch query is\n cheaper than the cache lookups it would replace.\n"
24
+ },
25
+ {
26
+ "doc_id": 9607,
27
+ "kind": "runbook",
28
+ "title": "Feature flags",
29
+ "service": "",
30
+ "author": "Mei Tanaka",
31
+ "day": 247,
32
+ "body": "# Feature flags\n\nEvery new user-facing feature ships **dark**: merged, deployed, and switched\noff, then turned on gradually.\n\n## Defining a flag\n\nA flag is defined by a `flag` change in the PR that introduces the guarded code.\nFlag and code land together, in one PR, so there is never a flag referencing\ncode that does not exist or guarded code with no way to turn it off. At merge\nthe flag is created **disabled in both environments** with a rollout of 0%.\n\nNaming: lowercase snake_case, describing the feature, not the experiment -\n`express_checkout`, `instant_refunds`, `new_search_ui`. Not `mei_test_2` and not\n`enable_new_thing_v3_final`.\n\n## Ordering: deploy the code, then enable the flag\n\n**The guarded code must be deployed to production BEFORE the flag is enabled\nthere.** Enabling a flag whose code is not deployed does one of two things:\nnothing at all (best case, and you waste an hour wondering why), or it activates\na half-present code path across a partially deployed fleet (worst case).\n\nSo the sequence is:\n\n1. PR with the module change and the `flag` change - CI - merge.\n2. Deploy to staging.\n3. Deploy to production. Tier-1 services canary at `canary_percent <= 25`,\n `assess_canary`, then `promote_canary` (see \"Deployment policy\").\n4. Only now: `set_feature_flag(flag, environment=\"production\", enabled=true,\n rollout_percent=10)`.\n\n## Initial rollout must not exceed 10%\n\nThe first production enablement is capped at **10%**. Sit there long enough to\nsee real traffic - at minimum one full traffic peak - and watch the owning\nservice's error rate and p99. Then ramp: 10 - 25 - 50 - 100, checking metrics at\neach step.\n\nFlags are **runtime toggles**: `set_feature_flag` takes effect immediately and\nneeds **no deploy**. That cuts both ways - it is why a flag is the fastest kill\nswitch we have, and it is why an unreviewed ramp to 100% is the fastest way to\ncause a sev2. The `instant_refunds` incident was exactly this: the flag went to\n100% in production and `checkout` `error_rate_pct` went from 0.3% to 5.5%.\n\n## Kill switch\n\nDuring an incident, disable the flag in the affected environment only. Leave the\nother environment as it is so you can still reproduce. See \"Incident response\".\n\n## Cleanup\n\n**Stale flags must be cleaned up after full rollout.** Once a flag has been at\n100% in production for two weeks and there is no plan to turn it off, remove the\nconditional from the code and delete the flag in a follow-up PR. Every flag left\nbehind is a branch of untested code and a future outage. The owning team reviews\nits flag list at each sprint boundary.\n"
33
+ },
34
+ {
35
+ "doc_id": 9609,
36
+ "kind": "runbook",
37
+ "title": "Security response",
38
+ "service": "",
39
+ "author": "Alex Osei",
40
+ "day": 263,
41
+ "body": "# Security response\n\nCovers dependency vulnerabilities reported by the scanner and secrets found in\nsource. Security tickets carry the `security` type and are prioritized above\nfeature work.\n\n## Vulnerable dependency\n\nOrdered steps:\n\n1. **Patch the vulnerable dependency.** Bump to the fixed version named in the\n finding via a PR with a `dependency` change. Do not jump several major\n versions to \"get ahead\" - patch to the fixed version, then plan the upgrade\n separately.\n2. **Deploy staging, then production.** Staging-first per the \"Deployment\n policy\". Tier-1 services canary at `canary_percent <= 25`, `assess_canary`,\n then `promote_canary`.\n3. **Verify the scanner shows the finding remediated.** Re-run the scan against\n the deployed service and confirm the vulnerability status is no longer\n `open`. A merged PR is not remediation; a deployed and re-scanned service is.\n4. **Post an audit summary to `#security` referencing the CVE id.** State the\n CVE, the service, the old and new versions, and when production was patched.\n Auditors read this channel; the CVE id must appear literally.\n5. **Close the security ticket.**\n\nTimelines by severity, measured from the finding appearing:\n\n| Severity | Production patched within |\n| -------- | ------------------------- |\n| critical | 48 hours |\n| high | 7 days |\n| medium | 30 days |\n| low | next maintenance window |\n\n## Secrets in code\n\nIf a credential, API key, or token is found in source, config, or CI logs:\n\n1. **Move it to the secret manager.** Set config key\n `use_secret_manager=true` for the service and reference the secret by name;\n the value never appears in the repo again.\n2. **Rotate the credential.** Assume it is compromised the moment it was\n committed - git history is forever and the repo is mirrored to CI. Rotation\n is not optional even if the repo is private.\n3. Deploy staging then production, verify the service still authenticates, and\n post the summary to `#security`.\n\nDo not \"delete the line and force-push\". The old blob is still reachable and the\ncredential is still live.\n\n## Escalation\n\nAnything involving customer data exposure, an actively exploited vulnerability,\nor credential misuse in production is a sev1 - open an incident and follow\n\"Incident response\" in parallel with this runbook.\n\n## Related\n\n- \"ADR-027: Move partner credentials to the secret manager\".\n"
42
+ },
43
+ {
44
+ "doc_id": 9612,
45
+ "kind": "runbook",
46
+ "title": "Queue consumer tuning",
47
+ "service": "notifications",
48
+ "author": "Priya Nair",
49
+ "day": 226,
50
+ "body": "# Queue consumer tuning\n\nOwner: platform. Primary consumer service: `notifications` (tier 2), which\ndrains the email, SMS, and push delivery queues. The same rules apply to any\nservice that consumes from the message broker.\n\n## The rule\n\n`prefetch_count` must be a **bounded** value. **Recommended: 50.**\n\n`prefetch_count=0` means **unlimited prefetch** and is the single worst setting\nin this runbook.\n\n## What prefetch does\n\nPrefetch is the number of unacknowledged messages the broker will push to a\nsingle consumer. With `prefetch_count=50`, a consumer holds at most 50\nin-flight messages; the broker will not send a 51st until one is acknowledged.\nThis is the backpressure mechanism - it is what lets a slow consumer tell the\nbroker to slow down.\n\nWith `prefetch_count=0` there is no backpressure. The broker pushes the entire\nbacklog to whichever consumer connects first. Consequences, all of which we have\nseen in `notifications`:\n\n- **Memory pressure.** A 400k-message backlog lands in one process's heap. RSS\n climbs until the container hits its memory limit.\n- **Consumer restarts.** The container is OOM-killed, the unacknowledged\n messages are redelivered, the restarted consumer grabs them all again, and it\n is killed again. A restart loop that looks like a broker problem and is not.\n- **Terrible load distribution.** One consumer holds everything while its\n siblings sit idle, so scaling out does nothing.\n- **Head-of-line latency.** A high-priority message sits behind 400k others.\n\n## Sizing\n\n| Message profile | prefetch_count |\n| ------------------------------ | -------------- |\n| Fast, uniform (a few ms each) | 100-200 |\n| Standard delivery work | **50** |\n| Slow or variable (seconds) | 5-10 |\n| Long-running jobs (minutes) | 1 |\n\nRule of thumb: `prefetch_count` should be roughly the number of messages a\nconsumer can process in one to two seconds. Start at 50 and adjust with\nevidence.\n\n## Related settings\n\n- `smtp_pool` on `notifications` bounds concurrent SMTP connections. Prefetch\n above the SMTP concurrency just buys queueing inside the process.\n- Ack **after** the work is done, never on receipt. Acking on receipt turns a\n crash into silent message loss.\n- Dead-letter after 5 delivery attempts so a poison message cannot loop forever.\n\n## Changing it\n\nRepo config: PR with a `config` change, CI, merge, staging, production.\n`notifications` is tier 2 - straight 100% deploy after staging. Watch consumer\nmemory and queue depth for one full peak after the change.\n"
51
+ },
52
+ {
53
+ "doc_id": 9613,
54
+ "kind": "runbook",
55
+ "title": "CDN and media delivery",
56
+ "service": "media-service",
57
+ "author": "Mei Tanaka",
58
+ "day": 221,
59
+ "body": "# CDN and media delivery\n\nCovers media-service, the product-image and asset delivery path owned by\ncommerce and shipped as part of the `catalog` service. Product photography,\ngenerated thumbnails, size charts, and marketing video posters all flow through\nit.\n\n## The rule\n\n`cdn_enabled=true` is **required in production** for media-service. Origin-only\nserving is not an acceptable production configuration.\n\n## Why\n\nWith the CDN enabled, edge nodes serve cached objects close to the user and the\norigin sees only cache misses and revalidations - typically under 5% of\nrequests. With `cdn_enabled=false`, every image request travels to the origin\nand out of the object store.\n\nMeasured impact of origin-only serving:\n\n- **~600ms added at p99** on image-heavy pages. Category and product-detail\n pages are the worst affected because they fan out to dozens of assets, and\n browsers cap parallel connections per origin, so the latency serializes.\n- **Object-store cost rises sharply.** Egress and per-request charges are billed\n on every single request instead of on misses. In the one week we ran\n origin-only during a migration, media egress was roughly 20x the normal line\n item.\n- Origin bandwidth saturates first during traffic spikes, and image failures\n make the storefront look broken even when checkout is perfectly healthy.\n\n## Config\n\n| Key | Production value | Notes |\n| --------------- | ---------------- | --------------------------------------- |\n| `cdn_enabled` | `true` | Required. |\n\nCache-control defaults: immutable, content-hashed asset URLs get a one-year\nmax-age; mutable paths get 300s with revalidation. Because asset URLs are\ncontent-hashed, a new image is a new URL - you should almost never need to purge.\n\n## Purging\n\nPurge only for a legal or trademark takedown, or for an asset published in\nerror. A full-prefix purge is effectively a cold cache: expect an origin load\nspike and a temporary p99 regression. Purge narrowly, by exact URL, during low\ntraffic.\n\n## Troubleshooting\n\n- Images slow but HTML fast: check `cdn_enabled` first, before anything else.\n- Cache hit ratio below 90%: usually a query string added to asset URLs, which\n fragments the cache key. Strip non-semantic query parameters at the edge.\n- 403s from the edge: signed-URL clock skew on the origin.\n\n## Changing it\n\nRepo config: PR with a `config` change, CI, merge, staging, then production per\nthe \"Deployment policy\". Verify p99 on a product-detail page and the edge hit\nratio before closing the ticket.\n"
60
+ },
61
+ {
62
+ "doc_id": 9614,
63
+ "kind": "design_doc",
64
+ "title": "Checkout architecture",
65
+ "service": "checkout",
66
+ "author": "Diego Ramos",
67
+ "day": 198,
68
+ "body": "# Checkout architecture\n\nService: `checkout` (tier 1, python, commerce). Owns the cart and the checkout\norchestration state machine. SLOs: `error_rate_pct < 1.0`,\n`latency_p99_ms < 400`.\n\n## Responsibilities\n\n`checkout` owns the transition from \"a cart exists\" to \"an order exists and is\npaid\". It does not own money movement (that is `payments`), product data (that\nis `catalog`), or customer notification (that is `notifications`). It owns the\nsequencing and the guarantee that the sequence happens exactly once.\n\nModules: `cart`, `checkout_flow`, and - once the loyalty program ships -\n`loyalty_redeem`.\n\n## The state machine\n\nEvery checkout session is a row with an explicit state:\n\n```\ncart_open -> pricing_locked -> payment_pending -> paid -> order_created\n | |\n +-> abandoned +-> payment_failed\n```\n\nTransitions are append-only and each is stamped with the idempotency key of the\nrequest that caused it. Replaying a request that has already produced a\ntransition returns the existing result rather than performing it again. This is\nwhat makes the checkout endpoint safe to retry, which matters because clients\nretry aggressively on mobile networks.\n\n## Dependencies\n\n| Downstream | Call | Timeout budget |\n| --------------- | ------------------------ | ------------------------- |\n| `catalog` | price and availability | `<= 2000ms`, 3 attempts |\n| `payments` | authorize and capture | `payment_timeout_ms` |\n| `notifications` | order confirmation | async, fire-and-forget |\n\nAll synchronous calls follow the \"Retry and timeout standard\": three attempts,\ntimeout at or below 2000ms. The `notifications` call is deliberately\nasynchronous - a confirmation email must never be able to fail an order.\n\n## Pricing lock\n\nAt `pricing_locked` we snapshot the price, the promotion, and the tax\ncomputation into the session row. From that point the customer pays the price\nthey were shown even if `catalog` changes underneath. The lock expires after 20\nminutes, after which the session re-prices.\n\n## Failure handling\n\n- `payments` timeout: the session stays `payment_pending` and a reconciliation\n job asks `payments` for the authoritative status. We never assume a timeout\n means \"did not happen\".\n- `catalog` unavailable: fail closed. We do not sell at a guessed price.\n- Partial capture: not supported; a capture is all-or-nothing per order.\n\n## Feature flags\n\nCheckout-adjacent behavior ships behind flags - `instant_refunds`,\n`express_checkout`. Per the \"Feature flags\" runbook, the code deploys first and\nthe flag is enabled afterwards at no more than 10%. `instant_refunds` is the\ncautionary tale: ramped to 100% in production, it took `error_rate_pct` from\n0.3% to 5.5% via a nil-pointer panic in the refund worker.\n\n## Open questions\n\n- Should the pricing lock move into `catalog` so `search` can honor it too?\n- Cart merge on login is still last-write-wins; it should be a real merge.\n"
69
+ },
70
+ {
71
+ "doc_id": 9617,
72
+ "kind": "design_doc",
73
+ "title": "Loyalty points program",
74
+ "service": "",
75
+ "author": "Diego Ramos",
76
+ "day": 288,
77
+ "body": "# Loyalty points program\n\nCross-service feature spanning `catalog`, `checkout`, and `storefront-web`.\nCustomers earn points on purchases and redeem them for order discounts.\n\n## Modules and ownership\n\n| Module | Service | Responsibility |\n| ----------------- | ----------------- | ------------------------------------- |\n| `loyalty_accrual` | `catalog` | Points-earning rules per product |\n| `loyalty_redeem` | `checkout` | Applying points as an order discount |\n| `loyalty_widget` | `storefront-web` | Balance display and redeem affordance |\n\nEach module ships in **its own PR against its own service**. There is no shared\nlibrary; the contract between them is the points-rate field on the product\npayload and the redeem call on the checkout API.\n\n## Why this split\n\nAccrual rules are product data - they vary per product and per category, they\nchange with merchandising campaigns, and they belong next to pricing. Redemption\nis an order-level money decision and belongs in the checkout state machine.\nDisplay is display. Putting accrual in `checkout` would have meant `checkout`\nreading the product rules table, which is exactly the coupling we spent last\nyear removing.\n\n## Rollout order\n\nDeployment order matters and is not negotiable:\n\n**`catalog` - then `checkout` - then `storefront-web`.**\n\nThe reasoning is a strict data dependency chain:\n\n1. `catalog` must be emitting a points rate on the product payload before\n `checkout` can compute a balance to redeem against. If `checkout` ships\n first, every redeem attempt reads a missing field and either errors or\n silently computes zero.\n2. `checkout` must expose the redeem endpoint and be live before\n `storefront-web` renders a redeem button. If the widget ships first,\n customers see a button that 404s - a visible, embarrassing failure on the\n busiest page we have.\n\n`catalog` is tier 2 (straight production deploy after staging). `checkout` and\n`storefront-web` are tier 1, so each is staging-first, then a production canary\nat `canary_percent <= 25`, `assess_canary`, then `promote_canary` - see\n\"Deployment policy\". Do not begin the next service's production deploy until the\nprevious one is fully promoted.\n\n## Points model\n\nBalances live in an append-only ledger, mirroring the approach in \"Payments\nsettlement pipeline\": `earn`, `redeem`, `expire`, `adjust`. Balance is the sum,\nnever a stored counter. Redemption is authorized at `pricing_locked` and\ncommitted at `paid`; an abandoned cart releases the hold after 20 minutes.\n\nDefault rate is 1 point per whole currency unit, 100 points equals one currency\nunit of discount, points expire 12 months after earning. Maximum redemption is\n50% of order subtotal.\n\n## Risks\n\n- Double-redeem across concurrent sessions. Mitigated by the hold and by the\n idempotency key on the checkout transition.\n- Accrual rule changes retroactively altering historical balances. The ledger\n stamps the rate version at earn time.\n"
78
+ },
79
+ {
80
+ "doc_id": 9620,
81
+ "kind": "adr",
82
+ "title": "ADR-027: Move partner credentials to the secret manager",
83
+ "service": "payments",
84
+ "author": "Alex Osei",
85
+ "day": 191,
86
+ "body": "# ADR-027: Move partner credentials to the secret manager\n\n**Status:** Accepted\n**Date:** day 191\n**Deciders:** security, platform, commerce\n\n## Context\n\nPartner credentials - the payment processor API key, the shipping carrier\ntokens, the SMTP credentials used by `notifications`, and the analytics\nwrite key - were stored as plain config values in each service's repo config\nand injected as environment variables at deploy time.\n\nThree problems made this untenable:\n\n1. **Git history is permanent.** Every credential ever committed remains in\n history, in every clone, and in every CI cache. Removing the line does not\n remove the secret.\n2. **Rotation was a deploy.** Rotating the processor key meant a PR, CI, staging,\n canary, promote - per service. So rotation happened roughly never, and the\n processor key in production had been unchanged for over a year.\n3. **No access audit.** We could not answer \"who read this value, and when\",\n which is a direct finding in the annual audit.\n\nThe trigger was a scanner hit: a carrier token visible in a config file in a\nrepo that four teams could read.\n\n## Decision\n\nAll partner credentials move to the managed **secret manager**. Each service\nopts in with the config key **`use_secret_manager=true`** and references secrets\nby name rather than value. The application resolves secrets at startup and on a\nrefresh interval; the plaintext never appears in the repo, in a PR diff, or in a\ndeploy artifact.\n\nEvery credential moved is **rotated as part of the move**, on the assumption\nthat anything previously in the repo is compromised.\n\nRollout order: `payments` first (highest value), then `notifications`, then the\nremaining services.\n\n## Alternatives considered\n\n**Encrypted secrets committed to the repo (sealed values).** Rejected: it solves\nplaintext exposure but not rotation-as-a-deploy, and the decryption key becomes\nthe new committed secret.\n\n**Environment variables set manually on hosts.** Rejected: unauditable,\ndrift-prone, and impossible to reproduce.\n\n**Do nothing, tighten repo permissions.** Rejected: it does not address history,\nrotation, or audit.\n\n## Consequences\n\nPositive: rotation is an operation, not a release; access is logged per read;\nsecret scanning in CI becomes a hard gate rather than advisory.\n\nNegative: a new startup-time dependency. If the secret manager is unreachable a\nservice cannot start, so we cache the last successful resolution on disk,\nencrypted, with a short TTL, to survive a brief outage.\n\nOperational procedure for a leaked credential is in the \"Security response\"\nrunbook: move to the secret manager, **rotate**, deploy, verify, post to\n`#security`.\n"
87
+ },
88
+ {
89
+ "doc_id": 9622,
90
+ "kind": "postmortem",
91
+ "title": "Postmortem: search cache stampede after index rebuild",
92
+ "service": "search",
93
+ "author": "Mei Tanaka",
94
+ "day": 183,
95
+ "body": "# Postmortem: search cache stampede after index rebuild\n\n**Severity:** sev2\n**Service:** `search`\n**Duration:** 34 minutes of degraded search\n**Author:** Mei Tanaka\n**Status:** action items complete\n\n## Summary\n\nA planned index rebuild swapped the search index alias at a moderate traffic\nhour. The alias swap invalidated the entire query cache. Every in-flight query\nmissed simultaneously and hit the primary index, driving `latency_p99_ms` from\n~210ms to a peak of 2100ms and firing the `search latency_p99_ms` alert against\nits 300ms SLO. Search was slow, not down; conversion on search-originated\nsessions dropped an estimated 18% for the duration.\n\n## Timeline (UTC)\n\n- **14:02** Engineer starts a full index rebuild for an analyzer change. Routine;\n done a dozen times before.\n- **14:41** Rebuild completes. Alias swaps to the new index. Query cache keys are\n namespaced by index generation, so the swap invalidates 100% of the cache.\n- **14:42** `latency_p99_ms` crosses 300ms. Alert fires, `medium`.\n- **14:44** On-call acknowledges. Initial hypothesis: the new analyzer is slow.\n- **14:51** Index CPU is pegged; per-query cost is unchanged from before the\n rebuild. Hypothesis discarded - it is volume, not per-query cost.\n- **14:58** Cache hit ratio confirmed at 3%, against a normal 76%. Root cause\n identified.\n- **15:06** Traffic to search temporarily shed at the gateway by 30% to let the\n cache refill.\n- **15:16** Hit ratio back above 60%; p99 at 340ms and falling.\n- **15:22** Shedding removed. p99 at 215ms.\n- **15:26** Alert resolved, incident resolved, update posted in `#incidents`.\n\n## Root cause\n\nThe query cache is namespaced by index generation. An alias swap therefore\nperforms a **complete, instantaneous cache flush** with no warm-up. Because the\ncache normally absorbs about **75% of index load**, the index was asked to serve\nroughly 4x its steady-state query volume within one second. Requests queued,\nlatency rose, clients retried, and the retries added load - a classic stampede\nwith a positive feedback loop.\n\n## Contributing factors\n\n- No warm-up step in the rebuild procedure. The runbook ended at \"swap alias\".\n- Rebuild was run at 14:00 local, in the daily traffic ramp, because the job\n takes 40 minutes and nobody wanted to babysit it at night.\n- Single-flight coalescing existed for identical concurrent queries but the\n stampede was across *thousands of distinct* queries, so coalescing did nothing.\n- No alert on cache hit ratio, so the actual signal was invisible for 14 minutes.\n\n## What went well\n\n- Alerting fired within a minute of the SLO breach.\n- Load shedding at the gateway was the correct blunt instrument and worked.\n\n## Action items\n\n1. Add a **warm-up phase** to the rebuild: replay the top 5000 queries against\n the new index before swapping the alias. **Done.**\n2. Add **+/-10% TTL jitter** to `cache_ttl_s=300` so natural expiry never\n synchronizes. **Done.**\n3. Alert on **cache hit ratio below 50%** for 5 minutes. **Done.**\n4. Move scheduled rebuilds to 03:00-05:00 UTC. **Done.**\n5. Document the stampede risk in the \"Search caching\" runbook. **Done.**\n"
96
+ },
97
+ {
98
+ "doc_id": 9623,
99
+ "kind": "postmortem",
100
+ "title": "Postmortem: catalog migration 0043 forced a rollback",
101
+ "service": "catalog",
102
+ "author": "Diego Ramos",
103
+ "day": 202,
104
+ "body": "# Postmortem: catalog migration 0043 forced a rollback\n\n**Severity:** sev1\n**Service:** `catalog` (with knock-on impact to `checkout` and `storefront-web`)\n**Duration:** 22 minutes of failed product-detail pages\n**Author:** Diego Ramos\n**Status:** action items complete\n\n## Summary\n\nMigration `0043_rename_price_column` renamed `catalog_products.price_cents` to\n`price_minor_units` in a single step, and the matching code version `v1.8.0` was\ndeployed immediately after. The migration was applied to production before the\ndeploy, as policy requires - but the migration was **not backwards compatible**\nwith the code version already running. Between the migration completing and the\nnew version being fully rolled out, the running `v1.7.6` instances queried a\ncolumn that no longer existed. Product-detail and category pages returned 500s;\n`checkout` fell back to failing closed on pricing, per its design.\n\n## Timeline (UTC)\n\n- **09:12** `apply_migration(catalog, production, 0043)` starts.\n- **09:13** Migration completes. Column renamed.\n- **09:13** `v1.7.6` instances begin throwing\n `UndefinedColumn: price_cents` on every pricing query.\n- **09:14** `catalog` error rate goes vertical. `checkout` starts failing closed.\n Two alerts fire.\n- **09:15** Deploy of `v1.8.0` starts, as planned, but rolls instance by instance.\n- **09:17** On-call acknowledges, declares sev1.\n- **09:19** Commander recognizes the pattern: schema ahead of code, partial fleet.\n- **09:21** Decision: do **not** attempt to reverse the migration. Accelerate the\n `v1.8.0` rollout instead.\n- **09:31** Rollout complete on all instances. Errors stop.\n- **09:34** Metrics confirmed recovered; alerts resolved; incident resolved.\n- **09:40** Update posted in `#incidents`; status page updated and cleared.\n- Later that day: `v1.8.0` was rolled back for an unrelated defect found in\n review, which is when the second lesson landed - the rolled-back `v1.7.6` code\n could not read the renamed column either, and a hotfix `v1.8.1` had to be cut\n because **migrations are forward-only** and there was no going back.\n\n## Root cause\n\nA **destructive, non-backwards-compatible schema change shipped in one step**. A\ncolumn rename is two incompatible states with no overlap: code that knows the old\nname and code that knows the new name cannot both work against the same schema.\nAny window in which both code versions run - and a rolling deploy guarantees such\na window - is an outage.\n\n## Contributing factors\n\n- The \"migration before code\" rule was followed correctly, and following it\n correctly was *insufficient*. The rule says nothing about compatibility with\n the code already running.\n- The migration had one reviewer, from the authoring team.\n- Rolling deploys were assumed to be fast enough not to matter. They are not.\n- `catalog` is tier 2, so there was no canary to catch it at 25%.\n\n## What went well\n\n- Nobody tried to hand-write a reverse migration under pressure. Rolling forward\n was the right call and it was made in six minutes.\n- `checkout` failing closed on pricing prevented selling at a wrong price.\n\n## Action items\n\n1. Write the **N-1 rule** into the \"Database migration policy\": every migration\n must leave the schema usable by the currently deployed code. **Done.**\n2. Mandate the **expand/contract** pattern for renames: add column, dual-write,\n backfill, switch reads, drop in a later migration. **Done.**\n3. Require a **second reviewer from platform** for migrations on tables above ten\n million rows. **Done.**\n4. Add a CI check that flags `DROP COLUMN`, `RENAME COLUMN`, and new `NOT NULL`\n constraints for explicit sign-off. **Done.**\n"
105
+ },
106
+ {
107
+ "doc_id": 9624,
108
+ "kind": "api_spec",
109
+ "title": "Public Orders API",
110
+ "service": "api-gateway",
111
+ "author": "Priya Nair",
112
+ "day": 265,
113
+ "body": "# Public Orders API\n\nServed by `api-gateway`. Two versions are live: **`/v1/orders` (deprecated)** and\n**`/v2/orders` (current)**. Authentication is a bearer partner token on both.\nRationale for the split is in \"ADR-031: Versioned public API (/v1 to /v2\norders)\".\n\n## Status\n\n| Path | Status | Notes |\n| ------------- | ---------- | -------------------------------------------- |\n| `/v1/orders` | deprecated | Emits `Deprecation` and `Sunset` headers. |\n| `/v2/orders` | current | Use for all new integrations. |\n\nTraffic between the two is weighted at the gateway and shifted in steps of at\nmost 50 percentage points per the \"API deprecation\" runbook. `/v1/orders` may\nonly be retired once it serves 0% of traffic; CI blocks retirement otherwise.\n\n## `GET /v2/orders`\n\nQuery parameters: `status`, `created_after` (RFC3339), `limit` (default 50, max\n200), `cursor`.\n\nResponse `200`:\n\n```json\n{\n \"data\": [\n {\n \"id\": \"ord_01H9Z\",\n \"status\": \"paid\",\n \"created_at\": \"2026-03-04T11:02:19Z\",\n \"currency\": \"USD\",\n \"amount_total_minor\": 12995,\n \"amount_tax_minor\": 1040,\n \"shipments\": [\n {\"id\": \"shp_1\", \"carrier\": \"ups\", \"tracking_number\": \"1Z...\",\n \"line_item_ids\": [\"li_1\", \"li_2\"], \"status\": \"in_transit\"}\n ],\n \"refunds\": [\n {\"id\": \"ref_1\", \"amount_minor\": 2500, \"reason\": \"damaged\",\n \"created_at\": \"2026-03-07T09:11:00Z\"}\n ],\n \"loyalty\": {\"points_earned\": 130, \"points_redeemed\": 0}\n }\n ],\n \"next_cursor\": \"eyJvIjoiMDFIOVoifQ\"\n}\n```\n\n## `POST /v2/orders`\n\nRequest:\n\n```json\n{\n \"idempotency_key\": \"5f2c...\",\n \"customer_id\": \"cus_88\",\n \"currency\": \"USD\",\n \"line_items\": [{\"sku\": \"NC-1042\", \"quantity\": 2, \"unit_price_minor\": 4995}],\n \"shipping_address_id\": \"addr_9\",\n \"loyalty\": {\"points_to_redeem\": 500}\n}\n```\n\n`idempotency_key` is required. Replaying the same key returns the original order\nwith `200` rather than creating a second one.\n\nResponses: `201` created; `409` idempotency key reused with a different body;\n`422` validation failure.\n\n## `/v1/orders` (deprecated)\n\nSame resource, older shape. Differences that break naive migration:\n\n- `total` is a **decimal string** (`\"129.95\"`), not integer minor units.\n- `tracking_number` is a **scalar** on the order; multi-shipment orders report\n only the first.\n- `refunded` is a **boolean**; partial refunds are indistinguishable from full.\n- No `loyalty` object.\n- Offset pagination (`page`, `per_page`) instead of `next_cursor`.\n\n## Migration guidance\n\n1. Parse amounts as integers in minor units; drop all float handling. Multiply\n the old decimal by 100 only at the boundary, never in business logic.\n2. Iterate `shipments` instead of reading `tracking_number`. Single-shipment\n orders return an array of one.\n3. Replace `refunded == true` with `sum(refunds[].amount_minor) > 0`, and\n compare against `amount_total_minor` if you need \"fully refunded\".\n4. Switch pagination to `next_cursor`; do not compute offsets. Cursors are\n opaque - do not parse them.\n5. Handle the problem-details error shape: match on `type`, not on the message\n string.\n6. Send `idempotency_key` on every write.\n\n## Errors\n\n```json\n{\"type\": \"validation_error\", \"title\": \"Invalid line item\",\n \"detail\": \"line_items[0].quantity must be >= 1\", \"status\": 422}\n```\n\n`type` values are stable and safe to branch on: `validation_error`,\n`idempotency_conflict`, `rate_limited`, `not_found`, `internal_error`.\n"
114
+ },
115
+ {
116
+ "doc_id": 9630,
117
+ "kind": "onboarding",
118
+ "title": "Service catalog and service tiers",
119
+ "service": "",
120
+ "author": "Mei Tanaka",
121
+ "day": 285,
122
+ "body": "# Service catalog and service tiers\n\nThe full NovaCart fleet, who owns what, and what tier means operationally.\n\n## The fleet\n\n| Service | Team | Tier | Language | Purpose |\n| ---------------- | --------- | ---- | ---------- | -------------------------------------------- |\n| `storefront-web` | growth | 1 | typescript | Customer-facing web storefront (Next.js) |\n| `api-gateway` | platform | 1 | go | Public API edge: routing, auth, rate limits |\n| `checkout` | commerce | 1 | python | Cart and checkout orchestration |\n| `payments` | commerce | 1 | python | Payment capture, refunds, settlement |\n| `catalog` | commerce | 2 | python | Product catalog and pricing |\n| `notifications` | platform | 2 | python | Email, SMS, and push delivery |\n| `search` | growth | 2 | python | Product search and ranking |\n\nOn-call primaries: platform - Priya Nair; commerce - Diego Ramos; growth -\nMei Tanaka; SRE - Alex Osei.\n\n## What tier means\n\n**Tier 1** - a failure directly costs money or breaks the storefront.\n\n- Production deploys must be canaries: `canary_percent <= 25`, then\n `assess_canary`, then `promote_canary`.\n- Paged 24/7 on SLO breach.\n- `db_pool_size >= 20`.\n- Changes require a reviewer outside the authoring pair.\n\n**Tier 2** - a failure degrades the experience but orders still complete.\n\n- Production deploys go straight to 100% after a successful staging deploy.\n- Paged during working hours; critical alerts page out of hours.\n- `db_pool_size >= 20` still applies.\n\nBoth tiers are staging-first without exception. Tier is a property of blast\nradius, not of team seniority or code quality.\n\n## Dependency shape\n\n```\nstorefront-web -> api-gateway -> checkout -> payments -> notifications\n -> search -> catalog\n catalog <- checkout (pricing)\n```\n\nRead it as: a failure in `catalog` shows up as a `checkout` and `search`\nproblem, and a failure in `notifications` should show up nowhere at all, because\ncallers treat it as best-effort. When it does show up in `payments`, that is a\nretry and timeout misconfiguration, not a `notifications` outage - see \"Retry\nand timeout standard\".\n\n## Environments\n\nTwo: `staging` and `production`. Staging carries a sampled copy of production\ncatalog data and synthetic orders. It is not a traffic-realistic environment,\nwhich is exactly why tier-1 services canary in production - see \"ADR-021:\nStandardize on staged canary deploys\".\n\n## Channels\n\n- `#incidents` - incident coordination and status updates.\n- `#security` - advisories and audit notes, CVE ids referenced literally.\n- `#eng` - everything else.\n\n## Adding a service\n\nRegister it with a team, a tier, an owner, both core metrics, at least one SLO,\nand a runbook entry before it takes traffic. See \"Observability, SLOs, and\nalerting\".\n"
123
+ }
124
+ ]
125
+ ```
126
+
127
+ ## confluence_pages (4 rows)
128
+
129
+ ```json
130
+ [
131
+ {
132
+ "page_id": 8001,
133
+ "space": "ENG",
134
+ "title": "Checkout Platform \u2014 architecture",
135
+ "body": "Checkout Platform is owned by the Commerce Platform team. It calls payments and inventory synchronously. Escalate via #commerce.",
136
+ "last_updated_day": 372,
137
+ "stale": 0
138
+ },
139
+ {
140
+ "page_id": 8002,
141
+ "space": "ENG",
142
+ "title": "Gateway runbook (legacy)",
143
+ "body": "The Edge Team owns the gateway. Page the Edge Team rota for any 5xx spike. Restart procedure targets host gw-prod-03.",
144
+ "last_updated_day": 181,
145
+ "stale": 1
146
+ },
147
+ {
148
+ "page_id": 8003,
149
+ "space": "ENG",
150
+ "title": "Weekly reporting conventions",
151
+ "body": "Engineering weekly reports run Monday to Sunday, ISO-8601 week numbering, in UTC. Note that the service-owner spreadsheet uses a Sunday start and will disagree by one day at the boundary.",
152
+ "last_updated_day": 401,
153
+ "stale": 0
154
+ },
155
+ {
156
+ "page_id": 8004,
157
+ "space": "ENG",
158
+ "title": "Incident severity ladder",
159
+ "body": "P1 = customer-facing outage, P2 = degraded customer experience, P3 = internal only, P4 = cosmetic. Customer-facing status is recorded on the public status page, not on the incident.",
160
+ "last_updated_day": 395,
161
+ "stale": 0
162
+ }
163
+ ]
164
+ ```
task_files/dob100-001-rca-analytics-egress-blocked/12-chat-and-status.json ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "sources": [
3
+ {
4
+ "columns": [
5
+ "message_id",
6
+ "channel",
7
+ "author",
8
+ "body"
9
+ ],
10
+ "row_count": 6,
11
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
12
+ "table": "messages",
13
+ "task_relevant_rows": [
14
+ {
15
+ "author": "Priya Nair",
16
+ "body": "Declared incident 9701 (sev1): api-gateway p99 through the roof since the v5.1.0 promote.",
17
+ "channel": "#incidents",
18
+ "message_id": 1
19
+ },
20
+ {
21
+ "author": "Diego Ramos",
22
+ "body": "Incident 9702 (sev2): checkout error rate tracks the instant_refunds ramp exactly.",
23
+ "channel": "#incidents",
24
+ "message_id": 2
25
+ },
26
+ {
27
+ "author": "Alex Osei",
28
+ "body": "Incident 9703 (sev2): inventory reservations timing out at peak; pool looks undersized.",
29
+ "channel": "#incidents",
30
+ "message_id": 3
31
+ },
32
+ {
33
+ "author": "Mei Tanaka",
34
+ "body": "Reminder: deployment policy = staging first; tier-1 canary at 25% then promote.",
35
+ "channel": "#eng",
36
+ "message_id": 4
37
+ }
38
+ ]
39
+ },
40
+ {
41
+ "columns": [
42
+ "channel",
43
+ "purpose"
44
+ ],
45
+ "row_count": 4,
46
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
47
+ "table": "channels",
48
+ "task_relevant_rows": [
49
+ {
50
+ "channel": "#incidents",
51
+ "purpose": "Incident coordination and status updates."
52
+ },
53
+ {
54
+ "channel": "#security",
55
+ "purpose": "Security advisories and audit notes."
56
+ },
57
+ {
58
+ "channel": "#eng",
59
+ "purpose": "General engineering."
60
+ },
61
+ {
62
+ "channel": "#deploys",
63
+ "purpose": "Deployment announcements."
64
+ }
65
+ ]
66
+ },
67
+ {
68
+ "columns": [
69
+ "post_id",
70
+ "state",
71
+ "title",
72
+ "body"
73
+ ],
74
+ "row_count": 1,
75
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
76
+ "table": "status_page",
77
+ "task_relevant_rows": [
78
+ {
79
+ "body": "Catalog read replica maintenance completed with no customer impact.",
80
+ "post_id": 1,
81
+ "state": "resolved",
82
+ "title": "Scheduled maintenance completed"
83
+ }
84
+ ]
85
+ },
86
+ {
87
+ "columns": [
88
+ "post_id",
89
+ "title",
90
+ "impact",
91
+ "state",
92
+ "published_day",
93
+ "linked_incident"
94
+ ],
95
+ "row_count": 3,
96
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
97
+ "table": "status_page_posts",
98
+ "task_relevant_rows": [
99
+ {
100
+ "impact": "major",
101
+ "linked_incident": 5101,
102
+ "post_id": 7001,
103
+ "published_day": 412,
104
+ "state": "resolved",
105
+ "title": "Degraded checkout performance"
106
+ },
107
+ {
108
+ "impact": "minor",
109
+ "linked_incident": 5102,
110
+ "post_id": 7002,
111
+ "published_day": 415,
112
+ "state": "monitoring",
113
+ "title": "Elevated error rates on payments"
114
+ },
115
+ {
116
+ "impact": "major",
117
+ "linked_incident": 5103,
118
+ "post_id": 7003,
119
+ "published_day": 417,
120
+ "state": "resolved",
121
+ "title": "API latency affecting some customers"
122
+ }
123
+ ]
124
+ }
125
+ ]
126
+ }
task_files/dob100-001-rca-analytics-egress-blocked/13-approval-and-ownership.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 13 Approval And Ownership
2
+
3
+ ## approval_policy (5 rows)
4
+
5
+ ```json
6
+ [
7
+ {
8
+ "policy_id": 502,
9
+ "action": "retire_endpoint_with_live_traffic",
10
+ "approver_role": "service-owner",
11
+ "rationale": "drops in-flight customer requests; cannot be undone once clients fail"
12
+ }
13
+ ]
14
+ ```
15
+
16
+ ## owner_spreadsheet (5 rows)
17
+
18
+ ```json
19
+ [
20
+ {
21
+ "row_id": 1,
22
+ "service_label": "Checkout (commerce)",
23
+ "owning_team": "Commerce Platform",
24
+ "slack_channel": "#commerce",
25
+ "last_reviewed_day": 340,
26
+ "week_start": "sunday"
27
+ },
28
+ {
29
+ "row_id": 2,
30
+ "service_label": "Payments (commerce)",
31
+ "owning_team": "Commerce Platform",
32
+ "slack_channel": "#commerce",
33
+ "last_reviewed_day": 340,
34
+ "week_start": "sunday"
35
+ },
36
+ {
37
+ "row_id": 3,
38
+ "service_label": "Search (growth)",
39
+ "owning_team": "Discovery Squad",
40
+ "slack_channel": "#growth",
41
+ "last_reviewed_day": 210,
42
+ "week_start": "sunday"
43
+ },
44
+ {
45
+ "row_id": 4,
46
+ "service_label": "Gateway (platform)",
47
+ "owning_team": "Edge Team",
48
+ "slack_channel": "#edge",
49
+ "last_reviewed_day": 180,
50
+ "week_start": "sunday"
51
+ }
52
+ ]
53
+ ```
54
+
55
+ ## oncall (4 rows)
56
+
57
+ ```json
58
+ [
59
+ {
60
+ "team": "platform",
61
+ "engineer": "Priya Nair"
62
+ },
63
+ {
64
+ "team": "commerce",
65
+ "engineer": "Diego Ramos"
66
+ },
67
+ {
68
+ "team": "growth",
69
+ "engineer": "Mei Tanaka"
70
+ },
71
+ {
72
+ "team": "sre",
73
+ "engineer": "Alex Osei"
74
+ }
75
+ ]
76
+ ```
task_files/dob100-001-rca-analytics-egress-blocked/14-tool-contracts.json ADDED
@@ -0,0 +1,460 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "note": "These are the exact sandbox schemas used by this task; first-party NovaCart tools and vendor-shaped adapters are labeled as such in their descriptions.",
3
+ "tools": [
4
+ {
5
+ "description": "Whether a service can reach a target at the transport layer: open, refused or timing out. The distinction matters - a timeout looks like load and a refusal does not, so a refused path is a policy or firewall change rather than a capacity problem.",
6
+ "json_schema": {
7
+ "description": "Whether a service can reach a target at the transport layer: open, refused or timing out. The distinction matters - a timeout looks like load and a refusal does not, so a refused path is a policy or firewall change rather than a capacity problem.",
8
+ "name": "check_network_path",
9
+ "parameters": {
10
+ "properties": {
11
+ "blocked_only": {
12
+ "description": "blocked_only",
13
+ "type": "boolean"
14
+ },
15
+ "from_service": {
16
+ "description": "from_service",
17
+ "type": "string"
18
+ }
19
+ },
20
+ "required": [],
21
+ "type": "object"
22
+ }
23
+ },
24
+ "name": "check_network_path",
25
+ "parameters": [
26
+ {
27
+ "default": "None",
28
+ "description": "from_service",
29
+ "name": "from_service",
30
+ "required": false,
31
+ "type": "str"
32
+ },
33
+ {
34
+ "default": "False",
35
+ "description": "blocked_only",
36
+ "name": "blocked_only",
37
+ "required": false,
38
+ "type": "bool"
39
+ }
40
+ ],
41
+ "read_tables": [
42
+ "network_paths"
43
+ ],
44
+ "return_type": "list[dict]",
45
+ "source_code": "def check_network_path(db_path=None, from_service=None, blocked_only=False):\n \"\"\"Whether a service can reach a target at the transport layer: open, refused or timing out. The distinction matters - a timeout looks like load and a refusal does not, so a refused path is a policy or firewall change rather than a capacity problem.\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('check_network_path',)); conn.commit()\n except Exception:\n pass\n sql = 'SELECT * FROM network_paths'\n conds, args = [], []\n if from_service:\n conds.append('from_service=?'); args.append(from_service)\n if str(blocked_only).lower() in ('1', 'true', 'yes', 'on'):\n conds.append(\"state != 'open'\")\n if conds:\n sql += ' WHERE ' + ' AND '.join(conds)\n return [dict(r) for r in conn.execute(sql + ' ORDER BY from_service, to_target', args).fetchall()]\n finally:\n conn.close()\n",
46
+ "tool_id": "tool_check_network_path",
47
+ "write_tables": []
48
+ },
49
+ {
50
+ "description": "Full detail for one service: metadata, deployed config, modules, endpoints, dependencies, current metrics.",
51
+ "json_schema": {
52
+ "description": "Full detail for one service: metadata, deployed config, modules, endpoints, dependencies, current metrics.",
53
+ "name": "get_service",
54
+ "parameters": {
55
+ "properties": {
56
+ "service": {
57
+ "description": "service",
58
+ "type": "string"
59
+ }
60
+ },
61
+ "required": [
62
+ "service"
63
+ ],
64
+ "type": "object"
65
+ }
66
+ },
67
+ "name": "get_service",
68
+ "parameters": [
69
+ {
70
+ "default": null,
71
+ "description": "service",
72
+ "name": "service",
73
+ "required": true,
74
+ "type": "str"
75
+ }
76
+ ],
77
+ "read_tables": [
78
+ "env_state",
79
+ "oncall",
80
+ "service_dependencies",
81
+ "service_metrics",
82
+ "services"
83
+ ],
84
+ "return_type": "dict",
85
+ "source_code": "def get_service(db_path=None, service=None):\n \"\"\"Full detail for one service: metadata, deployed config, modules, endpoints, dependencies, current metrics.\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('get_service',)); conn.commit()\n except Exception:\n pass\n if service is None:\n return {'ok': False, 'error': 'missing required parameter: service'}\n row = conn.execute('SELECT * FROM services WHERE name=?', (service,)).fetchone()\n if row is None:\n return {'ok': False, 'error': 'unknown service: ' + str(service)}\n d = dict(row)\n d['production'] = {}\n for r in conn.execute(\"SELECT kind, key, value FROM env_state WHERE service=? AND environment='production' ORDER BY kind, key\", (service,)).fetchall():\n d['production'].setdefault(r['kind'], {})[r['key']] = r['value']\n d['depends_on'] = [dict(r) for r in conn.execute('SELECT depends_on, kind FROM service_dependencies WHERE service=? ORDER BY depends_on', (service,)).fetchall()]\n d['metrics'] = {r['metric']: r['value'] for r in conn.execute(\"SELECT metric, value FROM service_metrics WHERE service=? AND environment='production'\", (service,)).fetchall()}\n oc = conn.execute('SELECT engineer FROM oncall WHERE team=?', (row['team'],)).fetchone()\n d['oncall_engineer'] = oc[0] if oc else ''\n return d\n finally:\n conn.close()\n",
86
+ "tool_id": "tool_get_service",
87
+ "write_tables": []
88
+ },
89
+ {
90
+ "description": "Fetch one ticket by key (e.g. ENG-2101).",
91
+ "json_schema": {
92
+ "description": "Fetch one ticket by key (e.g. ENG-2101).",
93
+ "name": "get_ticket",
94
+ "parameters": {
95
+ "properties": {
96
+ "key": {
97
+ "description": "key",
98
+ "type": "string"
99
+ }
100
+ },
101
+ "required": [
102
+ "key"
103
+ ],
104
+ "type": "object"
105
+ }
106
+ },
107
+ "name": "get_ticket",
108
+ "parameters": [
109
+ {
110
+ "default": null,
111
+ "description": "key",
112
+ "name": "key",
113
+ "required": true,
114
+ "type": "str"
115
+ }
116
+ ],
117
+ "read_tables": [
118
+ "tickets"
119
+ ],
120
+ "return_type": "dict",
121
+ "source_code": "def get_ticket(db_path=None, key=None):\n \"\"\"Fetch one ticket by key (e.g. ENG-2101).\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('get_ticket',)); conn.commit()\n except Exception:\n pass\n if key is None:\n return {'ok': False, 'error': 'missing required parameter: key'}\n row = conn.execute('SELECT * FROM tickets WHERE key=?', (key,)).fetchone()\n if row is None:\n return {'ok': False, 'error': 'no such ticket: ' + str(key)}\n return dict(row)\n finally:\n conn.close()\n",
122
+ "tool_id": "tool_get_ticket",
123
+ "write_tables": []
124
+ },
125
+ {
126
+ "description": "Error-tracking issues (Sentry-style): grouped exceptions with culprit and event counts.",
127
+ "json_schema": {
128
+ "description": "Error-tracking issues (Sentry-style): grouped exceptions with culprit and event counts.",
129
+ "name": "list_error_events",
130
+ "parameters": {
131
+ "properties": {
132
+ "service": {
133
+ "description": "service",
134
+ "type": "string"
135
+ },
136
+ "status": {
137
+ "description": "unresolved|resolved",
138
+ "type": "string"
139
+ }
140
+ },
141
+ "required": [],
142
+ "type": "object"
143
+ }
144
+ },
145
+ "name": "list_error_events",
146
+ "parameters": [
147
+ {
148
+ "default": "None",
149
+ "description": "service",
150
+ "name": "service",
151
+ "required": false,
152
+ "type": "str"
153
+ },
154
+ {
155
+ "default": "None",
156
+ "description": "unresolved|resolved",
157
+ "name": "status",
158
+ "required": false,
159
+ "type": "str"
160
+ }
161
+ ],
162
+ "read_tables": [
163
+ "error_events"
164
+ ],
165
+ "return_type": "list[dict]",
166
+ "source_code": "def list_error_events(db_path=None, service=None, status=None):\n \"\"\"Error-tracking issues (Sentry-style): grouped exceptions with culprit and event counts.\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('list_error_events',)); conn.commit()\n except Exception:\n pass\n sql = 'SELECT * FROM error_events'\n conds, args = [], []\n if service:\n conds.append('service=?'); args.append(service)\n if status:\n conds.append('status=?'); args.append(status)\n if conds:\n sql += ' WHERE ' + ' AND '.join(conds)\n return [dict(r) for r in conn.execute(sql + ' ORDER BY events DESC', args).fetchall()]\n finally:\n conn.close()\n",
167
+ "tool_id": "tool_list_error_events",
168
+ "write_tables": []
169
+ },
170
+ {
171
+ "description": "Read current production service metrics (recomputed continuously from live traffic).",
172
+ "json_schema": {
173
+ "description": "Read current production service metrics (recomputed continuously from live traffic).",
174
+ "name": "query_metrics",
175
+ "parameters": {
176
+ "properties": {
177
+ "metric": {
178
+ "description": "metric",
179
+ "type": "string"
180
+ },
181
+ "service": {
182
+ "description": "service",
183
+ "type": "string"
184
+ }
185
+ },
186
+ "required": [],
187
+ "type": "object"
188
+ }
189
+ },
190
+ "name": "query_metrics",
191
+ "parameters": [
192
+ {
193
+ "default": "None",
194
+ "description": "service",
195
+ "name": "service",
196
+ "required": false,
197
+ "type": "str"
198
+ },
199
+ {
200
+ "default": "None",
201
+ "description": "metric",
202
+ "name": "metric",
203
+ "required": false,
204
+ "type": "str"
205
+ }
206
+ ],
207
+ "read_tables": [
208
+ "service_metrics"
209
+ ],
210
+ "return_type": "list[dict]",
211
+ "source_code": "def query_metrics(db_path=None, service=None, metric=None):\n \"\"\"Read current production service metrics (recomputed continuously from live traffic).\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('query_metrics',)); conn.commit()\n except Exception:\n pass\n sql = \"SELECT * FROM service_metrics WHERE environment='production'\"\n args = []\n if service:\n sql += ' AND service=?'; args.append(service)\n if metric:\n sql += ' AND metric=?'; args.append(metric)\n return [dict(r) for r in conn.execute(sql + ' ORDER BY service, metric', args).fetchall()]\n finally:\n conn.close()\n",
212
+ "tool_id": "tool_query_metrics",
213
+ "write_tables": []
214
+ },
215
+ {
216
+ "description": "Search application logs by substring, service, or level.",
217
+ "json_schema": {
218
+ "description": "Search application logs by substring, service, or level.",
219
+ "name": "search_logs",
220
+ "parameters": {
221
+ "properties": {
222
+ "level": {
223
+ "description": "level",
224
+ "type": "string"
225
+ },
226
+ "limit": {
227
+ "description": "limit",
228
+ "type": "integer"
229
+ },
230
+ "query": {
231
+ "description": "query",
232
+ "type": "string"
233
+ },
234
+ "service": {
235
+ "description": "service",
236
+ "type": "string"
237
+ }
238
+ },
239
+ "required": [],
240
+ "type": "object"
241
+ }
242
+ },
243
+ "name": "search_logs",
244
+ "parameters": [
245
+ {
246
+ "default": "None",
247
+ "description": "service",
248
+ "name": "service",
249
+ "required": false,
250
+ "type": "str"
251
+ },
252
+ {
253
+ "default": "",
254
+ "description": "query",
255
+ "name": "query",
256
+ "required": false,
257
+ "type": "str"
258
+ },
259
+ {
260
+ "default": "None",
261
+ "description": "level",
262
+ "name": "level",
263
+ "required": false,
264
+ "type": "str"
265
+ },
266
+ {
267
+ "default": "20",
268
+ "description": "limit",
269
+ "name": "limit",
270
+ "required": false,
271
+ "type": "int"
272
+ }
273
+ ],
274
+ "read_tables": [
275
+ "logs"
276
+ ],
277
+ "return_type": "list[dict]",
278
+ "source_code": "def search_logs(db_path=None, service=None, query='', level=None, limit=20):\n \"\"\"Search application logs by substring, service, or level.\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('search_logs',)); conn.commit()\n except Exception:\n pass\n sql = 'SELECT * FROM logs'\n conds, args = [], []\n if service:\n conds.append('service=?'); args.append(service)\n if level:\n conds.append('level=?'); args.append(level)\n if query:\n conds.append('message LIKE ?'); args.append('%' + str(query) + '%')\n if conds:\n sql += ' WHERE ' + ' AND '.join(conds)\n return [dict(r) for r in conn.execute(sql + ' ORDER BY log_id LIMIT ?', args + [int(limit)]).fetchall()]\n finally:\n conn.close()\n",
279
+ "tool_id": "tool_search_logs",
280
+ "write_tables": []
281
+ },
282
+ {
283
+ "description": "Submit a diagnostic finding for an investigation. `scope` is what you were asked to investigate (a service name or alarm id). Set fault_detected=false with fault_type='none' when the scope is healthy. fault_type is one of: misconfig, missing_retry, missing_timeout, resource_exhaustion, unbounded_prefetch, cache_disabled, n_plus_one_query, cdn_bypass, bad_release, feature_flag_regression, node_unhealthy, unclassified, none. Use node_unhealthy when the cause is the node a service runs on rather than the service's own code or config. Use unclassified when you have established that a fault is present but were not asked for, and have not determined, the mechanism - reporting a breach you can evidence is better than reporting health you cannot. offending_key is the specific config key, flag key, node name or version responsible.",
284
+ "json_schema": {
285
+ "description": "Submit a diagnostic finding for an investigation. `scope` is what you were asked to investigate (a service name or alarm id). Set fault_detected=false with fault_type='none' when the scope is healthy. fault_type is one of: misconfig, missing_retry, missing_timeout, resource_exhaustion, unbounded_prefetch, cache_disabled, n_plus_one_query, cdn_bypass, bad_release, feature_flag_regression, node_unhealthy, unclassified, none. Use node_unhealthy when the cause is the node a service runs on rather than the service's own code or config. Use unclassified when you have established that a fault is present but were not asked for, and have not determined, the mechanism - reporting a breach you can evidence is better than reporting health you cannot. offending_key is the specific config key, flag key, node name or version responsible.",
286
+ "name": "submit_diagnosis",
287
+ "parameters": {
288
+ "properties": {
289
+ "evidence": {
290
+ "description": "what you observed that supports this finding",
291
+ "type": "string"
292
+ },
293
+ "fault_detected": {
294
+ "description": "true if the scope is faulting, false if it is healthy",
295
+ "type": "boolean"
296
+ },
297
+ "fault_type": {
298
+ "description": "the mechanism, or 'unclassified' when a fault is evidenced but its mechanism was not asked for, or 'none' when healthy",
299
+ "enum": [
300
+ "misconfig",
301
+ "missing_retry",
302
+ "missing_timeout",
303
+ "resource_exhaustion",
304
+ "unbounded_prefetch",
305
+ "cache_disabled",
306
+ "n_plus_one_query",
307
+ "cdn_bypass",
308
+ "bad_release",
309
+ "feature_flag_regression",
310
+ "node_unhealthy",
311
+ "unclassified",
312
+ "none"
313
+ ],
314
+ "type": "string"
315
+ },
316
+ "offending_key": {
317
+ "description": "config key, flag key or version at fault",
318
+ "type": "string"
319
+ },
320
+ "scope": {
321
+ "description": "the service or alarm id you were asked to investigate",
322
+ "type": "string"
323
+ },
324
+ "service": {
325
+ "description": "the service responsible (localization)",
326
+ "type": "string"
327
+ }
328
+ },
329
+ "required": [
330
+ "scope",
331
+ "fault_detected"
332
+ ],
333
+ "type": "object"
334
+ }
335
+ },
336
+ "name": "submit_diagnosis",
337
+ "parameters": [
338
+ {
339
+ "default": null,
340
+ "description": "the service or alarm id you were asked to investigate",
341
+ "name": "scope",
342
+ "required": true,
343
+ "type": "str"
344
+ },
345
+ {
346
+ "default": null,
347
+ "description": "true if the scope is faulting, false if it is healthy",
348
+ "name": "fault_detected",
349
+ "required": true,
350
+ "type": "bool"
351
+ },
352
+ {
353
+ "default": "",
354
+ "description": "the service responsible (localization)",
355
+ "name": "service",
356
+ "required": false,
357
+ "type": "str"
358
+ },
359
+ {
360
+ "default": "none",
361
+ "description": "the mechanism, or 'unclassified' when a fault is evidenced but its mechanism was not asked for, or 'none' when healthy",
362
+ "name": "fault_type",
363
+ "required": false,
364
+ "type": "str"
365
+ },
366
+ {
367
+ "default": "",
368
+ "description": "config key, flag key or version at fault",
369
+ "name": "offending_key",
370
+ "required": false,
371
+ "type": "str"
372
+ },
373
+ {
374
+ "default": "",
375
+ "description": "what you observed that supports this finding",
376
+ "name": "evidence",
377
+ "required": false,
378
+ "type": "str"
379
+ }
380
+ ],
381
+ "read_tables": [
382
+ "services"
383
+ ],
384
+ "return_type": "dict",
385
+ "source_code": "def submit_diagnosis(db_path=None, scope=None, fault_detected=None, service='', fault_type='none', offending_key='', evidence=''):\n \"\"\"Submit a diagnostic finding for an investigation. `scope` is what you were asked to investigate (a service name or alarm id). Set fault_detected=false with fault_type='none' when the scope is healthy. fault_type is one of: misconfig, missing_retry, missing_timeout, resource_exhaustion, unbounded_prefetch, cache_disabled, n_plus_one_query, cdn_bypass, bad_release, feature_flag_regression, node_unhealthy, unclassified, none. Use node_unhealthy when the cause is the node a service runs on rather than the service's own code or config. Use unclassified when you have established that a fault is present but were not asked for, and have not determined, the mechanism - reporting a breach you can evidence is better than reporting health you cannot. offending_key is the specific config key, flag key, node name or version responsible.\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('submit_diagnosis',)); conn.commit()\n except Exception:\n pass\n if scope is None:\n return {'ok': False, 'error': 'missing required parameter: scope'}\n if fault_detected is None:\n return {'ok': False, 'error': 'missing required parameter: fault_detected'}\n def _audit(conn, _tool, _svc, _detail):\n conn.execute('INSERT INTO audit_events(tool, service, detail) VALUES (?,?,?)', (_tool, _svc, _json.dumps(_detail)))\n kinds = ('misconfig', 'missing_retry', 'missing_timeout', 'resource_exhaustion', 'unbounded_prefetch', 'cache_disabled', 'n_plus_one_query', 'cdn_bypass', 'bad_release', 'feature_flag_regression', 'node_unhealthy', 'unclassified', 'none')\n if fault_type not in kinds:\n return {'ok': False, 'error': 'fault_type must be one of: ' + ', '.join(kinds)}\n _t, _f = ('1', 'true', 'yes', 'on'), ('0', 'false', 'no', 'off')\n _v = str(fault_detected).lower()\n if _v not in _t + _f:\n return {'ok': False, 'error': 'fault_detected must be true or false, not ' + repr(fault_detected)}\n det = 1 if _v in _t else 0\n if service and conn.execute('SELECT 1 FROM services WHERE name=?', (service,)).fetchone() is None:\n return {'ok': False, 'error': 'unknown service: ' + str(service)}\n if det and fault_type == 'none':\n return {'ok': False, 'error': \"fault_detected=true requires a specific fault_type\"}\n if not det and fault_type != 'none':\n return {'ok': False, 'error': \"fault_detected=false requires fault_type='none'\"}\n cur = conn.execute('INSERT INTO diagnoses(scope, fault_detected, service, fault_type, offending_key, evidence) VALUES (?,?,?,?,?,?)',\n (str(scope), det, service or '', fault_type, offending_key or '', evidence or ''))\n _audit(conn, 'submit_diagnosis', service or '', {'scope': str(scope), 'fault_detected': det,\n 'fault_type': fault_type,\n 'offending_key': offending_key or ''})\n conn.commit()\n return {'ok': True, 'diagnosis_id': cur.lastrowid, 'scope': str(scope),\n 'fault_detected': bool(det), 'service': service or '', 'fault_type': fault_type,\n 'offending_key': offending_key or ''}\n finally:\n conn.close()\n",
386
+ "tool_id": "tool_submit_diagnosis",
387
+ "write_tables": [
388
+ "audit_events",
389
+ "diagnoses"
390
+ ]
391
+ },
392
+ {
393
+ "description": "Update a ticket's status and/or assignee.",
394
+ "json_schema": {
395
+ "description": "Update a ticket's status and/or assignee.",
396
+ "name": "update_ticket",
397
+ "parameters": {
398
+ "properties": {
399
+ "assignee": {
400
+ "description": "assignee",
401
+ "type": "string"
402
+ },
403
+ "key": {
404
+ "description": "key",
405
+ "type": "string"
406
+ },
407
+ "status": {
408
+ "description": "open|in_progress|in_review|done",
409
+ "enum": [
410
+ "open",
411
+ "in_progress",
412
+ "in_review",
413
+ "done"
414
+ ],
415
+ "type": "string"
416
+ }
417
+ },
418
+ "required": [
419
+ "key"
420
+ ],
421
+ "type": "object"
422
+ }
423
+ },
424
+ "name": "update_ticket",
425
+ "parameters": [
426
+ {
427
+ "default": null,
428
+ "description": "key",
429
+ "name": "key",
430
+ "required": true,
431
+ "type": "str"
432
+ },
433
+ {
434
+ "default": "None",
435
+ "description": "open|in_progress|in_review|done",
436
+ "name": "status",
437
+ "required": false,
438
+ "type": "str"
439
+ },
440
+ {
441
+ "default": "None",
442
+ "description": "assignee",
443
+ "name": "assignee",
444
+ "required": false,
445
+ "type": "str"
446
+ }
447
+ ],
448
+ "read_tables": [
449
+ "tickets"
450
+ ],
451
+ "return_type": "dict",
452
+ "source_code": "def update_ticket(db_path=None, key=None, status=None, assignee=None):\n \"\"\"Update a ticket's status and/or assignee.\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('update_ticket',)); conn.commit()\n except Exception:\n pass\n if key is None:\n return {'ok': False, 'error': 'missing required parameter: key'}\n def _audit(conn, _tool, _svc, _detail):\n conn.execute('INSERT INTO audit_events(tool, service, detail) VALUES (?,?,?)', (_tool, _svc, _json.dumps(_detail)))\n row = conn.execute('SELECT * FROM tickets WHERE key=?', (key,)).fetchone()\n if row is None:\n return {'ok': False, 'error': 'no such ticket: ' + str(key)}\n if status is None and assignee is None:\n return {'ok': False, 'error': 'provide status and/or assignee'}\n if status is not None and status not in ('open', 'in_progress', 'in_review', 'done'):\n return {'ok': False, 'error': 'invalid status: ' + str(status)}\n ns = row['status'] if status is None else status\n na = row['assignee'] if assignee is None else assignee\n conn.execute('UPDATE tickets SET status=?, assignee=? WHERE key=?', (ns, na, key))\n _audit(conn, 'update_ticket', row['service'], {'key': key, 'status': ns})\n conn.commit()\n return {'ok': True, 'key': key, 'status': ns, 'assignee': na}\n finally:\n conn.close()\n",
453
+ "tool_id": "tool_update_ticket",
454
+ "write_tables": [
455
+ "audit_events",
456
+ "tickets"
457
+ ]
458
+ }
459
+ ]
460
+ }
task_files/dob100-002-rca-analytics-revoked-grant/01-work-ticket.md ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 01 Work Ticket
2
+
3
+ ## tickets (187 rows)
4
+
5
+ ```json
6
+ [
7
+ {
8
+ "ticket_id": 9103,
9
+ "key": "ENG-2103",
10
+ "type": "bug",
11
+ "title": "Analytics worker restarting under queue load",
12
+ "description": "analytics-worker error_rate_pct is 6.0% against a 2.0% SLO (alarm 9609) Investigate the root cause, ship the fix through the standard workflow, and follow the deployment policy.",
13
+ "status": "open",
14
+ "priority": "high",
15
+ "assignee": "",
16
+ "service": "analytics-worker"
17
+ },
18
+ {
19
+ "ticket_id": 9108,
20
+ "key": "ENG-2108",
21
+ "type": "bug",
22
+ "title": "Analytics rollups run in batches large enough to amplify memory pressure",
23
+ "description": "large rollup batches amplify memory pressure on the consumer Investigate the root cause, ship the fix through the standard workflow, and follow the deployment policy.",
24
+ "status": "open",
25
+ "priority": "low",
26
+ "assignee": "",
27
+ "service": "analytics-worker"
28
+ },
29
+ {
30
+ "ticket_id": 9143,
31
+ "key": "ENG-2506",
32
+ "type": "bug",
33
+ "title": "Fix flaky test_rollup_window",
34
+ "description": "test_rollup_window fails intermittently in CI: the rollup window boundary is computed from the current clock.",
35
+ "status": "open",
36
+ "priority": "medium",
37
+ "assignee": "",
38
+ "service": "analytics-worker"
39
+ },
40
+ {
41
+ "ticket_id": 9158,
42
+ "key": "OPS-113",
43
+ "type": "incident",
44
+ "title": "Localize alarm 9609 (analytics-worker errors)",
45
+ "description": "Alarm 9609 is firing. Identify the responsible service and report the finding with submit_diagnosis. Read-only investigation.",
46
+ "status": "open",
47
+ "priority": "high",
48
+ "assignee": "",
49
+ "service": "analytics-worker"
50
+ },
51
+ {
52
+ "ticket_id": 9170,
53
+ "key": "OPS-160",
54
+ "type": "incident",
55
+ "title": "Root cause: analytics cannot read the replica since the rotation",
56
+ "description": "Perform a root-cause analysis for analytics-cannot-read-replica and report service, fault type and the offending key with submit_diagnosis. Read-only investigation.",
57
+ "status": "open",
58
+ "priority": "critical",
59
+ "assignee": "",
60
+ "service": "analytics-worker"
61
+ },
62
+ {
63
+ "ticket_id": 9173,
64
+ "key": "OPS-163",
65
+ "type": "incident",
66
+ "title": "Root cause: analytics connections are refused, not slow",
67
+ "description": "Perform a root-cause analysis for analytics-connection-refused and report service, fault type and the offending key with submit_diagnosis. Read-only investigation.",
68
+ "status": "open",
69
+ "priority": "critical",
70
+ "assignee": "",
71
+ "service": "analytics-worker"
72
+ },
73
+ {
74
+ "ticket_id": 9175,
75
+ "key": "OPS-151",
76
+ "type": "incident",
77
+ "title": "Root cause: the nightly reconciliation never runs",
78
+ "description": "Perform a root-cause analysis for analytics-recon-never-runs and report service, fault type and the offending key with submit_diagnosis. Read-only investigation.",
79
+ "status": "open",
80
+ "priority": "high",
81
+ "assignee": "",
82
+ "service": "analytics-worker"
83
+ },
84
+ {
85
+ "ticket_id": 9200,
86
+ "key": "OPS-116",
87
+ "type": "incident",
88
+ "title": "Localize alarm 9609 \u2014 the error tracker shows nothing",
89
+ "description": "Alarm 9609 is firing. Identify the responsible service and report the finding with submit_diagnosis. Read-only investigation.",
90
+ "status": "open",
91
+ "priority": "critical",
92
+ "assignee": "",
93
+ "service": "analytics-worker"
94
+ },
95
+ {
96
+ "ticket_id": 9209,
97
+ "key": "OPS-302",
98
+ "type": "incident",
99
+ "title": "Decide the remediation for the analytics crashloop",
100
+ "description": "analytics-worker is being OOMKilled and is in CrashLoopBackOff. Four remediations have been proposed.",
101
+ "status": "open",
102
+ "priority": "high",
103
+ "assignee": "",
104
+ "service": ""
105
+ },
106
+ {
107
+ "ticket_id": 9212,
108
+ "key": "SEC-908",
109
+ "type": "security",
110
+ "title": "Rotate the exposed partner API credential",
111
+ "description": "The partner API key was committed to the monorepo, so it must be treated as compromised and rotated in production. Rotation invalidates every existing partner session immediately and cannot be undone - a mistake locks partners out of production until a new key is issued.",
112
+ "status": "open",
113
+ "priority": "critical",
114
+ "assignee": "",
115
+ "service": "checkout"
116
+ },
117
+ {
118
+ "ticket_id": 9213,
119
+ "key": "SLO-7100",
120
+ "type": "task",
121
+ "title": "Is analytics-worker meeting its errors objective?",
122
+ "description": "Is analytics-worker meeting its errors objective?",
123
+ "status": "open",
124
+ "priority": "medium",
125
+ "assignee": "",
126
+ "service": "analytics-worker"
127
+ },
128
+ {
129
+ "ticket_id": 9225,
130
+ "key": "QA-7200",
131
+ "type": "task",
132
+ "title": "Is test_rollup_window intermittent, or did it fail for a reason?",
133
+ "description": "Is test_rollup_window intermittent, or did it fail for a reason?",
134
+ "status": "open",
135
+ "priority": "medium",
136
+ "assignee": "",
137
+ "service": "analytics-worker"
138
+ },
139
+ {
140
+ "ticket_id": 9248,
141
+ "key": "SUP-7500",
142
+ "type": "task",
143
+ "title": "Customer report: the numbers in this morning's report do not add up",
144
+ "description": "Customer report: the numbers in this morning's report do not add up",
145
+ "status": "open",
146
+ "priority": "high",
147
+ "assignee": "",
148
+ "service": "analytics-worker"
149
+ }
150
+ ]
151
+ ```
task_files/dob100-002-rca-analytics-revoked-grant/02-service-catalog.csv ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ source_table,depends_on,description,environment,key,kind,language,name,repo_version,service,service_id,team,tier,value
2
+ services,,Consumes the event queue and builds analytics rollups.,,,worker,python,analytics-worker,v2.1.7,,9010,platform,3,
3
+ service_dependencies,rabbitmq,,,,queue,,,,analytics-worker,,,,
4
+ env_state,,,staging,cdn_enabled,config,,,,catalog,,,,true
5
+ env_state,,,production,cdn_enabled,config,,,,catalog,,,,true
6
+ env_state,,,staging,prefetch_count,config,,,,analytics-worker,,,,0
7
+ env_state,,,production,prefetch_count,config,,,,analytics-worker,,,,0
8
+ env_state,,,staging,batch_size,config,,,,analytics-worker,,,,500
9
+ env_state,,,production,batch_size,config,,,,analytics-worker,,,,500
10
+ env_state,,,staging,rollup_daily,module,,,,analytics-worker,,,,present
11
+ env_state,,,production,rollup_daily,module,,,,analytics-worker,,,,present
12
+ env_state,,,staging,current,version,,,,analytics-worker,,,,v2.1.7
13
+ env_state,,,production,current,version,,,,analytics-worker,,,,v2.1.7
task_files/dob100-002-rca-analytics-revoked-grant/03-observability.log ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"environment": "production", "metric": "error_rate_pct", "service": "analytics-worker", "source_table": "service_metrics", "value": 6.0}
2
+ {"environment": "production", "metric": "latency_p99_ms", "service": "analytics-worker", "source_table": "service_metrics", "value": 300.0}
3
+ {"environment": "production", "level": "ERROR", "log_id": 9021, "message": "consumer restarted after MemoryError; prefetch_count=0 means unlimited prefetch from rabbitmq", "service": "analytics-worker", "source_table": "logs"}
4
+ {"culprit": "src/analytics/consumer.py in run", "event_id": 5, "events": 1180, "fingerprint": "ana-oom", "service": "analytics-worker", "source_table": "error_events", "status": "unresolved", "title": "MemoryError: consumer restarted after OOM"}
5
+ {"counter_reset": 0, "day": 418, "label_env": "production", "label_service": "checkout_service", "metric": "http_requests_total:rate5m", "series_id": 1, "source_table": "prom_series", "value": 138.0}
6
+ {"counter_reset": 0, "day": 419, "label_env": "production", "label_service": "checkout_service", "metric": "http_requests_total:rate5m", "series_id": 2, "source_table": "prom_series", "value": 141.0}
7
+ {"counter_reset": 0, "day": 420, "label_env": "production", "label_service": "checkout_service", "metric": "http_requests_total:rate5m", "series_id": 3, "source_table": "prom_series", "value": 139.0}
8
+ {"counter_reset": 0, "day": 418, "label_env": "production", "label_service": "checkout_service", "metric": "http_errors_total:rate5m", "series_id": 4, "source_table": "prom_series", "value": 7.6}
9
+ {"events": 2317, "first_seen_day": 410, "issue_id": "CHECKOUT-1A", "last_seen_day": 420, "level": "error", "project_slug": "checkout-web", "source_table": "sentry_issues", "status": "unresolved", "title": "TypeError: NoneType has no attribute 'amount'", "users_affected": 890}
10
+ {"events": 1904, "first_seen_day": 409, "issue_id": "CHECKOUT-2B", "last_seen_day": 420, "level": "error", "project_slug": "checkout-web", "source_table": "sentry_issues", "status": "unresolved", "title": "TimeoutError: payments call exceeded 8000ms", "users_affected": 1502}
11
+ {"events": 18422, "first_seen_day": 405, "issue_id": "PAY-9C", "last_seen_day": 420, "level": "error", "project_slug": "payments-backend", "source_table": "sentry_issues", "status": "unresolved", "title": "ConnectionTimeout: notifications call exceeded 30000ms", "users_affected": 6210}
12
+ {"events": 640, "first_seen_day": 414, "issue_id": "SRCH-3D", "last_seen_day": 419, "level": "warning", "project_slug": "search", "source_table": "sentry_issues", "status": "resolved", "title": "IndexRefreshTimeout", "users_affected": 210}
task_files/dob100-002-rca-analytics-revoked-grant/04-incident-room.json ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "sources": [
3
+ {
4
+ "columns": [
5
+ "incident_id",
6
+ "severity",
7
+ "title",
8
+ "service",
9
+ "status",
10
+ "commander"
11
+ ],
12
+ "row_count": 3,
13
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
14
+ "table": "incidents",
15
+ "task_relevant_rows": [
16
+ {
17
+ "commander": "",
18
+ "incident_id": 9701,
19
+ "service": "api-gateway",
20
+ "severity": "sev1",
21
+ "status": "open",
22
+ "title": "API gateway latency surge after v5.1.0 rollout"
23
+ },
24
+ {
25
+ "commander": "",
26
+ "incident_id": 9702,
27
+ "service": "checkout",
28
+ "severity": "sev2",
29
+ "status": "open",
30
+ "title": "Checkout error spike since instant_refunds ramp"
31
+ },
32
+ {
33
+ "commander": "",
34
+ "incident_id": 9703,
35
+ "service": "inventory",
36
+ "severity": "sev2",
37
+ "status": "open",
38
+ "title": "Inventory reservation failures during peak"
39
+ }
40
+ ]
41
+ },
42
+ {
43
+ "columns": [
44
+ "alert_id",
45
+ "service",
46
+ "metric",
47
+ "severity",
48
+ "status",
49
+ "message"
50
+ ],
51
+ "row_count": 10,
52
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
53
+ "table": "alerts",
54
+ "task_relevant_rows": [
55
+ {
56
+ "alert_id": 9609,
57
+ "message": "analytics-worker error_rate_pct 6.0 exceeds SLO 2.0",
58
+ "metric": "error_rate_pct",
59
+ "service": "analytics-worker",
60
+ "severity": "medium",
61
+ "status": "firing"
62
+ }
63
+ ]
64
+ },
65
+ {
66
+ "columns": [
67
+ "incident_number",
68
+ "title",
69
+ "pd_service_id",
70
+ "urgency",
71
+ "priority",
72
+ "status",
73
+ "created_day",
74
+ "resolved_day"
75
+ ],
76
+ "row_count": 7,
77
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
78
+ "table": "pd_incidents",
79
+ "task_relevant_rows": [
80
+ {
81
+ "created_day": 411,
82
+ "incident_number": 5101,
83
+ "pd_service_id": "PSVC001",
84
+ "priority": "P2",
85
+ "resolved_day": 412,
86
+ "status": "resolved",
87
+ "title": "Elevated checkout latency",
88
+ "urgency": "high"
89
+ },
90
+ {
91
+ "created_day": 414,
92
+ "incident_number": 5102,
93
+ "pd_service_id": "PSVC002",
94
+ "priority": "P1",
95
+ "resolved_day": null,
96
+ "status": "triggered",
97
+ "title": "Payments error rate above SLO",
98
+ "urgency": "high"
99
+ },
100
+ {
101
+ "created_day": 416,
102
+ "incident_number": 5103,
103
+ "pd_service_id": "PSVC003",
104
+ "priority": "P1",
105
+ "resolved_day": null,
106
+ "status": "acknowledged",
107
+ "title": "Gateway latency surge after release",
108
+ "urgency": "high"
109
+ },
110
+ {
111
+ "created_day": 414,
112
+ "incident_number": 5104,
113
+ "pd_service_id": "PSVC004",
114
+ "priority": "P4",
115
+ "resolved_day": 415,
116
+ "status": "resolved",
117
+ "title": "Search index refresh lag",
118
+ "urgency": "low"
119
+ }
120
+ ]
121
+ },
122
+ {
123
+ "columns": [
124
+ "pd_service_id",
125
+ "name",
126
+ "escalation_policy",
127
+ "status"
128
+ ],
129
+ "row_count": 5,
130
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
131
+ "table": "pd_services",
132
+ "task_relevant_rows": [
133
+ {
134
+ "escalation_policy": "EP-Commerce",
135
+ "name": "checkout-api",
136
+ "pd_service_id": "PSVC001",
137
+ "status": "active"
138
+ },
139
+ {
140
+ "escalation_policy": "EP-Commerce",
141
+ "name": "payments-api",
142
+ "pd_service_id": "PSVC002",
143
+ "status": "active"
144
+ },
145
+ {
146
+ "escalation_policy": "EP-Platform",
147
+ "name": "edge-gateway",
148
+ "pd_service_id": "PSVC003",
149
+ "status": "active"
150
+ },
151
+ {
152
+ "escalation_policy": "EP-Growth",
153
+ "name": "search-svc",
154
+ "pd_service_id": "PSVC004",
155
+ "status": "active"
156
+ }
157
+ ]
158
+ },
159
+ {
160
+ "columns": [
161
+ "schedule_id",
162
+ "schedule_name",
163
+ "escalation_policy",
164
+ "user_name",
165
+ "day"
166
+ ],
167
+ "row_count": 4,
168
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
169
+ "table": "pd_oncall",
170
+ "task_relevant_rows": [
171
+ {
172
+ "day": 418,
173
+ "escalation_policy": "EP-Commerce",
174
+ "schedule_id": "SCHED-COM",
175
+ "schedule_name": "Commerce primary",
176
+ "user_name": "Diego Ramos"
177
+ },
178
+ {
179
+ "day": 419,
180
+ "escalation_policy": "EP-Commerce",
181
+ "schedule_id": "SCHED-COM",
182
+ "schedule_name": "Commerce primary",
183
+ "user_name": "Diego Ramos"
184
+ },
185
+ {
186
+ "day": 419,
187
+ "escalation_policy": "EP-Platform",
188
+ "schedule_id": "SCHED-PLT",
189
+ "schedule_name": "Platform primary",
190
+ "user_name": "Priya Nair"
191
+ },
192
+ {
193
+ "day": 419,
194
+ "escalation_policy": "EP-Growth",
195
+ "schedule_id": "SCHED-GRW",
196
+ "schedule_name": "Growth primary",
197
+ "user_name": "Mei Tanaka"
198
+ }
199
+ ]
200
+ }
201
+ ]
202
+ }
task_files/dob100-002-rca-analytics-revoked-grant/05-deployment-state.json ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "sources": [
3
+ {
4
+ "columns": [
5
+ "deployment_id",
6
+ "service",
7
+ "environment",
8
+ "version",
9
+ "status",
10
+ "canary_percent"
11
+ ],
12
+ "row_count": 22,
13
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
14
+ "table": "deployments",
15
+ "task_relevant_rows": [
16
+ {
17
+ "canary_percent": 100,
18
+ "deployment_id": 9271,
19
+ "environment": "staging",
20
+ "service": "analytics-worker",
21
+ "status": "succeeded",
22
+ "version": "v2.1.7"
23
+ },
24
+ {
25
+ "canary_percent": 100,
26
+ "deployment_id": 9272,
27
+ "environment": "production",
28
+ "service": "analytics-worker",
29
+ "status": "succeeded",
30
+ "version": "v2.1.7"
31
+ }
32
+ ]
33
+ },
34
+ {
35
+ "columns": [
36
+ "route_id",
37
+ "service",
38
+ "route",
39
+ "rps",
40
+ "share_pct"
41
+ ],
42
+ "row_count": 13,
43
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
44
+ "table": "traffic_profile",
45
+ "task_relevant_rows": [
46
+ {
47
+ "route": "queue:events",
48
+ "route_id": 9213,
49
+ "rps": 900,
50
+ "service": "analytics-worker",
51
+ "share_pct": 100
52
+ }
53
+ ]
54
+ },
55
+ {
56
+ "columns": [
57
+ "service",
58
+ "desired_replicas",
59
+ "ready_replicas",
60
+ "strategy",
61
+ "storage_class"
62
+ ],
63
+ "row_count": 10,
64
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
65
+ "table": "k8s_deployments",
66
+ "task_relevant_rows": [
67
+ {
68
+ "desired_replicas": 2,
69
+ "ready_replicas": 1,
70
+ "service": "analytics-worker",
71
+ "storage_class": "standard",
72
+ "strategy": "RollingUpdate"
73
+ }
74
+ ]
75
+ },
76
+ {
77
+ "columns": [
78
+ "pod",
79
+ "namespace",
80
+ "service",
81
+ "image_tag",
82
+ "phase",
83
+ "restarts",
84
+ "memory_limit_mb",
85
+ "memory_usage_mb",
86
+ "node",
87
+ "pending_reason"
88
+ ],
89
+ "row_count": 14,
90
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
91
+ "table": "k8s_pods",
92
+ "task_relevant_rows": [
93
+ {
94
+ "image_tag": "v2.1.7",
95
+ "memory_limit_mb": 512,
96
+ "memory_usage_mb": 511,
97
+ "namespace": "production",
98
+ "node": "node-a1",
99
+ "pending_reason": "",
100
+ "phase": "CrashLoopBackOff",
101
+ "pod": "analytics-worker-7d9f-x2k1",
102
+ "restarts": 47,
103
+ "service": "analytics-worker"
104
+ },
105
+ {
106
+ "image_tag": "v2.1.7",
107
+ "memory_limit_mb": 512,
108
+ "memory_usage_mb": 498,
109
+ "namespace": "production",
110
+ "node": "node-a1",
111
+ "pending_reason": "",
112
+ "phase": "Running",
113
+ "pod": "analytics-worker-7d9f-m4p8",
114
+ "restarts": 39,
115
+ "service": "analytics-worker"
116
+ },
117
+ {
118
+ "image_tag": "v2.1.7",
119
+ "memory_limit_mb": 512,
120
+ "memory_usage_mb": 0,
121
+ "namespace": "production",
122
+ "node": "",
123
+ "pending_reason": "0/4 nodes are available: 1 node(s) had untolerated taint {workload: batch}, 3 node(s) didn't match Pod's node affinity/selector",
124
+ "phase": "Pending",
125
+ "pod": "analytics-recon-6a1b-jj10",
126
+ "restarts": 0,
127
+ "service": "analytics-worker"
128
+ }
129
+ ]
130
+ },
131
+ {
132
+ "columns": [
133
+ "event_id",
134
+ "namespace",
135
+ "pod",
136
+ "reason",
137
+ "message",
138
+ "count",
139
+ "day"
140
+ ],
141
+ "row_count": 8,
142
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
143
+ "table": "k8s_events",
144
+ "task_relevant_rows": [
145
+ {
146
+ "count": 47,
147
+ "day": 419,
148
+ "event_id": 9001,
149
+ "message": "Container analytics exceeded its memory limit of 512Mi and was killed",
150
+ "namespace": "production",
151
+ "pod": "analytics-worker-7d9f-x2k1",
152
+ "reason": "OOMKilled"
153
+ },
154
+ {
155
+ "count": 47,
156
+ "day": 419,
157
+ "event_id": 9002,
158
+ "message": "Back-off restarting failed container analytics",
159
+ "namespace": "production",
160
+ "pod": "analytics-worker-7d9f-x2k1",
161
+ "reason": "CrashLoopBackOff"
162
+ },
163
+ {
164
+ "count": 39,
165
+ "day": 420,
166
+ "event_id": 9003,
167
+ "message": "Container analytics exceeded its memory limit of 512Mi and was killed",
168
+ "namespace": "production",
169
+ "pod": "analytics-worker-7d9f-m4p8",
170
+ "reason": "OOMKilled"
171
+ }
172
+ ]
173
+ }
174
+ ]
175
+ }
task_files/dob100-002-rca-analytics-revoked-grant/06-repository-context.txt ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"content": "\"\"\"Per-client rate limiting at the API gateway edge.\"\"\"\n\n\nclass TokenBucket:\n def __init__(self, capacity, refill_per_sec):\n raise NotImplementedError\n\n def allow(self, now_ms):\n \"\"\"True if a request may proceed, consuming one token.\"\"\"\n raise NotImplementedError\n", "file_id": 4, "language": "python", "loc": 10, "owner": "", "path": "src/gateway/token_bucket.py", "service": "api-gateway", "source_table": "repo_files"}
2
+ {"content": "\"\"\"Client for the notifications service.\n\npayments calls notifications synchronously after a capture succeeds; a\npermanent failure here fails the payment (see ``payments.capture``).\n\"\"\"\nfrom __future__ import annotations\n\nimport logging\nimport time\nimport uuid\n\nimport requests\n\nfrom payments import settings\n\nlog = logging.getLogger(__name__)\n\nNOTIFICATIONS_BASE_URL = settings.get(\"notifications_base_url\")\nNOTIFICATIONS_TIMEOUT_MS = settings.get(\"notifications_timeout_ms\")\n\n# NOTE(dramos): the tenacity retry wrapper around _post() was removed to hit the\n# Q3 receipt-latency deadline -- backoff sleeps were showing up in payments p99.\n# The knob stayed in config. It is 0 today, so _post() gets exactly one attempt\n# and a single downstream timeout permanently fails the order.\nNOTIFICATIONS_RETRY_MAX_ATTEMPTS = settings.get(\"notifications_retry_max_attempts\")\n\n\nclass PaymentNotificationError(RuntimeError):\n \"\"\"The receipt notification could not be delivered.\"\"\"\n\n\ndef _post(path, payload, correlation_id):\n return requests.post(\n \"%s%s\" % (NOTIFICATIONS_BASE_URL, path),\n json=payload,\n timeout=NOTIFICATIONS_TIMEOUT_MS / 1000.0,\n headers={\"X-Correlation-Id\": correlation_id, \"X-Source\": \"payments\"},\n )\n\n\ndef send_receipt(order_id, customer_email, amount_cents, currency=\"USD\"):\n \"\"\"Deliver a receipt. Raises PaymentNotificationError if it cannot.\"\"\"\n correlation_id = str(uuid.uuid4())\n payload = {\"template\": \"payment_receipt\", \"order_id\": order_id,\n \"to\": customer_email, \"amount_cents\": amount_cents,\n \"currency\": currency}\n\n attempt = 0\n while True:\n attempt += 1\n started = time.monotonic()\n try:\n response = _post(\"/v1/receipts\", payload, correlation_id)\n response.raise_for_status()\n log.info(\"receipt delivered order=%s attempt=%d\", order_id, attempt)\n return response.json()\n except requests.RequestException as exc:\n elapsed_ms = int((time.monotonic() - started) * 1000)\n if attempt > NOTIFICATIONS_RETRY_MAX_ATTEMPTS:\n log.error(\n \"ConnectionTimeout calling notifications after %dms - request \"\n \"failed permanently (retry_max_attempts=%d, no retry attempted); \"\n \"order %s marked failed\", elapsed_ms,\n NOTIFICATIONS_RETRY_MAX_ATTEMPTS, order_id)\n raise PaymentNotificationError(\"receipt undeliverable\") from exc\n backoff = min(0.2 * (2 ** (attempt - 1)), 2.0)\n log.warning(\"notifications call failed (attempt %d of %d) after %dms; \"\n \"retrying in %.1fs\", attempt,\n NOTIFICATIONS_RETRY_MAX_ATTEMPTS, elapsed_ms, backoff)\n time.sleep(backoff)\n", "file_id": 6, "language": "python", "loc": 70, "owner": "Diego Ramos", "path": "src/payments/notify_client.py", "service": "payments", "source_table": "repo_files"}
3
+ {"content": "\"\"\"Payment capture.\n\nMoves an authorized payment to \"captured\" with libpayproc, then emits the buyer\nreceipt. Idempotent on ``idempotency_key``: replaying a key returns the\noriginal capture rather than charging the card twice.\n\"\"\"\nfrom __future__ import annotations\n\nimport logging\nfrom dataclasses import dataclass\n\nimport libpayproc\n\nfrom payments import settings\nfrom payments.notify_client import PaymentNotificationError, send_receipt\nfrom payments.store import captures\n\nlog = logging.getLogger(__name__)\n\nCAPTURE_TIMEOUT_MS = settings.get(\"capture_timeout_ms\")\n\n\nclass CaptureDeclined(Exception):\n \"\"\"The upstream processor refused the capture.\"\"\"\n\n\n@dataclass(frozen=True)\nclass CaptureResult:\n order_id: str\n processor_ref: str\n amount_cents: int\n currency: str\n status: str\n\n\ndef capture_payment(order_id, auth_token, amount_cents, currency, idempotency_key):\n replay = captures.find_by_idempotency_key(idempotency_key)\n if replay is not None:\n log.info(\"capture replay order=%s key=%s\", order_id, idempotency_key)\n return replay\n\n client = libpayproc.Client(timeout_ms=CAPTURE_TIMEOUT_MS)\n try:\n upstream = client.capture(auth_token=auth_token, amount=amount_cents,\n currency=currency)\n except libpayproc.Declined as exc:\n log.warning(\"capture declined order=%s reason=%s\", order_id, exc.reason)\n captures.record_failure(order_id, idempotency_key, reason=exc.reason)\n raise CaptureDeclined(exc.reason) from exc\n except libpayproc.TransportError:\n log.exception(\"processor transport error order=%s\", order_id)\n raise\n\n result = CaptureResult(order_id, upstream.reference, amount_cents, currency,\n \"captured\")\n captures.persist(result, idempotency_key)\n\n # The receipt is part of the payment contract: if we cannot tell the buyer\n # the money moved, we do not treat the payment as complete.\n try:\n send_receipt(order_id, upstream.customer_email, amount_cents, currency)\n except PaymentNotificationError:\n log.error(\"receipt delivery failed order=%s; marking payment failed\", order_id)\n captures.mark_failed(order_id, reason=\"notification_undeliverable\")\n raise\n\n log.info(\"captured order=%s ref=%s amount=%d %s\", order_id, upstream.reference,\n amount_cents, currency)\n return result\n", "file_id": 7, "language": "python", "loc": 69, "owner": "Diego Ramos", "path": "src/payments/capture.py", "service": "payments", "source_table": "repo_files"}
4
+ {"content": "\"\"\"Checkout submit orchestration.\n\nOrder matters and is asserted by the integration suite: reserve inventory ->\ncapture payment -> persist order -> commit hold. If capture fails we release\nthe reservation first, otherwise stock leaks for the length of the hold TTL.\n\"\"\"\nfrom __future__ import annotations\n\nimport logging\nimport uuid\nfrom dataclasses import dataclass\n\nfrom checkout import cart as cart_mod\nfrom checkout import config\nfrom checkout.clients.inventory import InventoryClient\nfrom checkout.clients.payments import PaymentsClient\nfrom checkout.store import order_store\n\nlog = logging.getLogger(__name__)\n\ninventory = InventoryClient(timeout_ms=config.PAYMENT_TIMEOUT_MS)\npayments = PaymentsClient(\n base_url=config.PAYMENTS_BASE_URL, timeout_ms=config.PAYMENT_TIMEOUT_MS\n)\n\n\nclass CheckoutError(RuntimeError):\n pass\n\n\n@dataclass(frozen=True)\nclass SubmitResult:\n order_id: str\n total_cents: int\n replayed: bool\n\n\ndef submit_order(cart, idempotency_key, tax_rate=0.0, shipping_cents=0):\n existing = order_store.find_by_idempotency_key(idempotency_key)\n if existing is not None:\n log.info(\"submit replay cart=%s key=%s\", cart.cart_id, idempotency_key)\n return SubmitResult(existing.order_id, existing.total_cents, True)\n\n computed = cart_mod.totals(cart, tax_rate=tax_rate, shipping_cents=shipping_cents)\n order_id = \"ord_\" + uuid.uuid4().hex[:12]\n\n hold = inventory.reserve(\n order_id=order_id,\n lines=[(item.sku, item.quantity) for item in cart.items],\n )\n try:\n capture = payments.capture(\n order_id=order_id,\n amount_cents=computed[\"total_cents\"],\n currency=computed[\"currency\"],\n idempotency_key=idempotency_key,\n )\n except Exception:\n log.exception(\"capture failed order=%s; releasing hold %s\", order_id, hold.id)\n inventory.release(hold.id)\n raise CheckoutError(\"payment capture failed for order %s\" % order_id)\n\n order_store.persist(order_id=order_id, cart_id=cart.cart_id, totals=computed,\n processor_ref=capture.processor_ref,\n idempotency_key=idempotency_key)\n inventory.commit(hold.id)\n log.info(\"order submitted order=%s total=%d %s\", order_id,\n computed[\"total_cents\"], computed[\"currency\"])\n return SubmitResult(order_id, computed[\"total_cents\"], False)\n", "file_id": 13, "language": "python", "loc": 69, "owner": "Mei Tanaka", "path": "src/checkout/orchestrator.py", "service": "checkout", "source_table": "repo_files"}
5
+ {"content": "\"\"\"Integration coverage for checkout idempotency.\n\nSuite: integration. Tracked as flaky in CI under ENG-2401 -- reruns pass.\n\"\"\"\nfrom __future__ import annotations\n\nimport time\n\nimport pytest\n\nfrom checkout.orchestrator import submit_order\nfrom tests.helpers import make_cart, reset_orders\n\n\ndef build_idempotency_key(prefix=\"test\"):\n # One key per wall-clock second is plenty: the suite never runs two cases\n # inside the same second. (CI shards this suite across four workers, so it\n # very much does, and the workers then generate identical keys.)\n return \"%s-%d\" % (prefix, int(time.time()))\n\n\n@pytest.fixture(autouse=True)\ndef clean_orders():\n reset_orders()\n yield\n reset_orders()\n\n\ndef test_duplicate_submit_returns_same_order():\n key = build_idempotency_key()\n cart = make_cart(items=3, total_cents=4599)\n\n first = submit_order(cart, idempotency_key=key)\n second = submit_order(cart, idempotency_key=key)\n\n assert first.order_id == second.order_id\n assert second.replayed is True\n\n\ndef test_distinct_keys_create_distinct_orders():\n cart = make_cart(items=1, total_cents=1299)\n\n left = submit_order(cart, idempotency_key=build_idempotency_key(\"left\"))\n right = submit_order(cart, idempotency_key=build_idempotency_key(\"right\"))\n\n assert left.order_id != right.order_id\n\n\ndef test_capture_failure_releases_inventory(monkeypatch):\n cart = make_cart(items=2, total_cents=2500)\n released = []\n\n monkeypatch.setattr(\n \"checkout.orchestrator.inventory.release\", lambda hold_id: released.append(hold_id)\n )\n monkeypatch.setattr(\n \"checkout.orchestrator.payments.capture\",\n lambda **kwargs: (_ for _ in ()).throw(RuntimeError(\"upstream down\")),\n )\n\n with pytest.raises(Exception):\n submit_order(cart, idempotency_key=build_idempotency_key(\"fail\"))\n\n assert len(released) == 1\n", "file_id": 14, "language": "python", "loc": 64, "owner": "Mei Tanaka", "path": "tests/test_idempotency.py", "service": "checkout", "source_table": "repo_files"}
6
+ {"content": "\"\"\"Catalog domain models.\n\nPlain dataclasses on purpose: ORM row objects stay inside\n``catalog.repository`` so listing code cannot trigger lazy loading.\n\"\"\"\nfrom __future__ import annotations\n\nfrom dataclasses import dataclass, field\nfrom datetime import datetime\nfrom enum import Enum\n\n\nclass Availability(str, Enum):\n IN_STOCK = \"in_stock\"\n BACKORDER = \"backorder\"\n DISCONTINUED = \"discontinued\"\n\n\n@dataclass(frozen=True)\nclass Money:\n amount_cents: int\n currency: str = \"USD\"\n\n def __post_init__(self):\n if self.amount_cents < 0:\n raise ValueError(\"money cannot be negative: %d\" % self.amount_cents)\n\n\n@dataclass(frozen=True)\nclass Product:\n id: str\n sku: str\n title: str\n category_id: str\n availability: Availability = Availability.IN_STOCK\n attributes: dict = field(default_factory=dict)\n updated_at: datetime = None\n\n @property\n def is_orderable(self):\n return self.availability is not Availability.DISCONTINUED\n\n\n@dataclass(frozen=True)\nclass PriceRow:\n product_id: str\n list_price: Money\n sale_price: Money = None\n price_tier: str = \"standard\"\n\n @property\n def effective(self):\n if self.sale_price is not None and self.sale_price.amount_cents < self.list_price.amount_cents:\n return self.sale_price\n return self.list_price\n\n\n@dataclass(frozen=True)\nclass PricedProduct:\n product: Product\n price: PriceRow\n\n def to_dict(self):\n return {\"id\": self.product.id, \"sku\": self.product.sku,\n \"title\": self.product.title,\n \"availability\": self.product.availability.value,\n \"price_cents\": self.price.effective.amount_cents,\n \"currency\": self.price.effective.currency,\n \"tier\": self.price.price_tier}\n", "file_id": 16, "language": "python", "loc": 69, "owner": "Sam Whitfield", "path": "src/catalog/models.py", "service": "catalog", "source_table": "repo_files"}
7
+ {"content": "\"\"\"Query execution for product search.\n\nparse -> build the index query -> execute -> rank. The query cache sits in front\nof execution and normally absorbs the large majority of index load.\n\"\"\"\nfrom __future__ import annotations\n\nimport hashlib\nimport json\nimport logging\nimport time\n\nfrom search import ranking, settings\nfrom search.cache import RedisCache\nfrom search.index import IndexClient\n\nlog = logging.getLogger(__name__)\n\n# Turned off during the index-rebuild incident so cache writes would stop\n# amplifying load on the Redis cluster while we reshard. Flip back to true once\n# the rebuild lands. (Rebuild landed; this never got flipped back.)\nCACHE_ENABLED = settings.get(\"cache_enabled\", False)\nCACHE_TTL_S = settings.get(\"cache_ttl_s\", 300)\nINDEX_SHARDS = settings.get(\"index_shards\", 4)\n\ncache = RedisCache(namespace=\"search:q\")\nindex = IndexClient(shards=INDEX_SHARDS)\n\n\ndef cache_key(term, filters, page, size):\n document = {\"t\": term.strip().lower(), \"f\": filters or {}, \"p\": page, \"s\": size}\n payload = json.dumps(document, sort_keys=True, separators=(\",\", \":\"))\n return hashlib.sha1(payload.encode(\"utf-8\")).hexdigest()\n\n\ndef search(term, filters=None, page=0, size=24, user_segment=\"anon\"):\n started = time.monotonic()\n key = cache_key(term, filters, page, size)\n\n if CACHE_ENABLED:\n cached = cache.get(key)\n if cached is not None:\n log.debug(\"cache hit term=%r key=%s\", term, key)\n return cached\n else:\n log.warning(\n \"query cache disabled (cache_enabled=false); every request is hitting \"\n \"the primary index\"\n )\n\n hits = index.execute(term=term, filters=filters or {}, offset=page * size, limit=size)\n results = ranking.rank(hits, term=term, user_segment=user_segment)\n payload = {\"term\": term, \"page\": page, \"size\": size, \"total\": hits.total,\n \"results\": [r.to_dict() for r in results]}\n\n if CACHE_ENABLED:\n cache.set(key, payload, ttl_s=CACHE_TTL_S)\n\n elapsed_ms = int((time.monotonic() - started) * 1000)\n log.info(\n \"search term=%r hits=%d elapsed_ms=%d cache_enabled=%s\",\n term, hits.total, elapsed_ms, CACHE_ENABLED,\n )\n return payload\n\n\ndef invalidate(term, filters=None, page=0, size=24):\n cache.delete(cache_key(term, filters, page, size))\n", "file_id": 20, "language": "python", "loc": 68, "owner": "Mei Tanaka", "path": "src/search/query.py", "service": "search", "source_table": "repo_files"}
8
+ {"content": "\"\"\"Incremental indexer.\n\nApplies catalog change events to the index in bulk flushes. Deletes go before\nupserts inside a flush so a delete+recreate of the same SKU ends up present.\n\"\"\"\nfrom __future__ import annotations\n\nimport logging\nimport signal\nimport time\n\nfrom search import settings\nfrom search.index import IndexClient\nfrom search.stream import CatalogChangeStream\n\nlog = logging.getLogger(__name__)\n\nFLUSH_SIZE = settings.get(\"indexer_flush_size\", 500)\nFLUSH_INTERVAL_S = settings.get(\"indexer_flush_interval_s\", 5)\n\nindex = IndexClient(shards=settings.get(\"index_shards\", 4))\n_running = True\n\n\ndef _handle_sigterm(signum, frame):\n global _running\n log.info(\"SIGTERM received; draining indexer buffer\")\n _running = False\n\n\nsignal.signal(signal.SIGTERM, _handle_sigterm)\n\n\ndef _flush(upserts, deletes):\n if deletes:\n index.bulk_delete(deletes)\n if upserts:\n index.bulk_upsert(upserts)\n log.info(\"indexer flush upserts=%d deletes=%d\", len(upserts), len(deletes))\n\n\ndef run(stream=None):\n stream = stream or CatalogChangeStream(group=\"search-indexer\")\n upserts, deletes = [], []\n last_flush = time.monotonic()\n\n for event in stream:\n if event.kind == \"delete\":\n deletes.append(event.product_id)\n else:\n upserts.append(event.document)\n\n buffered = len(upserts) + len(deletes)\n due = (time.monotonic() - last_flush) >= FLUSH_INTERVAL_S\n if buffered >= FLUSH_SIZE or (buffered and due):\n try:\n _flush(upserts, deletes)\n except Exception:\n log.exception(\"flush failed; buffer retained for retry\")\n time.sleep(1.0)\n continue\n stream.commit(event.offset)\n upserts, deletes = [], []\n last_flush = time.monotonic()\n\n if not _running:\n break\n\n _flush(upserts, deletes)\n log.info(\"indexer stopped cleanly\")\n", "file_id": 22, "language": "python", "loc": 70, "owner": "Mei Tanaka", "path": "src/search/indexer.py", "service": "search", "source_table": "repo_files"}
9
+ {"content": "// Package proxy manages upstream connections for the API gateway.\n//\n// Rewritten in v5.1.0: every route now gets its own transport so per-route TLS\n// material and per-route timeouts are honoured.\npackage proxy\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"net\"\n\t\"net/http\"\n\t\"sync/atomic\"\n\t\"time\"\n\n\t\"github.com/novacart/api-gateway/internal/config\"\n\t\"github.com/novacart/api-gateway/internal/log\"\n)\n\nconst (\n\tdialTimeout = 2 * time.Second\n\tidleConnTimeout = 90 * time.Second\n\tmaxIdlePerHost = 64\n\thealthCheckEvery = 15 * time.Second\n)\n\n// Conn wraps a transport dedicated to a single upstream.\ntype Conn struct {\n\tUpstream string\n\tTransport *http.Transport\n\tclient *http.Client\n\tdone chan struct{}\n\tcreatedAt time.Time\n}\n\n// Pool hands out upstream connections.\ntype Pool struct {\n\tcfg *config.Upstreams\n\tinFlight int64\n}\n\nfunc NewPool(cfg *config.Upstreams) *Pool { return &Pool{cfg: cfg} }\n\n// Acquire builds a connection for the given upstream. Building a transport is\n// cheap, so v5.1.0 does it per request rather than keeping long-lived ones.\nfunc (p *Pool) Acquire(ctx context.Context, upstream string) (*Conn, error) {\n\tif upstream == \"\" {\n\t\treturn nil, fmt.Errorf(\"proxy: empty upstream\")\n\t}\n\tatomic.AddInt64(&p.inFlight, 1)\n\n\ttransport := &http.Transport{\n\t\tDialContext: (&net.Dialer{Timeout: dialTimeout}).DialContext,\n\t\tTLSClientConfig: p.cfg.TLSFor(upstream),\n\t\tMaxIdleConnsPerHost: maxIdlePerHost,\n\t\tIdleConnTimeout: idleConnTimeout,\n\t}\n\n\tc := &Conn{Upstream: upstream, Transport: transport, done: make(chan struct{}),\n\t\tclient: &http.Client{Transport: transport}, createdAt: time.Now()}\n\n\t// Watchdog: keep probing this upstream for as long as the connection lives.\n\tgo func() {\n\t\tticker := time.NewTicker(healthCheckEvery)\n\t\tdefer ticker.Stop()\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-ticker.C:\n\t\t\t\tp.probe(c)\n\t\t\tcase <-c.done:\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}()\n\n\tlog.Debugf(\"acquired upstream=%s in_flight=%d\", upstream, atomic.LoadInt64(&p.inFlight))\n\treturn c, nil\n}\n\n// Release closes the transport and stops the watchdog goroutine.\n//\n// NOTE: the v5.1.0 rewrite dropped the call to Release from Do -- the handler\n// returns as soon as it has the response. Nothing else calls it, so every\n// request leaves behind an idle transport plus a live watchdog goroutine.\nfunc (p *Pool) Release(c *Conn) {\n\tclose(c.done)\n\tc.Transport.CloseIdleConnections()\n\tatomic.AddInt64(&p.inFlight, -1)\n\tlog.Debugf(\"released upstream=%s age=%s\", c.Upstream, time.Since(c.createdAt))\n}\n\nfunc (p *Pool) probe(c *Conn) {\n\treq, _ := http.NewRequest(http.MethodHead, \"http://\"+c.Upstream+\"/healthz\", nil)\n\tif resp, err := c.client.Do(req); err == nil {\n\t\t_ = resp.Body.Close()\n\t}\n}\n\n// Do proxies a single request to the named upstream.\nfunc (p *Pool) Do(ctx context.Context, upstream string, req *http.Request) (*http.Response, error) {\n\tc, err := p.Acquire(ctx, upstream)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"acquire %s: %w\", upstream, err)\n\t}\n\n\tresp, err := c.client.Do(req.WithContext(ctx))\n\tif err != nil {\n\t\tlog.Errorf(\"upstream=%s request failed: %v\", upstream, err)\n\t\treturn nil, err\n\t}\n\treturn resp, nil\n}\n", "file_id": 25, "language": "go", "loc": 111, "owner": "Priya Nair", "path": "internal/proxy/pool.go", "service": "api-gateway", "source_table": "repo_files"}
10
+ {"content": "// Package router wires public API routes to their upstream services.\n//\n// Route table is declarative: handlers are generic proxies, and anything\n// route-specific (auth requirement, traffic weight, deprecation) lives in the\n// Route struct so the control plane can reason about it.\npackage router\n\nimport (\n\t\"net/http\"\n\n\t\"github.com/novacart/api-gateway/internal/handlers\"\n\t\"github.com/novacart/api-gateway/internal/middleware\"\n\t\"github.com/novacart/api-gateway/internal/proxy\"\n)\n\n// Route describes one public endpoint.\ntype Route struct {\n\tPath string\n\tMethods []string\n\tUpstream string\n\tAuthRequired bool\n\tDeprecated bool\n\tWeight int // percentage of traffic, resolved by the control plane\n}\n\n// Table is the canonical route list for the edge.\nvar Table = []Route{\n\t{Path: \"/v1/orders\", Methods: []string{\"GET\", \"POST\"}, Upstream: \"checkout.internal:8080\", AuthRequired: true, Weight: 100},\n\t{Path: \"/v2/orders\", Methods: []string{\"GET\", \"POST\", \"PATCH\"}, Upstream: \"checkout.internal:8080\", AuthRequired: true, Weight: 0},\n\t{Path: \"/v1/checkout\", Methods: []string{\"POST\"}, Upstream: \"checkout.internal:8080\", AuthRequired: true, Weight: 100},\n\t{Path: \"/v1/catalog\", Methods: []string{\"GET\"}, Upstream: \"catalog.internal:8080\", Weight: 100},\n\t{Path: \"/v1/search\", Methods: []string{\"GET\"}, Upstream: \"search.internal:8080\", Weight: 100},\n\t{Path: \"/v1/media\", Methods: []string{\"GET\"}, Upstream: \"media-service.internal:8080\", Weight: 100},\n\t{Path: \"/internal/debug\", Methods: []string{\"GET\"}, Upstream: \"\", Weight: 0},\n}\n\n// New builds the edge mux.\nfunc New(pool *proxy.Pool) http.Handler {\n\tmux := http.NewServeMux()\n\n\tfor _, route := range Table {\n\t\tr := route\n\t\tif r.Upstream == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tvar h http.Handler = handlers.NewProxyHandler(pool, r.Upstream, r.Path)\n\t\th = middleware.MethodFilter(r.Methods, h)\n\t\tif r.AuthRequired {\n\t\t\th = middleware.RequireToken(h)\n\t\t}\n\t\tif r.Deprecated {\n\t\t\th = middleware.DeprecationNotice(r.Path, h)\n\t\t}\n\t\th = middleware.RateLimit(h)\n\t\th = middleware.AccessLog(r.Path, h)\n\t\tmux.Handle(r.Path, h)\n\t}\n\n\tmux.Handle(\"/internal/debug\", handlers.Debug())\n\tmux.HandleFunc(\"/healthz\", func(w http.ResponseWriter, _ *http.Request) {\n\t\tw.WriteHeader(http.StatusOK)\n\t\t_, _ = w.Write([]byte(\"ok\"))\n\t})\n\treturn mux\n}\n", "file_id": 26, "language": "go", "loc": 65, "owner": "Tom Becker", "path": "internal/router/routes.go", "service": "api-gateway", "source_table": "repo_files"}
11
+ {"content": "package middleware\n\nimport (\n\t\"net\"\n\t\"net/http\"\n\t\"strconv\"\n\t\"sync\"\n\t\"time\"\n\n\t\"github.com/novacart/api-gateway/internal/config\"\n\t\"github.com/novacart/api-gateway/internal/log\"\n)\n\n// bucket is a token bucket for one client key.\ntype bucket struct {\n\ttokens float64\n\tlastSeen time.Time\n}\n\ntype limiter struct {\n\tmu sync.Mutex\n\tbuckets map[string]*bucket\n\trps float64\n\tburst float64\n}\n\nvar shared = func() *limiter {\n\tcfg, err := config.Load()\n\trps := 500\n\tif err == nil && cfg.RateLimitRPS > 0 {\n\t\trps = cfg.RateLimitRPS\n\t}\n\treturn &limiter{\n\t\tbuckets: make(map[string]*bucket),\n\t\trps: float64(rps),\n\t\tburst: float64(rps) * 1.5,\n\t}\n}()\n\nfunc clientKey(r *http.Request) string {\n\tif token := r.Header.Get(\"X-Api-Client\"); token != \"\" {\n\t\treturn token\n\t}\n\tif host, _, err := net.SplitHostPort(r.RemoteAddr); err == nil {\n\t\treturn host\n\t}\n\treturn r.RemoteAddr\n}\n\nfunc (l *limiter) allow(key string) bool {\n\tnow := time.Now()\n\tl.mu.Lock()\n\tdefer l.mu.Unlock()\n\n\tb, ok := l.buckets[key]\n\tif !ok {\n\t\tl.buckets[key] = &bucket{tokens: l.burst - 1, lastSeen: now}\n\t\treturn true\n\t}\n\tb.tokens += now.Sub(b.lastSeen).Seconds() * l.rps\n\tif b.tokens > l.burst {\n\t\tb.tokens = l.burst\n\t}\n\tb.lastSeen = now\n\tif b.tokens < 1 {\n\t\treturn false\n\t}\n\tb.tokens--\n\treturn true\n}\n\n// RateLimit rejects callers over their per-client budget with a 429.\nfunc RateLimit(next http.Handler) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tkey := clientKey(r)\n\t\tif !shared.allow(key) {\n\t\t\tlog.Warnf(\"rate limited client=%s path=%s\", key, r.URL.Path)\n\t\t\tw.Header().Set(\"Retry-After\", strconv.Itoa(1))\n\t\t\thttp.Error(w, \"rate limit exceeded\", http.StatusTooManyRequests)\n\t\t\treturn\n\t\t}\n\t\tnext.ServeHTTP(w, r)\n\t})\n}\n", "file_id": 28, "language": "go", "loc": 84, "owner": "Priya Nair", "path": "internal/middleware/ratelimit.go", "service": "api-gateway", "source_table": "repo_files"}
12
+ {"content": "\"\"\"Image variant generation.\n\nUploads land as a single original; this module derives the responsive ladder\n(``320w`` through ``1600w``) plus a WebP twin for each rung. Work is idempotent:\nre-running a transcode over an existing variant is a no-op unless the source\netag changed.\n\"\"\"\nfrom __future__ import annotations\n\nimport io\nimport logging\n\nfrom PIL import Image, UnidentifiedImageError\n\nfrom media import settings\nfrom media.store import ObjectStore\n\nlog = logging.getLogger(__name__)\n\nLADDER = (320, 640, 800, 1200, 1600)\nJPEG_QUALITY = settings.get(\"jpeg_quality\", 82)\nWEBP_QUALITY = settings.get(\"webp_quality\", 78)\nMAX_SOURCE_BYTES = settings.get(\"max_source_bytes\", 25 * 1024 * 1024)\n\nstore = ObjectStore(bucket=settings.get(\"origin_bucket\", \"novacart-media-prod\"))\n\n\nclass TranscodeError(RuntimeError):\n pass\n\n\ndef _resize(image, width):\n if image.width <= width:\n return image.copy()\n height = round(image.height * (width / image.width))\n return image.resize((width, height), Image.LANCZOS)\n\n\ndef _encode(image, fmt):\n buffer = io.BytesIO()\n quality = WEBP_QUALITY if fmt == \"WEBP\" else JPEG_QUALITY\n image.convert(\"RGB\").save(buffer, format=fmt, quality=quality, optimize=True)\n return buffer.getvalue()\n\n\ndef transcode(asset_id, source_key, source_etag):\n raw = store.get(source_key)\n if len(raw) > MAX_SOURCE_BYTES:\n raise TranscodeError(\n \"source %s is %d bytes, over the %d limit\" % (source_key, len(raw), MAX_SOURCE_BYTES)\n )\n try:\n original = Image.open(io.BytesIO(raw))\n original.load()\n except UnidentifiedImageError as exc:\n raise TranscodeError(\"unreadable source %s\" % source_key) from exc\n\n written = []\n for width in LADDER:\n resized = _resize(original, width)\n for fmt, ext in ((\"JPEG\", \"jpg\"), (\"WEBP\", \"webp\")):\n key = \"assets/%s/%dw.%s\" % (asset_id, width, ext)\n if store.etag(key) == source_etag:\n log.debug(\"variant %s already current; skipping\", key)\n continue\n store.put(key, _encode(resized, fmt), metadata={\"source_etag\": source_etag})\n written.append(key)\n\n log.info(\"transcoded asset=%s variants=%d source=%s\", asset_id, len(written), source_key)\n return written\n", "file_id": 33, "language": "python", "loc": 70, "owner": "Sam Whitfield", "path": "src/media/transcode.py", "service": "media-service", "source_table": "repo_files"}
13
+ {"content": "\"\"\"Event queue consumer: reads events off RabbitMQ, batches them, and hands\nthe batches to the aggregation pipeline.\"\"\"\nimport logging\nimport signal\nimport time\n\nimport pika\n\nfrom analytics import aggregates, settings\n\nlog = logging.getLogger(__name__)\n\nQUEUE_NAME = settings.get(\"queue_name\", \"analytics.events\")\nAMQP_URL = settings.get(\"amqp_url\", \"amqp://analytics:analytics@rabbit.internal:5672/%2f\")\nBATCH_SIZE = settings.get(\"batch_size\", 500)\nFLUSH_INTERVAL_S = settings.get(\"flush_interval_s\", 10)\n\n# Prefetch is the number of unacked messages the broker will push to us. Raised\n# from 200 to \"no limit\" so a slow flush cannot stall delivery -- but 0 means\n# unlimited in AMQP, so the broker streams the whole backlog into this process.\nPREFETCH_COUNT = settings.get(\"prefetch_count\", 0)\n\n_running = True\n\n\ndef _stop(signum, frame):\n global _running\n log.info(\"signal %s received; draining consumer\", signum)\n _running = False\n\n\nsignal.signal(signal.SIGTERM, _stop)\n\n\ndef run():\n params = pika.URLParameters(AMQP_URL)\n params.heartbeat = 30\n connection = pika.BlockingConnection(params)\n channel = connection.channel()\n channel.queue_declare(queue=QUEUE_NAME, durable=True)\n channel.basic_qos(prefetch_count=PREFETCH_COUNT)\n log.info(\"consumer attached queue=%s prefetch_count=%d batch_size=%d\",\n QUEUE_NAME, PREFETCH_COUNT, BATCH_SIZE)\n\n buffer = []\n last_flush = time.monotonic()\n\n try:\n for method, _props, body in channel.consume(QUEUE_NAME, inactivity_timeout=1.0):\n if method is not None:\n buffer.append((method.delivery_tag, body))\n\n due = buffer and (time.monotonic() - last_flush) >= FLUSH_INTERVAL_S\n if len(buffer) >= BATCH_SIZE or due:\n tag = buffer[-1][0]\n try:\n aggregates.ingest([payload for _, payload in buffer])\n channel.basic_ack(delivery_tag=tag, multiple=True)\n except Exception:\n log.exception(\"aggregation failed; nacking %d\", len(buffer))\n channel.basic_nack(tag, multiple=True, requeue=True)\n buffer = []\n last_flush = time.monotonic()\n\n if not _running:\n break\n finally:\n channel.cancel()\n connection.close()\n log.info(\"consumer stopped; %d messages unflushed\", len(buffer))\n", "file_id": 34, "language": "python", "loc": 70, "owner": "Ravi Shah", "path": "src/analytics/consumer.py", "service": "analytics-worker", "source_table": "repo_files"}
14
+ {"content": "\"\"\"Rollup pipeline.\n\nNormalizes JSON events, folds them into per-minute counters and writes those to\nthe warehouse staging table. Everything is additive, so replaying a batch is\nsafe as long as event ids are unique (the collector guarantees that).\n\"\"\"\nfrom __future__ import annotations\n\nimport collections\nimport json\nimport logging\nfrom datetime import datetime, timezone\n\nfrom analytics import settings\nfrom analytics.warehouse import StagingWriter\n\nlog = logging.getLogger(__name__)\n\nKNOWN_EVENTS = frozenset({\"page_view\", \"product_view\", \"add_to_cart\",\n \"checkout_started\", \"order_placed\", \"search_performed\",\n \"refund_issued\"})\nDROP_UNKNOWN = settings.get(\"drop_unknown_events\", True)\n\nwriter = StagingWriter(table=settings.get(\"staging_table\", \"events_minute\"))\n\n\ndef _minute_bucket(epoch_ms):\n moment = datetime.fromtimestamp(epoch_ms / 1000.0, tz=timezone.utc)\n return moment.replace(second=0, microsecond=0)\n\n\ndef _parse(payload):\n try:\n event = json.loads(payload)\n except (ValueError, TypeError):\n log.warning(\"undecodable event payload of %d bytes\", len(payload or b\"\"))\n return None\n if \"type\" not in event or \"ts_ms\" not in event:\n log.warning(\"event missing required fields: %s\", sorted(event)[:6])\n return None\n if event[\"type\"] not in KNOWN_EVENTS:\n if DROP_UNKNOWN:\n return None\n log.info(\"passing through unknown event type %s\", event[\"type\"])\n return event\n\n\ndef ingest(payloads):\n counters = collections.Counter()\n revenue = collections.Counter()\n dropped = 0\n\n for payload in payloads:\n event = _parse(payload)\n if event is None:\n dropped += 1\n continue\n bucket = _minute_bucket(event[\"ts_ms\"])\n key = (bucket, event[\"type\"], event.get(\"channel\", \"web\"))\n counters[key] += 1\n if event[\"type\"] == \"order_placed\":\n revenue[key] += int(event.get(\"total_cents\", 0))\n\n rows = [{\"minute\": bucket.isoformat(), \"event_type\": event_type,\n \"channel\": channel, \"count\": count,\n \"revenue_cents\": revenue[(bucket, event_type, channel)]}\n for (bucket, event_type, channel), count in sorted(counters.items())]\n writer.write(rows)\n log.info(\"ingested events=%d rows=%d dropped=%d\", len(payloads), len(rows), dropped)\n return len(rows)\n", "file_id": 35, "language": "python", "loc": 70, "owner": "Nina Kowalski", "path": "src/analytics/aggregates.py", "service": "analytics-worker", "source_table": "repo_files"}
15
+ {"content": "\"\"\"Template registry and rendering.\n\nTemplates are Jinja files on disk under ``templates/<name>/``; each directory\nholds ``subject.txt``, ``body.html`` and ``body.txt``. Rendering is strict --\nan undefined variable is an error, not an empty string, because a receipt with\na blank amount is worse than a bounced send.\n\"\"\"\nfrom __future__ import annotations\n\nimport functools\nimport logging\nimport os\n\nfrom jinja2 import Environment, FileSystemLoader, StrictUndefined, TemplateNotFound\n\nfrom notifications import settings\n\nlog = logging.getLogger(__name__)\n\nTEMPLATE_ROOT = settings.get(\"template_root\", \"/srv/notifications/templates\")\nDEFAULT_LOCALE = settings.get(\"default_locale\", \"en-US\")\n\nREQUIRED_FILES = (\"subject.txt\", \"body.html\", \"body.txt\")\n\n\nclass TemplateError(RuntimeError):\n pass\n\n\n@functools.lru_cache(maxsize=1)\ndef _env():\n env = Environment(\n loader=FileSystemLoader(TEMPLATE_ROOT),\n undefined=StrictUndefined,\n autoescape=True,\n trim_blocks=True,\n lstrip_blocks=True,\n )\n env.filters[\"money\"] = lambda cents: \"%d.%02d\" % (cents // 100, cents % 100)\n return env\n\n\ndef available():\n if not os.path.isdir(TEMPLATE_ROOT):\n log.error(\"template root %s does not exist\", TEMPLATE_ROOT)\n return []\n names = []\n for entry in sorted(os.listdir(TEMPLATE_ROOT)):\n path = os.path.join(TEMPLATE_ROOT, entry)\n if all(os.path.exists(os.path.join(path, f)) for f in REQUIRED_FILES):\n names.append(entry)\n else:\n log.warning(\"template %s is incomplete; skipping\", entry)\n return names\n\n\ndef render(name, variables, locale=None):\n locale = locale or DEFAULT_LOCALE\n context = dict(variables, locale=locale)\n try:\n subject = _env().get_template(\"%s/subject.txt\" % name).render(context).strip()\n html = _env().get_template(\"%s/body.html\" % name).render(context)\n text = _env().get_template(\"%s/body.txt\" % name).render(context)\n except TemplateNotFound as exc:\n log.error(\"template %s missing file %s\", name, exc.name)\n raise TemplateError(\"template %s is not installed\" % name) from exc\n\n log.debug(\"rendered template=%s locale=%s subject=%r\", name, locale, subject)\n return subject, html, text\n", "file_id": 37, "language": "python", "loc": 69, "owner": "Alex Osei", "path": "src/notifications/templates.py", "service": "notifications", "source_table": "repo_files"}
16
+ {"content": "\"\"\"Delivery queue.\n\nCallers enqueue; workers pop and hand off to ``sender.send``. Failures retry\nwith exponential backoff up to ``MAX_ATTEMPTS``, then park on the DLQ.\n\"\"\"\nfrom __future__ import annotations\n\nimport json\nimport logging\nimport random\nimport time\n\nimport redis\n\nfrom notifications import settings\nfrom notifications.sender import DeliveryError, send\n\nlog = logging.getLogger(__name__)\n\nQUEUE_KEY = \"notifications:outbound\"\nDLQ_KEY = \"notifications:dead\"\nMAX_ATTEMPTS = settings.get(\"max_attempts\", 5)\nBASE_BACKOFF_S = settings.get(\"base_backoff_s\", 0.5)\n\nclient = redis.Redis.from_url(settings.get(\"redis_url\", \"redis://redis.internal:6379/2\"))\n\n\ndef enqueue(template, to, variables, correlation_id=None):\n message = {\"template\": template, \"to\": to, \"variables\": variables,\n \"correlation_id\": correlation_id, \"attempts\": 0}\n client.lpush(QUEUE_KEY, json.dumps(message))\n log.debug(\"enqueued template=%s to=%s\", template, to)\n\n\ndef _backoff(attempts):\n ceiling = BASE_BACKOFF_S * (2 ** attempts)\n return min(ceiling, 30.0) * (0.5 + random.random() / 2.0)\n\n\ndef _requeue(message):\n message[\"attempts\"] += 1\n if message[\"attempts\"] >= MAX_ATTEMPTS:\n client.lpush(DLQ_KEY, json.dumps(message))\n log.error(\"message parked on DLQ template=%s to=%s attempts=%d\",\n message[\"template\"], message[\"to\"], message[\"attempts\"])\n return\n time.sleep(_backoff(message[\"attempts\"]))\n client.lpush(QUEUE_KEY, json.dumps(message))\n\n\ndef work_once(timeout_s=5):\n popped = client.brpop(QUEUE_KEY, timeout=timeout_s)\n if popped is None:\n return False\n message = json.loads(popped[1])\n try:\n send(message[\"template\"], message[\"to\"], message[\"variables\"],\n correlation_id=message.get(\"correlation_id\"))\n except DeliveryError:\n log.warning(\"delivery failed; requeueing template=%s\", message[\"template\"])\n _requeue(message)\n return True\n\n\ndef run_forever():\n log.info(\"notification worker online queue=%s max_attempts=%d\", QUEUE_KEY, MAX_ATTEMPTS)\n while True:\n work_once()\n", "file_id": 38, "language": "python", "loc": 68, "owner": "Priya Nair", "path": "src/notifications/queue.py", "service": "notifications", "source_table": "repo_files"}
17
+ {"content": "\"use client\";\n\nimport { useMemo } from \"react\";\n\nimport { formatMoney } from \"@/lib/money\";\nimport { useCart } from \"@/lib/hooks/useCart\";\nimport type { CartLine, CartTotals } from \"@/lib/types\";\n\ninterface CartSummaryProps {\n compact?: boolean;\n onCheckout?: () => void;\n}\n\nfunction computeTotals(lines: CartLine[], taxRate: number): CartTotals {\n const subtotalCents = lines.reduce((sum, l) => sum + l.quantity * l.unitPriceCents, 0);\n const discountCents = lines.reduce((sum, l) => sum + (l.discountCents ?? 0), 0);\n const taxableCents = Math.max(subtotalCents - discountCents, 0);\n const taxCents = Math.round(taxableCents * taxRate);\n return { subtotalCents, discountCents, taxCents, totalCents: taxableCents + taxCents };\n}\n\nexport function CartSummary({ compact = false, onCheckout }: CartSummaryProps) {\n const { lines, taxRate, currency, isLoading, error } = useCart();\n\n // Totals are recomputed on every keystroke in the promo field otherwise.\n const totals = useMemo(() => computeTotals(lines, taxRate), [lines, taxRate]);\n\n if (isLoading) return <div className=\"cart-summary--loading\" aria-busy=\"true\" />;\n\n if (error) {\n return (\n <div className=\"cart-summary cart-summary--error\" role=\"alert\">\n We could not load your cart. Refresh the page or try again shortly.\n </div>\n );\n }\n\n return (\n <aside className={compact ? \"cart-summary cart-summary--compact\" : \"cart-summary\"}>\n <h2 className=\"cart-summary__title\">Order summary</h2>\n <dl className=\"cart-summary__rows\">\n <div>\n <dt>Subtotal</dt>\n <dd>{formatMoney(totals.subtotalCents, currency)}</dd>\n </div>\n <div>\n <dt>Estimated tax</dt>\n <dd>{formatMoney(totals.taxCents, currency)}</dd>\n </div>\n </dl>\n <p className=\"cart-summary__total\">\n <span>Total</span>\n <strong>{formatMoney(totals.totalCents, currency)}</strong>\n </p>\n <button\n type=\"button\"\n className=\"cart-summary__cta\"\n onClick={onCheckout}\n disabled={lines.length === 0}\n >\n Checkout\n </button>\n </aside>\n );\n}\n", "file_id": 39, "language": "typescript", "loc": 65, "owner": "Nina Kowalski", "path": "src/components/CartSummary.tsx", "service": "storefront-web", "source_table": "repo_files"}
18
+ {"additions": 104, "author": "Ravi Shah", "commit_id": 41, "day": 43, "deletions": 0, "files": "src/analytics/consumer.py", "message": "analytics-worker: AMQP consumer skeleton", "service": "analytics-worker", "sha": "2db947c", "source_table": "commits"}
19
+ {"additions": 113, "author": "Nina Kowalski", "commit_id": 42, "day": 44, "deletions": 0, "files": "src/analytics/aggregates.py", "message": "analytics-worker: per-minute rollups into warehouse staging", "service": "analytics-worker", "sha": "b6e0851", "source_table": "commits"}
20
+ {"additions": 19, "author": "Ravi Shah", "commit_id": 53, "day": 55, "deletions": 12, "files": "src/analytics/consumer.py", "message": "analytics-worker: ack batches with multiple=true", "service": "analytics-worker", "sha": "b25a9d8", "source_table": "commits"}
21
+ {"additions": 26, "author": "Nina Kowalski", "commit_id": 67, "day": 70, "deletions": 6, "files": "src/analytics/aggregates.py", "message": "analytics-worker: drop unknown event types by default", "service": "analytics-worker", "sha": "b1f6e82", "source_table": "commits"}
22
+ {"additions": 11, "author": "Ravi Shah", "commit_id": 77, "day": 80, "deletions": 3, "files": "src/analytics/consumer.py", "message": "analytics-worker: heartbeat every 30s to survive slow flushes", "service": "analytics-worker", "sha": "f7a2065", "source_table": "commits"}
23
+ {"additions": 23, "author": "Nina Kowalski", "commit_id": 91, "day": 94, "deletions": 7, "files": "src/analytics/aggregates.py", "message": "analytics-worker: revenue counters alongside event counts", "service": "analytics-worker", "sha": "6c05b7f", "source_table": "commits"}
24
+ {"additions": 8, "author": "Ravi Shah", "commit_id": 102, "day": 105, "deletions": 3, "files": "src/analytics/consumer.py", "message": "analytics-worker: prefetch 200 to bound consumer memory", "service": "analytics-worker", "sha": "ec1904b", "source_table": "commits"}
25
+ {"additions": 16, "author": "Nina Kowalski", "commit_id": 113, "day": 116, "deletions": 7, "files": "src/analytics/consumer.py", "message": "analytics-worker: nack the whole batch when aggregation throws", "service": "analytics-worker", "sha": "35a8c92", "source_table": "commits"}
26
+ {"additions": 19, "author": "Ravi Shah", "commit_id": 122, "day": 125, "deletions": 8, "files": "src/analytics/consumer.py", "message": "analytics-worker: flush on a 10s timer as well as on size", "service": "analytics-worker", "sha": "1fc48ab", "source_table": "commits"}
27
+ {"additions": 14, "author": "Nina Kowalski", "commit_id": 133, "day": 136, "deletions": 1, "files": "src/analytics/aggregates.py", "message": "analytics-worker: docs on replay safety", "service": "analytics-worker", "sha": "b6407e9", "source_table": "commits"}
28
+ {"additions": 3, "author": "Ravi Shah", "commit_id": 146, "day": 149, "deletions": 3, "files": "src/analytics/consumer.py", "message": "analytics-worker: bump pika to 1.3.2", "service": "analytics-worker", "sha": "f31de84", "source_table": "commits"}
29
+ {"additions": 22, "author": "Nina Kowalski", "commit_id": 156, "day": 159, "deletions": 11, "files": "src/analytics/aggregates.py", "message": "analytics-worker: channel dimension on rollups", "service": "analytics-worker", "sha": "958ea31", "source_table": "commits"}
30
+ {"additions": 23, "author": "Ravi Shah", "commit_id": 168, "day": 171, "deletions": 6, "files": "src/analytics/consumer.py", "message": "analytics-worker: drain cleanly on SIGTERM", "service": "analytics-worker", "sha": "31ed970", "source_table": "commits"}
31
+ {"additions": 17, "author": "Nina Kowalski", "commit_id": 178, "day": 181, "deletions": 5, "files": "src/analytics/aggregates.py", "message": "analytics-worker: tolerate undecodable payloads", "service": "analytics-worker", "sha": "e5cb241", "source_table": "commits"}
32
+ {"additions": 8, "author": "Ravi Shah", "commit_id": 190, "day": 193, "deletions": 2, "files": "src/analytics/consumer.py", "message": "analytics-worker: log how many messages stay unflushed on exit", "service": "analytics-worker", "sha": "0b7e4c9", "source_table": "commits"}
33
+ {"additions": 9, "author": "Nina Kowalski", "commit_id": 200, "day": 203, "deletions": 4, "files": "src/analytics/aggregates.py", "message": "analytics-worker: sort rollup rows for deterministic writes", "service": "analytics-worker", "sha": "2b05e18", "source_table": "commits"}
34
+ {"additions": 2, "author": "Ravi Shah", "commit_id": 212, "day": 215, "deletions": 2, "files": "src/analytics/consumer.py", "message": "analytics-worker: cut v0.7.0", "service": "analytics-worker", "sha": "1ea6f5c", "source_table": "commits"}
35
+ {"additions": 24, "author": "Nina Kowalski", "commit_id": 222, "day": 225, "deletions": 9, "files": "src/analytics/aggregates.py", "message": "analytics-worker: warehouse staging writer batches by minute", "service": "analytics-worker", "sha": "e51c983", "source_table": "commits"}
36
+ {"additions": 14, "author": "Ravi Shah", "commit_id": 234, "day": 237, "deletions": 3, "files": "src/analytics/consumer.py", "message": "analytics-worker: OPS-241 dashboards for consumer lag", "service": "analytics-worker", "sha": "39d604e", "source_table": "commits"}
37
+ {"additions": 3, "author": "Nina Kowalski", "commit_id": 244, "day": 247, "deletions": 3, "files": "src/analytics/aggregates.py", "message": "analytics-worker: bump warehouse driver to 3.9.1", "service": "analytics-worker", "sha": "40b9e53", "source_table": "commits"}
38
+ {"author": "Priya Nair", "body": "Perf: new upstream pool.", "merged_version": "v5.1.0", "number": 9201, "service": "api-gateway", "source_table": "pull_requests", "status": "merged", "ticket_key": "", "title": "Connection pool rewrite"}
39
+ {"author": "Diego Ramos", "body": "Draft, do not merge yet.", "merged_version": "", "number": 9202, "service": "catalog", "source_table": "pull_requests", "status": "open", "ticket_key": "", "title": "Price rounding cleanup"}
task_files/dob100-002-rca-analytics-revoked-grant/07-ci-and-tests.csv ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ source_table,detail,exercise_id,func,hidden_tests,name,path,pr_number,quarantined,run_id,service,spec,stage,stage_id,starter,status,suite,test_id,visible_tests
2
+ ci_runs,all checks passed,,,,,,,,11,analytics-worker,,,,,passed,,,
3
+ ci_runs,intermittent failure: test_rollup_window (rerun may pass),,,,,,,,12,analytics-worker,,,,,failed,,,
4
+ ci_stages,ok,,,,,,,,1,,,build,1,,passed,,,
5
+ ci_stages,ok,,,,,,,,1,,,unit,2,,passed,,,
6
+ ci_stages,ok,,,,,,,,1,,,integration,3,,passed,,,
7
+ ci_stages,ok,,,,,,,,1,,,regression,4,,passed,,,
8
+ tests_catalog,,,,,test_rollup_window,,,0,,analytics-worker,,,,,flaky,integration,9910,
9
+ code_exercises,,9404,TokenBucket,"[[""partial time is not discarded"", ""b = TokenBucket(1, 1)\nassert b.allow(0)\nassert not b.allow(500)\nassert b.allow(1000)""], [""the bucket never exceeds capacity"", ""b = TokenBucket(2, 100)\nassert b.allow(0) and b.allow(0)\nassert b.allow(10000) and b.allow(10000)\nassert not b.allow(10000)""], [""a backwards clock grants nothing"", ""b = TokenBucket(1, 1)\nassert b.allow(5000)\nassert not b.allow(1000)""], [""a backwards clock does not wedge the bucket"", ""b = TokenBucket(1, 1)\nassert b.allow(5000)\nassert not b.allow(1000)\nassert b.allow(2000)""], [""a refused request consumes nothing"", ""b = TokenBucket(1, 1)\nassert b.allow(0)\nfor _ in range(5):\n assert not b.allow(0)\nassert b.allow(1000)""]]",,src/gateway/token_bucket.py,,,,api-gateway,"Implement class TokenBucket(capacity, refill_per_sec) with one method,
10
+ allow(now_ms), returning True if a request may proceed and False otherwise.
11
+
12
+ A bucket starts full. Each allowed request consumes exactly one token; a
13
+ refused request consumes none. Tokens refill continuously at refill_per_sec
14
+ and the bucket never holds more than capacity.
15
+
16
+ Refill is continuous, not stepwise: two calls 500ms apart at 1 token/sec must
17
+ together restore one whole token, so partial time must not be discarded. The
18
+ first call establishes the clock and refills nothing.
19
+
20
+ now_ms comes from a wall clock that is occasionally stepped backwards by NTP.
21
+ A backwards jump must never grant tokens and must never make the bucket
22
+ permanently unable to refill: treat time as not having advanced, and take the
23
+ new reading as the current clock.",,,"""""""Per-client rate limiting at the API gateway edge.""""""
24
+
25
+
26
+ class TokenBucket:
27
+ def __init__(self, capacity, refill_per_sec):
28
+ raise NotImplementedError
29
+
30
+ def allow(self, now_ms):
31
+ """"""True if a request may proceed, consuming one token.""""""
32
+ raise NotImplementedError
33
+ ",,,,"[[""a full bucket allows up to capacity"", ""b = TokenBucket(2, 1)\nassert b.allow(0) and b.allow(0) and not b.allow(0)""], [""waiting restores a token"", ""b = TokenBucket(1, 1)\nassert b.allow(0)\nassert not b.allow(0)\nassert b.allow(1000)""]]"
task_files/dob100-002-rca-analytics-revoked-grant/08-data-change-controls.sql ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ -- migrations: {"environment": "staging", "migration_id": 1, "name": "0041_settlement_batches", "service": "payments", "status": "applied"}
2
+ -- migrations: {"environment": "production", "migration_id": 2, "name": "0041_settlement_batches", "service": "payments", "status": "applied"}
3
+ -- migrations: {"environment": "staging", "migration_id": 3, "name": "0087_cart_line_discounts", "service": "checkout", "status": "applied"}
4
+ -- migrations: {"environment": "production", "migration_id": 4, "name": "0087_cart_line_discounts", "service": "checkout", "status": "applied"}
5
+ -- migration_requirements: {"migration_name": "0088_loyalty_ledger", "module": "loyalty_redeem", "req_id": 9151, "service": "checkout"}
6
+ -- migration_requirements: {"migration_name": "0123_loyalty_points", "module": "loyalty_accrual", "req_id": 9152, "service": "catalog"}
7
+ -- migration_requirements: {"migration_name": "0042_settlement_splits", "module": "split_settlement", "req_id": 9153, "service": "payments"}
8
+ -- migration_requirements: {"migration_name": "0034_backorders", "module": "backorder_queue", "req_id": 9154, "service": "inventory"}
9
+ -- db_grants: {"changed_day": 418, "component": "pg-replica", "grant_id": 9905, "note": "role dropped during the day-418 credential rotation; the running pods were never restarted and still present the old role", "role": "analytics_ro", "service": "analytics-worker", "state": "revoked"}
10
+ -- db_grants: {"changed_day": 390, "component": "rabbitmq", "grant_id": 9908, "note": "", "role": "analytics_sub", "service": "analytics-worker", "state": "active"}
task_files/dob100-002-rca-analytics-revoked-grant/09-feature-and-security.yaml ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "sources": [
3
+ {
4
+ "columns": [
5
+ "flag_id",
6
+ "key",
7
+ "service",
8
+ "description",
9
+ "environment",
10
+ "enabled",
11
+ "rollout_percent"
12
+ ],
13
+ "row_count": 8,
14
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
15
+ "table": "feature_flags",
16
+ "task_relevant_rows": [
17
+ {
18
+ "description": "Pilot: refund immediately at checkout instead of async batch.",
19
+ "enabled": 1,
20
+ "environment": "production",
21
+ "flag_id": 9301,
22
+ "key": "instant_refunds",
23
+ "rollout_percent": 100,
24
+ "service": "checkout"
25
+ },
26
+ {
27
+ "description": "Pilot: refund immediately at checkout instead of async batch.",
28
+ "enabled": 1,
29
+ "environment": "staging",
30
+ "flag_id": 9302,
31
+ "key": "instant_refunds",
32
+ "rollout_percent": 100,
33
+ "service": "checkout"
34
+ },
35
+ {
36
+ "description": "Redesigned search results page.",
37
+ "enabled": 0,
38
+ "environment": "production",
39
+ "flag_id": 9303,
40
+ "key": "new_search_ui",
41
+ "rollout_percent": 0,
42
+ "service": "search"
43
+ },
44
+ {
45
+ "description": "Redesigned search results page.",
46
+ "enabled": 1,
47
+ "environment": "staging",
48
+ "flag_id": 9304,
49
+ "key": "new_search_ui",
50
+ "rollout_percent": 100,
51
+ "service": "search"
52
+ }
53
+ ]
54
+ },
55
+ {
56
+ "columns": [
57
+ "vuln_id",
58
+ "cve",
59
+ "package",
60
+ "service",
61
+ "severity",
62
+ "fixed_version",
63
+ "status"
64
+ ],
65
+ "row_count": 4,
66
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
67
+ "table": "vulnerabilities",
68
+ "task_relevant_rows": [
69
+ {
70
+ "cve": "CVE-2026-31337",
71
+ "fixed_version": "2.4.0",
72
+ "package": "libpayproc",
73
+ "service": "payments",
74
+ "severity": "critical",
75
+ "status": "open",
76
+ "vuln_id": 9801
77
+ },
78
+ {
79
+ "cve": "CVE-2026-40881",
80
+ "fixed_version": "11.4.0",
81
+ "package": "stripe-sdk",
82
+ "service": "checkout",
83
+ "severity": "high",
84
+ "status": "open",
85
+ "vuln_id": 9802
86
+ },
87
+ {
88
+ "cve": "CVE-2026-22190",
89
+ "fixed_version": "2.11.0",
90
+ "package": "pydantic",
91
+ "service": "catalog",
92
+ "severity": "medium",
93
+ "status": "remediated",
94
+ "vuln_id": 9803
95
+ },
96
+ {
97
+ "cve": "CVE-2026-51002",
98
+ "fixed_version": "2.33.0",
99
+ "package": "requests",
100
+ "service": "payments",
101
+ "severity": "high",
102
+ "status": "open",
103
+ "vuln_id": 9804
104
+ }
105
+ ]
106
+ },
107
+ {
108
+ "columns": [
109
+ "rule_id",
110
+ "name",
111
+ "service_label",
112
+ "expr",
113
+ "severity",
114
+ "group_by",
115
+ "routes_to"
116
+ ],
117
+ "row_count": 5,
118
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
119
+ "table": "alert_rules",
120
+ "task_relevant_rows": [
121
+ {
122
+ "expr": "histogram_quantile(0.99, gateway_latency) > 250",
123
+ "group_by": "service",
124
+ "name": "GatewayHighLatency",
125
+ "routes_to": "EP-Platform",
126
+ "rule_id": 601,
127
+ "service_label": "gateway_service",
128
+ "severity": "critical"
129
+ },
130
+ {
131
+ "expr": "rate(gateway_errors[5m]) > 0.01",
132
+ "group_by": "service",
133
+ "name": "GatewayErrorRate",
134
+ "routes_to": "EP-Platform",
135
+ "rule_id": 602,
136
+ "service_label": "gateway_service",
137
+ "severity": "high"
138
+ },
139
+ {
140
+ "expr": "avg(latency) by (cluster) > 400",
141
+ "group_by": "cluster",
142
+ "name": "ClusterWideLatency",
143
+ "routes_to": "EP-Platform",
144
+ "rule_id": 603,
145
+ "service_label": "",
146
+ "severity": "critical"
147
+ },
148
+ {
149
+ "expr": "cache_hit_ratio{tier=\"gateway-edge\"} < 0.8",
150
+ "group_by": "service",
151
+ "name": "EdgeCacheHitRate",
152
+ "routes_to": "EP-Platform",
153
+ "rule_id": 604,
154
+ "service_label": "edge_cache_service",
155
+ "severity": "medium"
156
+ }
157
+ ]
158
+ },
159
+ {
160
+ "columns": [
161
+ "silence_id",
162
+ "matcher",
163
+ "created_by",
164
+ "reason",
165
+ "expires_day"
166
+ ],
167
+ "row_count": 1,
168
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
169
+ "table": "alert_silences",
170
+ "task_relevant_rows": [
171
+ {
172
+ "created_by": "Sam Whitfield",
173
+ "expires_day": 402,
174
+ "matcher": "alertname=\"EdgeCacheHitRate\"",
175
+ "reason": "muted during the CDN migration, never lifted",
176
+ "silence_id": 801
177
+ }
178
+ ]
179
+ }
180
+ ]
181
+ }
task_files/dob100-002-rca-analytics-revoked-grant/10-vendor-trackers.json ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "sources": [
3
+ {
4
+ "columns": [
5
+ "key",
6
+ "project",
7
+ "summary",
8
+ "issue_type",
9
+ "status",
10
+ "resolution",
11
+ "priority",
12
+ "component",
13
+ "assignee",
14
+ "created_day",
15
+ "updated_day"
16
+ ],
17
+ "row_count": 11,
18
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
19
+ "table": "jira_issues",
20
+ "task_relevant_rows": [
21
+ {
22
+ "assignee": "Alex Osei",
23
+ "component": "analytics-worker",
24
+ "created_day": 415,
25
+ "issue_type": "Bug",
26
+ "key": "ENG-2103",
27
+ "priority": "High",
28
+ "project": "ENG",
29
+ "resolution": "",
30
+ "status": "In Progress",
31
+ "summary": "Analytics worker restarting under queue load",
32
+ "updated_day": 419
33
+ },
34
+ {
35
+ "assignee": "Diego Ramos",
36
+ "component": "payments",
37
+ "created_day": 402,
38
+ "issue_type": "Bug",
39
+ "key": "ENG-3002",
40
+ "priority": "High",
41
+ "project": "ENG",
42
+ "resolution": "Fixed",
43
+ "status": "Done",
44
+ "summary": "Duplicate charge on retried payment",
45
+ "updated_day": 409
46
+ },
47
+ {
48
+ "assignee": "",
49
+ "component": "checkout",
50
+ "created_day": 396,
51
+ "issue_type": "Bug",
52
+ "key": "ENG-3004",
53
+ "priority": "Low",
54
+ "project": "ENG",
55
+ "resolution": "Won't Do",
56
+ "status": "Done",
57
+ "summary": "Cart total rounds incorrectly for multi-currency",
58
+ "updated_day": 404
59
+ }
60
+ ]
61
+ },
62
+ {
63
+ "columns": [
64
+ "identifier",
65
+ "team",
66
+ "title",
67
+ "state",
68
+ "priority",
69
+ "label",
70
+ "created_day"
71
+ ],
72
+ "row_count": 4,
73
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
74
+ "table": "linear_issues",
75
+ "task_relevant_rows": [
76
+ {
77
+ "created_day": 411,
78
+ "identifier": "GRW-88",
79
+ "label": "bug",
80
+ "priority": 1,
81
+ "state": "In Progress",
82
+ "team": "Growth",
83
+ "title": "Checkout slow at peak \u2014 customers dropping off"
84
+ },
85
+ {
86
+ "created_day": 408,
87
+ "identifier": "GRW-91",
88
+ "label": "bug",
89
+ "priority": 3,
90
+ "state": "Todo",
91
+ "team": "Growth",
92
+ "title": "Search shows stale products after reindex"
93
+ },
94
+ {
95
+ "created_day": 417,
96
+ "identifier": "GRW-95",
97
+ "label": "bug",
98
+ "priority": 4,
99
+ "state": "Todo",
100
+ "team": "Growth",
101
+ "title": "Autocomplete flickers on slow connections"
102
+ },
103
+ {
104
+ "created_day": 416,
105
+ "identifier": "GRW-97",
106
+ "label": "bug,performance",
107
+ "priority": 2,
108
+ "state": "In Progress",
109
+ "team": "Growth",
110
+ "title": "Product images load from origin, not CDN"
111
+ }
112
+ ]
113
+ },
114
+ {
115
+ "columns": [
116
+ "number",
117
+ "repo",
118
+ "title",
119
+ "state",
120
+ "labels",
121
+ "created_day"
122
+ ],
123
+ "row_count": 28,
124
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
125
+ "table": "github_issues",
126
+ "task_relevant_rows": [
127
+ {
128
+ "created_day": 396,
129
+ "labels": "bug",
130
+ "number": 4404,
131
+ "repo": "novacart/storefront",
132
+ "state": "closed",
133
+ "title": "Rate limiter allows bursts above the configured ceiling"
134
+ },
135
+ {
136
+ "created_day": 403,
137
+ "labels": "bug,priority",
138
+ "number": 4407,
139
+ "repo": "novacart/platform",
140
+ "state": "open",
141
+ "title": "Refund webhook retried indefinitely on 4xx"
142
+ },
143
+ {
144
+ "created_day": 410,
145
+ "labels": "bug,customer-report",
146
+ "number": 4409,
147
+ "repo": "novacart/commerce",
148
+ "state": "open",
149
+ "title": "Dark mode toggle resets on navigation"
150
+ },
151
+ {
152
+ "created_day": 417,
153
+ "labels": "enhancement",
154
+ "number": 4411,
155
+ "repo": "novacart/growth",
156
+ "state": "open",
157
+ "title": "Checkout page hangs before redirect"
158
+ }
159
+ ]
160
+ },
161
+ {
162
+ "columns": [
163
+ "source",
164
+ "target",
165
+ "kind"
166
+ ],
167
+ "row_count": 4,
168
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
169
+ "table": "issue_links",
170
+ "task_relevant_rows": [
171
+ {
172
+ "kind": "duplicates",
173
+ "source": "ENG-3001",
174
+ "target": "GRW-88"
175
+ },
176
+ {
177
+ "kind": "duplicates",
178
+ "source": "ENG-3001",
179
+ "target": "4412"
180
+ },
181
+ {
182
+ "kind": "duplicates",
183
+ "source": "ENG-3003",
184
+ "target": "GRW-91"
185
+ },
186
+ {
187
+ "kind": "duplicates",
188
+ "source": "ENG-3003",
189
+ "target": "4402"
190
+ }
191
+ ]
192
+ }
193
+ ]
194
+ }
task_files/dob100-002-rca-analytics-revoked-grant/11-knowledge-base.md ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 11 Knowledge Base
2
+
3
+ ## documents (30 rows)
4
+
5
+ ```json
6
+ [
7
+ {
8
+ "doc_id": 9604,
9
+ "kind": "runbook",
10
+ "title": "Search caching",
11
+ "service": "search",
12
+ "author": "Mei Tanaka",
13
+ "day": 233,
14
+ "body": "# Search caching\n\nOwner: growth. Service: `search` (tier 2, python). SLO:\n`latency_p99_ms < 300`.\n\n## The rule\n\nProduction `search` **requires `cache_enabled=true`**. This is not a tuning\nknob; it is a capacity assumption baked into how the index cluster is sized.\n\n## Why\n\nThe query cache sits in front of the primary index and absorbs roughly **75% of\nindex load**. Search traffic is extremely head-heavy: the top few thousand\nqueries (\"black jeans\", \"usb-c cable\", \"gift card\") are a large majority of all\nrequests, and their result sets change only when the index is rebuilt. Serving\nthose from cache is close to free.\n\nWith `cache_enabled=false` every request goes to the primary index. Observed\neffect in production: `latency_p99_ms` moves from a ~210ms baseline to ~640ms and\nkeeps climbing as concurrency rises, blowing through the 300ms SLO and firing a\n`medium` alert. The service does not error - it just gets slow, which is why this\none is easy to miss until the alert fires. The tell in the logs is:\n\n```\nWARN query cache disabled (cache_enabled=false); every request is hitting the primary index\n```\n\n## Config keys\n\n| Key | Production value | Notes |\n| --------------- | ---------------- | ------------------------------------------ |\n| `cache_enabled` | `true` | Required. Never ship `false` to production. |\n| `cache_ttl_s` | `300` | Standard TTL. Five minutes. |\n| `index_shards` | `4` | Change only with a capacity review. |\n\n`cache_ttl_s=300` is the standard. It is a deliberate compromise: long enough\nthat the hit rate stays above 70%, short enough that a price or availability\nchange is visible within five minutes. Do not lower it below 60 - at that point\nthe stampede risk (below) outweighs the freshness gain. Do not raise it above\n900 without merchandising sign-off, because stale out-of-stock results generate\nsupport tickets.\n\n## Cache stampede\n\nA cold cache is dangerous, not merely slow. When many identical queries miss at\nonce they all reach the index simultaneously. We ship single-flight coalescing\nplus a +/-10% TTL jitter for exactly this reason. If you flush the cache\nmanually, do it during low traffic and expect a latency spike. The full story is\nin \"Postmortem: search cache stampede after index rebuild\".\n\n## Changing cache config\n\n`cache_enabled` and `cache_ttl_s` are repo config, not runtime flags. Changing\nthem means a PR with a `config` change, CI, merge, then a deploy - staging\nfirst, per the \"Deployment policy\". `search` is tier 2, so production deploys go\nstraight to 100%.\n\n## Verification\n\nAfter deploying, confirm `latency_p99_ms` has returned to the ~210ms band before\nresolving any related alert.\n"
15
+ },
16
+ {
17
+ "doc_id": 9605,
18
+ "kind": "runbook",
19
+ "title": "Catalog pricing performance",
20
+ "service": "catalog",
21
+ "author": "Diego Ramos",
22
+ "day": 229,
23
+ "body": "# Catalog pricing performance\n\nOwner: commerce. Service: `catalog` (tier 2, python). Consumed by `search`,\n`checkout`, and `storefront-web` on every product listing render.\n\n## The rule\n\n`batch_pricing_enabled=true` is **required in production**.\n\n## Why\n\n`catalog` resolves a price per product from the pricing rules table, applying\nthe active promotion, the customer's currency, and any tier discount. With\n`batch_pricing_enabled=false`, the listing endpoint loops over the products in\nthe response and issues one pricing query per product. This is a textbook\n**N+1 pattern**: a 48-item category page produces 1 listing query plus 48\npricing queries.\n\nMeasured cost: the per-product loop adds roughly **500ms at p99** on a standard\ncategory page. It also multiplies database connection checkouts by the page\nsize, which is how a catalog slowdown turns into a `db_pool_size` exhaustion\nevent in a service that was nowhere near its own limits (see \"Connection pool\nsizing\").\n\nWith `batch_pricing_enabled=true` the same page issues one listing query and one\nbatched pricing query with an `IN` clause over the product ids, then applies\npromotions in memory. Same results, two round trips.\n\n## Config keys\n\n| Key | Production value | Notes |\n| ------------------------- | ---------------- | -------------------------------------- |\n| `batch_pricing_enabled` | `true` | Required. The N+1 killer. |\n| `cdn_enabled` | `true` | See \"CDN and media delivery\". |\n\n## How to spot it\n\n- p99 on `catalog` listing endpoints scales with page size rather than staying\n flat. If 24 items is 200ms and 96 items is 900ms, it is the loop.\n- Database query counts per request in the hundreds.\n- Log lines of the form `pricing lookup for product_id=... (batch disabled)`\n repeating with the same trace id.\n\n## Fixing it\n\n`batch_pricing_enabled` is repo config. Ship it as a PR with a `config` change,\nrun CI, merge, deploy to staging, then production. `catalog` is tier 2 so the\nproduction deploy is a straight 100% deploy - no canary required, though a\ncanary is never wrong.\n\nAfter the deploy, re-measure p99 on a large category page before closing the\nticket.\n\n## Do not\n\n- Do not \"fix\" this by raising `db_pool_size`. That hides the symptom and moves\n the failure to the database.\n- Do not add a per-product cache in front of the loop. The batch query is\n cheaper than the cache lookups it would replace.\n"
24
+ },
25
+ {
26
+ "doc_id": 9607,
27
+ "kind": "runbook",
28
+ "title": "Feature flags",
29
+ "service": "",
30
+ "author": "Mei Tanaka",
31
+ "day": 247,
32
+ "body": "# Feature flags\n\nEvery new user-facing feature ships **dark**: merged, deployed, and switched\noff, then turned on gradually.\n\n## Defining a flag\n\nA flag is defined by a `flag` change in the PR that introduces the guarded code.\nFlag and code land together, in one PR, so there is never a flag referencing\ncode that does not exist or guarded code with no way to turn it off. At merge\nthe flag is created **disabled in both environments** with a rollout of 0%.\n\nNaming: lowercase snake_case, describing the feature, not the experiment -\n`express_checkout`, `instant_refunds`, `new_search_ui`. Not `mei_test_2` and not\n`enable_new_thing_v3_final`.\n\n## Ordering: deploy the code, then enable the flag\n\n**The guarded code must be deployed to production BEFORE the flag is enabled\nthere.** Enabling a flag whose code is not deployed does one of two things:\nnothing at all (best case, and you waste an hour wondering why), or it activates\na half-present code path across a partially deployed fleet (worst case).\n\nSo the sequence is:\n\n1. PR with the module change and the `flag` change - CI - merge.\n2. Deploy to staging.\n3. Deploy to production. Tier-1 services canary at `canary_percent <= 25`,\n `assess_canary`, then `promote_canary` (see \"Deployment policy\").\n4. Only now: `set_feature_flag(flag, environment=\"production\", enabled=true,\n rollout_percent=10)`.\n\n## Initial rollout must not exceed 10%\n\nThe first production enablement is capped at **10%**. Sit there long enough to\nsee real traffic - at minimum one full traffic peak - and watch the owning\nservice's error rate and p99. Then ramp: 10 - 25 - 50 - 100, checking metrics at\neach step.\n\nFlags are **runtime toggles**: `set_feature_flag` takes effect immediately and\nneeds **no deploy**. That cuts both ways - it is why a flag is the fastest kill\nswitch we have, and it is why an unreviewed ramp to 100% is the fastest way to\ncause a sev2. The `instant_refunds` incident was exactly this: the flag went to\n100% in production and `checkout` `error_rate_pct` went from 0.3% to 5.5%.\n\n## Kill switch\n\nDuring an incident, disable the flag in the affected environment only. Leave the\nother environment as it is so you can still reproduce. See \"Incident response\".\n\n## Cleanup\n\n**Stale flags must be cleaned up after full rollout.** Once a flag has been at\n100% in production for two weeks and there is no plan to turn it off, remove the\nconditional from the code and delete the flag in a follow-up PR. Every flag left\nbehind is a branch of untested code and a future outage. The owning team reviews\nits flag list at each sprint boundary.\n"
33
+ },
34
+ {
35
+ "doc_id": 9609,
36
+ "kind": "runbook",
37
+ "title": "Security response",
38
+ "service": "",
39
+ "author": "Alex Osei",
40
+ "day": 263,
41
+ "body": "# Security response\n\nCovers dependency vulnerabilities reported by the scanner and secrets found in\nsource. Security tickets carry the `security` type and are prioritized above\nfeature work.\n\n## Vulnerable dependency\n\nOrdered steps:\n\n1. **Patch the vulnerable dependency.** Bump to the fixed version named in the\n finding via a PR with a `dependency` change. Do not jump several major\n versions to \"get ahead\" - patch to the fixed version, then plan the upgrade\n separately.\n2. **Deploy staging, then production.** Staging-first per the \"Deployment\n policy\". Tier-1 services canary at `canary_percent <= 25`, `assess_canary`,\n then `promote_canary`.\n3. **Verify the scanner shows the finding remediated.** Re-run the scan against\n the deployed service and confirm the vulnerability status is no longer\n `open`. A merged PR is not remediation; a deployed and re-scanned service is.\n4. **Post an audit summary to `#security` referencing the CVE id.** State the\n CVE, the service, the old and new versions, and when production was patched.\n Auditors read this channel; the CVE id must appear literally.\n5. **Close the security ticket.**\n\nTimelines by severity, measured from the finding appearing:\n\n| Severity | Production patched within |\n| -------- | ------------------------- |\n| critical | 48 hours |\n| high | 7 days |\n| medium | 30 days |\n| low | next maintenance window |\n\n## Secrets in code\n\nIf a credential, API key, or token is found in source, config, or CI logs:\n\n1. **Move it to the secret manager.** Set config key\n `use_secret_manager=true` for the service and reference the secret by name;\n the value never appears in the repo again.\n2. **Rotate the credential.** Assume it is compromised the moment it was\n committed - git history is forever and the repo is mirrored to CI. Rotation\n is not optional even if the repo is private.\n3. Deploy staging then production, verify the service still authenticates, and\n post the summary to `#security`.\n\nDo not \"delete the line and force-push\". The old blob is still reachable and the\ncredential is still live.\n\n## Escalation\n\nAnything involving customer data exposure, an actively exploited vulnerability,\nor credential misuse in production is a sev1 - open an incident and follow\n\"Incident response\" in parallel with this runbook.\n\n## Related\n\n- \"ADR-027: Move partner credentials to the secret manager\".\n"
42
+ },
43
+ {
44
+ "doc_id": 9612,
45
+ "kind": "runbook",
46
+ "title": "Queue consumer tuning",
47
+ "service": "notifications",
48
+ "author": "Priya Nair",
49
+ "day": 226,
50
+ "body": "# Queue consumer tuning\n\nOwner: platform. Primary consumer service: `notifications` (tier 2), which\ndrains the email, SMS, and push delivery queues. The same rules apply to any\nservice that consumes from the message broker.\n\n## The rule\n\n`prefetch_count` must be a **bounded** value. **Recommended: 50.**\n\n`prefetch_count=0` means **unlimited prefetch** and is the single worst setting\nin this runbook.\n\n## What prefetch does\n\nPrefetch is the number of unacknowledged messages the broker will push to a\nsingle consumer. With `prefetch_count=50`, a consumer holds at most 50\nin-flight messages; the broker will not send a 51st until one is acknowledged.\nThis is the backpressure mechanism - it is what lets a slow consumer tell the\nbroker to slow down.\n\nWith `prefetch_count=0` there is no backpressure. The broker pushes the entire\nbacklog to whichever consumer connects first. Consequences, all of which we have\nseen in `notifications`:\n\n- **Memory pressure.** A 400k-message backlog lands in one process's heap. RSS\n climbs until the container hits its memory limit.\n- **Consumer restarts.** The container is OOM-killed, the unacknowledged\n messages are redelivered, the restarted consumer grabs them all again, and it\n is killed again. A restart loop that looks like a broker problem and is not.\n- **Terrible load distribution.** One consumer holds everything while its\n siblings sit idle, so scaling out does nothing.\n- **Head-of-line latency.** A high-priority message sits behind 400k others.\n\n## Sizing\n\n| Message profile | prefetch_count |\n| ------------------------------ | -------------- |\n| Fast, uniform (a few ms each) | 100-200 |\n| Standard delivery work | **50** |\n| Slow or variable (seconds) | 5-10 |\n| Long-running jobs (minutes) | 1 |\n\nRule of thumb: `prefetch_count` should be roughly the number of messages a\nconsumer can process in one to two seconds. Start at 50 and adjust with\nevidence.\n\n## Related settings\n\n- `smtp_pool` on `notifications` bounds concurrent SMTP connections. Prefetch\n above the SMTP concurrency just buys queueing inside the process.\n- Ack **after** the work is done, never on receipt. Acking on receipt turns a\n crash into silent message loss.\n- Dead-letter after 5 delivery attempts so a poison message cannot loop forever.\n\n## Changing it\n\nRepo config: PR with a `config` change, CI, merge, staging, production.\n`notifications` is tier 2 - straight 100% deploy after staging. Watch consumer\nmemory and queue depth for one full peak after the change.\n"
51
+ },
52
+ {
53
+ "doc_id": 9613,
54
+ "kind": "runbook",
55
+ "title": "CDN and media delivery",
56
+ "service": "media-service",
57
+ "author": "Mei Tanaka",
58
+ "day": 221,
59
+ "body": "# CDN and media delivery\n\nCovers media-service, the product-image and asset delivery path owned by\ncommerce and shipped as part of the `catalog` service. Product photography,\ngenerated thumbnails, size charts, and marketing video posters all flow through\nit.\n\n## The rule\n\n`cdn_enabled=true` is **required in production** for media-service. Origin-only\nserving is not an acceptable production configuration.\n\n## Why\n\nWith the CDN enabled, edge nodes serve cached objects close to the user and the\norigin sees only cache misses and revalidations - typically under 5% of\nrequests. With `cdn_enabled=false`, every image request travels to the origin\nand out of the object store.\n\nMeasured impact of origin-only serving:\n\n- **~600ms added at p99** on image-heavy pages. Category and product-detail\n pages are the worst affected because they fan out to dozens of assets, and\n browsers cap parallel connections per origin, so the latency serializes.\n- **Object-store cost rises sharply.** Egress and per-request charges are billed\n on every single request instead of on misses. In the one week we ran\n origin-only during a migration, media egress was roughly 20x the normal line\n item.\n- Origin bandwidth saturates first during traffic spikes, and image failures\n make the storefront look broken even when checkout is perfectly healthy.\n\n## Config\n\n| Key | Production value | Notes |\n| --------------- | ---------------- | --------------------------------------- |\n| `cdn_enabled` | `true` | Required. |\n\nCache-control defaults: immutable, content-hashed asset URLs get a one-year\nmax-age; mutable paths get 300s with revalidation. Because asset URLs are\ncontent-hashed, a new image is a new URL - you should almost never need to purge.\n\n## Purging\n\nPurge only for a legal or trademark takedown, or for an asset published in\nerror. A full-prefix purge is effectively a cold cache: expect an origin load\nspike and a temporary p99 regression. Purge narrowly, by exact URL, during low\ntraffic.\n\n## Troubleshooting\n\n- Images slow but HTML fast: check `cdn_enabled` first, before anything else.\n- Cache hit ratio below 90%: usually a query string added to asset URLs, which\n fragments the cache key. Strip non-semantic query parameters at the edge.\n- 403s from the edge: signed-URL clock skew on the origin.\n\n## Changing it\n\nRepo config: PR with a `config` change, CI, merge, staging, then production per\nthe \"Deployment policy\". Verify p99 on a product-detail page and the edge hit\nratio before closing the ticket.\n"
60
+ },
61
+ {
62
+ "doc_id": 9614,
63
+ "kind": "design_doc",
64
+ "title": "Checkout architecture",
65
+ "service": "checkout",
66
+ "author": "Diego Ramos",
67
+ "day": 198,
68
+ "body": "# Checkout architecture\n\nService: `checkout` (tier 1, python, commerce). Owns the cart and the checkout\norchestration state machine. SLOs: `error_rate_pct < 1.0`,\n`latency_p99_ms < 400`.\n\n## Responsibilities\n\n`checkout` owns the transition from \"a cart exists\" to \"an order exists and is\npaid\". It does not own money movement (that is `payments`), product data (that\nis `catalog`), or customer notification (that is `notifications`). It owns the\nsequencing and the guarantee that the sequence happens exactly once.\n\nModules: `cart`, `checkout_flow`, and - once the loyalty program ships -\n`loyalty_redeem`.\n\n## The state machine\n\nEvery checkout session is a row with an explicit state:\n\n```\ncart_open -> pricing_locked -> payment_pending -> paid -> order_created\n | |\n +-> abandoned +-> payment_failed\n```\n\nTransitions are append-only and each is stamped with the idempotency key of the\nrequest that caused it. Replaying a request that has already produced a\ntransition returns the existing result rather than performing it again. This is\nwhat makes the checkout endpoint safe to retry, which matters because clients\nretry aggressively on mobile networks.\n\n## Dependencies\n\n| Downstream | Call | Timeout budget |\n| --------------- | ------------------------ | ------------------------- |\n| `catalog` | price and availability | `<= 2000ms`, 3 attempts |\n| `payments` | authorize and capture | `payment_timeout_ms` |\n| `notifications` | order confirmation | async, fire-and-forget |\n\nAll synchronous calls follow the \"Retry and timeout standard\": three attempts,\ntimeout at or below 2000ms. The `notifications` call is deliberately\nasynchronous - a confirmation email must never be able to fail an order.\n\n## Pricing lock\n\nAt `pricing_locked` we snapshot the price, the promotion, and the tax\ncomputation into the session row. From that point the customer pays the price\nthey were shown even if `catalog` changes underneath. The lock expires after 20\nminutes, after which the session re-prices.\n\n## Failure handling\n\n- `payments` timeout: the session stays `payment_pending` and a reconciliation\n job asks `payments` for the authoritative status. We never assume a timeout\n means \"did not happen\".\n- `catalog` unavailable: fail closed. We do not sell at a guessed price.\n- Partial capture: not supported; a capture is all-or-nothing per order.\n\n## Feature flags\n\nCheckout-adjacent behavior ships behind flags - `instant_refunds`,\n`express_checkout`. Per the \"Feature flags\" runbook, the code deploys first and\nthe flag is enabled afterwards at no more than 10%. `instant_refunds` is the\ncautionary tale: ramped to 100% in production, it took `error_rate_pct` from\n0.3% to 5.5% via a nil-pointer panic in the refund worker.\n\n## Open questions\n\n- Should the pricing lock move into `catalog` so `search` can honor it too?\n- Cart merge on login is still last-write-wins; it should be a real merge.\n"
69
+ },
70
+ {
71
+ "doc_id": 9617,
72
+ "kind": "design_doc",
73
+ "title": "Loyalty points program",
74
+ "service": "",
75
+ "author": "Diego Ramos",
76
+ "day": 288,
77
+ "body": "# Loyalty points program\n\nCross-service feature spanning `catalog`, `checkout`, and `storefront-web`.\nCustomers earn points on purchases and redeem them for order discounts.\n\n## Modules and ownership\n\n| Module | Service | Responsibility |\n| ----------------- | ----------------- | ------------------------------------- |\n| `loyalty_accrual` | `catalog` | Points-earning rules per product |\n| `loyalty_redeem` | `checkout` | Applying points as an order discount |\n| `loyalty_widget` | `storefront-web` | Balance display and redeem affordance |\n\nEach module ships in **its own PR against its own service**. There is no shared\nlibrary; the contract between them is the points-rate field on the product\npayload and the redeem call on the checkout API.\n\n## Why this split\n\nAccrual rules are product data - they vary per product and per category, they\nchange with merchandising campaigns, and they belong next to pricing. Redemption\nis an order-level money decision and belongs in the checkout state machine.\nDisplay is display. Putting accrual in `checkout` would have meant `checkout`\nreading the product rules table, which is exactly the coupling we spent last\nyear removing.\n\n## Rollout order\n\nDeployment order matters and is not negotiable:\n\n**`catalog` - then `checkout` - then `storefront-web`.**\n\nThe reasoning is a strict data dependency chain:\n\n1. `catalog` must be emitting a points rate on the product payload before\n `checkout` can compute a balance to redeem against. If `checkout` ships\n first, every redeem attempt reads a missing field and either errors or\n silently computes zero.\n2. `checkout` must expose the redeem endpoint and be live before\n `storefront-web` renders a redeem button. If the widget ships first,\n customers see a button that 404s - a visible, embarrassing failure on the\n busiest page we have.\n\n`catalog` is tier 2 (straight production deploy after staging). `checkout` and\n`storefront-web` are tier 1, so each is staging-first, then a production canary\nat `canary_percent <= 25`, `assess_canary`, then `promote_canary` - see\n\"Deployment policy\". Do not begin the next service's production deploy until the\nprevious one is fully promoted.\n\n## Points model\n\nBalances live in an append-only ledger, mirroring the approach in \"Payments\nsettlement pipeline\": `earn`, `redeem`, `expire`, `adjust`. Balance is the sum,\nnever a stored counter. Redemption is authorized at `pricing_locked` and\ncommitted at `paid`; an abandoned cart releases the hold after 20 minutes.\n\nDefault rate is 1 point per whole currency unit, 100 points equals one currency\nunit of discount, points expire 12 months after earning. Maximum redemption is\n50% of order subtotal.\n\n## Risks\n\n- Double-redeem across concurrent sessions. Mitigated by the hold and by the\n idempotency key on the checkout transition.\n- Accrual rule changes retroactively altering historical balances. The ledger\n stamps the rate version at earn time.\n"
78
+ },
79
+ {
80
+ "doc_id": 9620,
81
+ "kind": "adr",
82
+ "title": "ADR-027: Move partner credentials to the secret manager",
83
+ "service": "payments",
84
+ "author": "Alex Osei",
85
+ "day": 191,
86
+ "body": "# ADR-027: Move partner credentials to the secret manager\n\n**Status:** Accepted\n**Date:** day 191\n**Deciders:** security, platform, commerce\n\n## Context\n\nPartner credentials - the payment processor API key, the shipping carrier\ntokens, the SMTP credentials used by `notifications`, and the analytics\nwrite key - were stored as plain config values in each service's repo config\nand injected as environment variables at deploy time.\n\nThree problems made this untenable:\n\n1. **Git history is permanent.** Every credential ever committed remains in\n history, in every clone, and in every CI cache. Removing the line does not\n remove the secret.\n2. **Rotation was a deploy.** Rotating the processor key meant a PR, CI, staging,\n canary, promote - per service. So rotation happened roughly never, and the\n processor key in production had been unchanged for over a year.\n3. **No access audit.** We could not answer \"who read this value, and when\",\n which is a direct finding in the annual audit.\n\nThe trigger was a scanner hit: a carrier token visible in a config file in a\nrepo that four teams could read.\n\n## Decision\n\nAll partner credentials move to the managed **secret manager**. Each service\nopts in with the config key **`use_secret_manager=true`** and references secrets\nby name rather than value. The application resolves secrets at startup and on a\nrefresh interval; the plaintext never appears in the repo, in a PR diff, or in a\ndeploy artifact.\n\nEvery credential moved is **rotated as part of the move**, on the assumption\nthat anything previously in the repo is compromised.\n\nRollout order: `payments` first (highest value), then `notifications`, then the\nremaining services.\n\n## Alternatives considered\n\n**Encrypted secrets committed to the repo (sealed values).** Rejected: it solves\nplaintext exposure but not rotation-as-a-deploy, and the decryption key becomes\nthe new committed secret.\n\n**Environment variables set manually on hosts.** Rejected: unauditable,\ndrift-prone, and impossible to reproduce.\n\n**Do nothing, tighten repo permissions.** Rejected: it does not address history,\nrotation, or audit.\n\n## Consequences\n\nPositive: rotation is an operation, not a release; access is logged per read;\nsecret scanning in CI becomes a hard gate rather than advisory.\n\nNegative: a new startup-time dependency. If the secret manager is unreachable a\nservice cannot start, so we cache the last successful resolution on disk,\nencrypted, with a short TTL, to survive a brief outage.\n\nOperational procedure for a leaked credential is in the \"Security response\"\nrunbook: move to the secret manager, **rotate**, deploy, verify, post to\n`#security`.\n"
87
+ },
88
+ {
89
+ "doc_id": 9622,
90
+ "kind": "postmortem",
91
+ "title": "Postmortem: search cache stampede after index rebuild",
92
+ "service": "search",
93
+ "author": "Mei Tanaka",
94
+ "day": 183,
95
+ "body": "# Postmortem: search cache stampede after index rebuild\n\n**Severity:** sev2\n**Service:** `search`\n**Duration:** 34 minutes of degraded search\n**Author:** Mei Tanaka\n**Status:** action items complete\n\n## Summary\n\nA planned index rebuild swapped the search index alias at a moderate traffic\nhour. The alias swap invalidated the entire query cache. Every in-flight query\nmissed simultaneously and hit the primary index, driving `latency_p99_ms` from\n~210ms to a peak of 2100ms and firing the `search latency_p99_ms` alert against\nits 300ms SLO. Search was slow, not down; conversion on search-originated\nsessions dropped an estimated 18% for the duration.\n\n## Timeline (UTC)\n\n- **14:02** Engineer starts a full index rebuild for an analyzer change. Routine;\n done a dozen times before.\n- **14:41** Rebuild completes. Alias swaps to the new index. Query cache keys are\n namespaced by index generation, so the swap invalidates 100% of the cache.\n- **14:42** `latency_p99_ms` crosses 300ms. Alert fires, `medium`.\n- **14:44** On-call acknowledges. Initial hypothesis: the new analyzer is slow.\n- **14:51** Index CPU is pegged; per-query cost is unchanged from before the\n rebuild. Hypothesis discarded - it is volume, not per-query cost.\n- **14:58** Cache hit ratio confirmed at 3%, against a normal 76%. Root cause\n identified.\n- **15:06** Traffic to search temporarily shed at the gateway by 30% to let the\n cache refill.\n- **15:16** Hit ratio back above 60%; p99 at 340ms and falling.\n- **15:22** Shedding removed. p99 at 215ms.\n- **15:26** Alert resolved, incident resolved, update posted in `#incidents`.\n\n## Root cause\n\nThe query cache is namespaced by index generation. An alias swap therefore\nperforms a **complete, instantaneous cache flush** with no warm-up. Because the\ncache normally absorbs about **75% of index load**, the index was asked to serve\nroughly 4x its steady-state query volume within one second. Requests queued,\nlatency rose, clients retried, and the retries added load - a classic stampede\nwith a positive feedback loop.\n\n## Contributing factors\n\n- No warm-up step in the rebuild procedure. The runbook ended at \"swap alias\".\n- Rebuild was run at 14:00 local, in the daily traffic ramp, because the job\n takes 40 minutes and nobody wanted to babysit it at night.\n- Single-flight coalescing existed for identical concurrent queries but the\n stampede was across *thousands of distinct* queries, so coalescing did nothing.\n- No alert on cache hit ratio, so the actual signal was invisible for 14 minutes.\n\n## What went well\n\n- Alerting fired within a minute of the SLO breach.\n- Load shedding at the gateway was the correct blunt instrument and worked.\n\n## Action items\n\n1. Add a **warm-up phase** to the rebuild: replay the top 5000 queries against\n the new index before swapping the alias. **Done.**\n2. Add **+/-10% TTL jitter** to `cache_ttl_s=300` so natural expiry never\n synchronizes. **Done.**\n3. Alert on **cache hit ratio below 50%** for 5 minutes. **Done.**\n4. Move scheduled rebuilds to 03:00-05:00 UTC. **Done.**\n5. Document the stampede risk in the \"Search caching\" runbook. **Done.**\n"
96
+ },
97
+ {
98
+ "doc_id": 9623,
99
+ "kind": "postmortem",
100
+ "title": "Postmortem: catalog migration 0043 forced a rollback",
101
+ "service": "catalog",
102
+ "author": "Diego Ramos",
103
+ "day": 202,
104
+ "body": "# Postmortem: catalog migration 0043 forced a rollback\n\n**Severity:** sev1\n**Service:** `catalog` (with knock-on impact to `checkout` and `storefront-web`)\n**Duration:** 22 minutes of failed product-detail pages\n**Author:** Diego Ramos\n**Status:** action items complete\n\n## Summary\n\nMigration `0043_rename_price_column` renamed `catalog_products.price_cents` to\n`price_minor_units` in a single step, and the matching code version `v1.8.0` was\ndeployed immediately after. The migration was applied to production before the\ndeploy, as policy requires - but the migration was **not backwards compatible**\nwith the code version already running. Between the migration completing and the\nnew version being fully rolled out, the running `v1.7.6` instances queried a\ncolumn that no longer existed. Product-detail and category pages returned 500s;\n`checkout` fell back to failing closed on pricing, per its design.\n\n## Timeline (UTC)\n\n- **09:12** `apply_migration(catalog, production, 0043)` starts.\n- **09:13** Migration completes. Column renamed.\n- **09:13** `v1.7.6` instances begin throwing\n `UndefinedColumn: price_cents` on every pricing query.\n- **09:14** `catalog` error rate goes vertical. `checkout` starts failing closed.\n Two alerts fire.\n- **09:15** Deploy of `v1.8.0` starts, as planned, but rolls instance by instance.\n- **09:17** On-call acknowledges, declares sev1.\n- **09:19** Commander recognizes the pattern: schema ahead of code, partial fleet.\n- **09:21** Decision: do **not** attempt to reverse the migration. Accelerate the\n `v1.8.0` rollout instead.\n- **09:31** Rollout complete on all instances. Errors stop.\n- **09:34** Metrics confirmed recovered; alerts resolved; incident resolved.\n- **09:40** Update posted in `#incidents`; status page updated and cleared.\n- Later that day: `v1.8.0` was rolled back for an unrelated defect found in\n review, which is when the second lesson landed - the rolled-back `v1.7.6` code\n could not read the renamed column either, and a hotfix `v1.8.1` had to be cut\n because **migrations are forward-only** and there was no going back.\n\n## Root cause\n\nA **destructive, non-backwards-compatible schema change shipped in one step**. A\ncolumn rename is two incompatible states with no overlap: code that knows the old\nname and code that knows the new name cannot both work against the same schema.\nAny window in which both code versions run - and a rolling deploy guarantees such\na window - is an outage.\n\n## Contributing factors\n\n- The \"migration before code\" rule was followed correctly, and following it\n correctly was *insufficient*. The rule says nothing about compatibility with\n the code already running.\n- The migration had one reviewer, from the authoring team.\n- Rolling deploys were assumed to be fast enough not to matter. They are not.\n- `catalog` is tier 2, so there was no canary to catch it at 25%.\n\n## What went well\n\n- Nobody tried to hand-write a reverse migration under pressure. Rolling forward\n was the right call and it was made in six minutes.\n- `checkout` failing closed on pricing prevented selling at a wrong price.\n\n## Action items\n\n1. Write the **N-1 rule** into the \"Database migration policy\": every migration\n must leave the schema usable by the currently deployed code. **Done.**\n2. Mandate the **expand/contract** pattern for renames: add column, dual-write,\n backfill, switch reads, drop in a later migration. **Done.**\n3. Require a **second reviewer from platform** for migrations on tables above ten\n million rows. **Done.**\n4. Add a CI check that flags `DROP COLUMN`, `RENAME COLUMN`, and new `NOT NULL`\n constraints for explicit sign-off. **Done.**\n"
105
+ },
106
+ {
107
+ "doc_id": 9624,
108
+ "kind": "api_spec",
109
+ "title": "Public Orders API",
110
+ "service": "api-gateway",
111
+ "author": "Priya Nair",
112
+ "day": 265,
113
+ "body": "# Public Orders API\n\nServed by `api-gateway`. Two versions are live: **`/v1/orders` (deprecated)** and\n**`/v2/orders` (current)**. Authentication is a bearer partner token on both.\nRationale for the split is in \"ADR-031: Versioned public API (/v1 to /v2\norders)\".\n\n## Status\n\n| Path | Status | Notes |\n| ------------- | ---------- | -------------------------------------------- |\n| `/v1/orders` | deprecated | Emits `Deprecation` and `Sunset` headers. |\n| `/v2/orders` | current | Use for all new integrations. |\n\nTraffic between the two is weighted at the gateway and shifted in steps of at\nmost 50 percentage points per the \"API deprecation\" runbook. `/v1/orders` may\nonly be retired once it serves 0% of traffic; CI blocks retirement otherwise.\n\n## `GET /v2/orders`\n\nQuery parameters: `status`, `created_after` (RFC3339), `limit` (default 50, max\n200), `cursor`.\n\nResponse `200`:\n\n```json\n{\n \"data\": [\n {\n \"id\": \"ord_01H9Z\",\n \"status\": \"paid\",\n \"created_at\": \"2026-03-04T11:02:19Z\",\n \"currency\": \"USD\",\n \"amount_total_minor\": 12995,\n \"amount_tax_minor\": 1040,\n \"shipments\": [\n {\"id\": \"shp_1\", \"carrier\": \"ups\", \"tracking_number\": \"1Z...\",\n \"line_item_ids\": [\"li_1\", \"li_2\"], \"status\": \"in_transit\"}\n ],\n \"refunds\": [\n {\"id\": \"ref_1\", \"amount_minor\": 2500, \"reason\": \"damaged\",\n \"created_at\": \"2026-03-07T09:11:00Z\"}\n ],\n \"loyalty\": {\"points_earned\": 130, \"points_redeemed\": 0}\n }\n ],\n \"next_cursor\": \"eyJvIjoiMDFIOVoifQ\"\n}\n```\n\n## `POST /v2/orders`\n\nRequest:\n\n```json\n{\n \"idempotency_key\": \"5f2c...\",\n \"customer_id\": \"cus_88\",\n \"currency\": \"USD\",\n \"line_items\": [{\"sku\": \"NC-1042\", \"quantity\": 2, \"unit_price_minor\": 4995}],\n \"shipping_address_id\": \"addr_9\",\n \"loyalty\": {\"points_to_redeem\": 500}\n}\n```\n\n`idempotency_key` is required. Replaying the same key returns the original order\nwith `200` rather than creating a second one.\n\nResponses: `201` created; `409` idempotency key reused with a different body;\n`422` validation failure.\n\n## `/v1/orders` (deprecated)\n\nSame resource, older shape. Differences that break naive migration:\n\n- `total` is a **decimal string** (`\"129.95\"`), not integer minor units.\n- `tracking_number` is a **scalar** on the order; multi-shipment orders report\n only the first.\n- `refunded` is a **boolean**; partial refunds are indistinguishable from full.\n- No `loyalty` object.\n- Offset pagination (`page`, `per_page`) instead of `next_cursor`.\n\n## Migration guidance\n\n1. Parse amounts as integers in minor units; drop all float handling. Multiply\n the old decimal by 100 only at the boundary, never in business logic.\n2. Iterate `shipments` instead of reading `tracking_number`. Single-shipment\n orders return an array of one.\n3. Replace `refunded == true` with `sum(refunds[].amount_minor) > 0`, and\n compare against `amount_total_minor` if you need \"fully refunded\".\n4. Switch pagination to `next_cursor`; do not compute offsets. Cursors are\n opaque - do not parse them.\n5. Handle the problem-details error shape: match on `type`, not on the message\n string.\n6. Send `idempotency_key` on every write.\n\n## Errors\n\n```json\n{\"type\": \"validation_error\", \"title\": \"Invalid line item\",\n \"detail\": \"line_items[0].quantity must be >= 1\", \"status\": 422}\n```\n\n`type` values are stable and safe to branch on: `validation_error`,\n`idempotency_conflict`, `rate_limited`, `not_found`, `internal_error`.\n"
114
+ },
115
+ {
116
+ "doc_id": 9630,
117
+ "kind": "onboarding",
118
+ "title": "Service catalog and service tiers",
119
+ "service": "",
120
+ "author": "Mei Tanaka",
121
+ "day": 285,
122
+ "body": "# Service catalog and service tiers\n\nThe full NovaCart fleet, who owns what, and what tier means operationally.\n\n## The fleet\n\n| Service | Team | Tier | Language | Purpose |\n| ---------------- | --------- | ---- | ---------- | -------------------------------------------- |\n| `storefront-web` | growth | 1 | typescript | Customer-facing web storefront (Next.js) |\n| `api-gateway` | platform | 1 | go | Public API edge: routing, auth, rate limits |\n| `checkout` | commerce | 1 | python | Cart and checkout orchestration |\n| `payments` | commerce | 1 | python | Payment capture, refunds, settlement |\n| `catalog` | commerce | 2 | python | Product catalog and pricing |\n| `notifications` | platform | 2 | python | Email, SMS, and push delivery |\n| `search` | growth | 2 | python | Product search and ranking |\n\nOn-call primaries: platform - Priya Nair; commerce - Diego Ramos; growth -\nMei Tanaka; SRE - Alex Osei.\n\n## What tier means\n\n**Tier 1** - a failure directly costs money or breaks the storefront.\n\n- Production deploys must be canaries: `canary_percent <= 25`, then\n `assess_canary`, then `promote_canary`.\n- Paged 24/7 on SLO breach.\n- `db_pool_size >= 20`.\n- Changes require a reviewer outside the authoring pair.\n\n**Tier 2** - a failure degrades the experience but orders still complete.\n\n- Production deploys go straight to 100% after a successful staging deploy.\n- Paged during working hours; critical alerts page out of hours.\n- `db_pool_size >= 20` still applies.\n\nBoth tiers are staging-first without exception. Tier is a property of blast\nradius, not of team seniority or code quality.\n\n## Dependency shape\n\n```\nstorefront-web -> api-gateway -> checkout -> payments -> notifications\n -> search -> catalog\n catalog <- checkout (pricing)\n```\n\nRead it as: a failure in `catalog` shows up as a `checkout` and `search`\nproblem, and a failure in `notifications` should show up nowhere at all, because\ncallers treat it as best-effort. When it does show up in `payments`, that is a\nretry and timeout misconfiguration, not a `notifications` outage - see \"Retry\nand timeout standard\".\n\n## Environments\n\nTwo: `staging` and `production`. Staging carries a sampled copy of production\ncatalog data and synthetic orders. It is not a traffic-realistic environment,\nwhich is exactly why tier-1 services canary in production - see \"ADR-021:\nStandardize on staged canary deploys\".\n\n## Channels\n\n- `#incidents` - incident coordination and status updates.\n- `#security` - advisories and audit notes, CVE ids referenced literally.\n- `#eng` - everything else.\n\n## Adding a service\n\nRegister it with a team, a tier, an owner, both core metrics, at least one SLO,\nand a runbook entry before it takes traffic. See \"Observability, SLOs, and\nalerting\".\n"
123
+ }
124
+ ]
125
+ ```
126
+
127
+ ## confluence_pages (4 rows)
128
+
129
+ ```json
130
+ [
131
+ {
132
+ "page_id": 8001,
133
+ "space": "ENG",
134
+ "title": "Checkout Platform \u2014 architecture",
135
+ "body": "Checkout Platform is owned by the Commerce Platform team. It calls payments and inventory synchronously. Escalate via #commerce.",
136
+ "last_updated_day": 372,
137
+ "stale": 0
138
+ },
139
+ {
140
+ "page_id": 8002,
141
+ "space": "ENG",
142
+ "title": "Gateway runbook (legacy)",
143
+ "body": "The Edge Team owns the gateway. Page the Edge Team rota for any 5xx spike. Restart procedure targets host gw-prod-03.",
144
+ "last_updated_day": 181,
145
+ "stale": 1
146
+ },
147
+ {
148
+ "page_id": 8003,
149
+ "space": "ENG",
150
+ "title": "Weekly reporting conventions",
151
+ "body": "Engineering weekly reports run Monday to Sunday, ISO-8601 week numbering, in UTC. Note that the service-owner spreadsheet uses a Sunday start and will disagree by one day at the boundary.",
152
+ "last_updated_day": 401,
153
+ "stale": 0
154
+ },
155
+ {
156
+ "page_id": 8004,
157
+ "space": "ENG",
158
+ "title": "Incident severity ladder",
159
+ "body": "P1 = customer-facing outage, P2 = degraded customer experience, P3 = internal only, P4 = cosmetic. Customer-facing status is recorded on the public status page, not on the incident.",
160
+ "last_updated_day": 395,
161
+ "stale": 0
162
+ }
163
+ ]
164
+ ```
task_files/dob100-002-rca-analytics-revoked-grant/12-chat-and-status.json ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "sources": [
3
+ {
4
+ "columns": [
5
+ "message_id",
6
+ "channel",
7
+ "author",
8
+ "body"
9
+ ],
10
+ "row_count": 6,
11
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
12
+ "table": "messages",
13
+ "task_relevant_rows": [
14
+ {
15
+ "author": "Priya Nair",
16
+ "body": "Declared incident 9701 (sev1): api-gateway p99 through the roof since the v5.1.0 promote.",
17
+ "channel": "#incidents",
18
+ "message_id": 1
19
+ },
20
+ {
21
+ "author": "Diego Ramos",
22
+ "body": "Incident 9702 (sev2): checkout error rate tracks the instant_refunds ramp exactly.",
23
+ "channel": "#incidents",
24
+ "message_id": 2
25
+ },
26
+ {
27
+ "author": "Alex Osei",
28
+ "body": "Incident 9703 (sev2): inventory reservations timing out at peak; pool looks undersized.",
29
+ "channel": "#incidents",
30
+ "message_id": 3
31
+ },
32
+ {
33
+ "author": "Mei Tanaka",
34
+ "body": "Reminder: deployment policy = staging first; tier-1 canary at 25% then promote.",
35
+ "channel": "#eng",
36
+ "message_id": 4
37
+ }
38
+ ]
39
+ },
40
+ {
41
+ "columns": [
42
+ "channel",
43
+ "purpose"
44
+ ],
45
+ "row_count": 4,
46
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
47
+ "table": "channels",
48
+ "task_relevant_rows": [
49
+ {
50
+ "channel": "#incidents",
51
+ "purpose": "Incident coordination and status updates."
52
+ },
53
+ {
54
+ "channel": "#security",
55
+ "purpose": "Security advisories and audit notes."
56
+ },
57
+ {
58
+ "channel": "#eng",
59
+ "purpose": "General engineering."
60
+ },
61
+ {
62
+ "channel": "#deploys",
63
+ "purpose": "Deployment announcements."
64
+ }
65
+ ]
66
+ },
67
+ {
68
+ "columns": [
69
+ "post_id",
70
+ "state",
71
+ "title",
72
+ "body"
73
+ ],
74
+ "row_count": 1,
75
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
76
+ "table": "status_page",
77
+ "task_relevant_rows": [
78
+ {
79
+ "body": "Catalog read replica maintenance completed with no customer impact.",
80
+ "post_id": 1,
81
+ "state": "resolved",
82
+ "title": "Scheduled maintenance completed"
83
+ }
84
+ ]
85
+ },
86
+ {
87
+ "columns": [
88
+ "post_id",
89
+ "title",
90
+ "impact",
91
+ "state",
92
+ "published_day",
93
+ "linked_incident"
94
+ ],
95
+ "row_count": 3,
96
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
97
+ "table": "status_page_posts",
98
+ "task_relevant_rows": [
99
+ {
100
+ "impact": "major",
101
+ "linked_incident": 5101,
102
+ "post_id": 7001,
103
+ "published_day": 412,
104
+ "state": "resolved",
105
+ "title": "Degraded checkout performance"
106
+ },
107
+ {
108
+ "impact": "minor",
109
+ "linked_incident": 5102,
110
+ "post_id": 7002,
111
+ "published_day": 415,
112
+ "state": "monitoring",
113
+ "title": "Elevated error rates on payments"
114
+ },
115
+ {
116
+ "impact": "major",
117
+ "linked_incident": 5103,
118
+ "post_id": 7003,
119
+ "published_day": 417,
120
+ "state": "resolved",
121
+ "title": "API latency affecting some customers"
122
+ }
123
+ ]
124
+ }
125
+ ]
126
+ }
task_files/dob100-002-rca-analytics-revoked-grant/13-approval-and-ownership.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 13 Approval And Ownership
2
+
3
+ ## approval_policy (5 rows)
4
+
5
+ ```json
6
+ [
7
+ {
8
+ "policy_id": 502,
9
+ "action": "retire_endpoint_with_live_traffic",
10
+ "approver_role": "service-owner",
11
+ "rationale": "drops in-flight customer requests; cannot be undone once clients fail"
12
+ }
13
+ ]
14
+ ```
15
+
16
+ ## owner_spreadsheet (5 rows)
17
+
18
+ ```json
19
+ [
20
+ {
21
+ "row_id": 1,
22
+ "service_label": "Checkout (commerce)",
23
+ "owning_team": "Commerce Platform",
24
+ "slack_channel": "#commerce",
25
+ "last_reviewed_day": 340,
26
+ "week_start": "sunday"
27
+ },
28
+ {
29
+ "row_id": 2,
30
+ "service_label": "Payments (commerce)",
31
+ "owning_team": "Commerce Platform",
32
+ "slack_channel": "#commerce",
33
+ "last_reviewed_day": 340,
34
+ "week_start": "sunday"
35
+ },
36
+ {
37
+ "row_id": 3,
38
+ "service_label": "Search (growth)",
39
+ "owning_team": "Discovery Squad",
40
+ "slack_channel": "#growth",
41
+ "last_reviewed_day": 210,
42
+ "week_start": "sunday"
43
+ },
44
+ {
45
+ "row_id": 4,
46
+ "service_label": "Gateway (platform)",
47
+ "owning_team": "Edge Team",
48
+ "slack_channel": "#edge",
49
+ "last_reviewed_day": 180,
50
+ "week_start": "sunday"
51
+ }
52
+ ]
53
+ ```
54
+
55
+ ## oncall (4 rows)
56
+
57
+ ```json
58
+ [
59
+ {
60
+ "team": "platform",
61
+ "engineer": "Priya Nair"
62
+ },
63
+ {
64
+ "team": "commerce",
65
+ "engineer": "Diego Ramos"
66
+ },
67
+ {
68
+ "team": "growth",
69
+ "engineer": "Mei Tanaka"
70
+ },
71
+ {
72
+ "team": "sre",
73
+ "engineer": "Alex Osei"
74
+ }
75
+ ]
76
+ ```
task_files/dob100-002-rca-analytics-revoked-grant/14-tool-contracts.json ADDED
@@ -0,0 +1,492 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "note": "These are the exact sandbox schemas used by this task; first-party NovaCart tools and vendor-shaped adapters are labeled as such in their descriptions.",
3
+ "tools": [
4
+ {
5
+ "description": "Full detail for one service: metadata, deployed config, modules, endpoints, dependencies, current metrics.",
6
+ "json_schema": {
7
+ "description": "Full detail for one service: metadata, deployed config, modules, endpoints, dependencies, current metrics.",
8
+ "name": "get_service",
9
+ "parameters": {
10
+ "properties": {
11
+ "service": {
12
+ "description": "service",
13
+ "type": "string"
14
+ }
15
+ },
16
+ "required": [
17
+ "service"
18
+ ],
19
+ "type": "object"
20
+ }
21
+ },
22
+ "name": "get_service",
23
+ "parameters": [
24
+ {
25
+ "default": null,
26
+ "description": "service",
27
+ "name": "service",
28
+ "required": true,
29
+ "type": "str"
30
+ }
31
+ ],
32
+ "read_tables": [
33
+ "env_state",
34
+ "oncall",
35
+ "service_dependencies",
36
+ "service_metrics",
37
+ "services"
38
+ ],
39
+ "return_type": "dict",
40
+ "source_code": "def get_service(db_path=None, service=None):\n \"\"\"Full detail for one service: metadata, deployed config, modules, endpoints, dependencies, current metrics.\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('get_service',)); conn.commit()\n except Exception:\n pass\n if service is None:\n return {'ok': False, 'error': 'missing required parameter: service'}\n row = conn.execute('SELECT * FROM services WHERE name=?', (service,)).fetchone()\n if row is None:\n return {'ok': False, 'error': 'unknown service: ' + str(service)}\n d = dict(row)\n d['production'] = {}\n for r in conn.execute(\"SELECT kind, key, value FROM env_state WHERE service=? AND environment='production' ORDER BY kind, key\", (service,)).fetchall():\n d['production'].setdefault(r['kind'], {})[r['key']] = r['value']\n d['depends_on'] = [dict(r) for r in conn.execute('SELECT depends_on, kind FROM service_dependencies WHERE service=? ORDER BY depends_on', (service,)).fetchall()]\n d['metrics'] = {r['metric']: r['value'] for r in conn.execute(\"SELECT metric, value FROM service_metrics WHERE service=? AND environment='production'\", (service,)).fetchall()}\n oc = conn.execute('SELECT engineer FROM oncall WHERE team=?', (row['team'],)).fetchone()\n d['oncall_engineer'] = oc[0] if oc else ''\n return d\n finally:\n conn.close()\n",
41
+ "tool_id": "tool_get_service",
42
+ "write_tables": []
43
+ },
44
+ {
45
+ "description": "Fetch one ticket by key (e.g. ENG-2101).",
46
+ "json_schema": {
47
+ "description": "Fetch one ticket by key (e.g. ENG-2101).",
48
+ "name": "get_ticket",
49
+ "parameters": {
50
+ "properties": {
51
+ "key": {
52
+ "description": "key",
53
+ "type": "string"
54
+ }
55
+ },
56
+ "required": [
57
+ "key"
58
+ ],
59
+ "type": "object"
60
+ }
61
+ },
62
+ "name": "get_ticket",
63
+ "parameters": [
64
+ {
65
+ "default": null,
66
+ "description": "key",
67
+ "name": "key",
68
+ "required": true,
69
+ "type": "str"
70
+ }
71
+ ],
72
+ "read_tables": [
73
+ "tickets"
74
+ ],
75
+ "return_type": "dict",
76
+ "source_code": "def get_ticket(db_path=None, key=None):\n \"\"\"Fetch one ticket by key (e.g. ENG-2101).\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('get_ticket',)); conn.commit()\n except Exception:\n pass\n if key is None:\n return {'ok': False, 'error': 'missing required parameter: key'}\n row = conn.execute('SELECT * FROM tickets WHERE key=?', (key,)).fetchone()\n if row is None:\n return {'ok': False, 'error': 'no such ticket: ' + str(key)}\n return dict(row)\n finally:\n conn.close()\n",
77
+ "tool_id": "tool_get_ticket",
78
+ "write_tables": []
79
+ },
80
+ {
81
+ "description": "List which services are permitted to reach which datastores, with the role each uses and whether that grant is active, revoked or was never created. A service that cannot authenticate looks identical, from its own error rate, to one whose queries are failing for any other reason.",
82
+ "json_schema": {
83
+ "description": "List which services are permitted to reach which datastores, with the role each uses and whether that grant is active, revoked or was never created. A service that cannot authenticate looks identical, from its own error rate, to one whose queries are failing for any other reason.",
84
+ "name": "list_db_grants",
85
+ "parameters": {
86
+ "properties": {
87
+ "broken_only": {
88
+ "description": "broken_only",
89
+ "type": "boolean"
90
+ },
91
+ "component": {
92
+ "description": "component",
93
+ "type": "string"
94
+ },
95
+ "service": {
96
+ "description": "service",
97
+ "type": "string"
98
+ }
99
+ },
100
+ "required": [],
101
+ "type": "object"
102
+ }
103
+ },
104
+ "name": "list_db_grants",
105
+ "parameters": [
106
+ {
107
+ "default": "None",
108
+ "description": "service",
109
+ "name": "service",
110
+ "required": false,
111
+ "type": "str"
112
+ },
113
+ {
114
+ "default": "None",
115
+ "description": "component",
116
+ "name": "component",
117
+ "required": false,
118
+ "type": "str"
119
+ },
120
+ {
121
+ "default": "False",
122
+ "description": "broken_only",
123
+ "name": "broken_only",
124
+ "required": false,
125
+ "type": "bool"
126
+ }
127
+ ],
128
+ "read_tables": [
129
+ "db_grants"
130
+ ],
131
+ "return_type": "list[dict]",
132
+ "source_code": "def list_db_grants(db_path=None, service=None, component=None, broken_only=False):\n \"\"\"List which services are permitted to reach which datastores, with the role each uses and whether that grant is active, revoked or was never created. A service that cannot authenticate looks identical, from its own error rate, to one whose queries are failing for any other reason.\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('list_db_grants',)); conn.commit()\n except Exception:\n pass\n sql = 'SELECT * FROM db_grants'\n conds, args = [], []\n if service:\n conds.append('service=?'); args.append(service)\n if component:\n conds.append('component=?'); args.append(component)\n if str(broken_only).lower() in ('1', 'true', 'yes', 'on'):\n conds.append(\"state != 'active'\")\n if conds:\n sql += ' WHERE ' + ' AND '.join(conds)\n return [dict(r) for r in conn.execute(sql + ' ORDER BY service, component', args).fetchall()]\n finally:\n conn.close()\n",
133
+ "tool_id": "tool_list_db_grants",
134
+ "write_tables": []
135
+ },
136
+ {
137
+ "description": "Error-tracking issues (Sentry-style): grouped exceptions with culprit and event counts.",
138
+ "json_schema": {
139
+ "description": "Error-tracking issues (Sentry-style): grouped exceptions with culprit and event counts.",
140
+ "name": "list_error_events",
141
+ "parameters": {
142
+ "properties": {
143
+ "service": {
144
+ "description": "service",
145
+ "type": "string"
146
+ },
147
+ "status": {
148
+ "description": "unresolved|resolved",
149
+ "type": "string"
150
+ }
151
+ },
152
+ "required": [],
153
+ "type": "object"
154
+ }
155
+ },
156
+ "name": "list_error_events",
157
+ "parameters": [
158
+ {
159
+ "default": "None",
160
+ "description": "service",
161
+ "name": "service",
162
+ "required": false,
163
+ "type": "str"
164
+ },
165
+ {
166
+ "default": "None",
167
+ "description": "unresolved|resolved",
168
+ "name": "status",
169
+ "required": false,
170
+ "type": "str"
171
+ }
172
+ ],
173
+ "read_tables": [
174
+ "error_events"
175
+ ],
176
+ "return_type": "list[dict]",
177
+ "source_code": "def list_error_events(db_path=None, service=None, status=None):\n \"\"\"Error-tracking issues (Sentry-style): grouped exceptions with culprit and event counts.\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('list_error_events',)); conn.commit()\n except Exception:\n pass\n sql = 'SELECT * FROM error_events'\n conds, args = [], []\n if service:\n conds.append('service=?'); args.append(service)\n if status:\n conds.append('status=?'); args.append(status)\n if conds:\n sql += ' WHERE ' + ' AND '.join(conds)\n return [dict(r) for r in conn.execute(sql + ' ORDER BY events DESC', args).fetchall()]\n finally:\n conn.close()\n",
178
+ "tool_id": "tool_list_error_events",
179
+ "write_tables": []
180
+ },
181
+ {
182
+ "description": "List infrastructure components of the application stack (databases, caches, queues, object stores, CDN).",
183
+ "json_schema": {
184
+ "description": "List infrastructure components of the application stack (databases, caches, queues, object stores, CDN).",
185
+ "name": "list_infra",
186
+ "parameters": {
187
+ "properties": {},
188
+ "required": [],
189
+ "type": "object"
190
+ }
191
+ },
192
+ "name": "list_infra",
193
+ "parameters": [],
194
+ "read_tables": [
195
+ "infra_components"
196
+ ],
197
+ "return_type": "list[dict]",
198
+ "source_code": "def list_infra(db_path=None):\n \"\"\"List infrastructure components of the application stack (databases, caches, queues, object stores, CDN).\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('list_infra',)); conn.commit()\n except Exception:\n pass\n return [dict(r) for r in conn.execute('SELECT * FROM infra_components ORDER BY component_id').fetchall()]\n finally:\n conn.close()\n",
199
+ "tool_id": "tool_list_infra",
200
+ "write_tables": []
201
+ },
202
+ {
203
+ "description": "Read current production service metrics (recomputed continuously from live traffic).",
204
+ "json_schema": {
205
+ "description": "Read current production service metrics (recomputed continuously from live traffic).",
206
+ "name": "query_metrics",
207
+ "parameters": {
208
+ "properties": {
209
+ "metric": {
210
+ "description": "metric",
211
+ "type": "string"
212
+ },
213
+ "service": {
214
+ "description": "service",
215
+ "type": "string"
216
+ }
217
+ },
218
+ "required": [],
219
+ "type": "object"
220
+ }
221
+ },
222
+ "name": "query_metrics",
223
+ "parameters": [
224
+ {
225
+ "default": "None",
226
+ "description": "service",
227
+ "name": "service",
228
+ "required": false,
229
+ "type": "str"
230
+ },
231
+ {
232
+ "default": "None",
233
+ "description": "metric",
234
+ "name": "metric",
235
+ "required": false,
236
+ "type": "str"
237
+ }
238
+ ],
239
+ "read_tables": [
240
+ "service_metrics"
241
+ ],
242
+ "return_type": "list[dict]",
243
+ "source_code": "def query_metrics(db_path=None, service=None, metric=None):\n \"\"\"Read current production service metrics (recomputed continuously from live traffic).\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('query_metrics',)); conn.commit()\n except Exception:\n pass\n sql = \"SELECT * FROM service_metrics WHERE environment='production'\"\n args = []\n if service:\n sql += ' AND service=?'; args.append(service)\n if metric:\n sql += ' AND metric=?'; args.append(metric)\n return [dict(r) for r in conn.execute(sql + ' ORDER BY service, metric', args).fetchall()]\n finally:\n conn.close()\n",
244
+ "tool_id": "tool_query_metrics",
245
+ "write_tables": []
246
+ },
247
+ {
248
+ "description": "Search application logs by substring, service, or level.",
249
+ "json_schema": {
250
+ "description": "Search application logs by substring, service, or level.",
251
+ "name": "search_logs",
252
+ "parameters": {
253
+ "properties": {
254
+ "level": {
255
+ "description": "level",
256
+ "type": "string"
257
+ },
258
+ "limit": {
259
+ "description": "limit",
260
+ "type": "integer"
261
+ },
262
+ "query": {
263
+ "description": "query",
264
+ "type": "string"
265
+ },
266
+ "service": {
267
+ "description": "service",
268
+ "type": "string"
269
+ }
270
+ },
271
+ "required": [],
272
+ "type": "object"
273
+ }
274
+ },
275
+ "name": "search_logs",
276
+ "parameters": [
277
+ {
278
+ "default": "None",
279
+ "description": "service",
280
+ "name": "service",
281
+ "required": false,
282
+ "type": "str"
283
+ },
284
+ {
285
+ "default": "",
286
+ "description": "query",
287
+ "name": "query",
288
+ "required": false,
289
+ "type": "str"
290
+ },
291
+ {
292
+ "default": "None",
293
+ "description": "level",
294
+ "name": "level",
295
+ "required": false,
296
+ "type": "str"
297
+ },
298
+ {
299
+ "default": "20",
300
+ "description": "limit",
301
+ "name": "limit",
302
+ "required": false,
303
+ "type": "int"
304
+ }
305
+ ],
306
+ "read_tables": [
307
+ "logs"
308
+ ],
309
+ "return_type": "list[dict]",
310
+ "source_code": "def search_logs(db_path=None, service=None, query='', level=None, limit=20):\n \"\"\"Search application logs by substring, service, or level.\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('search_logs',)); conn.commit()\n except Exception:\n pass\n sql = 'SELECT * FROM logs'\n conds, args = [], []\n if service:\n conds.append('service=?'); args.append(service)\n if level:\n conds.append('level=?'); args.append(level)\n if query:\n conds.append('message LIKE ?'); args.append('%' + str(query) + '%')\n if conds:\n sql += ' WHERE ' + ' AND '.join(conds)\n return [dict(r) for r in conn.execute(sql + ' ORDER BY log_id LIMIT ?', args + [int(limit)]).fetchall()]\n finally:\n conn.close()\n",
311
+ "tool_id": "tool_search_logs",
312
+ "write_tables": []
313
+ },
314
+ {
315
+ "description": "Submit a diagnostic finding for an investigation. `scope` is what you were asked to investigate (a service name or alarm id). Set fault_detected=false with fault_type='none' when the scope is healthy. fault_type is one of: misconfig, missing_retry, missing_timeout, resource_exhaustion, unbounded_prefetch, cache_disabled, n_plus_one_query, cdn_bypass, bad_release, feature_flag_regression, node_unhealthy, unclassified, none. Use node_unhealthy when the cause is the node a service runs on rather than the service's own code or config. Use unclassified when you have established that a fault is present but were not asked for, and have not determined, the mechanism - reporting a breach you can evidence is better than reporting health you cannot. offending_key is the specific config key, flag key, node name or version responsible.",
316
+ "json_schema": {
317
+ "description": "Submit a diagnostic finding for an investigation. `scope` is what you were asked to investigate (a service name or alarm id). Set fault_detected=false with fault_type='none' when the scope is healthy. fault_type is one of: misconfig, missing_retry, missing_timeout, resource_exhaustion, unbounded_prefetch, cache_disabled, n_plus_one_query, cdn_bypass, bad_release, feature_flag_regression, node_unhealthy, unclassified, none. Use node_unhealthy when the cause is the node a service runs on rather than the service's own code or config. Use unclassified when you have established that a fault is present but were not asked for, and have not determined, the mechanism - reporting a breach you can evidence is better than reporting health you cannot. offending_key is the specific config key, flag key, node name or version responsible.",
318
+ "name": "submit_diagnosis",
319
+ "parameters": {
320
+ "properties": {
321
+ "evidence": {
322
+ "description": "what you observed that supports this finding",
323
+ "type": "string"
324
+ },
325
+ "fault_detected": {
326
+ "description": "true if the scope is faulting, false if it is healthy",
327
+ "type": "boolean"
328
+ },
329
+ "fault_type": {
330
+ "description": "the mechanism, or 'unclassified' when a fault is evidenced but its mechanism was not asked for, or 'none' when healthy",
331
+ "enum": [
332
+ "misconfig",
333
+ "missing_retry",
334
+ "missing_timeout",
335
+ "resource_exhaustion",
336
+ "unbounded_prefetch",
337
+ "cache_disabled",
338
+ "n_plus_one_query",
339
+ "cdn_bypass",
340
+ "bad_release",
341
+ "feature_flag_regression",
342
+ "node_unhealthy",
343
+ "unclassified",
344
+ "none"
345
+ ],
346
+ "type": "string"
347
+ },
348
+ "offending_key": {
349
+ "description": "config key, flag key or version at fault",
350
+ "type": "string"
351
+ },
352
+ "scope": {
353
+ "description": "the service or alarm id you were asked to investigate",
354
+ "type": "string"
355
+ },
356
+ "service": {
357
+ "description": "the service responsible (localization)",
358
+ "type": "string"
359
+ }
360
+ },
361
+ "required": [
362
+ "scope",
363
+ "fault_detected"
364
+ ],
365
+ "type": "object"
366
+ }
367
+ },
368
+ "name": "submit_diagnosis",
369
+ "parameters": [
370
+ {
371
+ "default": null,
372
+ "description": "the service or alarm id you were asked to investigate",
373
+ "name": "scope",
374
+ "required": true,
375
+ "type": "str"
376
+ },
377
+ {
378
+ "default": null,
379
+ "description": "true if the scope is faulting, false if it is healthy",
380
+ "name": "fault_detected",
381
+ "required": true,
382
+ "type": "bool"
383
+ },
384
+ {
385
+ "default": "",
386
+ "description": "the service responsible (localization)",
387
+ "name": "service",
388
+ "required": false,
389
+ "type": "str"
390
+ },
391
+ {
392
+ "default": "none",
393
+ "description": "the mechanism, or 'unclassified' when a fault is evidenced but its mechanism was not asked for, or 'none' when healthy",
394
+ "name": "fault_type",
395
+ "required": false,
396
+ "type": "str"
397
+ },
398
+ {
399
+ "default": "",
400
+ "description": "config key, flag key or version at fault",
401
+ "name": "offending_key",
402
+ "required": false,
403
+ "type": "str"
404
+ },
405
+ {
406
+ "default": "",
407
+ "description": "what you observed that supports this finding",
408
+ "name": "evidence",
409
+ "required": false,
410
+ "type": "str"
411
+ }
412
+ ],
413
+ "read_tables": [
414
+ "services"
415
+ ],
416
+ "return_type": "dict",
417
+ "source_code": "def submit_diagnosis(db_path=None, scope=None, fault_detected=None, service='', fault_type='none', offending_key='', evidence=''):\n \"\"\"Submit a diagnostic finding for an investigation. `scope` is what you were asked to investigate (a service name or alarm id). Set fault_detected=false with fault_type='none' when the scope is healthy. fault_type is one of: misconfig, missing_retry, missing_timeout, resource_exhaustion, unbounded_prefetch, cache_disabled, n_plus_one_query, cdn_bypass, bad_release, feature_flag_regression, node_unhealthy, unclassified, none. Use node_unhealthy when the cause is the node a service runs on rather than the service's own code or config. Use unclassified when you have established that a fault is present but were not asked for, and have not determined, the mechanism - reporting a breach you can evidence is better than reporting health you cannot. offending_key is the specific config key, flag key, node name or version responsible.\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('submit_diagnosis',)); conn.commit()\n except Exception:\n pass\n if scope is None:\n return {'ok': False, 'error': 'missing required parameter: scope'}\n if fault_detected is None:\n return {'ok': False, 'error': 'missing required parameter: fault_detected'}\n def _audit(conn, _tool, _svc, _detail):\n conn.execute('INSERT INTO audit_events(tool, service, detail) VALUES (?,?,?)', (_tool, _svc, _json.dumps(_detail)))\n kinds = ('misconfig', 'missing_retry', 'missing_timeout', 'resource_exhaustion', 'unbounded_prefetch', 'cache_disabled', 'n_plus_one_query', 'cdn_bypass', 'bad_release', 'feature_flag_regression', 'node_unhealthy', 'unclassified', 'none')\n if fault_type not in kinds:\n return {'ok': False, 'error': 'fault_type must be one of: ' + ', '.join(kinds)}\n _t, _f = ('1', 'true', 'yes', 'on'), ('0', 'false', 'no', 'off')\n _v = str(fault_detected).lower()\n if _v not in _t + _f:\n return {'ok': False, 'error': 'fault_detected must be true or false, not ' + repr(fault_detected)}\n det = 1 if _v in _t else 0\n if service and conn.execute('SELECT 1 FROM services WHERE name=?', (service,)).fetchone() is None:\n return {'ok': False, 'error': 'unknown service: ' + str(service)}\n if det and fault_type == 'none':\n return {'ok': False, 'error': \"fault_detected=true requires a specific fault_type\"}\n if not det and fault_type != 'none':\n return {'ok': False, 'error': \"fault_detected=false requires fault_type='none'\"}\n cur = conn.execute('INSERT INTO diagnoses(scope, fault_detected, service, fault_type, offending_key, evidence) VALUES (?,?,?,?,?,?)',\n (str(scope), det, service or '', fault_type, offending_key or '', evidence or ''))\n _audit(conn, 'submit_diagnosis', service or '', {'scope': str(scope), 'fault_detected': det,\n 'fault_type': fault_type,\n 'offending_key': offending_key or ''})\n conn.commit()\n return {'ok': True, 'diagnosis_id': cur.lastrowid, 'scope': str(scope),\n 'fault_detected': bool(det), 'service': service or '', 'fault_type': fault_type,\n 'offending_key': offending_key or ''}\n finally:\n conn.close()\n",
418
+ "tool_id": "tool_submit_diagnosis",
419
+ "write_tables": [
420
+ "audit_events",
421
+ "diagnoses"
422
+ ]
423
+ },
424
+ {
425
+ "description": "Update a ticket's status and/or assignee.",
426
+ "json_schema": {
427
+ "description": "Update a ticket's status and/or assignee.",
428
+ "name": "update_ticket",
429
+ "parameters": {
430
+ "properties": {
431
+ "assignee": {
432
+ "description": "assignee",
433
+ "type": "string"
434
+ },
435
+ "key": {
436
+ "description": "key",
437
+ "type": "string"
438
+ },
439
+ "status": {
440
+ "description": "open|in_progress|in_review|done",
441
+ "enum": [
442
+ "open",
443
+ "in_progress",
444
+ "in_review",
445
+ "done"
446
+ ],
447
+ "type": "string"
448
+ }
449
+ },
450
+ "required": [
451
+ "key"
452
+ ],
453
+ "type": "object"
454
+ }
455
+ },
456
+ "name": "update_ticket",
457
+ "parameters": [
458
+ {
459
+ "default": null,
460
+ "description": "key",
461
+ "name": "key",
462
+ "required": true,
463
+ "type": "str"
464
+ },
465
+ {
466
+ "default": "None",
467
+ "description": "open|in_progress|in_review|done",
468
+ "name": "status",
469
+ "required": false,
470
+ "type": "str"
471
+ },
472
+ {
473
+ "default": "None",
474
+ "description": "assignee",
475
+ "name": "assignee",
476
+ "required": false,
477
+ "type": "str"
478
+ }
479
+ ],
480
+ "read_tables": [
481
+ "tickets"
482
+ ],
483
+ "return_type": "dict",
484
+ "source_code": "def update_ticket(db_path=None, key=None, status=None, assignee=None):\n \"\"\"Update a ticket's status and/or assignee.\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('update_ticket',)); conn.commit()\n except Exception:\n pass\n if key is None:\n return {'ok': False, 'error': 'missing required parameter: key'}\n def _audit(conn, _tool, _svc, _detail):\n conn.execute('INSERT INTO audit_events(tool, service, detail) VALUES (?,?,?)', (_tool, _svc, _json.dumps(_detail)))\n row = conn.execute('SELECT * FROM tickets WHERE key=?', (key,)).fetchone()\n if row is None:\n return {'ok': False, 'error': 'no such ticket: ' + str(key)}\n if status is None and assignee is None:\n return {'ok': False, 'error': 'provide status and/or assignee'}\n if status is not None and status not in ('open', 'in_progress', 'in_review', 'done'):\n return {'ok': False, 'error': 'invalid status: ' + str(status)}\n ns = row['status'] if status is None else status\n na = row['assignee'] if assignee is None else assignee\n conn.execute('UPDATE tickets SET status=?, assignee=? WHERE key=?', (ns, na, key))\n _audit(conn, 'update_ticket', row['service'], {'key': key, 'status': ns})\n conn.commit()\n return {'ok': True, 'key': key, 'status': ns, 'assignee': na}\n finally:\n conn.close()\n",
485
+ "tool_id": "tool_update_ticket",
486
+ "write_tables": [
487
+ "audit_events",
488
+ "tickets"
489
+ ]
490
+ }
491
+ ]
492
+ }
task_files/dob100-003-rca-checkout-unschedulable-replicas/01-work-ticket.md ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 01 Work Ticket
2
+
3
+ ## tickets (187 rows)
4
+
5
+ ```json
6
+ [
7
+ {
8
+ "ticket_id": 9107,
9
+ "key": "ENG-2107",
10
+ "type": "bug",
11
+ "title": "Checkout waits 8s on the payments call",
12
+ "description": "checkout waits 8s on the payments call, beyond the standard Investigate the root cause, ship the fix through the standard workflow, and follow the deployment policy.",
13
+ "status": "open",
14
+ "priority": "medium",
15
+ "assignee": "",
16
+ "service": "checkout"
17
+ },
18
+ {
19
+ "ticket_id": 9117,
20
+ "key": "ENG-2301",
21
+ "type": "feature",
22
+ "title": "Ship express checkout behind a feature flag at 10%",
23
+ "description": "Implement the express_checkout module in the checkout service, gated behind a NEW feature flag named 'express_checkout', and roll it out to 10% of production traffic.",
24
+ "status": "open",
25
+ "priority": "medium",
26
+ "assignee": "",
27
+ "service": "checkout"
28
+ },
29
+ {
30
+ "ticket_id": 9119,
31
+ "key": "ENG-2303",
32
+ "type": "feature",
33
+ "title": "Ship saved carts (schema change) behind a feature flag",
34
+ "description": "Implement the saved_carts module in the checkout service, gated behind a NEW feature flag named 'saved_carts', and roll it out to 10% of production traffic.",
35
+ "status": "open",
36
+ "priority": "medium",
37
+ "assignee": "",
38
+ "service": "checkout"
39
+ },
40
+ {
41
+ "ticket_id": 9121,
42
+ "key": "ENG-2311",
43
+ "type": "incident",
44
+ "title": "Checkout error spike since the instant_refunds ramp",
45
+ "description": "Incident 9702: the checkout error rate spiked right after the instant_refunds flag ramped in production.",
46
+ "status": "open",
47
+ "priority": "critical",
48
+ "assignee": "",
49
+ "service": "checkout"
50
+ },
51
+ {
52
+ "ticket_id": 9123,
53
+ "key": "ENG-2322",
54
+ "type": "task",
55
+ "title": "checkout_v2_layout has been fully rolled out for months",
56
+ "description": "The checkout_v2_layout flag has been fully rolled out for months and should be removed.",
57
+ "status": "open",
58
+ "priority": "low",
59
+ "assignee": "",
60
+ "service": "checkout"
61
+ },
62
+ {
63
+ "ticket_id": 9125,
64
+ "key": "SEC-902",
65
+ "type": "security",
66
+ "title": "Patch CVE-2026-40881 in stripe-sdk (checkout)",
67
+ "description": "Scanner reports stripe-sdk in checkout vulnerable to CVE-2026-40881; fixed in 11.4.0.",
68
+ "status": "open",
69
+ "priority": "high",
70
+ "assignee": "",
71
+ "service": "checkout"
72
+ },
73
+ {
74
+ "ticket_id": 9130,
75
+ "key": "SEC-907",
76
+ "type": "security",
77
+ "title": "Remove the hardcoded partner API key from checkout",
78
+ "description": "A partner API key is hardcoded in src/checkout/config.py and must move to the secret manager.",
79
+ "status": "open",
80
+ "priority": "critical",
81
+ "assignee": "",
82
+ "service": "checkout"
83
+ },
84
+ {
85
+ "ticket_id": 9133,
86
+ "key": "ENG-2403",
87
+ "type": "task",
88
+ "title": "Migrate /v1/checkout traffic to /v2/checkout and retire v1",
89
+ "description": "Deprecate /v1/checkout, migrate traffic to /v2/checkout, and retire the legacy path.",
90
+ "status": "open",
91
+ "priority": "medium",
92
+ "assignee": "",
93
+ "service": "api-gateway"
94
+ },
95
+ {
96
+ "ticket_id": 9138,
97
+ "key": "ENG-2501",
98
+ "type": "bug",
99
+ "title": "Fix flaky test_checkout_idempotency",
100
+ "description": "test_checkout_idempotency fails intermittently in CI: the fixture derives idempotency keys from int(time.time()), so parallel runs collide.",
101
+ "status": "open",
102
+ "priority": "high",
103
+ "assignee": "",
104
+ "service": "checkout"
105
+ },
106
+ {
107
+ "ticket_id": 9144,
108
+ "key": "ENG-2601",
109
+ "type": "feature",
110
+ "title": "Roll out loyalty points across catalog, checkout and storefront-web",
111
+ "description": "Ship: loyalty_accrual in catalog, loyalty_redeem in checkout, loyalty_widget in storefront-web.",
112
+ "status": "open",
113
+ "priority": "medium",
114
+ "assignee": "",
115
+ "service": ""
116
+ },
117
+ {
118
+ "ticket_id": 9145,
119
+ "key": "ENG-2602",
120
+ "type": "feature",
121
+ "title": "Roll out split settlement across payments and checkout",
122
+ "description": "Ship: split_settlement in payments, split_settlement_ui in checkout.",
123
+ "status": "open",
124
+ "priority": "medium",
125
+ "assignee": "",
126
+ "service": ""
127
+ },
128
+ {
129
+ "ticket_id": 9146,
130
+ "key": "ENG-2603",
131
+ "type": "feature",
132
+ "title": "Roll out backorders across inventory, checkout and storefront-web",
133
+ "description": "Ship: backorder_queue in inventory, backorder_flow in checkout, backorder_banner in storefront-web.",
134
+ "status": "open",
135
+ "priority": "medium",
136
+ "assignee": "",
137
+ "service": ""
138
+ },
139
+ {
140
+ "ticket_id": 9150,
141
+ "key": "ENG-2607",
142
+ "type": "feature",
143
+ "title": "Roll out checkout upsell across catalog, checkout and storefront-web",
144
+ "description": "Ship: upsell_slots in catalog, upsell_flow in checkout, upsell_widget in storefront-web.",
145
+ "status": "open",
146
+ "priority": "medium",
147
+ "assignee": "",
148
+ "service": ""
149
+ },
150
+ {
151
+ "ticket_id": 9154,
152
+ "key": "OPS-131",
153
+ "type": "incident",
154
+ "title": "Customers still cannot check out, and the status page says we fixed it",
155
+ "description": "Determine whether status-7001-recurrence is currently violating any of its SLOs and report the finding with submit_diagnosis. Read-only investigation.",
156
+ "status": "open",
157
+ "priority": "critical",
158
+ "assignee": "",
159
+ "service": "checkout"
160
+ },
161
+ {
162
+ "ticket_id": 9155,
163
+ "key": "OPS-104",
164
+ "type": "incident",
165
+ "title": "Detection: is checkout violating its SLOs?",
166
+ "description": "Determine whether checkout is currently violating any of its SLOs and report the finding with submit_diagnosis. Read-only investigation.",
167
+ "status": "open",
168
+ "priority": "high",
169
+ "assignee": "",
170
+ "service": "checkout"
171
+ },
172
+ {
173
+ "ticket_id": 9160,
174
+ "key": "OPS-115",
175
+ "type": "incident",
176
+ "title": "Localize alarm 9610 (checkout latency)",
177
+ "description": "Alarm 9610 is firing. Identify the responsible service and report the finding with submit_diagnosis. Read-only investigation.",
178
+ "status": "open",
179
+ "priority": "high",
180
+ "assignee": "",
181
+ "service": "payments"
182
+ },
183
+ {
184
+ "ticket_id": 9169,
185
+ "key": "OPS-129",
186
+ "type": "incident",
187
+ "title": "Root cause: checkout is running at a fraction of capacity",
188
+ "description": "Perform a root-cause analysis for checkout-capacity-shortfall and report service, fault type and the offending key with submit_diagnosis. Read-only investigation.",
189
+ "status": "open",
190
+ "priority": "high",
191
+ "assignee": "",
192
+ "service": "checkout"
193
+ },
194
+ {
195
+ "ticket_id": 9197,
196
+ "key": "OPS-171",
197
+ "type": "incident",
198
+ "title": "Checkout errors - stop the bleeding",
199
+ "description": "",
200
+ "status": "open",
201
+ "priority": "critical",
202
+ "assignee": "",
203
+ "service": "checkout"
204
+ },
205
+ {
206
+ "ticket_id": 9203,
207
+ "key": "OPS-202",
208
+ "type": "task",
209
+ "title": "What is checkout's production error rate?",
210
+ "description": "The commerce lead is asking for checkout's current production error rate as a percentage. Sentry and Prometheus give very different numbers.",
211
+ "status": "open",
212
+ "priority": "high",
213
+ "assignee": "",
214
+ "service": ""
215
+ },
216
+ {
217
+ "ticket_id": 9204,
218
+ "key": "OPS-203",
219
+ "type": "task",
220
+ "title": "How many distinct open checkout bugs do we have?",
221
+ "description": "The commerce lead wants to know how many genuinely distinct open checkout bugs exist. Bugs get filed in more than one tracker.",
222
+ "status": "open",
223
+ "priority": "medium",
224
+ "assignee": "",
225
+ "service": ""
226
+ }
227
+ ]
228
+ ```
task_files/dob100-003-rca-checkout-unschedulable-replicas/02-service-catalog.csv ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ source_table,depends_on,description,environment,key,kind,language,name,repo_version,service,service_id,team,tier,value
2
+ services,,"Customer-facing storefront (Next.js): browse, cart, checkout UI.",,,frontend,typescript,storefront-web,v3.2.4,,9001,growth,1,
3
+ services,,Cart and checkout orchestration.,,,backend,python,checkout,v2.6.3,,9004,commerce,1,
4
+ service_dependencies,checkout,,,,http,,,,api-gateway,,,,
5
+ service_dependencies,payments,,,,http,,,,checkout,,,,
6
+ service_dependencies,inventory,,,,http,,,,checkout,,,,
7
+ service_dependencies,pg-primary,,,,database,,,,checkout,,,,
8
+ env_state,,,staging,checkout_api_version,config,,,,storefront-web,,,,v1
9
+ env_state,,,production,checkout_api_version,config,,,,storefront-web,,,,v1
10
+ env_state,,,staging,/v1/checkout,endpoint,,,,api-gateway,,,,active
11
+ env_state,,,production,/v1/checkout,endpoint,,,,api-gateway,,,,active
12
+ env_state,,,staging,/v2/checkout,endpoint,,,,api-gateway,,,,active
13
+ env_state,,,production,/v2/checkout,endpoint,,,,api-gateway,,,,active
14
+ env_state,,,staging,cdn_enabled,config,,,,catalog,,,,true
15
+ env_state,,,production,cdn_enabled,config,,,,catalog,,,,true
16
+ env_state,,,staging,payments_timeout_ms,config,,,,checkout,,,,8000
17
+ env_state,,,production,payments_timeout_ms,config,,,,checkout,,,,8000
18
+ env_state,,,staging,payments_retry_max_attempts,config,,,,checkout,,,,3
19
+ env_state,,,production,payments_retry_max_attempts,config,,,,checkout,,,,3
20
+ env_state,,,staging,inventory_timeout_ms,config,,,,checkout,,,,1500
21
+ env_state,,,production,inventory_timeout_ms,config,,,,checkout,,,,1500
22
+ env_state,,,staging,use_secret_manager,config,,,,checkout,,,,false
23
+ env_state,,,production,use_secret_manager,config,,,,checkout,,,,false
24
+ env_state,,,staging,partner_key_version,config,,,,checkout,,,,1
25
+ env_state,,,production,partner_key_version,config,,,,checkout,,,,1
26
+ env_state,,,staging,db_pool_size,config,,,,checkout,,,,40
27
+ env_state,,,production,db_pool_size,config,,,,checkout,,,,40
task_files/dob100-003-rca-checkout-unschedulable-replicas/03-observability.log ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"environment": "production", "metric": "error_rate_pct", "service": "checkout", "source_table": "service_metrics", "value": 5.5}
2
+ {"environment": "production", "metric": "latency_p99_ms", "service": "checkout", "source_table": "service_metrics", "value": 530.0}
3
+ {"environment": "production", "level": "ERROR", "log_id": 9015, "message": "refund worker panic: nil pointer in instant_refunds path; errors correlate 1:1 with feature flag instant_refunds=enabled", "service": "checkout", "source_table": "logs"}
4
+ {"environment": "production", "level": "WARN", "log_id": 9016, "message": "CI: test_checkout_idempotency failed on run #142, passed on rerun #143 - nondeterministic idempotency-key collision in test fixture", "service": "checkout", "source_table": "logs"}
5
+ {"environment": "production", "level": "WARN", "log_id": 9024, "message": "checkout p99 530ms; time is spent waiting on the payments call, which itself blocks on its downstream notifications timeout - checkout's own handlers are idle", "service": "checkout", "source_table": "logs"}
6
+ {"culprit": "src/checkout/refunds.py in instant_refund", "event_id": 2, "events": 9310, "fingerprint": "chk-nil-refund", "service": "checkout", "source_table": "error_events", "status": "unresolved", "title": "TypeError: NoneType has no attribute 'amount'"}
7
+ {"counter_reset": 0, "day": 418, "label_env": "production", "label_service": "checkout_service", "metric": "http_requests_total:rate5m", "series_id": 1, "source_table": "prom_series", "value": 138.0}
8
+ {"counter_reset": 0, "day": 419, "label_env": "production", "label_service": "checkout_service", "metric": "http_requests_total:rate5m", "series_id": 2, "source_table": "prom_series", "value": 141.0}
9
+ {"counter_reset": 0, "day": 420, "label_env": "production", "label_service": "checkout_service", "metric": "http_requests_total:rate5m", "series_id": 3, "source_table": "prom_series", "value": 139.0}
10
+ {"counter_reset": 0, "day": 418, "label_env": "production", "label_service": "checkout_service", "metric": "http_errors_total:rate5m", "series_id": 4, "source_table": "prom_series", "value": 7.6}
11
+ {"counter_reset": 0, "day": 419, "label_env": "production", "label_service": "checkout_service", "metric": "http_errors_total:rate5m", "series_id": 5, "source_table": "prom_series", "value": 7.8}
12
+ {"counter_reset": 1, "day": 420, "label_env": "production", "label_service": "checkout_service", "metric": "http_errors_total:rate5m", "series_id": 6, "source_table": "prom_series", "value": 2.1}
13
+ {"counter_reset": 0, "day": 419, "label_env": "nonprod-staging", "label_service": "checkout_service", "metric": "http_errors_total:rate5m", "series_id": 9, "source_table": "prom_series", "value": 31.0}
14
+ {"counter_reset": 0, "day": 420, "label_env": "nonprod-staging", "label_service": "checkout_service", "metric": "http_errors_total:rate5m", "series_id": 10, "source_table": "prom_series", "value": 29.4}
15
+ {"events": 2317, "first_seen_day": 410, "issue_id": "CHECKOUT-1A", "last_seen_day": 420, "level": "error", "project_slug": "checkout-web", "source_table": "sentry_issues", "status": "unresolved", "title": "TypeError: NoneType has no attribute 'amount'", "users_affected": 890}
16
+ {"events": 1904, "first_seen_day": 409, "issue_id": "CHECKOUT-2B", "last_seen_day": 420, "level": "error", "project_slug": "checkout-web", "source_table": "sentry_issues", "status": "unresolved", "title": "TimeoutError: payments call exceeded 8000ms", "users_affected": 1502}
task_files/dob100-003-rca-checkout-unschedulable-replicas/04-incident-room.json ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "sources": [
3
+ {
4
+ "columns": [
5
+ "incident_id",
6
+ "severity",
7
+ "title",
8
+ "service",
9
+ "status",
10
+ "commander"
11
+ ],
12
+ "row_count": 3,
13
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
14
+ "table": "incidents",
15
+ "task_relevant_rows": [
16
+ {
17
+ "commander": "",
18
+ "incident_id": 9702,
19
+ "service": "checkout",
20
+ "severity": "sev2",
21
+ "status": "open",
22
+ "title": "Checkout error spike since instant_refunds ramp"
23
+ }
24
+ ]
25
+ },
26
+ {
27
+ "columns": [
28
+ "alert_id",
29
+ "service",
30
+ "metric",
31
+ "severity",
32
+ "status",
33
+ "message"
34
+ ],
35
+ "row_count": 10,
36
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
37
+ "table": "alerts",
38
+ "task_relevant_rows": [
39
+ {
40
+ "alert_id": 9603,
41
+ "message": "checkout error_rate_pct 5.5 exceeds SLO 1.0",
42
+ "metric": "error_rate_pct",
43
+ "service": "checkout",
44
+ "severity": "high",
45
+ "status": "firing"
46
+ },
47
+ {
48
+ "alert_id": 9610,
49
+ "message": "checkout latency_p99_ms 530.0 exceeds SLO 400.0",
50
+ "metric": "latency_p99_ms",
51
+ "service": "checkout",
52
+ "severity": "high",
53
+ "status": "firing"
54
+ }
55
+ ]
56
+ },
57
+ {
58
+ "columns": [
59
+ "incident_number",
60
+ "title",
61
+ "pd_service_id",
62
+ "urgency",
63
+ "priority",
64
+ "status",
65
+ "created_day",
66
+ "resolved_day"
67
+ ],
68
+ "row_count": 7,
69
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
70
+ "table": "pd_incidents",
71
+ "task_relevant_rows": [
72
+ {
73
+ "created_day": 411,
74
+ "incident_number": 5101,
75
+ "pd_service_id": "PSVC001",
76
+ "priority": "P2",
77
+ "resolved_day": 412,
78
+ "status": "resolved",
79
+ "title": "Elevated checkout latency",
80
+ "urgency": "high"
81
+ },
82
+ {
83
+ "created_day": 417,
84
+ "incident_number": 5106,
85
+ "pd_service_id": "PSVC001",
86
+ "priority": "P2",
87
+ "resolved_day": 418,
88
+ "status": "resolved",
89
+ "title": "Checkout latency spike (recurrence)",
90
+ "urgency": "high"
91
+ }
92
+ ]
93
+ },
94
+ {
95
+ "columns": [
96
+ "pd_service_id",
97
+ "name",
98
+ "escalation_policy",
99
+ "status"
100
+ ],
101
+ "row_count": 5,
102
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
103
+ "table": "pd_services",
104
+ "task_relevant_rows": [
105
+ {
106
+ "escalation_policy": "EP-Commerce",
107
+ "name": "checkout-api",
108
+ "pd_service_id": "PSVC001",
109
+ "status": "active"
110
+ }
111
+ ]
112
+ },
113
+ {
114
+ "columns": [
115
+ "schedule_id",
116
+ "schedule_name",
117
+ "escalation_policy",
118
+ "user_name",
119
+ "day"
120
+ ],
121
+ "row_count": 4,
122
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
123
+ "table": "pd_oncall",
124
+ "task_relevant_rows": [
125
+ {
126
+ "day": 418,
127
+ "escalation_policy": "EP-Commerce",
128
+ "schedule_id": "SCHED-COM",
129
+ "schedule_name": "Commerce primary",
130
+ "user_name": "Diego Ramos"
131
+ },
132
+ {
133
+ "day": 419,
134
+ "escalation_policy": "EP-Commerce",
135
+ "schedule_id": "SCHED-COM",
136
+ "schedule_name": "Commerce primary",
137
+ "user_name": "Diego Ramos"
138
+ },
139
+ {
140
+ "day": 419,
141
+ "escalation_policy": "EP-Platform",
142
+ "schedule_id": "SCHED-PLT",
143
+ "schedule_name": "Platform primary",
144
+ "user_name": "Priya Nair"
145
+ },
146
+ {
147
+ "day": 419,
148
+ "escalation_policy": "EP-Growth",
149
+ "schedule_id": "SCHED-GRW",
150
+ "schedule_name": "Growth primary",
151
+ "user_name": "Mei Tanaka"
152
+ }
153
+ ]
154
+ }
155
+ ]
156
+ }
task_files/dob100-003-rca-checkout-unschedulable-replicas/05-deployment-state.json ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "sources": [
3
+ {
4
+ "columns": [
5
+ "deployment_id",
6
+ "service",
7
+ "environment",
8
+ "version",
9
+ "status",
10
+ "canary_percent"
11
+ ],
12
+ "row_count": 22,
13
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
14
+ "table": "deployments",
15
+ "task_relevant_rows": [
16
+ {
17
+ "canary_percent": 100,
18
+ "deployment_id": 9257,
19
+ "environment": "staging",
20
+ "service": "checkout",
21
+ "status": "succeeded",
22
+ "version": "v2.6.3"
23
+ },
24
+ {
25
+ "canary_percent": 100,
26
+ "deployment_id": 9258,
27
+ "environment": "production",
28
+ "service": "checkout",
29
+ "status": "succeeded",
30
+ "version": "v2.6.3"
31
+ }
32
+ ]
33
+ },
34
+ {
35
+ "columns": [
36
+ "route_id",
37
+ "service",
38
+ "route",
39
+ "rps",
40
+ "share_pct"
41
+ ],
42
+ "row_count": 13,
43
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
44
+ "table": "traffic_profile",
45
+ "task_relevant_rows": [
46
+ {
47
+ "route": "POST /v1/checkout",
48
+ "route_id": 9205,
49
+ "rps": 138,
50
+ "service": "api-gateway",
51
+ "share_pct": 100
52
+ }
53
+ ]
54
+ },
55
+ {
56
+ "columns": [
57
+ "service",
58
+ "desired_replicas",
59
+ "ready_replicas",
60
+ "strategy",
61
+ "storage_class"
62
+ ],
63
+ "row_count": 10,
64
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
65
+ "table": "k8s_deployments",
66
+ "task_relevant_rows": [
67
+ {
68
+ "desired_replicas": 2,
69
+ "ready_replicas": 1,
70
+ "service": "analytics-worker",
71
+ "storage_class": "standard",
72
+ "strategy": "RollingUpdate"
73
+ },
74
+ {
75
+ "desired_replicas": 3,
76
+ "ready_replicas": 3,
77
+ "service": "api-gateway",
78
+ "storage_class": "standard",
79
+ "strategy": "RollingUpdate"
80
+ },
81
+ {
82
+ "desired_replicas": 3,
83
+ "ready_replicas": 3,
84
+ "service": "catalog",
85
+ "storage_class": "standard",
86
+ "strategy": "RollingUpdate"
87
+ },
88
+ {
89
+ "desired_replicas": 64,
90
+ "ready_replicas": 6,
91
+ "service": "checkout",
92
+ "storage_class": "standard",
93
+ "strategy": "RollingUpdate"
94
+ },
95
+ {
96
+ "desired_replicas": 2,
97
+ "ready_replicas": 1,
98
+ "service": "inventory",
99
+ "storage_class": "fast-ssd-gp4",
100
+ "strategy": "RollingUpdate"
101
+ },
102
+ {
103
+ "desired_replicas": 2,
104
+ "ready_replicas": 2,
105
+ "service": "media-service",
106
+ "storage_class": "standard",
107
+ "strategy": "Recreate"
108
+ },
109
+ {
110
+ "desired_replicas": 2,
111
+ "ready_replicas": 2,
112
+ "service": "notifications",
113
+ "storage_class": "standard",
114
+ "strategy": "RollingUpdate"
115
+ },
116
+ {
117
+ "desired_replicas": 3,
118
+ "ready_replicas": 3,
119
+ "service": "payments",
120
+ "storage_class": "standard",
121
+ "strategy": "RollingUpdate"
122
+ },
123
+ {
124
+ "desired_replicas": 3,
125
+ "ready_replicas": 3,
126
+ "service": "search",
127
+ "storage_class": "standard",
128
+ "strategy": "RollingUpdate"
129
+ },
130
+ {
131
+ "desired_replicas": 4,
132
+ "ready_replicas": 4,
133
+ "service": "storefront-web",
134
+ "storage_class": "standard",
135
+ "strategy": "RollingUpdate"
136
+ }
137
+ ]
138
+ },
139
+ {
140
+ "columns": [
141
+ "pod",
142
+ "namespace",
143
+ "service",
144
+ "image_tag",
145
+ "phase",
146
+ "restarts",
147
+ "memory_limit_mb",
148
+ "memory_usage_mb",
149
+ "node",
150
+ "pending_reason"
151
+ ],
152
+ "row_count": 14,
153
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
154
+ "table": "k8s_pods",
155
+ "task_relevant_rows": [
156
+ {
157
+ "image_tag": "v2.6.3",
158
+ "memory_limit_mb": 2048,
159
+ "memory_usage_mb": 890,
160
+ "namespace": "production",
161
+ "node": "node-a1",
162
+ "pending_reason": "",
163
+ "phase": "Running",
164
+ "pod": "checkout-5b8c-aa10",
165
+ "restarts": 0,
166
+ "service": "checkout"
167
+ },
168
+ {
169
+ "image_tag": "v2.6.3",
170
+ "memory_limit_mb": 2048,
171
+ "memory_usage_mb": 0,
172
+ "namespace": "production",
173
+ "node": "",
174
+ "pending_reason": "0/4 nodes are available: 4 Insufficient cpu (58 of 64 replicas unschedulable)",
175
+ "phase": "Pending",
176
+ "pod": "checkout-5b8c-bb31",
177
+ "restarts": 0,
178
+ "service": "checkout"
179
+ }
180
+ ]
181
+ },
182
+ {
183
+ "columns": [
184
+ "event_id",
185
+ "namespace",
186
+ "pod",
187
+ "reason",
188
+ "message",
189
+ "count",
190
+ "day"
191
+ ],
192
+ "row_count": 8,
193
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
194
+ "table": "k8s_events",
195
+ "task_relevant_rows": [
196
+ {
197
+ "count": 47,
198
+ "day": 419,
199
+ "event_id": 9001,
200
+ "message": "Container analytics exceeded its memory limit of 512Mi and was killed",
201
+ "namespace": "production",
202
+ "pod": "analytics-worker-7d9f-x2k1",
203
+ "reason": "OOMKilled"
204
+ },
205
+ {
206
+ "count": 47,
207
+ "day": 419,
208
+ "event_id": 9002,
209
+ "message": "Back-off restarting failed container analytics",
210
+ "namespace": "production",
211
+ "pod": "analytics-worker-7d9f-x2k1",
212
+ "reason": "CrashLoopBackOff"
213
+ },
214
+ {
215
+ "count": 39,
216
+ "day": 420,
217
+ "event_id": 9003,
218
+ "message": "Container analytics exceeded its memory limit of 512Mi and was killed",
219
+ "namespace": "production",
220
+ "pod": "analytics-worker-7d9f-m4p8",
221
+ "reason": "OOMKilled"
222
+ },
223
+ {
224
+ "count": 1,
225
+ "day": 417,
226
+ "event_id": 9004,
227
+ "message": "Stopping container gateway for rollout",
228
+ "namespace": "production",
229
+ "pod": "api-gateway-9f2e-cc33",
230
+ "reason": "Killing"
231
+ }
232
+ ]
233
+ }
234
+ ]
235
+ }
task_files/dob100-003-rca-checkout-unschedulable-replicas/06-repository-context.txt ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"content": "\"\"\"Per-client rate limiting at the API gateway edge.\"\"\"\n\n\nclass TokenBucket:\n def __init__(self, capacity, refill_per_sec):\n raise NotImplementedError\n\n def allow(self, now_ms):\n \"\"\"True if a request may proceed, consuming one token.\"\"\"\n raise NotImplementedError\n", "file_id": 4, "language": "python", "loc": 10, "owner": "", "path": "src/gateway/token_bucket.py", "service": "api-gateway", "source_table": "repo_files"}
2
+ {"content": "\"\"\"Client for the notifications service.\n\npayments calls notifications synchronously after a capture succeeds; a\npermanent failure here fails the payment (see ``payments.capture``).\n\"\"\"\nfrom __future__ import annotations\n\nimport logging\nimport time\nimport uuid\n\nimport requests\n\nfrom payments import settings\n\nlog = logging.getLogger(__name__)\n\nNOTIFICATIONS_BASE_URL = settings.get(\"notifications_base_url\")\nNOTIFICATIONS_TIMEOUT_MS = settings.get(\"notifications_timeout_ms\")\n\n# NOTE(dramos): the tenacity retry wrapper around _post() was removed to hit the\n# Q3 receipt-latency deadline -- backoff sleeps were showing up in payments p99.\n# The knob stayed in config. It is 0 today, so _post() gets exactly one attempt\n# and a single downstream timeout permanently fails the order.\nNOTIFICATIONS_RETRY_MAX_ATTEMPTS = settings.get(\"notifications_retry_max_attempts\")\n\n\nclass PaymentNotificationError(RuntimeError):\n \"\"\"The receipt notification could not be delivered.\"\"\"\n\n\ndef _post(path, payload, correlation_id):\n return requests.post(\n \"%s%s\" % (NOTIFICATIONS_BASE_URL, path),\n json=payload,\n timeout=NOTIFICATIONS_TIMEOUT_MS / 1000.0,\n headers={\"X-Correlation-Id\": correlation_id, \"X-Source\": \"payments\"},\n )\n\n\ndef send_receipt(order_id, customer_email, amount_cents, currency=\"USD\"):\n \"\"\"Deliver a receipt. Raises PaymentNotificationError if it cannot.\"\"\"\n correlation_id = str(uuid.uuid4())\n payload = {\"template\": \"payment_receipt\", \"order_id\": order_id,\n \"to\": customer_email, \"amount_cents\": amount_cents,\n \"currency\": currency}\n\n attempt = 0\n while True:\n attempt += 1\n started = time.monotonic()\n try:\n response = _post(\"/v1/receipts\", payload, correlation_id)\n response.raise_for_status()\n log.info(\"receipt delivered order=%s attempt=%d\", order_id, attempt)\n return response.json()\n except requests.RequestException as exc:\n elapsed_ms = int((time.monotonic() - started) * 1000)\n if attempt > NOTIFICATIONS_RETRY_MAX_ATTEMPTS:\n log.error(\n \"ConnectionTimeout calling notifications after %dms - request \"\n \"failed permanently (retry_max_attempts=%d, no retry attempted); \"\n \"order %s marked failed\", elapsed_ms,\n NOTIFICATIONS_RETRY_MAX_ATTEMPTS, order_id)\n raise PaymentNotificationError(\"receipt undeliverable\") from exc\n backoff = min(0.2 * (2 ** (attempt - 1)), 2.0)\n log.warning(\"notifications call failed (attempt %d of %d) after %dms; \"\n \"retrying in %.1fs\", attempt,\n NOTIFICATIONS_RETRY_MAX_ATTEMPTS, elapsed_ms, backoff)\n time.sleep(backoff)\n", "file_id": 6, "language": "python", "loc": 70, "owner": "Diego Ramos", "path": "src/payments/notify_client.py", "service": "payments", "source_table": "repo_files"}
3
+ {"content": "\"\"\"Payment capture.\n\nMoves an authorized payment to \"captured\" with libpayproc, then emits the buyer\nreceipt. Idempotent on ``idempotency_key``: replaying a key returns the\noriginal capture rather than charging the card twice.\n\"\"\"\nfrom __future__ import annotations\n\nimport logging\nfrom dataclasses import dataclass\n\nimport libpayproc\n\nfrom payments import settings\nfrom payments.notify_client import PaymentNotificationError, send_receipt\nfrom payments.store import captures\n\nlog = logging.getLogger(__name__)\n\nCAPTURE_TIMEOUT_MS = settings.get(\"capture_timeout_ms\")\n\n\nclass CaptureDeclined(Exception):\n \"\"\"The upstream processor refused the capture.\"\"\"\n\n\n@dataclass(frozen=True)\nclass CaptureResult:\n order_id: str\n processor_ref: str\n amount_cents: int\n currency: str\n status: str\n\n\ndef capture_payment(order_id, auth_token, amount_cents, currency, idempotency_key):\n replay = captures.find_by_idempotency_key(idempotency_key)\n if replay is not None:\n log.info(\"capture replay order=%s key=%s\", order_id, idempotency_key)\n return replay\n\n client = libpayproc.Client(timeout_ms=CAPTURE_TIMEOUT_MS)\n try:\n upstream = client.capture(auth_token=auth_token, amount=amount_cents,\n currency=currency)\n except libpayproc.Declined as exc:\n log.warning(\"capture declined order=%s reason=%s\", order_id, exc.reason)\n captures.record_failure(order_id, idempotency_key, reason=exc.reason)\n raise CaptureDeclined(exc.reason) from exc\n except libpayproc.TransportError:\n log.exception(\"processor transport error order=%s\", order_id)\n raise\n\n result = CaptureResult(order_id, upstream.reference, amount_cents, currency,\n \"captured\")\n captures.persist(result, idempotency_key)\n\n # The receipt is part of the payment contract: if we cannot tell the buyer\n # the money moved, we do not treat the payment as complete.\n try:\n send_receipt(order_id, upstream.customer_email, amount_cents, currency)\n except PaymentNotificationError:\n log.error(\"receipt delivery failed order=%s; marking payment failed\", order_id)\n captures.mark_failed(order_id, reason=\"notification_undeliverable\")\n raise\n\n log.info(\"captured order=%s ref=%s amount=%d %s\", order_id, upstream.reference,\n amount_cents, currency)\n return result\n", "file_id": 7, "language": "python", "loc": 69, "owner": "Diego Ramos", "path": "src/payments/capture.py", "service": "payments", "source_table": "repo_files"}
4
+ {"content": "\"\"\"Static configuration for the checkout service.\n\nAnything in here is baked at build time and needs a deploy to change. Runtime\ntunables belong in the config document read by ``checkout.settings``.\n\"\"\"\nfrom __future__ import annotations\n\nimport logging\nimport os\n\nlog = logging.getLogger(__name__)\n\nSERVICE_NAME = \"checkout\"\nENVIRONMENT = os.environ.get(\"NOVACART_ENV\", \"staging\")\n\nPAYMENT_TIMEOUT_MS = int(os.environ.get(\"CHECKOUT_PAYMENT_TIMEOUT_MS\", \"8000\"))\nCART_TTL_SECONDS = 60 * 60 * 24 * 3\nMAX_LINE_ITEMS = 100\nCURRENCY_DEFAULT = \"USD\"\n\nPAYMENTS_BASE_URL = os.environ.get(\n \"CHECKOUT_PAYMENTS_URL\", \"http://payments.internal:8080\"\n)\nCATALOG_BASE_URL = os.environ.get(\n \"CHECKOUT_CATALOG_URL\", \"http://catalog.internal:8080\"\n)\n\n# Partner settlement API credentials.\n# TODO(ENG-2178): move this to the secret manager (vault path\n# novacart/checkout/partner) before partner GA. Committed inline so the staging\n# box could boot on a Friday afternoon; it is the live key, not a test key.\nPARTNER_API_KEY = \"pk_live_9f2c4a71b8e34d05a6c7d1e8f0b3a25c\"\nPARTNER_API_BASE = \"https://partners.novacart.io/settlement/v2\"\n\nRETRYABLE_STATUS = frozenset({408, 429, 500, 502, 503, 504})\n\n\ndef partner_headers():\n return {\n \"Authorization\": \"Bearer \" + PARTNER_API_KEY,\n \"X-NovaCart-Service\": SERVICE_NAME,\n }\n\n\ndef describe():\n \"\"\"Log the effective config. Never log credential values.\"\"\"\n log.info(\n \"checkout config env=%s payment_timeout_ms=%d cart_ttl_s=%d max_items=%d \"\n \"partner_key=%s\",\n ENVIRONMENT,\n PAYMENT_TIMEOUT_MS,\n CART_TTL_SECONDS,\n MAX_LINE_ITEMS,\n \"set\" if PARTNER_API_KEY else \"unset\",\n )\n", "file_id": 10, "language": "python", "loc": 55, "owner": "Nina Kowalski", "path": "src/checkout/config.py", "service": "checkout", "source_table": "repo_files"}
5
+ {"content": "\"\"\"Refund issuance.\n\nTwo paths: ``instant_refunds`` (flag-gated pilot) settles inline while the\nshopper is on the page; the legacy path records an intent and lets the async\nworker settle it on the next batch run.\n\"\"\"\nfrom __future__ import annotations\n\nimport logging\n\nfrom checkout import config, flags\nfrom checkout.clients.payments import PaymentsClient\nfrom checkout.store import refund_store\n\nlog = logging.getLogger(__name__)\n\npayments = PaymentsClient(\n base_url=config.PAYMENTS_BASE_URL, timeout_ms=config.PAYMENT_TIMEOUT_MS\n)\n\n\nclass RefundError(RuntimeError):\n pass\n\n\ndef _audit(order_id, record, actor, amount_cents):\n log.info(\n \"refund audit order=%s ledger=%s actor=%s amount=%d\",\n order_id, record.ledger_entry_id, actor, amount_cents,\n )\n\n\ndef issue_refund(order_id, amount_cents, actor):\n record = refund_store.find_by_order(order_id)\n\n if flags.enabled(\"instant_refunds\"):\n # Fast path. The refund row is written by the checkout submit path, so\n # by the time we land here it is always present. (It is not present for\n # orders captured before the pilot, or when the read races the write --\n # find_by_order returns None in both cases.)\n ledger_entry_id = record.ledger_entry_id\n response = payments.refund(\n processor_ref=record.processor_ref,\n amount_cents=amount_cents,\n ledger_entry_id=ledger_entry_id,\n )\n refund_store.mark_settled(record.id, response.reference)\n _audit(order_id, record, actor, amount_cents)\n log.info(\"instant refund settled order=%s ref=%s\", order_id, response.reference)\n return response.reference\n\n if record is None:\n record = refund_store.create_intent(order_id, amount_cents, actor)\n log.info(\"created refund intent order=%s (no prior refund row)\", order_id)\n\n refund_store.enqueue(record.id)\n log.info(\"queued refund order=%s intent=%s for async settlement\", order_id, record.id)\n return None\n\n\ndef cancel_refund(order_id, actor):\n record = refund_store.find_by_order(order_id)\n if record is None:\n raise RefundError(\"no refund to cancel for order %s\" % order_id)\n if record.status == \"settled\":\n raise RefundError(\"refund %s already settled\" % record.id)\n refund_store.cancel(record.id, actor)\n log.info(\"refund cancelled order=%s intent=%s actor=%s\", order_id, record.id, actor)\n", "file_id": 11, "language": "python", "loc": 68, "owner": "Lena Ortiz", "path": "src/checkout/refunds.py", "service": "checkout", "source_table": "repo_files"}
6
+ {"content": "\"\"\"Cart aggregate: line items, totals, and promotion application.\n\nTotals are computed in integer cents throughout. Rounding happens exactly once,\nat tax time, using banker's rounding to match the finance ledger.\n\"\"\"\nfrom __future__ import annotations\n\nimport logging\nfrom dataclasses import dataclass, field\nfrom decimal import ROUND_HALF_EVEN, Decimal\n\nfrom checkout import config\nfrom checkout.promotions import apply_promotions\n\nlog = logging.getLogger(__name__)\n\n\nclass CartLimitExceeded(ValueError):\n pass\n\n\n@dataclass\nclass LineItem:\n sku: str\n quantity: int\n unit_price_cents: int\n\n @property\n def subtotal_cents(self):\n return self.quantity * self.unit_price_cents\n\n\n@dataclass\nclass Cart:\n cart_id: str\n currency: str = config.CURRENCY_DEFAULT\n items: list = field(default_factory=list)\n promo_codes: list = field(default_factory=list)\n\n def add(self, item):\n if len(self.items) >= config.MAX_LINE_ITEMS:\n raise CartLimitExceeded(\"cart %s is full\" % self.cart_id)\n for existing in self.items:\n if existing.sku == item.sku:\n existing.quantity += item.quantity\n return existing\n self.items.append(item)\n return item\n\ndef subtotal_cents(cart):\n return sum(item.subtotal_cents for item in cart.items)\n\n\ndef tax_cents(taxable_cents, rate):\n product = Decimal(taxable_cents) * Decimal(str(rate))\n return int(product.quantize(Decimal(\"1\"), rounding=ROUND_HALF_EVEN))\n\n\ndef totals(cart, tax_rate=0.0, shipping_cents=0):\n gross = subtotal_cents(cart)\n discount = apply_promotions(cart, gross)\n taxable = max(gross - discount, 0)\n tax = tax_cents(taxable, tax_rate)\n total = taxable + tax + shipping_cents\n log.debug(\"totals cart=%s gross=%d discount=%d tax=%d total=%d\",\n cart.cart_id, gross, discount, tax, total)\n return {\"subtotal_cents\": gross, \"discount_cents\": discount, \"tax_cents\": tax,\n \"shipping_cents\": shipping_cents, \"total_cents\": total,\n \"currency\": cart.currency}\n", "file_id": 12, "language": "python", "loc": 69, "owner": "Nina Kowalski", "path": "src/checkout/cart.py", "service": "checkout", "source_table": "repo_files"}
7
+ {"content": "\"\"\"Checkout submit orchestration.\n\nOrder matters and is asserted by the integration suite: reserve inventory ->\ncapture payment -> persist order -> commit hold. If capture fails we release\nthe reservation first, otherwise stock leaks for the length of the hold TTL.\n\"\"\"\nfrom __future__ import annotations\n\nimport logging\nimport uuid\nfrom dataclasses import dataclass\n\nfrom checkout import cart as cart_mod\nfrom checkout import config\nfrom checkout.clients.inventory import InventoryClient\nfrom checkout.clients.payments import PaymentsClient\nfrom checkout.store import order_store\n\nlog = logging.getLogger(__name__)\n\ninventory = InventoryClient(timeout_ms=config.PAYMENT_TIMEOUT_MS)\npayments = PaymentsClient(\n base_url=config.PAYMENTS_BASE_URL, timeout_ms=config.PAYMENT_TIMEOUT_MS\n)\n\n\nclass CheckoutError(RuntimeError):\n pass\n\n\n@dataclass(frozen=True)\nclass SubmitResult:\n order_id: str\n total_cents: int\n replayed: bool\n\n\ndef submit_order(cart, idempotency_key, tax_rate=0.0, shipping_cents=0):\n existing = order_store.find_by_idempotency_key(idempotency_key)\n if existing is not None:\n log.info(\"submit replay cart=%s key=%s\", cart.cart_id, idempotency_key)\n return SubmitResult(existing.order_id, existing.total_cents, True)\n\n computed = cart_mod.totals(cart, tax_rate=tax_rate, shipping_cents=shipping_cents)\n order_id = \"ord_\" + uuid.uuid4().hex[:12]\n\n hold = inventory.reserve(\n order_id=order_id,\n lines=[(item.sku, item.quantity) for item in cart.items],\n )\n try:\n capture = payments.capture(\n order_id=order_id,\n amount_cents=computed[\"total_cents\"],\n currency=computed[\"currency\"],\n idempotency_key=idempotency_key,\n )\n except Exception:\n log.exception(\"capture failed order=%s; releasing hold %s\", order_id, hold.id)\n inventory.release(hold.id)\n raise CheckoutError(\"payment capture failed for order %s\" % order_id)\n\n order_store.persist(order_id=order_id, cart_id=cart.cart_id, totals=computed,\n processor_ref=capture.processor_ref,\n idempotency_key=idempotency_key)\n inventory.commit(hold.id)\n log.info(\"order submitted order=%s total=%d %s\", order_id,\n computed[\"total_cents\"], computed[\"currency\"])\n return SubmitResult(order_id, computed[\"total_cents\"], False)\n", "file_id": 13, "language": "python", "loc": 69, "owner": "Mei Tanaka", "path": "src/checkout/orchestrator.py", "service": "checkout", "source_table": "repo_files"}
8
+ {"content": "\"\"\"Integration coverage for checkout idempotency.\n\nSuite: integration. Tracked as flaky in CI under ENG-2401 -- reruns pass.\n\"\"\"\nfrom __future__ import annotations\n\nimport time\n\nimport pytest\n\nfrom checkout.orchestrator import submit_order\nfrom tests.helpers import make_cart, reset_orders\n\n\ndef build_idempotency_key(prefix=\"test\"):\n # One key per wall-clock second is plenty: the suite never runs two cases\n # inside the same second. (CI shards this suite across four workers, so it\n # very much does, and the workers then generate identical keys.)\n return \"%s-%d\" % (prefix, int(time.time()))\n\n\n@pytest.fixture(autouse=True)\ndef clean_orders():\n reset_orders()\n yield\n reset_orders()\n\n\ndef test_duplicate_submit_returns_same_order():\n key = build_idempotency_key()\n cart = make_cart(items=3, total_cents=4599)\n\n first = submit_order(cart, idempotency_key=key)\n second = submit_order(cart, idempotency_key=key)\n\n assert first.order_id == second.order_id\n assert second.replayed is True\n\n\ndef test_distinct_keys_create_distinct_orders():\n cart = make_cart(items=1, total_cents=1299)\n\n left = submit_order(cart, idempotency_key=build_idempotency_key(\"left\"))\n right = submit_order(cart, idempotency_key=build_idempotency_key(\"right\"))\n\n assert left.order_id != right.order_id\n\n\ndef test_capture_failure_releases_inventory(monkeypatch):\n cart = make_cart(items=2, total_cents=2500)\n released = []\n\n monkeypatch.setattr(\n \"checkout.orchestrator.inventory.release\", lambda hold_id: released.append(hold_id)\n )\n monkeypatch.setattr(\n \"checkout.orchestrator.payments.capture\",\n lambda **kwargs: (_ for _ in ()).throw(RuntimeError(\"upstream down\")),\n )\n\n with pytest.raises(Exception):\n submit_order(cart, idempotency_key=build_idempotency_key(\"fail\"))\n\n assert len(released) == 1\n", "file_id": 14, "language": "python", "loc": 64, "owner": "Mei Tanaka", "path": "tests/test_idempotency.py", "service": "checkout", "source_table": "repo_files"}
9
+ {"content": "-- 0031_refund_ledger.sql\n-- Adds the refund ledger backing the instant_refunds pilot.\n-- Forward-only: the async settlement worker keeps writing to refund_intent,\n-- the inline path writes both rows in one transaction.\n\nBEGIN;\n\nCREATE TABLE IF NOT EXISTS refund_ledger (\n id BIGSERIAL PRIMARY KEY,\n order_id TEXT NOT NULL,\n processor_ref TEXT,\n amount_cents BIGINT NOT NULL CHECK (amount_cents > 0),\n currency CHAR(3) NOT NULL DEFAULT 'USD',\n status TEXT NOT NULL DEFAULT 'pending',\n actor TEXT NOT NULL,\n created_at TIMESTAMPTZ NOT NULL DEFAULT now(),\n settled_at TIMESTAMPTZ,\n CONSTRAINT refund_ledger_status_ck\n CHECK (status IN ('pending', 'settled', 'cancelled', 'failed'))\n);\n\n-- One open refund per order; settled/cancelled rows are kept for audit.\nCREATE UNIQUE INDEX IF NOT EXISTS refund_ledger_open_order_uq\n ON refund_ledger (order_id)\n WHERE status = 'pending';\n\nCREATE INDEX IF NOT EXISTS refund_ledger_settled_at_idx\n ON refund_ledger (settled_at DESC)\n WHERE settled_at IS NOT NULL;\n\nALTER TABLE refund_intent\n ADD COLUMN IF NOT EXISTS ledger_entry_id BIGINT REFERENCES refund_ledger (id);\n\nCOMMIT;\n", "file_id": 15, "language": "sql", "loc": 34, "owner": "Lena Ortiz", "path": "db/migrations/0031_refund_ledger.sql", "service": "checkout", "source_table": "repo_files"}
10
+ {"content": "\"\"\"Catalog domain models.\n\nPlain dataclasses on purpose: ORM row objects stay inside\n``catalog.repository`` so listing code cannot trigger lazy loading.\n\"\"\"\nfrom __future__ import annotations\n\nfrom dataclasses import dataclass, field\nfrom datetime import datetime\nfrom enum import Enum\n\n\nclass Availability(str, Enum):\n IN_STOCK = \"in_stock\"\n BACKORDER = \"backorder\"\n DISCONTINUED = \"discontinued\"\n\n\n@dataclass(frozen=True)\nclass Money:\n amount_cents: int\n currency: str = \"USD\"\n\n def __post_init__(self):\n if self.amount_cents < 0:\n raise ValueError(\"money cannot be negative: %d\" % self.amount_cents)\n\n\n@dataclass(frozen=True)\nclass Product:\n id: str\n sku: str\n title: str\n category_id: str\n availability: Availability = Availability.IN_STOCK\n attributes: dict = field(default_factory=dict)\n updated_at: datetime = None\n\n @property\n def is_orderable(self):\n return self.availability is not Availability.DISCONTINUED\n\n\n@dataclass(frozen=True)\nclass PriceRow:\n product_id: str\n list_price: Money\n sale_price: Money = None\n price_tier: str = \"standard\"\n\n @property\n def effective(self):\n if self.sale_price is not None and self.sale_price.amount_cents < self.list_price.amount_cents:\n return self.sale_price\n return self.list_price\n\n\n@dataclass(frozen=True)\nclass PricedProduct:\n product: Product\n price: PriceRow\n\n def to_dict(self):\n return {\"id\": self.product.id, \"sku\": self.product.sku,\n \"title\": self.product.title,\n \"availability\": self.product.availability.value,\n \"price_cents\": self.price.effective.amount_cents,\n \"currency\": self.price.effective.currency,\n \"tier\": self.price.price_tier}\n", "file_id": 16, "language": "python", "loc": 69, "owner": "Sam Whitfield", "path": "src/catalog/models.py", "service": "catalog", "source_table": "repo_files"}
11
+ {"content": "\"\"\"Query execution for product search.\n\nparse -> build the index query -> execute -> rank. The query cache sits in front\nof execution and normally absorbs the large majority of index load.\n\"\"\"\nfrom __future__ import annotations\n\nimport hashlib\nimport json\nimport logging\nimport time\n\nfrom search import ranking, settings\nfrom search.cache import RedisCache\nfrom search.index import IndexClient\n\nlog = logging.getLogger(__name__)\n\n# Turned off during the index-rebuild incident so cache writes would stop\n# amplifying load on the Redis cluster while we reshard. Flip back to true once\n# the rebuild lands. (Rebuild landed; this never got flipped back.)\nCACHE_ENABLED = settings.get(\"cache_enabled\", False)\nCACHE_TTL_S = settings.get(\"cache_ttl_s\", 300)\nINDEX_SHARDS = settings.get(\"index_shards\", 4)\n\ncache = RedisCache(namespace=\"search:q\")\nindex = IndexClient(shards=INDEX_SHARDS)\n\n\ndef cache_key(term, filters, page, size):\n document = {\"t\": term.strip().lower(), \"f\": filters or {}, \"p\": page, \"s\": size}\n payload = json.dumps(document, sort_keys=True, separators=(\",\", \":\"))\n return hashlib.sha1(payload.encode(\"utf-8\")).hexdigest()\n\n\ndef search(term, filters=None, page=0, size=24, user_segment=\"anon\"):\n started = time.monotonic()\n key = cache_key(term, filters, page, size)\n\n if CACHE_ENABLED:\n cached = cache.get(key)\n if cached is not None:\n log.debug(\"cache hit term=%r key=%s\", term, key)\n return cached\n else:\n log.warning(\n \"query cache disabled (cache_enabled=false); every request is hitting \"\n \"the primary index\"\n )\n\n hits = index.execute(term=term, filters=filters or {}, offset=page * size, limit=size)\n results = ranking.rank(hits, term=term, user_segment=user_segment)\n payload = {\"term\": term, \"page\": page, \"size\": size, \"total\": hits.total,\n \"results\": [r.to_dict() for r in results]}\n\n if CACHE_ENABLED:\n cache.set(key, payload, ttl_s=CACHE_TTL_S)\n\n elapsed_ms = int((time.monotonic() - started) * 1000)\n log.info(\n \"search term=%r hits=%d elapsed_ms=%d cache_enabled=%s\",\n term, hits.total, elapsed_ms, CACHE_ENABLED,\n )\n return payload\n\n\ndef invalidate(term, filters=None, page=0, size=24):\n cache.delete(cache_key(term, filters, page, size))\n", "file_id": 20, "language": "python", "loc": 68, "owner": "Mei Tanaka", "path": "src/search/query.py", "service": "search", "source_table": "repo_files"}
12
+ {"content": "\"\"\"Incremental indexer.\n\nApplies catalog change events to the index in bulk flushes. Deletes go before\nupserts inside a flush so a delete+recreate of the same SKU ends up present.\n\"\"\"\nfrom __future__ import annotations\n\nimport logging\nimport signal\nimport time\n\nfrom search import settings\nfrom search.index import IndexClient\nfrom search.stream import CatalogChangeStream\n\nlog = logging.getLogger(__name__)\n\nFLUSH_SIZE = settings.get(\"indexer_flush_size\", 500)\nFLUSH_INTERVAL_S = settings.get(\"indexer_flush_interval_s\", 5)\n\nindex = IndexClient(shards=settings.get(\"index_shards\", 4))\n_running = True\n\n\ndef _handle_sigterm(signum, frame):\n global _running\n log.info(\"SIGTERM received; draining indexer buffer\")\n _running = False\n\n\nsignal.signal(signal.SIGTERM, _handle_sigterm)\n\n\ndef _flush(upserts, deletes):\n if deletes:\n index.bulk_delete(deletes)\n if upserts:\n index.bulk_upsert(upserts)\n log.info(\"indexer flush upserts=%d deletes=%d\", len(upserts), len(deletes))\n\n\ndef run(stream=None):\n stream = stream or CatalogChangeStream(group=\"search-indexer\")\n upserts, deletes = [], []\n last_flush = time.monotonic()\n\n for event in stream:\n if event.kind == \"delete\":\n deletes.append(event.product_id)\n else:\n upserts.append(event.document)\n\n buffered = len(upserts) + len(deletes)\n due = (time.monotonic() - last_flush) >= FLUSH_INTERVAL_S\n if buffered >= FLUSH_SIZE or (buffered and due):\n try:\n _flush(upserts, deletes)\n except Exception:\n log.exception(\"flush failed; buffer retained for retry\")\n time.sleep(1.0)\n continue\n stream.commit(event.offset)\n upserts, deletes = [], []\n last_flush = time.monotonic()\n\n if not _running:\n break\n\n _flush(upserts, deletes)\n log.info(\"indexer stopped cleanly\")\n", "file_id": 22, "language": "python", "loc": 70, "owner": "Mei Tanaka", "path": "src/search/indexer.py", "service": "search", "source_table": "repo_files"}
13
+ {"content": "// Package proxy manages upstream connections for the API gateway.\n//\n// Rewritten in v5.1.0: every route now gets its own transport so per-route TLS\n// material and per-route timeouts are honoured.\npackage proxy\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"net\"\n\t\"net/http\"\n\t\"sync/atomic\"\n\t\"time\"\n\n\t\"github.com/novacart/api-gateway/internal/config\"\n\t\"github.com/novacart/api-gateway/internal/log\"\n)\n\nconst (\n\tdialTimeout = 2 * time.Second\n\tidleConnTimeout = 90 * time.Second\n\tmaxIdlePerHost = 64\n\thealthCheckEvery = 15 * time.Second\n)\n\n// Conn wraps a transport dedicated to a single upstream.\ntype Conn struct {\n\tUpstream string\n\tTransport *http.Transport\n\tclient *http.Client\n\tdone chan struct{}\n\tcreatedAt time.Time\n}\n\n// Pool hands out upstream connections.\ntype Pool struct {\n\tcfg *config.Upstreams\n\tinFlight int64\n}\n\nfunc NewPool(cfg *config.Upstreams) *Pool { return &Pool{cfg: cfg} }\n\n// Acquire builds a connection for the given upstream. Building a transport is\n// cheap, so v5.1.0 does it per request rather than keeping long-lived ones.\nfunc (p *Pool) Acquire(ctx context.Context, upstream string) (*Conn, error) {\n\tif upstream == \"\" {\n\t\treturn nil, fmt.Errorf(\"proxy: empty upstream\")\n\t}\n\tatomic.AddInt64(&p.inFlight, 1)\n\n\ttransport := &http.Transport{\n\t\tDialContext: (&net.Dialer{Timeout: dialTimeout}).DialContext,\n\t\tTLSClientConfig: p.cfg.TLSFor(upstream),\n\t\tMaxIdleConnsPerHost: maxIdlePerHost,\n\t\tIdleConnTimeout: idleConnTimeout,\n\t}\n\n\tc := &Conn{Upstream: upstream, Transport: transport, done: make(chan struct{}),\n\t\tclient: &http.Client{Transport: transport}, createdAt: time.Now()}\n\n\t// Watchdog: keep probing this upstream for as long as the connection lives.\n\tgo func() {\n\t\tticker := time.NewTicker(healthCheckEvery)\n\t\tdefer ticker.Stop()\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-ticker.C:\n\t\t\t\tp.probe(c)\n\t\t\tcase <-c.done:\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}()\n\n\tlog.Debugf(\"acquired upstream=%s in_flight=%d\", upstream, atomic.LoadInt64(&p.inFlight))\n\treturn c, nil\n}\n\n// Release closes the transport and stops the watchdog goroutine.\n//\n// NOTE: the v5.1.0 rewrite dropped the call to Release from Do -- the handler\n// returns as soon as it has the response. Nothing else calls it, so every\n// request leaves behind an idle transport plus a live watchdog goroutine.\nfunc (p *Pool) Release(c *Conn) {\n\tclose(c.done)\n\tc.Transport.CloseIdleConnections()\n\tatomic.AddInt64(&p.inFlight, -1)\n\tlog.Debugf(\"released upstream=%s age=%s\", c.Upstream, time.Since(c.createdAt))\n}\n\nfunc (p *Pool) probe(c *Conn) {\n\treq, _ := http.NewRequest(http.MethodHead, \"http://\"+c.Upstream+\"/healthz\", nil)\n\tif resp, err := c.client.Do(req); err == nil {\n\t\t_ = resp.Body.Close()\n\t}\n}\n\n// Do proxies a single request to the named upstream.\nfunc (p *Pool) Do(ctx context.Context, upstream string, req *http.Request) (*http.Response, error) {\n\tc, err := p.Acquire(ctx, upstream)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"acquire %s: %w\", upstream, err)\n\t}\n\n\tresp, err := c.client.Do(req.WithContext(ctx))\n\tif err != nil {\n\t\tlog.Errorf(\"upstream=%s request failed: %v\", upstream, err)\n\t\treturn nil, err\n\t}\n\treturn resp, nil\n}\n", "file_id": 25, "language": "go", "loc": 111, "owner": "Priya Nair", "path": "internal/proxy/pool.go", "service": "api-gateway", "source_table": "repo_files"}
14
+ {"content": "// Package router wires public API routes to their upstream services.\n//\n// Route table is declarative: handlers are generic proxies, and anything\n// route-specific (auth requirement, traffic weight, deprecation) lives in the\n// Route struct so the control plane can reason about it.\npackage router\n\nimport (\n\t\"net/http\"\n\n\t\"github.com/novacart/api-gateway/internal/handlers\"\n\t\"github.com/novacart/api-gateway/internal/middleware\"\n\t\"github.com/novacart/api-gateway/internal/proxy\"\n)\n\n// Route describes one public endpoint.\ntype Route struct {\n\tPath string\n\tMethods []string\n\tUpstream string\n\tAuthRequired bool\n\tDeprecated bool\n\tWeight int // percentage of traffic, resolved by the control plane\n}\n\n// Table is the canonical route list for the edge.\nvar Table = []Route{\n\t{Path: \"/v1/orders\", Methods: []string{\"GET\", \"POST\"}, Upstream: \"checkout.internal:8080\", AuthRequired: true, Weight: 100},\n\t{Path: \"/v2/orders\", Methods: []string{\"GET\", \"POST\", \"PATCH\"}, Upstream: \"checkout.internal:8080\", AuthRequired: true, Weight: 0},\n\t{Path: \"/v1/checkout\", Methods: []string{\"POST\"}, Upstream: \"checkout.internal:8080\", AuthRequired: true, Weight: 100},\n\t{Path: \"/v1/catalog\", Methods: []string{\"GET\"}, Upstream: \"catalog.internal:8080\", Weight: 100},\n\t{Path: \"/v1/search\", Methods: []string{\"GET\"}, Upstream: \"search.internal:8080\", Weight: 100},\n\t{Path: \"/v1/media\", Methods: []string{\"GET\"}, Upstream: \"media-service.internal:8080\", Weight: 100},\n\t{Path: \"/internal/debug\", Methods: []string{\"GET\"}, Upstream: \"\", Weight: 0},\n}\n\n// New builds the edge mux.\nfunc New(pool *proxy.Pool) http.Handler {\n\tmux := http.NewServeMux()\n\n\tfor _, route := range Table {\n\t\tr := route\n\t\tif r.Upstream == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tvar h http.Handler = handlers.NewProxyHandler(pool, r.Upstream, r.Path)\n\t\th = middleware.MethodFilter(r.Methods, h)\n\t\tif r.AuthRequired {\n\t\t\th = middleware.RequireToken(h)\n\t\t}\n\t\tif r.Deprecated {\n\t\t\th = middleware.DeprecationNotice(r.Path, h)\n\t\t}\n\t\th = middleware.RateLimit(h)\n\t\th = middleware.AccessLog(r.Path, h)\n\t\tmux.Handle(r.Path, h)\n\t}\n\n\tmux.Handle(\"/internal/debug\", handlers.Debug())\n\tmux.HandleFunc(\"/healthz\", func(w http.ResponseWriter, _ *http.Request) {\n\t\tw.WriteHeader(http.StatusOK)\n\t\t_, _ = w.Write([]byte(\"ok\"))\n\t})\n\treturn mux\n}\n", "file_id": 26, "language": "go", "loc": 65, "owner": "Tom Becker", "path": "internal/router/routes.go", "service": "api-gateway", "source_table": "repo_files"}
15
+ {"content": "package middleware\n\nimport (\n\t\"net\"\n\t\"net/http\"\n\t\"strconv\"\n\t\"sync\"\n\t\"time\"\n\n\t\"github.com/novacart/api-gateway/internal/config\"\n\t\"github.com/novacart/api-gateway/internal/log\"\n)\n\n// bucket is a token bucket for one client key.\ntype bucket struct {\n\ttokens float64\n\tlastSeen time.Time\n}\n\ntype limiter struct {\n\tmu sync.Mutex\n\tbuckets map[string]*bucket\n\trps float64\n\tburst float64\n}\n\nvar shared = func() *limiter {\n\tcfg, err := config.Load()\n\trps := 500\n\tif err == nil && cfg.RateLimitRPS > 0 {\n\t\trps = cfg.RateLimitRPS\n\t}\n\treturn &limiter{\n\t\tbuckets: make(map[string]*bucket),\n\t\trps: float64(rps),\n\t\tburst: float64(rps) * 1.5,\n\t}\n}()\n\nfunc clientKey(r *http.Request) string {\n\tif token := r.Header.Get(\"X-Api-Client\"); token != \"\" {\n\t\treturn token\n\t}\n\tif host, _, err := net.SplitHostPort(r.RemoteAddr); err == nil {\n\t\treturn host\n\t}\n\treturn r.RemoteAddr\n}\n\nfunc (l *limiter) allow(key string) bool {\n\tnow := time.Now()\n\tl.mu.Lock()\n\tdefer l.mu.Unlock()\n\n\tb, ok := l.buckets[key]\n\tif !ok {\n\t\tl.buckets[key] = &bucket{tokens: l.burst - 1, lastSeen: now}\n\t\treturn true\n\t}\n\tb.tokens += now.Sub(b.lastSeen).Seconds() * l.rps\n\tif b.tokens > l.burst {\n\t\tb.tokens = l.burst\n\t}\n\tb.lastSeen = now\n\tif b.tokens < 1 {\n\t\treturn false\n\t}\n\tb.tokens--\n\treturn true\n}\n\n// RateLimit rejects callers over their per-client budget with a 429.\nfunc RateLimit(next http.Handler) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tkey := clientKey(r)\n\t\tif !shared.allow(key) {\n\t\t\tlog.Warnf(\"rate limited client=%s path=%s\", key, r.URL.Path)\n\t\t\tw.Header().Set(\"Retry-After\", strconv.Itoa(1))\n\t\t\thttp.Error(w, \"rate limit exceeded\", http.StatusTooManyRequests)\n\t\t\treturn\n\t\t}\n\t\tnext.ServeHTTP(w, r)\n\t})\n}\n", "file_id": 28, "language": "go", "loc": 84, "owner": "Priya Nair", "path": "internal/middleware/ratelimit.go", "service": "api-gateway", "source_table": "repo_files"}
16
+ {"content": "package com.novacart.inventory;\n\nimport com.zaxxer.hikari.HikariConfig;\nimport com.zaxxer.hikari.HikariDataSource;\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\n\nimport java.sql.*;\nimport java.util.ArrayList;\nimport java.util.List;\n\n/**\n * Stock reads and writes. The pool is created here rather than injected so the\n * sizing stays visible next to the queries that depend on it.\n */\npublic final class StockRepository {\n\n private static final Logger LOG = LoggerFactory.getLogger(StockRepository.class);\n\n /**\n * Connection pool size. Sized during the 2-pod pilot and never revisited;\n * inventory now runs 12 pods behind the checkout reserve path, and every\n * reserve call holds a connection for the length of the upstream write.\n */\n private static final int DB_POOL_SIZE = 5;\n\n private static final long CONNECTION_TIMEOUT_MS = 3_000L;\n private static final String SELECT_ON_HAND =\n \"SELECT sku, on_hand, reserved FROM stock_level WHERE sku = ? FOR UPDATE\";\n private static final String SELECT_BATCH =\n \"SELECT sku, on_hand, reserved FROM stock_level WHERE sku = ANY (?)\";\n\n\n private final HikariDataSource dataSource;\n\n public StockRepository(String jdbcUrl, String user, String password) {\n HikariConfig config = new HikariConfig();\n config.setJdbcUrl(jdbcUrl);\n config.setUsername(user);\n config.setPassword(password);\n config.setMaximumPoolSize(DB_POOL_SIZE);\n config.setMinimumIdle(DB_POOL_SIZE);\n config.setConnectionTimeout(CONNECTION_TIMEOUT_MS);\n config.setPoolName(\"inventory-stock\");\n this.dataSource = new HikariDataSource(config);\n LOG.info(\"stock pool ready db_pool_size={} connection_timeout_ms={}\",\n DB_POOL_SIZE, CONNECTION_TIMEOUT_MS);\n }\n\n public StockLevel findForUpdate(Connection tx, String sku) throws SQLException {\n try (PreparedStatement ps = tx.prepareStatement(SELECT_ON_HAND)) {\n ps.setString(1, sku);\n try (ResultSet rs = ps.executeQuery()) {\n if (!rs.next()) {\n LOG.warn(\"no stock row for sku={}\", sku);\n return null;\n }\n return new StockLevel(rs.getString(\"sku\"), rs.getInt(\"on_hand\"),\n rs.getInt(\"reserved\"));\n }\n }\n }\n public List<StockLevel> findAll(List<String> skus) {\n List<StockLevel> levels = new ArrayList<>(skus.size());\n long started = System.nanoTime();\n try (Connection conn = dataSource.getConnection();\n PreparedStatement ps = conn.prepareStatement(SELECT_BATCH)) {\n ps.setArray(1, conn.createArrayOf(\"text\", skus.toArray()));\n try (ResultSet rs = ps.executeQuery()) {\n while (rs.next()) {\n levels.add(new StockLevel(rs.getString(\"sku\"), rs.getInt(\"on_hand\"),\n rs.getInt(\"reserved\")));\n }\n }\n } catch (SQLException e) {\n LOG.error(\"stock lookup failed for {} skus (pool size {}): {}\",\n skus.size(), DB_POOL_SIZE, e.getMessage(), e);\n throw new StockUnavailableException(\"stock lookup failed\", e);\n }\n LOG.debug(\"findAll skus={} took_ms={}\", skus.size(),\n (System.nanoTime() - started) / 1_000_000L);\n return levels;\n }\n\n public Connection begin() throws SQLException {\n Connection conn = dataSource.getConnection();\n conn.setAutoCommit(false);\n return conn;\n }\n}\n", "file_id": 29, "language": "java", "loc": 90, "owner": "Tom Becker", "path": "src/main/java/com/novacart/inventory/StockRepository.java", "service": "inventory", "source_table": "repo_files"}
17
+ {"content": "package com.novacart.inventory;\n\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\n\nimport java.sql.Connection;\nimport java.sql.SQLException;\nimport java.time.Duration;\nimport java.time.Instant;\nimport java.util.List;\nimport java.util.UUID;\n\n/**\n * Places and releases stock holds for checkout. A hold is soft: it decrements\n * availability without moving on_hand, and expires after {@link #HOLD_TTL}.\n */\npublic class ReservationService {\n\n private static final Logger LOG = LoggerFactory.getLogger(ReservationService.class);\n private static final Duration HOLD_TTL = Duration.ofMinutes(20);\n\n private final StockRepository stock;\n private final HoldRepository holds;\n\n public ReservationService(StockRepository stock, HoldRepository holds) {\n this.stock = stock;\n this.holds = holds;\n }\n\n public Hold reserve(String orderId, List<ReservationLine> lines) {\n String holdId = \"hold_\" + UUID.randomUUID().toString().substring(0, 12);\n Instant expiresAt = Instant.now().plus(HOLD_TTL);\n\n Connection tx = null;\n try {\n tx = stock.begin();\n for (ReservationLine line : lines) {\n StockLevel level = stock.findForUpdate(tx, line.sku());\n if (level == null) {\n throw new StockUnavailableException(\"unknown sku \" + line.sku());\n }\n int available = level.onHand() - level.reserved();\n if (available < line.quantity()) {\n LOG.warn(\"insufficient stock sku={} requested={} available={}\",\n line.sku(), line.quantity(), available);\n throw new StockUnavailableException(\"insufficient stock: \" + line.sku());\n }\n holds.appendLine(tx, holdId, line.sku(), line.quantity());\n }\n holds.create(tx, holdId, orderId, expiresAt);\n tx.commit();\n LOG.info(\"reserved hold={} order={} lines={}\", holdId, orderId, lines.size());\n return new Hold(holdId, orderId, expiresAt);\n } catch (SQLException e) {\n rollbackQuietly(tx);\n LOG.error(\"reserve failed order={}: {}\", orderId, e.getMessage(), e);\n throw new StockUnavailableException(\"reserve failed for order \" + orderId, e);\n } finally {\n closeQuietly(tx);\n }\n }\n\n public void release(String holdId) {\n holds.release(holdId);\n LOG.info(\"released hold={}\", holdId);\n }\n\n private void rollbackQuietly(Connection tx) {\n if (tx == null) {\n return;\n }\n try {\n tx.rollback();\n } catch (SQLException ignored) {\n LOG.debug(\"rollback failed; connection is being discarded\");\n }\n }\n\n private void closeQuietly(Connection tx) {\n try {\n if (tx != null) {\n tx.close();\n }\n } catch (SQLException e) {\n LOG.warn(\"could not return connection to pool: {}\", e.getMessage());\n }\n }\n}\n", "file_id": 30, "language": "java", "loc": 88, "owner": "Ravi Shah", "path": "src/main/java/com/novacart/inventory/ReservationService.java", "service": "inventory", "source_table": "repo_files"}
18
+ {"content": "package com.novacart.inventory;\n\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\nimport org.springframework.http.HttpStatus;\nimport org.springframework.http.ResponseEntity;\nimport org.springframework.web.bind.annotation.GetMapping;\nimport org.springframework.web.bind.annotation.PathVariable;\nimport org.springframework.web.bind.annotation.PostMapping;\nimport org.springframework.web.bind.annotation.RequestBody;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestParam;\nimport org.springframework.web.bind.annotation.RestController;\n\nimport java.util.List;\nimport java.util.Map;\n\n/** HTTP surface for stock levels and holds. Called by checkout and by ops tooling. */\n@RestController\n@RequestMapping(\"/v1/stock\")\npublic class StockController {\n\n private static final Logger LOG = LoggerFactory.getLogger(StockController.class);\n private static final int MAX_BATCH = 200;\n\n private final StockRepository stock;\n private final ReservationService reservations;\n\n public StockController(StockRepository stock, ReservationService reservations) {\n this.stock = stock;\n this.reservations = reservations;\n }\n\n @GetMapping(\"/levels\")\n public ResponseEntity<List<StockLevel>> levels(@RequestParam List<String> sku) {\n if (sku.size() > MAX_BATCH) {\n LOG.warn(\"batch too large: {} skus (max {})\", sku.size(), MAX_BATCH);\n return ResponseEntity.status(HttpStatus.PAYLOAD_TOO_LARGE).build();\n }\n return ResponseEntity.ok(stock.findAll(sku));\n }\n\n @PostMapping(\"/holds\")\n public ResponseEntity<Map<String, Object>> reserve(@RequestBody ReserveRequest request) {\n try {\n Hold hold = reservations.reserve(request.orderId(), request.lines());\n return ResponseEntity.status(HttpStatus.CREATED).body(Map.of(\n \"hold_id\", hold.id(),\n \"order_id\", hold.orderId(),\n \"expires_at\", hold.expiresAt().toString()));\n } catch (StockUnavailableException e) {\n LOG.info(\"reserve rejected order={} reason={}\", request.orderId(), e.getMessage());\n return ResponseEntity.status(HttpStatus.CONFLICT)\n .body(Map.of(\"error\", \"stock_unavailable\", \"detail\", e.getMessage()));\n }\n }\n\n @PostMapping(\"/holds/{holdId}/release\")\n public ResponseEntity<Void> release(@PathVariable String holdId) {\n reservations.release(holdId);\n return ResponseEntity.noContent().build();\n }\n}\n", "file_id": 31, "language": "java", "loc": 63, "owner": "Tom Becker", "path": "src/main/java/com/novacart/inventory/StockController.java", "service": "inventory", "source_table": "repo_files"}
19
+ {"content": "\"\"\"Image variant generation.\n\nUploads land as a single original; this module derives the responsive ladder\n(``320w`` through ``1600w``) plus a WebP twin for each rung. Work is idempotent:\nre-running a transcode over an existing variant is a no-op unless the source\netag changed.\n\"\"\"\nfrom __future__ import annotations\n\nimport io\nimport logging\n\nfrom PIL import Image, UnidentifiedImageError\n\nfrom media import settings\nfrom media.store import ObjectStore\n\nlog = logging.getLogger(__name__)\n\nLADDER = (320, 640, 800, 1200, 1600)\nJPEG_QUALITY = settings.get(\"jpeg_quality\", 82)\nWEBP_QUALITY = settings.get(\"webp_quality\", 78)\nMAX_SOURCE_BYTES = settings.get(\"max_source_bytes\", 25 * 1024 * 1024)\n\nstore = ObjectStore(bucket=settings.get(\"origin_bucket\", \"novacart-media-prod\"))\n\n\nclass TranscodeError(RuntimeError):\n pass\n\n\ndef _resize(image, width):\n if image.width <= width:\n return image.copy()\n height = round(image.height * (width / image.width))\n return image.resize((width, height), Image.LANCZOS)\n\n\ndef _encode(image, fmt):\n buffer = io.BytesIO()\n quality = WEBP_QUALITY if fmt == \"WEBP\" else JPEG_QUALITY\n image.convert(\"RGB\").save(buffer, format=fmt, quality=quality, optimize=True)\n return buffer.getvalue()\n\n\ndef transcode(asset_id, source_key, source_etag):\n raw = store.get(source_key)\n if len(raw) > MAX_SOURCE_BYTES:\n raise TranscodeError(\n \"source %s is %d bytes, over the %d limit\" % (source_key, len(raw), MAX_SOURCE_BYTES)\n )\n try:\n original = Image.open(io.BytesIO(raw))\n original.load()\n except UnidentifiedImageError as exc:\n raise TranscodeError(\"unreadable source %s\" % source_key) from exc\n\n written = []\n for width in LADDER:\n resized = _resize(original, width)\n for fmt, ext in ((\"JPEG\", \"jpg\"), (\"WEBP\", \"webp\")):\n key = \"assets/%s/%dw.%s\" % (asset_id, width, ext)\n if store.etag(key) == source_etag:\n log.debug(\"variant %s already current; skipping\", key)\n continue\n store.put(key, _encode(resized, fmt), metadata={\"source_etag\": source_etag})\n written.append(key)\n\n log.info(\"transcoded asset=%s variants=%d source=%s\", asset_id, len(written), source_key)\n return written\n", "file_id": 33, "language": "python", "loc": 70, "owner": "Sam Whitfield", "path": "src/media/transcode.py", "service": "media-service", "source_table": "repo_files"}
20
+ {"content": "\"\"\"Event queue consumer: reads events off RabbitMQ, batches them, and hands\nthe batches to the aggregation pipeline.\"\"\"\nimport logging\nimport signal\nimport time\n\nimport pika\n\nfrom analytics import aggregates, settings\n\nlog = logging.getLogger(__name__)\n\nQUEUE_NAME = settings.get(\"queue_name\", \"analytics.events\")\nAMQP_URL = settings.get(\"amqp_url\", \"amqp://analytics:analytics@rabbit.internal:5672/%2f\")\nBATCH_SIZE = settings.get(\"batch_size\", 500)\nFLUSH_INTERVAL_S = settings.get(\"flush_interval_s\", 10)\n\n# Prefetch is the number of unacked messages the broker will push to us. Raised\n# from 200 to \"no limit\" so a slow flush cannot stall delivery -- but 0 means\n# unlimited in AMQP, so the broker streams the whole backlog into this process.\nPREFETCH_COUNT = settings.get(\"prefetch_count\", 0)\n\n_running = True\n\n\ndef _stop(signum, frame):\n global _running\n log.info(\"signal %s received; draining consumer\", signum)\n _running = False\n\n\nsignal.signal(signal.SIGTERM, _stop)\n\n\ndef run():\n params = pika.URLParameters(AMQP_URL)\n params.heartbeat = 30\n connection = pika.BlockingConnection(params)\n channel = connection.channel()\n channel.queue_declare(queue=QUEUE_NAME, durable=True)\n channel.basic_qos(prefetch_count=PREFETCH_COUNT)\n log.info(\"consumer attached queue=%s prefetch_count=%d batch_size=%d\",\n QUEUE_NAME, PREFETCH_COUNT, BATCH_SIZE)\n\n buffer = []\n last_flush = time.monotonic()\n\n try:\n for method, _props, body in channel.consume(QUEUE_NAME, inactivity_timeout=1.0):\n if method is not None:\n buffer.append((method.delivery_tag, body))\n\n due = buffer and (time.monotonic() - last_flush) >= FLUSH_INTERVAL_S\n if len(buffer) >= BATCH_SIZE or due:\n tag = buffer[-1][0]\n try:\n aggregates.ingest([payload for _, payload in buffer])\n channel.basic_ack(delivery_tag=tag, multiple=True)\n except Exception:\n log.exception(\"aggregation failed; nacking %d\", len(buffer))\n channel.basic_nack(tag, multiple=True, requeue=True)\n buffer = []\n last_flush = time.monotonic()\n\n if not _running:\n break\n finally:\n channel.cancel()\n connection.close()\n log.info(\"consumer stopped; %d messages unflushed\", len(buffer))\n", "file_id": 34, "language": "python", "loc": 70, "owner": "Ravi Shah", "path": "src/analytics/consumer.py", "service": "analytics-worker", "source_table": "repo_files"}
21
+ {"additions": 74, "author": "Nina Kowalski", "commit_id": 3, "day": 3, "deletions": 0, "files": "src/checkout/config.py", "message": "checkout: bootstrap service package and settings module", "service": "checkout", "sha": "c72e5a9", "source_table": "commits"}
22
+ {"additions": 88, "author": "Mei Tanaka", "commit_id": 5, "day": 5, "deletions": 0, "files": "src/app/checkout/page.tsx", "message": "storefront-web: scaffold app router and base layout", "service": "storefront-web", "sha": "a05f3e8", "source_table": "commits"}
23
+ {"additions": 143, "author": "Lena Ortiz", "commit_id": 8, "day": 9, "deletions": 2, "files": "src/checkout/cart.py", "message": "checkout: cart aggregate with integer-cent arithmetic", "service": "checkout", "sha": "5cd80a1", "source_table": "commits"}
24
+ {"additions": 127, "author": "Nina Kowalski", "commit_id": 12, "day": 13, "deletions": 8, "files": "src/checkout/orchestrator.py", "message": "checkout: reserve-then-capture orchestration", "service": "checkout", "sha": "7bc153e", "source_table": "commits"}
25
+ {"additions": 71, "author": "Mei Tanaka", "commit_id": 20, "day": 22, "deletions": 0, "files": "tests/test_idempotency.py", "message": "checkout: integration suite for idempotent submits", "service": "checkout", "sha": "d18c7b4", "source_table": "commits"}
26
+ {"additions": 24, "author": "Lena Ortiz", "commit_id": 29, "day": 31, "deletions": 5, "files": "src/checkout/cart.py,src/checkout/config.py", "message": "checkout: cap carts at 100 line items", "service": "checkout", "sha": "7e14ab8", "source_table": "commits"}
27
+ {"additions": 63, "author": "Mei Tanaka", "commit_id": 37, "day": 39, "deletions": 21, "files": "src/app/checkout/page.tsx", "message": "storefront-web: checkout page skeleton behind cart cookie", "service": "storefront-web", "sha": "d7f30c6", "source_table": "commits"}
28
+ {"additions": 38, "author": "Nina Kowalski", "commit_id": 38, "day": 40, "deletions": 7, "files": "src/checkout/orchestrator.py,tests/test_idempotency.py", "message": "checkout: release inventory hold when capture fails", "service": "checkout", "sha": "1e59b8f", "source_table": "commits"}
29
+ {"additions": 132, "author": "Lena Ortiz", "commit_id": 49, "day": 51, "deletions": 0, "files": "src/checkout/refunds.py", "message": "checkout: refund intents and the async settle worker", "service": "checkout", "sha": "3c8e60b", "source_table": "commits"}
30
+ {"additions": 19, "author": "Ravi Shah", "commit_id": 53, "day": 55, "deletions": 12, "files": "src/analytics/consumer.py", "message": "analytics-worker: ack batches with multiple=true", "service": "analytics-worker", "sha": "b25a9d8", "source_table": "commits"}
31
+ {"additions": 18, "author": "Mei Tanaka", "commit_id": 56, "day": 58, "deletions": 2, "files": "src/checkout/orchestrator.py", "message": "checkout: docs for the submit ordering guarantees", "service": "checkout", "sha": "9f0a4d7", "source_table": "commits"}
32
+ {"additions": 23, "author": "Nina Kowalski", "commit_id": 64, "day": 67, "deletions": 9, "files": "src/checkout/cart.py", "message": "checkout: banker's rounding for tax to match the ledger", "service": "checkout", "sha": "0ac6e39", "source_table": "commits"}
33
+ {"additions": 22, "author": "Lena Ortiz", "commit_id": 72, "day": 75, "deletions": 3, "files": "src/checkout/refunds.py", "message": "checkout: cancel_refund guards already-settled refunds", "service": "checkout", "sha": "c93b7e4", "source_table": "commits"}
34
+ {"additions": 29, "author": "Mei Tanaka", "commit_id": 81, "day": 84, "deletions": 6, "files": "tests/test_idempotency.py", "message": "checkout: helper fixtures for the integration suite", "service": "checkout", "sha": "c26805d", "source_table": "commits"}
35
+ {"additions": 8, "author": "Nina Kowalski", "commit_id": 90, "day": 93, "deletions": 3, "files": "src/checkout/config.py", "message": "checkout: never log the partner credential value", "service": "checkout", "sha": "a7e4593", "source_table": "commits"}
36
+ {"additions": 16, "author": "Mei Tanaka", "commit_id": 96, "day": 99, "deletions": 4, "files": "src/app/checkout/page.tsx", "message": "storefront-web: redirect empty carts away from checkout", "service": "storefront-web", "sha": "97b2e6d", "source_table": "commits"}
37
+ {"additions": 37, "author": "Lena Ortiz", "commit_id": 98, "day": 101, "deletions": 12, "files": "src/checkout/cart.py", "message": "checkout: promotion stacking rules", "service": "checkout", "sha": "d6e937f", "source_table": "commits"}
38
+ {"additions": 24, "author": "Mei Tanaka", "commit_id": 108, "day": 111, "deletions": 2, "files": "tests/test_idempotency.py", "message": "checkout: assert hold release on capture failure", "service": "checkout", "sha": "8a5f21d", "source_table": "commits"}
39
+ {"additions": 9, "author": "Nina Kowalski", "commit_id": 118, "day": 121, "deletions": 3, "files": "src/checkout/config.py", "message": "checkout: read payment timeout from the environment", "service": "checkout", "sha": "5c17e49", "source_table": "commits"}
40
+ {"additions": 34, "author": "Lena Ortiz", "commit_id": 127, "day": 130, "deletions": 0, "files": "db/migrations/0031_refund_ledger.sql", "message": "checkout: refund ledger migration", "service": "checkout", "sha": "9147fed", "source_table": "commits"}
41
+ {"author": "Priya Nair", "body": "Perf: new upstream pool.", "merged_version": "v5.1.0", "number": 9201, "service": "api-gateway", "source_table": "pull_requests", "status": "merged", "ticket_key": "", "title": "Connection pool rewrite"}
42
+ {"author": "Diego Ramos", "body": "Draft, do not merge yet.", "merged_version": "", "number": 9202, "service": "catalog", "source_table": "pull_requests", "status": "open", "ticket_key": "", "title": "Price rounding cleanup"}
task_files/dob100-003-rca-checkout-unschedulable-replicas/07-ci-and-tests.csv ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ source_table,detail,exercise_id,func,hidden_tests,name,path,pr_number,quarantined,run_id,service,spec,stage,stage_id,starter,status,suite,test_id,visible_tests
2
+ ci_runs,intermittent failure: test_checkout_idempotency (rerun may pass),,,,,,,,2,checkout,,,,,failed,,,
3
+ ci_runs,all checks passed,,,,,,,,3,checkout,,,,,passed,,,
4
+ ci_stages,intermittent failure: test_checkout_idempotency (rerun may pass),,,,,,,,2,,,integration,7,,failed,,,
5
+ tests_catalog,,,,,test_cart_totals,,,0,,checkout,,,,,passing,unit,9901,
6
+ tests_catalog,,,,,test_checkout_idempotency,,,0,,checkout,,,,,flaky,integration,9902,
7
+ code_exercises,,9404,TokenBucket,"[[""partial time is not discarded"", ""b = TokenBucket(1, 1)\nassert b.allow(0)\nassert not b.allow(500)\nassert b.allow(1000)""], [""the bucket never exceeds capacity"", ""b = TokenBucket(2, 100)\nassert b.allow(0) and b.allow(0)\nassert b.allow(10000) and b.allow(10000)\nassert not b.allow(10000)""], [""a backwards clock grants nothing"", ""b = TokenBucket(1, 1)\nassert b.allow(5000)\nassert not b.allow(1000)""], [""a backwards clock does not wedge the bucket"", ""b = TokenBucket(1, 1)\nassert b.allow(5000)\nassert not b.allow(1000)\nassert b.allow(2000)""], [""a refused request consumes nothing"", ""b = TokenBucket(1, 1)\nassert b.allow(0)\nfor _ in range(5):\n assert not b.allow(0)\nassert b.allow(1000)""]]",,src/gateway/token_bucket.py,,,,api-gateway,"Implement class TokenBucket(capacity, refill_per_sec) with one method,
8
+ allow(now_ms), returning True if a request may proceed and False otherwise.
9
+
10
+ A bucket starts full. Each allowed request consumes exactly one token; a
11
+ refused request consumes none. Tokens refill continuously at refill_per_sec
12
+ and the bucket never holds more than capacity.
13
+
14
+ Refill is continuous, not stepwise: two calls 500ms apart at 1 token/sec must
15
+ together restore one whole token, so partial time must not be discarded. The
16
+ first call establishes the clock and refills nothing.
17
+
18
+ now_ms comes from a wall clock that is occasionally stepped backwards by NTP.
19
+ A backwards jump must never grant tokens and must never make the bucket
20
+ permanently unable to refill: treat time as not having advanced, and take the
21
+ new reading as the current clock.",,,"""""""Per-client rate limiting at the API gateway edge.""""""
22
+
23
+
24
+ class TokenBucket:
25
+ def __init__(self, capacity, refill_per_sec):
26
+ raise NotImplementedError
27
+
28
+ def allow(self, now_ms):
29
+ """"""True if a request may proceed, consuming one token.""""""
30
+ raise NotImplementedError
31
+ ",,,,"[[""a full bucket allows up to capacity"", ""b = TokenBucket(2, 1)\nassert b.allow(0) and b.allow(0) and not b.allow(0)""], [""waiting restores a token"", ""b = TokenBucket(1, 1)\nassert b.allow(0)\nassert not b.allow(0)\nassert b.allow(1000)""]]"
task_files/dob100-003-rca-checkout-unschedulable-replicas/08-data-change-controls.sql ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ -- migrations: {"environment": "staging", "migration_id": 3, "name": "0087_cart_line_discounts", "service": "checkout", "status": "applied"}
2
+ -- migrations: {"environment": "production", "migration_id": 4, "name": "0087_cart_line_discounts", "service": "checkout", "status": "applied"}
3
+ -- migration_requirements: {"migration_name": "0088_loyalty_ledger", "module": "loyalty_redeem", "req_id": 9151, "service": "checkout"}
4
+ -- migration_requirements: {"migration_name": "0089_saved_carts", "module": "saved_carts", "req_id": 9155, "service": "checkout"}
5
+ -- db_grants: {"changed_day": 390, "component": "pg-primary", "grant_id": 9902, "note": "", "role": "checkout_rw", "service": "checkout", "state": "active"}
task_files/dob100-003-rca-checkout-unschedulable-replicas/09-feature-and-security.yaml ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "sources": [
3
+ {
4
+ "columns": [
5
+ "flag_id",
6
+ "key",
7
+ "service",
8
+ "description",
9
+ "environment",
10
+ "enabled",
11
+ "rollout_percent"
12
+ ],
13
+ "row_count": 8,
14
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
15
+ "table": "feature_flags",
16
+ "task_relevant_rows": [
17
+ {
18
+ "description": "Pilot: refund immediately at checkout instead of async batch.",
19
+ "enabled": 1,
20
+ "environment": "production",
21
+ "flag_id": 9301,
22
+ "key": "instant_refunds",
23
+ "rollout_percent": 100,
24
+ "service": "checkout"
25
+ },
26
+ {
27
+ "description": "Pilot: refund immediately at checkout instead of async batch.",
28
+ "enabled": 1,
29
+ "environment": "staging",
30
+ "flag_id": 9302,
31
+ "key": "instant_refunds",
32
+ "rollout_percent": 100,
33
+ "service": "checkout"
34
+ },
35
+ {
36
+ "description": "Checkout redesign, fully rolled out last quarter; stale flag.",
37
+ "enabled": 1,
38
+ "environment": "production",
39
+ "flag_id": 9307,
40
+ "key": "checkout_v2_layout",
41
+ "rollout_percent": 100,
42
+ "service": "checkout"
43
+ },
44
+ {
45
+ "description": "Checkout redesign, fully rolled out last quarter; stale flag.",
46
+ "enabled": 1,
47
+ "environment": "staging",
48
+ "flag_id": 9308,
49
+ "key": "checkout_v2_layout",
50
+ "rollout_percent": 100,
51
+ "service": "checkout"
52
+ }
53
+ ]
54
+ },
55
+ {
56
+ "columns": [
57
+ "vuln_id",
58
+ "cve",
59
+ "package",
60
+ "service",
61
+ "severity",
62
+ "fixed_version",
63
+ "status"
64
+ ],
65
+ "row_count": 4,
66
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
67
+ "table": "vulnerabilities",
68
+ "task_relevant_rows": [
69
+ {
70
+ "cve": "CVE-2026-40881",
71
+ "fixed_version": "11.4.0",
72
+ "package": "stripe-sdk",
73
+ "service": "checkout",
74
+ "severity": "high",
75
+ "status": "open",
76
+ "vuln_id": 9802
77
+ }
78
+ ]
79
+ },
80
+ {
81
+ "columns": [
82
+ "rule_id",
83
+ "name",
84
+ "service_label",
85
+ "expr",
86
+ "severity",
87
+ "group_by",
88
+ "routes_to"
89
+ ],
90
+ "row_count": 5,
91
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
92
+ "table": "alert_rules",
93
+ "task_relevant_rows": [
94
+ {
95
+ "expr": "queue_depth > 1000",
96
+ "group_by": "service",
97
+ "name": "LegacyCheckoutQueueDepth",
98
+ "routes_to": "EP-Commerce",
99
+ "rule_id": 605,
100
+ "service_label": "checkout_legacy_worker",
101
+ "severity": "high"
102
+ }
103
+ ]
104
+ },
105
+ {
106
+ "columns": [
107
+ "silence_id",
108
+ "matcher",
109
+ "created_by",
110
+ "reason",
111
+ "expires_day"
112
+ ],
113
+ "row_count": 1,
114
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
115
+ "table": "alert_silences",
116
+ "task_relevant_rows": [
117
+ {
118
+ "created_by": "Sam Whitfield",
119
+ "expires_day": 402,
120
+ "matcher": "alertname=\"EdgeCacheHitRate\"",
121
+ "reason": "muted during the CDN migration, never lifted",
122
+ "silence_id": 801
123
+ }
124
+ ]
125
+ }
126
+ ]
127
+ }
task_files/dob100-003-rca-checkout-unschedulable-replicas/10-vendor-trackers.json ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "sources": [
3
+ {
4
+ "columns": [
5
+ "key",
6
+ "project",
7
+ "summary",
8
+ "issue_type",
9
+ "status",
10
+ "resolution",
11
+ "priority",
12
+ "component",
13
+ "assignee",
14
+ "created_day",
15
+ "updated_day"
16
+ ],
17
+ "row_count": 11,
18
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
19
+ "table": "jira_issues",
20
+ "task_relevant_rows": [
21
+ {
22
+ "assignee": "",
23
+ "component": "checkout",
24
+ "created_day": 411,
25
+ "issue_type": "Bug",
26
+ "key": "ENG-3001",
27
+ "priority": "Medium",
28
+ "project": "ENG",
29
+ "resolution": "",
30
+ "status": "Backlog",
31
+ "summary": "Checkout latency spike during evening peak",
32
+ "updated_day": 413
33
+ },
34
+ {
35
+ "assignee": "Diego Ramos",
36
+ "component": "payments",
37
+ "created_day": 402,
38
+ "issue_type": "Bug",
39
+ "key": "ENG-3002",
40
+ "priority": "High",
41
+ "project": "ENG",
42
+ "resolution": "Fixed",
43
+ "status": "Done",
44
+ "summary": "Duplicate charge on retried payment",
45
+ "updated_day": 409
46
+ },
47
+ {
48
+ "assignee": "",
49
+ "component": "checkout",
50
+ "created_day": 396,
51
+ "issue_type": "Bug",
52
+ "key": "ENG-3004",
53
+ "priority": "Low",
54
+ "project": "ENG",
55
+ "resolution": "Won't Do",
56
+ "status": "Done",
57
+ "summary": "Cart total rounds incorrectly for multi-currency",
58
+ "updated_day": 404
59
+ }
60
+ ]
61
+ },
62
+ {
63
+ "columns": [
64
+ "identifier",
65
+ "team",
66
+ "title",
67
+ "state",
68
+ "priority",
69
+ "label",
70
+ "created_day"
71
+ ],
72
+ "row_count": 4,
73
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
74
+ "table": "linear_issues",
75
+ "task_relevant_rows": [
76
+ {
77
+ "created_day": 411,
78
+ "identifier": "GRW-88",
79
+ "label": "bug",
80
+ "priority": 1,
81
+ "state": "In Progress",
82
+ "team": "Growth",
83
+ "title": "Checkout slow at peak \u2014 customers dropping off"
84
+ }
85
+ ]
86
+ },
87
+ {
88
+ "columns": [
89
+ "number",
90
+ "repo",
91
+ "title",
92
+ "state",
93
+ "labels",
94
+ "created_day"
95
+ ],
96
+ "row_count": 28,
97
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
98
+ "table": "github_issues",
99
+ "task_relevant_rows": [
100
+ {
101
+ "created_day": 417,
102
+ "labels": "enhancement",
103
+ "number": 4411,
104
+ "repo": "novacart/growth",
105
+ "state": "open",
106
+ "title": "Checkout page hangs before redirect"
107
+ }
108
+ ]
109
+ },
110
+ {
111
+ "columns": [
112
+ "source",
113
+ "target",
114
+ "kind"
115
+ ],
116
+ "row_count": 4,
117
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
118
+ "table": "issue_links",
119
+ "task_relevant_rows": [
120
+ {
121
+ "kind": "duplicates",
122
+ "source": "ENG-3001",
123
+ "target": "GRW-88"
124
+ },
125
+ {
126
+ "kind": "duplicates",
127
+ "source": "ENG-3001",
128
+ "target": "4412"
129
+ },
130
+ {
131
+ "kind": "duplicates",
132
+ "source": "ENG-3003",
133
+ "target": "GRW-91"
134
+ },
135
+ {
136
+ "kind": "duplicates",
137
+ "source": "ENG-3003",
138
+ "target": "4402"
139
+ }
140
+ ]
141
+ }
142
+ ]
143
+ }
task_files/dob100-003-rca-checkout-unschedulable-replicas/11-knowledge-base.md ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 11 Knowledge Base
2
+
3
+ ## documents (30 rows)
4
+
5
+ ```json
6
+ [
7
+ {
8
+ "doc_id": 9601,
9
+ "kind": "policy",
10
+ "title": "Deployment policy",
11
+ "service": "",
12
+ "author": "Priya Nair",
13
+ "day": 268,
14
+ "body": "# Deployment policy\n\nThis policy is binding for every NovaCart service. It is enforced partly by\ntooling and partly by review; deviations are treated as incidents.\n\n## Staging first, always\n\nEvery production deploy must first succeed on staging with the **same version**.\n`deploy_service(service, environment=\"staging\", version=V)` must be in a\n`succeeded` state for version `V` before `deploy_service(service,\nenvironment=\"production\", version=V)` is accepted. Deploying a version to\nproduction that has never been deployed to staging is rejected. There is no\n\"hotfix exception\" - a hotfix is still a version, and it still goes to staging\nfirst. In practice this costs about ninety seconds and it has caught eleven bad\nreleases in the last two quarters.\n\n## Tier-1 services canary\n\nTier-1 services are the four that are directly in the money path or in front of\ncustomers:\n\n- `storefront-web`\n- `api-gateway`\n- `checkout`\n- `payments`\n\nFor these, the production deploy must be a canary: call `deploy_service` with\n`canary_percent <= 25`. Twenty-five percent is a ceiling, not a target; 10% is\nthe usual first step for anything touching payment capture. The canary must then\nbe assessed with `assess_canary` and may only be promoted with `promote_canary`\nonce the assessment reports healthy. Promoting a canary that `assess_canary`\nreports as unhealthy is the single most common way engineers turn a small\nregression into a SEV1 - see \"Postmortem: api-gateway v5.1.0 latency surge\"\nin the incident archive.\n\nTier-2 services (`catalog`, `notifications`, `search`) deploy at 100% directly,\nstill staging-first.\n\n## Rollback\n\n`rollback_deployment` is **exempt** from the staging-first rule. During an\nincident you roll back immediately; you do not stage a rollback. Rolling back\nreturns the service to the previously succeeded production version. See the\n\"Incident response\" runbook for where rollback sits in the mitigation ordering,\nand \"Rollback and recovery\" for the mechanics.\n\n## Deployment score\n\nEvery deploy that trips an alarm counts against the owning team's deployment\nscore, which is reviewed monthly. A tripped alarm on a canary that was correctly\nassessed and *not* promoted is recorded but weighted at one quarter - the\ncanary did its job. This is deliberate: we would rather you canary and catch it\nthan skip the canary and get lucky.\n\n## Related\n\n- \"Database migration policy\" - migrations precede the code that needs them.\n- \"ADR-021: Standardize on staged canary deploys\" - why we chose this shape.\n- \"Engineering onboarding: how we ship\" - the end-to-end workflow.\n"
15
+ },
16
+ {
17
+ "doc_id": 9603,
18
+ "kind": "runbook",
19
+ "title": "Retry and timeout standard",
20
+ "service": "",
21
+ "author": "Priya Nair",
22
+ "day": 241,
23
+ "body": "# Retry and timeout standard\n\nApplies to every cross-service call in the NovaCart fleet. Two config keys per\ndownstream dependency, named after the downstream service.\n\n## The two keys\n\nFor a caller talking to downstream service `X`:\n\n- `<downstream>_retry_max_attempts` - **must be 3**\n- `<downstream>_timeout_ms` - **must be at most 2000**\n\nSo `payments` calling `notifications` runs with\n`notifications_retry_max_attempts=3` and `notifications_timeout_ms=2000` (or\nlower). `checkout` calling `payments` runs with `payments_retry_max_attempts=3`\nand `payment_timeout_ms` inside the 2000ms ceiling.\n\nRetries use exponential backoff with jitter; the backoff schedule is applied\nautomatically by the shared HTTP client, so you do not configure delays. Three\nattempts means one initial call plus two retries, worst case roughly\n`3 * timeout_ms` plus backoff.\n\n## Why 3 and why 2000\n\n**A retry value of 0 means one timeout permanently fails the request.** There is\nno second chance. A single blip in a downstream - a pod restart, a brief GC\npause, a rebalanced connection - becomes a user-visible failure and a failed\norder. This is not hypothetical: payments ran with\n`notifications_retry_max_attempts=0` and `notifications_timeout_ms=30000` for\nseveral weeks and pushed `error_rate_pct` from a baseline of 0.4% to 3.8%,\nstraight through the 1.0% SLO.\n\nThe 2000ms ceiling exists because timeouts multiply up the call stack. A 30000ms\ntimeout on a leaf call does not \"wait patiently\" - it holds a request-handling\nworker and a database connection for thirty seconds, and under load that is how\nyou exhaust a pool (see \"Connection pool sizing\"). If a downstream genuinely\ncannot answer in two seconds, the call belongs on a queue, not in the request\npath.\n\n## Checklist for a new dependency\n\n1. Add `<downstream>_retry_max_attempts=3` to the caller's config.\n2. Add `<downstream>_timeout_ms` at or below 2000.\n3. Confirm the call is idempotent, or that the downstream deduplicates by\n idempotency key. Retrying a non-idempotent write is worse than failing.\n4. Confirm the caller's own inbound timeout is larger than\n `attempts * timeout_ms` plus backoff, or the retry budget is fiction.\n5. Add the dependency to the service's dependency section in its design doc.\n\n## Anti-patterns\n\n- Retrying on 4xx. Only retry timeouts, connection errors, 429, and 5xx.\n- Retrying inside a retry. Nested retries multiply: 3 x 3 = 9 calls.\n- Raising the timeout to \"fix\" a slow downstream. Fix the downstream.\n"
24
+ },
25
+ {
26
+ "doc_id": 9604,
27
+ "kind": "runbook",
28
+ "title": "Search caching",
29
+ "service": "search",
30
+ "author": "Mei Tanaka",
31
+ "day": 233,
32
+ "body": "# Search caching\n\nOwner: growth. Service: `search` (tier 2, python). SLO:\n`latency_p99_ms < 300`.\n\n## The rule\n\nProduction `search` **requires `cache_enabled=true`**. This is not a tuning\nknob; it is a capacity assumption baked into how the index cluster is sized.\n\n## Why\n\nThe query cache sits in front of the primary index and absorbs roughly **75% of\nindex load**. Search traffic is extremely head-heavy: the top few thousand\nqueries (\"black jeans\", \"usb-c cable\", \"gift card\") are a large majority of all\nrequests, and their result sets change only when the index is rebuilt. Serving\nthose from cache is close to free.\n\nWith `cache_enabled=false` every request goes to the primary index. Observed\neffect in production: `latency_p99_ms` moves from a ~210ms baseline to ~640ms and\nkeeps climbing as concurrency rises, blowing through the 300ms SLO and firing a\n`medium` alert. The service does not error - it just gets slow, which is why this\none is easy to miss until the alert fires. The tell in the logs is:\n\n```\nWARN query cache disabled (cache_enabled=false); every request is hitting the primary index\n```\n\n## Config keys\n\n| Key | Production value | Notes |\n| --------------- | ---------------- | ------------------------------------------ |\n| `cache_enabled` | `true` | Required. Never ship `false` to production. |\n| `cache_ttl_s` | `300` | Standard TTL. Five minutes. |\n| `index_shards` | `4` | Change only with a capacity review. |\n\n`cache_ttl_s=300` is the standard. It is a deliberate compromise: long enough\nthat the hit rate stays above 70%, short enough that a price or availability\nchange is visible within five minutes. Do not lower it below 60 - at that point\nthe stampede risk (below) outweighs the freshness gain. Do not raise it above\n900 without merchandising sign-off, because stale out-of-stock results generate\nsupport tickets.\n\n## Cache stampede\n\nA cold cache is dangerous, not merely slow. When many identical queries miss at\nonce they all reach the index simultaneously. We ship single-flight coalescing\nplus a +/-10% TTL jitter for exactly this reason. If you flush the cache\nmanually, do it during low traffic and expect a latency spike. The full story is\nin \"Postmortem: search cache stampede after index rebuild\".\n\n## Changing cache config\n\n`cache_enabled` and `cache_ttl_s` are repo config, not runtime flags. Changing\nthem means a PR with a `config` change, CI, merge, then a deploy - staging\nfirst, per the \"Deployment policy\". `search` is tier 2, so production deploys go\nstraight to 100%.\n\n## Verification\n\nAfter deploying, confirm `latency_p99_ms` has returned to the ~210ms band before\nresolving any related alert.\n"
33
+ },
34
+ {
35
+ "doc_id": 9605,
36
+ "kind": "runbook",
37
+ "title": "Catalog pricing performance",
38
+ "service": "catalog",
39
+ "author": "Diego Ramos",
40
+ "day": 229,
41
+ "body": "# Catalog pricing performance\n\nOwner: commerce. Service: `catalog` (tier 2, python). Consumed by `search`,\n`checkout`, and `storefront-web` on every product listing render.\n\n## The rule\n\n`batch_pricing_enabled=true` is **required in production**.\n\n## Why\n\n`catalog` resolves a price per product from the pricing rules table, applying\nthe active promotion, the customer's currency, and any tier discount. With\n`batch_pricing_enabled=false`, the listing endpoint loops over the products in\nthe response and issues one pricing query per product. This is a textbook\n**N+1 pattern**: a 48-item category page produces 1 listing query plus 48\npricing queries.\n\nMeasured cost: the per-product loop adds roughly **500ms at p99** on a standard\ncategory page. It also multiplies database connection checkouts by the page\nsize, which is how a catalog slowdown turns into a `db_pool_size` exhaustion\nevent in a service that was nowhere near its own limits (see \"Connection pool\nsizing\").\n\nWith `batch_pricing_enabled=true` the same page issues one listing query and one\nbatched pricing query with an `IN` clause over the product ids, then applies\npromotions in memory. Same results, two round trips.\n\n## Config keys\n\n| Key | Production value | Notes |\n| ------------------------- | ---------------- | -------------------------------------- |\n| `batch_pricing_enabled` | `true` | Required. The N+1 killer. |\n| `cdn_enabled` | `true` | See \"CDN and media delivery\". |\n\n## How to spot it\n\n- p99 on `catalog` listing endpoints scales with page size rather than staying\n flat. If 24 items is 200ms and 96 items is 900ms, it is the loop.\n- Database query counts per request in the hundreds.\n- Log lines of the form `pricing lookup for product_id=... (batch disabled)`\n repeating with the same trace id.\n\n## Fixing it\n\n`batch_pricing_enabled` is repo config. Ship it as a PR with a `config` change,\nrun CI, merge, deploy to staging, then production. `catalog` is tier 2 so the\nproduction deploy is a straight 100% deploy - no canary required, though a\ncanary is never wrong.\n\nAfter the deploy, re-measure p99 on a large category page before closing the\nticket.\n\n## Do not\n\n- Do not \"fix\" this by raising `db_pool_size`. That hides the symptom and moves\n the failure to the database.\n- Do not add a per-product cache in front of the loop. The batch query is\n cheaper than the cache lookups it would replace.\n"
42
+ },
43
+ {
44
+ "doc_id": 9606,
45
+ "kind": "runbook",
46
+ "title": "Incident response",
47
+ "service": "",
48
+ "author": "Priya Nair",
49
+ "day": 271,
50
+ "body": "# Incident response\n\nThe one runbook everyone is expected to know cold. When an alert fires, follow\nthese steps **in order**. Do not skip ahead to root cause analysis - mitigate\nfirst, understand later.\n\n## The ordered steps\n\n1. **Acknowledge the firing alert.** This tells everyone else the page has an\n owner. An unacknowledged alert is assumed unowned and will escalate.\n2. **Mitigate.** Two levers, in order of preference:\n - `rollback_deployment` if the regression correlates with a deploy. Rollback\n is exempt from staging-first (see \"Deployment policy\").\n - Feature-flag kill switch: `set_feature_flag(..., enabled=false)` in the\n affected environment only. Flags are runtime toggles and need no deploy.\n Mitigation is not the fix. Do not spend twenty minutes writing a patch while\n customers are failing.\n3. **Verify metric recovery.** Read the metric that fired. It must actually be\n back inside its SLO. \"It looks better\" is not verification.\n4. **Resolve the alert.**\n5. **Resolve the incident.**\n6. **Post an update in `#incidents`.** What broke, what you did, current status.\n One paragraph is fine; silence is not.\n7. **Publish a public status-page update** for any customer-visible incident.\n If a customer could have seen an error, a slow page, or a failed order, it is\n customer-visible. When in doubt, publish.\n8. **For sev1, file a postmortem ticket** (type `postmortem`) naming the\n service and the version or flag involved. Sev1 postmortems are due within\n five working days.\n\n## Severity\n\n- **sev1** - money path broken or the whole site is down. `checkout`,\n `payments`, `api-gateway`, `storefront-web` hard-failing. Postmortem\n mandatory.\n- **sev2** - significant degradation, workaround exists, revenue impact\n bounded. Postmortem optional but encouraged.\n- **sev3** - internal or cosmetic, no customer impact.\n\n## Choosing the mitigation\n\n| Signal | Mitigation |\n| ------------------------------------------------- | -------------------- |\n| Regression starts exactly at a deploy timestamp | `rollback_deployment` |\n| Regression tracks a feature-flag rollout percent | Flag kill switch |\n| Config value is obviously wrong in production | Config PR + deploy |\n| Downstream dependency is the one that is unhealthy | Page that team too |\n\nIf the deploy that caused it was a canary, do not promote it - roll the canary\nback and leave production on the previous version.\n\n## Things that go wrong\n\n- Resolving the alert before verifying recovery. It re-fires in four minutes and\n now nobody trusts the alert.\n- Kill-switching a flag in *both* environments when only production is broken.\n Leave staging enabled so you can reproduce.\n- Forgetting the status-page update. Support finds out from customers.\n\n## Related\n\n- \"Deployment policy\", \"Rollback and recovery\", \"On-call and alert triage\".\n"
51
+ },
52
+ {
53
+ "doc_id": 9607,
54
+ "kind": "runbook",
55
+ "title": "Feature flags",
56
+ "service": "",
57
+ "author": "Mei Tanaka",
58
+ "day": 247,
59
+ "body": "# Feature flags\n\nEvery new user-facing feature ships **dark**: merged, deployed, and switched\noff, then turned on gradually.\n\n## Defining a flag\n\nA flag is defined by a `flag` change in the PR that introduces the guarded code.\nFlag and code land together, in one PR, so there is never a flag referencing\ncode that does not exist or guarded code with no way to turn it off. At merge\nthe flag is created **disabled in both environments** with a rollout of 0%.\n\nNaming: lowercase snake_case, describing the feature, not the experiment -\n`express_checkout`, `instant_refunds`, `new_search_ui`. Not `mei_test_2` and not\n`enable_new_thing_v3_final`.\n\n## Ordering: deploy the code, then enable the flag\n\n**The guarded code must be deployed to production BEFORE the flag is enabled\nthere.** Enabling a flag whose code is not deployed does one of two things:\nnothing at all (best case, and you waste an hour wondering why), or it activates\na half-present code path across a partially deployed fleet (worst case).\n\nSo the sequence is:\n\n1. PR with the module change and the `flag` change - CI - merge.\n2. Deploy to staging.\n3. Deploy to production. Tier-1 services canary at `canary_percent <= 25`,\n `assess_canary`, then `promote_canary` (see \"Deployment policy\").\n4. Only now: `set_feature_flag(flag, environment=\"production\", enabled=true,\n rollout_percent=10)`.\n\n## Initial rollout must not exceed 10%\n\nThe first production enablement is capped at **10%**. Sit there long enough to\nsee real traffic - at minimum one full traffic peak - and watch the owning\nservice's error rate and p99. Then ramp: 10 - 25 - 50 - 100, checking metrics at\neach step.\n\nFlags are **runtime toggles**: `set_feature_flag` takes effect immediately and\nneeds **no deploy**. That cuts both ways - it is why a flag is the fastest kill\nswitch we have, and it is why an unreviewed ramp to 100% is the fastest way to\ncause a sev2. The `instant_refunds` incident was exactly this: the flag went to\n100% in production and `checkout` `error_rate_pct` went from 0.3% to 5.5%.\n\n## Kill switch\n\nDuring an incident, disable the flag in the affected environment only. Leave the\nother environment as it is so you can still reproduce. See \"Incident response\".\n\n## Cleanup\n\n**Stale flags must be cleaned up after full rollout.** Once a flag has been at\n100% in production for two weeks and there is no plan to turn it off, remove the\nconditional from the code and delete the flag in a follow-up PR. Every flag left\nbehind is a branch of untested code and a future outage. The owning team reviews\nits flag list at each sprint boundary.\n"
60
+ },
61
+ {
62
+ "doc_id": 9609,
63
+ "kind": "runbook",
64
+ "title": "Security response",
65
+ "service": "",
66
+ "author": "Alex Osei",
67
+ "day": 263,
68
+ "body": "# Security response\n\nCovers dependency vulnerabilities reported by the scanner and secrets found in\nsource. Security tickets carry the `security` type and are prioritized above\nfeature work.\n\n## Vulnerable dependency\n\nOrdered steps:\n\n1. **Patch the vulnerable dependency.** Bump to the fixed version named in the\n finding via a PR with a `dependency` change. Do not jump several major\n versions to \"get ahead\" - patch to the fixed version, then plan the upgrade\n separately.\n2. **Deploy staging, then production.** Staging-first per the \"Deployment\n policy\". Tier-1 services canary at `canary_percent <= 25`, `assess_canary`,\n then `promote_canary`.\n3. **Verify the scanner shows the finding remediated.** Re-run the scan against\n the deployed service and confirm the vulnerability status is no longer\n `open`. A merged PR is not remediation; a deployed and re-scanned service is.\n4. **Post an audit summary to `#security` referencing the CVE id.** State the\n CVE, the service, the old and new versions, and when production was patched.\n Auditors read this channel; the CVE id must appear literally.\n5. **Close the security ticket.**\n\nTimelines by severity, measured from the finding appearing:\n\n| Severity | Production patched within |\n| -------- | ------------------------- |\n| critical | 48 hours |\n| high | 7 days |\n| medium | 30 days |\n| low | next maintenance window |\n\n## Secrets in code\n\nIf a credential, API key, or token is found in source, config, or CI logs:\n\n1. **Move it to the secret manager.** Set config key\n `use_secret_manager=true` for the service and reference the secret by name;\n the value never appears in the repo again.\n2. **Rotate the credential.** Assume it is compromised the moment it was\n committed - git history is forever and the repo is mirrored to CI. Rotation\n is not optional even if the repo is private.\n3. Deploy staging then production, verify the service still authenticates, and\n post the summary to `#security`.\n\nDo not \"delete the line and force-push\". The old blob is still reachable and the\ncredential is still live.\n\n## Escalation\n\nAnything involving customer data exposure, an actively exploited vulnerability,\nor credential misuse in production is a sev1 - open an incident and follow\n\"Incident response\" in parallel with this runbook.\n\n## Related\n\n- \"ADR-027: Move partner credentials to the secret manager\".\n"
69
+ },
70
+ {
71
+ "doc_id": 9610,
72
+ "kind": "runbook",
73
+ "title": "Flaky tests",
74
+ "service": "",
75
+ "author": "Diego Ramos",
76
+ "day": 244,
77
+ "body": "# Flaky tests\n\nA flaky test is a test that passes and fails without the code changing. It is\nworse than a failing test, because it teaches the team to ignore red builds.\n\n## Diagnose from CI history\n\nStart with `list_ci_runs` for the service. You are looking for the same test\nname alternating between `passed` and `failed` across runs on the same commit or\nadjacent commits. The CI detail line usually names it:\n\n```\nintermittent failure: test_checkout_idempotency (rerun may pass)\n```\n\nCommon root causes, roughly in order of how often we hit them:\n\n1. **Shared mutable fixture state** - two tests write the same row, key, or temp\n file, and ordering decides who wins. The `test_checkout_idempotency` flake was\n a nondeterministic idempotency-key collision in the fixture.\n2. **Time and timezone** - `now()` at a boundary, tests that assume ordering by\n second-resolution timestamps.\n3. **Unseeded randomness** - random ids that occasionally collide.\n4. **Real sleeps and races** - `sleep(0.1)` standing in for a synchronization\n point.\n5. **Network or clock dependence** - a test that quietly reaches a real service.\n\n## Fix the root cause\n\nShip the fix as a PR containing a `test_fix` change with **action `fix`**. The\nchange should make the test deterministic: seed the randomness, isolate the\nfixture per test, inject the clock, replace sleeps with explicit waits.\n\n**Quarantine is a last resort.** A `test_fix` change with action `quarantine`\nstops the test from blocking CI, but it **does not close the ticket** - the\nticket stays open until an action `fix` change lands. Quarantine is for\nunblocking a release train at 2am, not for closing your backlog. Quarantined\ntests are reviewed weekly and anything quarantined for more than two weeks is\nescalated to the owning team's lead.\n\n## Prove stability\n\nAfter merging, demonstrate stability with **3 consecutive green main-branch\nruns**: `run_ci(service=...)` three times, all `passed`, with no other change in\nbetween. One green run proves nothing about a test that fails half the time -\nthree consecutive greens give roughly 87% confidence for a 50% flake and much\nmore for the typical 10-20% flake.\n\nOnly then close the ticket.\n\n## Prevention\n\n- No shared fixtures across test files; build state per test.\n- Inject the clock, never call `now()` directly in application code under test.\n- Seed every random source in the test harness.\n- If a test needs a real dependency, it is an integration test - label it and\n run it in the integration stage.\n"
78
+ },
79
+ {
80
+ "doc_id": 9612,
81
+ "kind": "runbook",
82
+ "title": "Queue consumer tuning",
83
+ "service": "notifications",
84
+ "author": "Priya Nair",
85
+ "day": 226,
86
+ "body": "# Queue consumer tuning\n\nOwner: platform. Primary consumer service: `notifications` (tier 2), which\ndrains the email, SMS, and push delivery queues. The same rules apply to any\nservice that consumes from the message broker.\n\n## The rule\n\n`prefetch_count` must be a **bounded** value. **Recommended: 50.**\n\n`prefetch_count=0` means **unlimited prefetch** and is the single worst setting\nin this runbook.\n\n## What prefetch does\n\nPrefetch is the number of unacknowledged messages the broker will push to a\nsingle consumer. With `prefetch_count=50`, a consumer holds at most 50\nin-flight messages; the broker will not send a 51st until one is acknowledged.\nThis is the backpressure mechanism - it is what lets a slow consumer tell the\nbroker to slow down.\n\nWith `prefetch_count=0` there is no backpressure. The broker pushes the entire\nbacklog to whichever consumer connects first. Consequences, all of which we have\nseen in `notifications`:\n\n- **Memory pressure.** A 400k-message backlog lands in one process's heap. RSS\n climbs until the container hits its memory limit.\n- **Consumer restarts.** The container is OOM-killed, the unacknowledged\n messages are redelivered, the restarted consumer grabs them all again, and it\n is killed again. A restart loop that looks like a broker problem and is not.\n- **Terrible load distribution.** One consumer holds everything while its\n siblings sit idle, so scaling out does nothing.\n- **Head-of-line latency.** A high-priority message sits behind 400k others.\n\n## Sizing\n\n| Message profile | prefetch_count |\n| ------------------------------ | -------------- |\n| Fast, uniform (a few ms each) | 100-200 |\n| Standard delivery work | **50** |\n| Slow or variable (seconds) | 5-10 |\n| Long-running jobs (minutes) | 1 |\n\nRule of thumb: `prefetch_count` should be roughly the number of messages a\nconsumer can process in one to two seconds. Start at 50 and adjust with\nevidence.\n\n## Related settings\n\n- `smtp_pool` on `notifications` bounds concurrent SMTP connections. Prefetch\n above the SMTP concurrency just buys queueing inside the process.\n- Ack **after** the work is done, never on receipt. Acking on receipt turns a\n crash into silent message loss.\n- Dead-letter after 5 delivery attempts so a poison message cannot loop forever.\n\n## Changing it\n\nRepo config: PR with a `config` change, CI, merge, staging, production.\n`notifications` is tier 2 - straight 100% deploy after staging. Watch consumer\nmemory and queue depth for one full peak after the change.\n"
87
+ },
88
+ {
89
+ "doc_id": 9613,
90
+ "kind": "runbook",
91
+ "title": "CDN and media delivery",
92
+ "service": "media-service",
93
+ "author": "Mei Tanaka",
94
+ "day": 221,
95
+ "body": "# CDN and media delivery\n\nCovers media-service, the product-image and asset delivery path owned by\ncommerce and shipped as part of the `catalog` service. Product photography,\ngenerated thumbnails, size charts, and marketing video posters all flow through\nit.\n\n## The rule\n\n`cdn_enabled=true` is **required in production** for media-service. Origin-only\nserving is not an acceptable production configuration.\n\n## Why\n\nWith the CDN enabled, edge nodes serve cached objects close to the user and the\norigin sees only cache misses and revalidations - typically under 5% of\nrequests. With `cdn_enabled=false`, every image request travels to the origin\nand out of the object store.\n\nMeasured impact of origin-only serving:\n\n- **~600ms added at p99** on image-heavy pages. Category and product-detail\n pages are the worst affected because they fan out to dozens of assets, and\n browsers cap parallel connections per origin, so the latency serializes.\n- **Object-store cost rises sharply.** Egress and per-request charges are billed\n on every single request instead of on misses. In the one week we ran\n origin-only during a migration, media egress was roughly 20x the normal line\n item.\n- Origin bandwidth saturates first during traffic spikes, and image failures\n make the storefront look broken even when checkout is perfectly healthy.\n\n## Config\n\n| Key | Production value | Notes |\n| --------------- | ---------------- | --------------------------------------- |\n| `cdn_enabled` | `true` | Required. |\n\nCache-control defaults: immutable, content-hashed asset URLs get a one-year\nmax-age; mutable paths get 300s with revalidation. Because asset URLs are\ncontent-hashed, a new image is a new URL - you should almost never need to purge.\n\n## Purging\n\nPurge only for a legal or trademark takedown, or for an asset published in\nerror. A full-prefix purge is effectively a cold cache: expect an origin load\nspike and a temporary p99 regression. Purge narrowly, by exact URL, during low\ntraffic.\n\n## Troubleshooting\n\n- Images slow but HTML fast: check `cdn_enabled` first, before anything else.\n- Cache hit ratio below 90%: usually a query string added to asset URLs, which\n fragments the cache key. Strip non-semantic query parameters at the edge.\n- 403s from the edge: signed-URL clock skew on the origin.\n\n## Changing it\n\nRepo config: PR with a `config` change, CI, merge, staging, then production per\nthe \"Deployment policy\". Verify p99 on a product-detail page and the edge hit\nratio before closing the ticket.\n"
96
+ },
97
+ {
98
+ "doc_id": 9614,
99
+ "kind": "design_doc",
100
+ "title": "Checkout architecture",
101
+ "service": "checkout",
102
+ "author": "Diego Ramos",
103
+ "day": 198,
104
+ "body": "# Checkout architecture\n\nService: `checkout` (tier 1, python, commerce). Owns the cart and the checkout\norchestration state machine. SLOs: `error_rate_pct < 1.0`,\n`latency_p99_ms < 400`.\n\n## Responsibilities\n\n`checkout` owns the transition from \"a cart exists\" to \"an order exists and is\npaid\". It does not own money movement (that is `payments`), product data (that\nis `catalog`), or customer notification (that is `notifications`). It owns the\nsequencing and the guarantee that the sequence happens exactly once.\n\nModules: `cart`, `checkout_flow`, and - once the loyalty program ships -\n`loyalty_redeem`.\n\n## The state machine\n\nEvery checkout session is a row with an explicit state:\n\n```\ncart_open -> pricing_locked -> payment_pending -> paid -> order_created\n | |\n +-> abandoned +-> payment_failed\n```\n\nTransitions are append-only and each is stamped with the idempotency key of the\nrequest that caused it. Replaying a request that has already produced a\ntransition returns the existing result rather than performing it again. This is\nwhat makes the checkout endpoint safe to retry, which matters because clients\nretry aggressively on mobile networks.\n\n## Dependencies\n\n| Downstream | Call | Timeout budget |\n| --------------- | ------------------------ | ------------------------- |\n| `catalog` | price and availability | `<= 2000ms`, 3 attempts |\n| `payments` | authorize and capture | `payment_timeout_ms` |\n| `notifications` | order confirmation | async, fire-and-forget |\n\nAll synchronous calls follow the \"Retry and timeout standard\": three attempts,\ntimeout at or below 2000ms. The `notifications` call is deliberately\nasynchronous - a confirmation email must never be able to fail an order.\n\n## Pricing lock\n\nAt `pricing_locked` we snapshot the price, the promotion, and the tax\ncomputation into the session row. From that point the customer pays the price\nthey were shown even if `catalog` changes underneath. The lock expires after 20\nminutes, after which the session re-prices.\n\n## Failure handling\n\n- `payments` timeout: the session stays `payment_pending` and a reconciliation\n job asks `payments` for the authoritative status. We never assume a timeout\n means \"did not happen\".\n- `catalog` unavailable: fail closed. We do not sell at a guessed price.\n- Partial capture: not supported; a capture is all-or-nothing per order.\n\n## Feature flags\n\nCheckout-adjacent behavior ships behind flags - `instant_refunds`,\n`express_checkout`. Per the \"Feature flags\" runbook, the code deploys first and\nthe flag is enabled afterwards at no more than 10%. `instant_refunds` is the\ncautionary tale: ramped to 100% in production, it took `error_rate_pct` from\n0.3% to 5.5% via a nil-pointer panic in the refund worker.\n\n## Open questions\n\n- Should the pricing lock move into `catalog` so `search` can honor it too?\n- Cart merge on login is still last-write-wins; it should be a real merge.\n"
105
+ },
106
+ {
107
+ "doc_id": 9615,
108
+ "kind": "design_doc",
109
+ "title": "Payments settlement pipeline",
110
+ "service": "payments",
111
+ "author": "Diego Ramos",
112
+ "day": 205,
113
+ "body": "# Payments settlement pipeline\n\nService: `payments` (tier 1, python, commerce). Owns capture, refunds, and daily\nsettlement against the processor. SLOs: `error_rate_pct < 1.0`,\n`latency_p99_ms < 200`.\n\n## Ledger first\n\nEverything in `payments` is derived from an append-only ledger. A capture is not\n\"a field set to captured\" - it is a sequence of ledger entries that must balance.\nNothing is ever updated in place; corrections are compensating entries. This is\nwhat makes settlement reconcilable at all.\n\nEntry kinds: `authorization`, `capture`, `refund`, `chargeback`, `fee`,\n`payout`. Each carries the processor reference id, the currency, the minor-unit\namount, and the order id.\n\n## Synchronous path\n\n1. `checkout` calls authorize with an idempotency key.\n2. `payments` writes an `authorization` entry and calls the processor through\n `libpayproc`.\n3. On success, capture is either immediate or deferred to fulfilment depending\n on the merchant configuration.\n4. `payments` emits an event; `notifications` sends the receipt.\n\nThe call to `notifications` is where this service has historically hurt itself.\nIt must run with `notifications_retry_max_attempts=3` and\n`notifications_timeout_ms` at or below 2000, per the \"Retry and timeout\nstandard\". Running with retries at 0 and a 30000ms timeout produced\n`ConnectionTimeout` errors that permanently failed the request and marked orders\nfailed, pushing `error_rate_pct` from a 0.4% baseline to 3.8%.\n\n## Nightly settlement\n\nAt 02:00 UTC the settlement job:\n\n1. Freezes the ledger cursor for the previous day.\n2. Fetches the processor's settlement file.\n3. Matches each processor line to a ledger entry by reference id.\n4. Writes `fee` and `payout` entries for matched lines.\n5. Files unmatched lines into an exceptions queue for manual review.\n\nThe exceptions queue is expected to be small but never empty - a handful of\ncross-midnight captures land there daily and clear the next run.\n\n## Invariants\n\n- Sum of `capture` minus `refund` minus `chargeback` per order is never\n negative.\n- No order has a `capture` without a preceding `authorization`.\n- Every `payout` reconciles to a processor settlement line.\n\nThese are asserted by a checker that runs after settlement; a violation pages\ncommerce immediately.\n\n## Pool and dependencies\n\n`db_pool_size` is 20 (the floor from \"Connection pool sizing\"). `libpayproc` is\npinned and patched promptly - it is the highest-value dependency in the fleet\nfor an attacker, and CVE handling follows \"Security response\".\n\n## Open questions\n\n- Multi-currency payouts still net in the merchant's home currency only.\n- Chargeback ingestion is a daily poll; a webhook would cut the delay to minutes.\n"
114
+ },
115
+ {
116
+ "doc_id": 9617,
117
+ "kind": "design_doc",
118
+ "title": "Loyalty points program",
119
+ "service": "",
120
+ "author": "Diego Ramos",
121
+ "day": 288,
122
+ "body": "# Loyalty points program\n\nCross-service feature spanning `catalog`, `checkout`, and `storefront-web`.\nCustomers earn points on purchases and redeem them for order discounts.\n\n## Modules and ownership\n\n| Module | Service | Responsibility |\n| ----------------- | ----------------- | ------------------------------------- |\n| `loyalty_accrual` | `catalog` | Points-earning rules per product |\n| `loyalty_redeem` | `checkout` | Applying points as an order discount |\n| `loyalty_widget` | `storefront-web` | Balance display and redeem affordance |\n\nEach module ships in **its own PR against its own service**. There is no shared\nlibrary; the contract between them is the points-rate field on the product\npayload and the redeem call on the checkout API.\n\n## Why this split\n\nAccrual rules are product data - they vary per product and per category, they\nchange with merchandising campaigns, and they belong next to pricing. Redemption\nis an order-level money decision and belongs in the checkout state machine.\nDisplay is display. Putting accrual in `checkout` would have meant `checkout`\nreading the product rules table, which is exactly the coupling we spent last\nyear removing.\n\n## Rollout order\n\nDeployment order matters and is not negotiable:\n\n**`catalog` - then `checkout` - then `storefront-web`.**\n\nThe reasoning is a strict data dependency chain:\n\n1. `catalog` must be emitting a points rate on the product payload before\n `checkout` can compute a balance to redeem against. If `checkout` ships\n first, every redeem attempt reads a missing field and either errors or\n silently computes zero.\n2. `checkout` must expose the redeem endpoint and be live before\n `storefront-web` renders a redeem button. If the widget ships first,\n customers see a button that 404s - a visible, embarrassing failure on the\n busiest page we have.\n\n`catalog` is tier 2 (straight production deploy after staging). `checkout` and\n`storefront-web` are tier 1, so each is staging-first, then a production canary\nat `canary_percent <= 25`, `assess_canary`, then `promote_canary` - see\n\"Deployment policy\". Do not begin the next service's production deploy until the\nprevious one is fully promoted.\n\n## Points model\n\nBalances live in an append-only ledger, mirroring the approach in \"Payments\nsettlement pipeline\": `earn`, `redeem`, `expire`, `adjust`. Balance is the sum,\nnever a stored counter. Redemption is authorized at `pricing_locked` and\ncommitted at `paid`; an abandoned cart releases the hold after 20 minutes.\n\nDefault rate is 1 point per whole currency unit, 100 points equals one currency\nunit of discount, points expire 12 months after earning. Maximum redemption is\n50% of order subtotal.\n\n## Risks\n\n- Double-redeem across concurrent sessions. Mitigated by the hold and by the\n idempotency key on the checkout transition.\n- Accrual rule changes retroactively altering historical balances. The ledger\n stamps the rate version at earn time.\n"
123
+ },
124
+ {
125
+ "doc_id": 9618,
126
+ "kind": "adr",
127
+ "title": "ADR-014: Adopt per-service feature flags",
128
+ "service": "",
129
+ "author": "Mei Tanaka",
130
+ "day": 156,
131
+ "body": "# ADR-014: Adopt per-service feature flags\n\n**Status:** Accepted\n**Date:** day 156\n**Deciders:** growth, platform, commerce leads\n\n## Context\n\nBefore this decision, shipping a user-facing change meant shipping a deploy, and\nturning it off meant shipping another deploy. For tier-1 services that is a\nstaging deploy, a canary, an assessment, and a promotion - fifteen to forty\nminutes on a good day. During the `checkout` incident in the previous quarter,\nthose minutes were the entire outage.\n\nWe also had three ad-hoc mechanisms doing flag-shaped work: an environment\nvariable in `storefront-web` (`ab_test_bucket`), a hardcoded allowlist in\n`checkout`, and a database table in `catalog` that nobody remembered owning.\nNone were auditable and none could be changed safely under pressure.\n\n## Decision\n\nAdopt a single **per-service feature flag** system with the following\nproperties:\n\n1. A flag is scoped to exactly one service and one environment. There is no\n global flag. `new_search_ui` in staging and `new_search_ui` in production are\n independent records with independent enabled state and rollout percent.\n2. A flag is **defined by a `flag` change in the PR that introduces the guarded\n code**, so flag and code are reviewed together and land together.\n3. At merge, the flag exists **disabled in both environments** at 0% rollout.\n4. Toggling is a **runtime operation** (`set_feature_flag`) requiring **no\n deploy**.\n5. Guarded code must be **deployed to production before the flag is enabled**\n there.\n6. Initial production rollout is capped at **10%**.\n\n## Alternatives considered\n\n**Trunk-based with no flags, relying on fast rollback.** Rejected: rollback is\nminutes and coarse - it reverts everything in the release, including unrelated\nfixes. A flag reverts one behavior in seconds.\n\n**A third-party flag SaaS.** Rejected for now: an external network dependency in\nthe request path of tier-1 services, and flag evaluation would have needed a\ncache with its own failure modes. Revisit if we outgrow the current model.\n\n**Global (cross-service) flags.** Rejected: they imply synchronized deploys\nacross services, which is precisely the coupling we are trying to avoid. The\nloyalty rollout demonstrates the alternative - ordered per-service deploys.\n\n## Consequences\n\nPositive: mitigation in seconds via kill switch; dark launches; percentage\nramps; a per-service audit trail of who toggled what.\n\nNegative: every flag is a branch in the code, and untested branches rot. This is\nwhy the \"Feature flags\" runbook mandates cleanup of stale flags after full\nrollout, reviewed at each sprint boundary.\n"
132
+ },
133
+ {
134
+ "doc_id": 9619,
135
+ "kind": "adr",
136
+ "title": "ADR-021: Standardize on staged canary deploys",
137
+ "service": "",
138
+ "author": "Priya Nair",
139
+ "day": 174,
140
+ "body": "# ADR-021: Standardize on staged canary deploys\n\n**Status:** Accepted\n**Date:** day 174\n**Deciders:** platform, SRE, engineering leadership\n\n## Context\n\nProduction deploys were all-at-once. A bad release reached 100% of traffic in\nthe time it took the fleet to roll, which meant every defect that got past CI\nand staging became a full-blast customer incident. Over two quarters, four of\nour six sev1s and sev2s followed this shape: deploy, metric moves, scramble,\nroll back. Mean time to detect was decent - our alerting is good - but by\ndetection time, everyone was already affected.\n\nStaging catches a lot, but it does not catch what only real traffic produces:\nproduction data shapes, real concurrency, real cache states, real client\ndiversity. A goroutine leak in a connection pool is invisible on staging's\ntraffic profile and obvious at 1000 rps.\n\n## Decision\n\nStandardize on **staged canary deploys** for tier-1 services:\n`storefront-web`, `api-gateway`, `checkout`, `payments`.\n\n1. Every production deploy still requires the **same version** to have\n succeeded on **staging** first.\n2. The production deploy starts as a canary: `deploy_service` with\n `canary_percent <= 25`.\n3. The canary is evaluated with **`assess_canary`**, which compares the canary\n population's error rate and latency against the stable population over the\n soak window.\n4. Only when `assess_canary` reports **healthy** may the release be advanced\n with **`promote_canary`**.\n5. If it reports unhealthy, roll the canary back. Do not promote and watch.\n6. `rollback_deployment` is exempt from staging-first.\n\nTier-2 services (`catalog`, `notifications`, `search`) deploy at 100% after\nstaging. Their blast radius is degradation, not lost orders, and the operational\noverhead of canarying everything was judged not worth it.\n\n## Alternatives considered\n\n**Blue/green.** Rejected: the cutover is still all-at-once, so it improves\nrollback speed but not exposure. It also doubles the running fleet.\n\n**Canary everything, all tiers.** Rejected as too slow for the number of deploys\ntier-2 services make. Revisit if a tier-2 service ever causes a sev1.\n\n**Time-based auto-promotion without assessment.** Rejected: a timer is not a\nsignal. It codifies \"nothing paged in ten minutes\" as health, and slow burns -\nthe exact class canaries are for - do not page in ten minutes.\n\n## Consequences\n\nDeploys take longer, and engineers must wait for an assessment. The tooling\nenforces `canary_percent <= 25` on tier-1 production deploys. Any deploy that\ntrips an alarm counts against the team's deployment score, weighted at one\nquarter if the canary was correctly assessed and not promoted - the incentive\npoints toward canarying honestly.\n\nOperational detail lives in \"Deployment policy\".\n"
141
+ },
142
+ {
143
+ "doc_id": 9620,
144
+ "kind": "adr",
145
+ "title": "ADR-027: Move partner credentials to the secret manager",
146
+ "service": "payments",
147
+ "author": "Alex Osei",
148
+ "day": 191,
149
+ "body": "# ADR-027: Move partner credentials to the secret manager\n\n**Status:** Accepted\n**Date:** day 191\n**Deciders:** security, platform, commerce\n\n## Context\n\nPartner credentials - the payment processor API key, the shipping carrier\ntokens, the SMTP credentials used by `notifications`, and the analytics\nwrite key - were stored as plain config values in each service's repo config\nand injected as environment variables at deploy time.\n\nThree problems made this untenable:\n\n1. **Git history is permanent.** Every credential ever committed remains in\n history, in every clone, and in every CI cache. Removing the line does not\n remove the secret.\n2. **Rotation was a deploy.** Rotating the processor key meant a PR, CI, staging,\n canary, promote - per service. So rotation happened roughly never, and the\n processor key in production had been unchanged for over a year.\n3. **No access audit.** We could not answer \"who read this value, and when\",\n which is a direct finding in the annual audit.\n\nThe trigger was a scanner hit: a carrier token visible in a config file in a\nrepo that four teams could read.\n\n## Decision\n\nAll partner credentials move to the managed **secret manager**. Each service\nopts in with the config key **`use_secret_manager=true`** and references secrets\nby name rather than value. The application resolves secrets at startup and on a\nrefresh interval; the plaintext never appears in the repo, in a PR diff, or in a\ndeploy artifact.\n\nEvery credential moved is **rotated as part of the move**, on the assumption\nthat anything previously in the repo is compromised.\n\nRollout order: `payments` first (highest value), then `notifications`, then the\nremaining services.\n\n## Alternatives considered\n\n**Encrypted secrets committed to the repo (sealed values).** Rejected: it solves\nplaintext exposure but not rotation-as-a-deploy, and the decryption key becomes\nthe new committed secret.\n\n**Environment variables set manually on hosts.** Rejected: unauditable,\ndrift-prone, and impossible to reproduce.\n\n**Do nothing, tighten repo permissions.** Rejected: it does not address history,\nrotation, or audit.\n\n## Consequences\n\nPositive: rotation is an operation, not a release; access is logged per read;\nsecret scanning in CI becomes a hard gate rather than advisory.\n\nNegative: a new startup-time dependency. If the secret manager is unreachable a\nservice cannot start, so we cache the last successful resolution on disk,\nencrypted, with a short TTL, to survive a brief outage.\n\nOperational procedure for a leaked credential is in the \"Security response\"\nrunbook: move to the secret manager, **rotate**, deploy, verify, post to\n`#security`.\n"
150
+ },
151
+ {
152
+ "doc_id": 9622,
153
+ "kind": "postmortem",
154
+ "title": "Postmortem: search cache stampede after index rebuild",
155
+ "service": "search",
156
+ "author": "Mei Tanaka",
157
+ "day": 183,
158
+ "body": "# Postmortem: search cache stampede after index rebuild\n\n**Severity:** sev2\n**Service:** `search`\n**Duration:** 34 minutes of degraded search\n**Author:** Mei Tanaka\n**Status:** action items complete\n\n## Summary\n\nA planned index rebuild swapped the search index alias at a moderate traffic\nhour. The alias swap invalidated the entire query cache. Every in-flight query\nmissed simultaneously and hit the primary index, driving `latency_p99_ms` from\n~210ms to a peak of 2100ms and firing the `search latency_p99_ms` alert against\nits 300ms SLO. Search was slow, not down; conversion on search-originated\nsessions dropped an estimated 18% for the duration.\n\n## Timeline (UTC)\n\n- **14:02** Engineer starts a full index rebuild for an analyzer change. Routine;\n done a dozen times before.\n- **14:41** Rebuild completes. Alias swaps to the new index. Query cache keys are\n namespaced by index generation, so the swap invalidates 100% of the cache.\n- **14:42** `latency_p99_ms` crosses 300ms. Alert fires, `medium`.\n- **14:44** On-call acknowledges. Initial hypothesis: the new analyzer is slow.\n- **14:51** Index CPU is pegged; per-query cost is unchanged from before the\n rebuild. Hypothesis discarded - it is volume, not per-query cost.\n- **14:58** Cache hit ratio confirmed at 3%, against a normal 76%. Root cause\n identified.\n- **15:06** Traffic to search temporarily shed at the gateway by 30% to let the\n cache refill.\n- **15:16** Hit ratio back above 60%; p99 at 340ms and falling.\n- **15:22** Shedding removed. p99 at 215ms.\n- **15:26** Alert resolved, incident resolved, update posted in `#incidents`.\n\n## Root cause\n\nThe query cache is namespaced by index generation. An alias swap therefore\nperforms a **complete, instantaneous cache flush** with no warm-up. Because the\ncache normally absorbs about **75% of index load**, the index was asked to serve\nroughly 4x its steady-state query volume within one second. Requests queued,\nlatency rose, clients retried, and the retries added load - a classic stampede\nwith a positive feedback loop.\n\n## Contributing factors\n\n- No warm-up step in the rebuild procedure. The runbook ended at \"swap alias\".\n- Rebuild was run at 14:00 local, in the daily traffic ramp, because the job\n takes 40 minutes and nobody wanted to babysit it at night.\n- Single-flight coalescing existed for identical concurrent queries but the\n stampede was across *thousands of distinct* queries, so coalescing did nothing.\n- No alert on cache hit ratio, so the actual signal was invisible for 14 minutes.\n\n## What went well\n\n- Alerting fired within a minute of the SLO breach.\n- Load shedding at the gateway was the correct blunt instrument and worked.\n\n## Action items\n\n1. Add a **warm-up phase** to the rebuild: replay the top 5000 queries against\n the new index before swapping the alias. **Done.**\n2. Add **+/-10% TTL jitter** to `cache_ttl_s=300` so natural expiry never\n synchronizes. **Done.**\n3. Alert on **cache hit ratio below 50%** for 5 minutes. **Done.**\n4. Move scheduled rebuilds to 03:00-05:00 UTC. **Done.**\n5. Document the stampede risk in the \"Search caching\" runbook. **Done.**\n"
159
+ },
160
+ {
161
+ "doc_id": 9623,
162
+ "kind": "postmortem",
163
+ "title": "Postmortem: catalog migration 0043 forced a rollback",
164
+ "service": "catalog",
165
+ "author": "Diego Ramos",
166
+ "day": 202,
167
+ "body": "# Postmortem: catalog migration 0043 forced a rollback\n\n**Severity:** sev1\n**Service:** `catalog` (with knock-on impact to `checkout` and `storefront-web`)\n**Duration:** 22 minutes of failed product-detail pages\n**Author:** Diego Ramos\n**Status:** action items complete\n\n## Summary\n\nMigration `0043_rename_price_column` renamed `catalog_products.price_cents` to\n`price_minor_units` in a single step, and the matching code version `v1.8.0` was\ndeployed immediately after. The migration was applied to production before the\ndeploy, as policy requires - but the migration was **not backwards compatible**\nwith the code version already running. Between the migration completing and the\nnew version being fully rolled out, the running `v1.7.6` instances queried a\ncolumn that no longer existed. Product-detail and category pages returned 500s;\n`checkout` fell back to failing closed on pricing, per its design.\n\n## Timeline (UTC)\n\n- **09:12** `apply_migration(catalog, production, 0043)` starts.\n- **09:13** Migration completes. Column renamed.\n- **09:13** `v1.7.6` instances begin throwing\n `UndefinedColumn: price_cents` on every pricing query.\n- **09:14** `catalog` error rate goes vertical. `checkout` starts failing closed.\n Two alerts fire.\n- **09:15** Deploy of `v1.8.0` starts, as planned, but rolls instance by instance.\n- **09:17** On-call acknowledges, declares sev1.\n- **09:19** Commander recognizes the pattern: schema ahead of code, partial fleet.\n- **09:21** Decision: do **not** attempt to reverse the migration. Accelerate the\n `v1.8.0` rollout instead.\n- **09:31** Rollout complete on all instances. Errors stop.\n- **09:34** Metrics confirmed recovered; alerts resolved; incident resolved.\n- **09:40** Update posted in `#incidents`; status page updated and cleared.\n- Later that day: `v1.8.0` was rolled back for an unrelated defect found in\n review, which is when the second lesson landed - the rolled-back `v1.7.6` code\n could not read the renamed column either, and a hotfix `v1.8.1` had to be cut\n because **migrations are forward-only** and there was no going back.\n\n## Root cause\n\nA **destructive, non-backwards-compatible schema change shipped in one step**. A\ncolumn rename is two incompatible states with no overlap: code that knows the old\nname and code that knows the new name cannot both work against the same schema.\nAny window in which both code versions run - and a rolling deploy guarantees such\na window - is an outage.\n\n## Contributing factors\n\n- The \"migration before code\" rule was followed correctly, and following it\n correctly was *insufficient*. The rule says nothing about compatibility with\n the code already running.\n- The migration had one reviewer, from the authoring team.\n- Rolling deploys were assumed to be fast enough not to matter. They are not.\n- `catalog` is tier 2, so there was no canary to catch it at 25%.\n\n## What went well\n\n- Nobody tried to hand-write a reverse migration under pressure. Rolling forward\n was the right call and it was made in six minutes.\n- `checkout` failing closed on pricing prevented selling at a wrong price.\n\n## Action items\n\n1. Write the **N-1 rule** into the \"Database migration policy\": every migration\n must leave the schema usable by the currently deployed code. **Done.**\n2. Mandate the **expand/contract** pattern for renames: add column, dual-write,\n backfill, switch reads, drop in a later migration. **Done.**\n3. Require a **second reviewer from platform** for migrations on tables above ten\n million rows. **Done.**\n4. Add a CI check that flags `DROP COLUMN`, `RENAME COLUMN`, and new `NOT NULL`\n constraints for explicit sign-off. **Done.**\n"
168
+ },
169
+ {
170
+ "doc_id": 9624,
171
+ "kind": "api_spec",
172
+ "title": "Public Orders API",
173
+ "service": "api-gateway",
174
+ "author": "Priya Nair",
175
+ "day": 265,
176
+ "body": "# Public Orders API\n\nServed by `api-gateway`. Two versions are live: **`/v1/orders` (deprecated)** and\n**`/v2/orders` (current)**. Authentication is a bearer partner token on both.\nRationale for the split is in \"ADR-031: Versioned public API (/v1 to /v2\norders)\".\n\n## Status\n\n| Path | Status | Notes |\n| ------------- | ---------- | -------------------------------------------- |\n| `/v1/orders` | deprecated | Emits `Deprecation` and `Sunset` headers. |\n| `/v2/orders` | current | Use for all new integrations. |\n\nTraffic between the two is weighted at the gateway and shifted in steps of at\nmost 50 percentage points per the \"API deprecation\" runbook. `/v1/orders` may\nonly be retired once it serves 0% of traffic; CI blocks retirement otherwise.\n\n## `GET /v2/orders`\n\nQuery parameters: `status`, `created_after` (RFC3339), `limit` (default 50, max\n200), `cursor`.\n\nResponse `200`:\n\n```json\n{\n \"data\": [\n {\n \"id\": \"ord_01H9Z\",\n \"status\": \"paid\",\n \"created_at\": \"2026-03-04T11:02:19Z\",\n \"currency\": \"USD\",\n \"amount_total_minor\": 12995,\n \"amount_tax_minor\": 1040,\n \"shipments\": [\n {\"id\": \"shp_1\", \"carrier\": \"ups\", \"tracking_number\": \"1Z...\",\n \"line_item_ids\": [\"li_1\", \"li_2\"], \"status\": \"in_transit\"}\n ],\n \"refunds\": [\n {\"id\": \"ref_1\", \"amount_minor\": 2500, \"reason\": \"damaged\",\n \"created_at\": \"2026-03-07T09:11:00Z\"}\n ],\n \"loyalty\": {\"points_earned\": 130, \"points_redeemed\": 0}\n }\n ],\n \"next_cursor\": \"eyJvIjoiMDFIOVoifQ\"\n}\n```\n\n## `POST /v2/orders`\n\nRequest:\n\n```json\n{\n \"idempotency_key\": \"5f2c...\",\n \"customer_id\": \"cus_88\",\n \"currency\": \"USD\",\n \"line_items\": [{\"sku\": \"NC-1042\", \"quantity\": 2, \"unit_price_minor\": 4995}],\n \"shipping_address_id\": \"addr_9\",\n \"loyalty\": {\"points_to_redeem\": 500}\n}\n```\n\n`idempotency_key` is required. Replaying the same key returns the original order\nwith `200` rather than creating a second one.\n\nResponses: `201` created; `409` idempotency key reused with a different body;\n`422` validation failure.\n\n## `/v1/orders` (deprecated)\n\nSame resource, older shape. Differences that break naive migration:\n\n- `total` is a **decimal string** (`\"129.95\"`), not integer minor units.\n- `tracking_number` is a **scalar** on the order; multi-shipment orders report\n only the first.\n- `refunded` is a **boolean**; partial refunds are indistinguishable from full.\n- No `loyalty` object.\n- Offset pagination (`page`, `per_page`) instead of `next_cursor`.\n\n## Migration guidance\n\n1. Parse amounts as integers in minor units; drop all float handling. Multiply\n the old decimal by 100 only at the boundary, never in business logic.\n2. Iterate `shipments` instead of reading `tracking_number`. Single-shipment\n orders return an array of one.\n3. Replace `refunded == true` with `sum(refunds[].amount_minor) > 0`, and\n compare against `amount_total_minor` if you need \"fully refunded\".\n4. Switch pagination to `next_cursor`; do not compute offsets. Cursors are\n opaque - do not parse them.\n5. Handle the problem-details error shape: match on `type`, not on the message\n string.\n6. Send `idempotency_key` on every write.\n\n## Errors\n\n```json\n{\"type\": \"validation_error\", \"title\": \"Invalid line item\",\n \"detail\": \"line_items[0].quantity must be >= 1\", \"status\": 422}\n```\n\n`type` values are stable and safe to branch on: `validation_error`,\n`idempotency_conflict`, `rate_limited`, `not_found`, `internal_error`.\n"
177
+ },
178
+ {
179
+ "doc_id": 9625,
180
+ "kind": "onboarding",
181
+ "title": "Engineering onboarding: how we ship",
182
+ "service": "",
183
+ "author": "Priya Nair",
184
+ "day": 290,
185
+ "body": "# Engineering onboarding: how we ship\n\nRead this first. It is the whole workflow end to end; the runbooks it points at\nhave the detail.\n\n## The path\n\n**ticket - PR with structured changes - CI - merge - staging - canary - promote -\nverify - close**\n\n### 1. Ticket\n\nAll work starts from a ticket. It carries the type (`bug`, `feature`,\n`incident`, `security`, `postmortem`), the priority, and the owning service. If\nyou are doing work with no ticket, you are doing work nobody can find later.\n\n### 2. PR with structured changes\n\nA pull request is linked to its ticket and carries **structured changes**, not\njust prose. Change types:\n\n| Change type | Use for |\n| ------------ | ---------------------------------------------- |\n| `config` | A config key and value in the service repo |\n| `module` | Adding or removing a code module |\n| `dependency` | Upgrading a library (see \"Security response\") |\n| `endpoint` | Adding, deprecating, or retiring an endpoint |\n| `flag` | Defining a feature flag |\n| `test_fix` | Fixing (`fix`) or quarantining a flaky test |\n\nStructured changes are what make a PR mechanically checkable and what the deploy\ntooling reads. One concern per PR.\n\n### 3. CI\n\nCI runs four stages in order: **build - unit - integration - regression**. A\nfailing stage stops the run. Some checks are hard gates: retiring an endpoint\nthat still serves traffic fails CI, and so does a secret detected in the diff.\n\n### 4. Merge\n\nMerging cuts a version for the service. The version is the unit that gets\ndeployed; nothing reaches an environment except as a version.\n\n### 5. Staging\n\n`deploy_service(service, \"staging\", version)`. **Every production deploy must\nfirst succeed on staging with the same version** - see \"Deployment policy\". If\nthe change needs a schema migration, `apply_migration` runs against staging\n*before* this deploy - see \"Database migration policy\".\n\n### 6. Canary\n\nFor tier-1 services (`storefront-web`, `api-gateway`, `checkout`, `payments`),\nthe production deploy starts as a canary: `deploy_service` with\n`canary_percent <= 25`. Tier-2 services (`catalog`, `notifications`, `search`)\ndeploy at 100%.\n\n### 7. Promote\n\nRun `assess_canary`. Only when it reports **healthy** do you `promote_canary`.\nAn unhealthy canary is rolled back, not promoted.\n\n### 8. Verify\n\nRead the metric you were trying to move. Confirm it is inside its SLO. If an\nalert was firing, resolve it only after the metric has actually recovered.\n\n### 9. Close\n\nClose the ticket. If it was an incident, follow \"Incident response\" for the\nalert, incident, `#incidents` update, status page, and - for sev1 - the\npostmortem ticket.\n\n## Things new engineers get wrong\n\n- Enabling a feature flag before the guarded code is deployed. Deploy first, then\n enable, at no more than 10%.\n- Skipping staging for \"a one-line config change\". There are no exceptions.\n- Promoting a canary because it \"looked fine\" instead of assessing it.\n- Resolving an alert before verifying recovery.\n- Quarantining a flaky test and closing the ticket. It does not close the ticket.\n\n## Where to look next\n\n\"Deployment policy\", \"Database migration policy\", \"Incident response\",\n\"Feature flags\", \"Retry and timeout standard\", \"Service catalog and service\ntiers\".\n"
186
+ }
187
+ ]
188
+ ```
189
+
190
+ ## confluence_pages (4 rows)
191
+
192
+ ```json
193
+ [
194
+ {
195
+ "page_id": 8001,
196
+ "space": "ENG",
197
+ "title": "Checkout Platform \u2014 architecture",
198
+ "body": "Checkout Platform is owned by the Commerce Platform team. It calls payments and inventory synchronously. Escalate via #commerce.",
199
+ "last_updated_day": 372,
200
+ "stale": 0
201
+ }
202
+ ]
203
+ ```
task_files/dob100-003-rca-checkout-unschedulable-replicas/12-chat-and-status.json ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "sources": [
3
+ {
4
+ "columns": [
5
+ "message_id",
6
+ "channel",
7
+ "author",
8
+ "body"
9
+ ],
10
+ "row_count": 6,
11
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
12
+ "table": "messages",
13
+ "task_relevant_rows": [
14
+ {
15
+ "author": "Diego Ramos",
16
+ "body": "Incident 9702 (sev2): checkout error rate tracks the instant_refunds ramp exactly.",
17
+ "channel": "#incidents",
18
+ "message_id": 2
19
+ },
20
+ {
21
+ "author": "Jordan Blake",
22
+ "body": "Scanner run complete: 3 open findings across payments, checkout, catalog.",
23
+ "channel": "#security",
24
+ "message_id": 6
25
+ }
26
+ ]
27
+ },
28
+ {
29
+ "columns": [
30
+ "channel",
31
+ "purpose"
32
+ ],
33
+ "row_count": 4,
34
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
35
+ "table": "channels",
36
+ "task_relevant_rows": [
37
+ {
38
+ "channel": "#incidents",
39
+ "purpose": "Incident coordination and status updates."
40
+ },
41
+ {
42
+ "channel": "#security",
43
+ "purpose": "Security advisories and audit notes."
44
+ },
45
+ {
46
+ "channel": "#eng",
47
+ "purpose": "General engineering."
48
+ },
49
+ {
50
+ "channel": "#deploys",
51
+ "purpose": "Deployment announcements."
52
+ }
53
+ ]
54
+ },
55
+ {
56
+ "columns": [
57
+ "post_id",
58
+ "state",
59
+ "title",
60
+ "body"
61
+ ],
62
+ "row_count": 1,
63
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
64
+ "table": "status_page",
65
+ "task_relevant_rows": [
66
+ {
67
+ "body": "Catalog read replica maintenance completed with no customer impact.",
68
+ "post_id": 1,
69
+ "state": "resolved",
70
+ "title": "Scheduled maintenance completed"
71
+ }
72
+ ]
73
+ },
74
+ {
75
+ "columns": [
76
+ "post_id",
77
+ "title",
78
+ "impact",
79
+ "state",
80
+ "published_day",
81
+ "linked_incident"
82
+ ],
83
+ "row_count": 3,
84
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
85
+ "table": "status_page_posts",
86
+ "task_relevant_rows": [
87
+ {
88
+ "impact": "major",
89
+ "linked_incident": 5101,
90
+ "post_id": 7001,
91
+ "published_day": 412,
92
+ "state": "resolved",
93
+ "title": "Degraded checkout performance"
94
+ }
95
+ ]
96
+ }
97
+ ]
98
+ }
task_files/dob100-003-rca-checkout-unschedulable-replicas/13-approval-and-ownership.md ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 13 Approval And Ownership
2
+
3
+ ## approval_policy (5 rows)
4
+
5
+ ```json
6
+ [
7
+ {
8
+ "policy_id": 502,
9
+ "action": "retire_endpoint_with_live_traffic",
10
+ "approver_role": "service-owner",
11
+ "rationale": "drops in-flight customer requests; cannot be undone once clients fail"
12
+ }
13
+ ]
14
+ ```
15
+
16
+ ## owner_spreadsheet (5 rows)
17
+
18
+ ```json
19
+ [
20
+ {
21
+ "row_id": 1,
22
+ "service_label": "Checkout (commerce)",
23
+ "owning_team": "Commerce Platform",
24
+ "slack_channel": "#commerce",
25
+ "last_reviewed_day": 340,
26
+ "week_start": "sunday"
27
+ }
28
+ ]
29
+ ```
30
+
31
+ ## oncall (4 rows)
32
+
33
+ ```json
34
+ [
35
+ {
36
+ "team": "platform",
37
+ "engineer": "Priya Nair"
38
+ },
39
+ {
40
+ "team": "commerce",
41
+ "engineer": "Diego Ramos"
42
+ },
43
+ {
44
+ "team": "growth",
45
+ "engineer": "Mei Tanaka"
46
+ },
47
+ {
48
+ "team": "sre",
49
+ "engineer": "Alex Osei"
50
+ }
51
+ ]
52
+ ```
task_files/dob100-003-rca-checkout-unschedulable-replicas/14-tool-contracts.json ADDED
@@ -0,0 +1,550 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "note": "These are the exact sandbox schemas used by this task; first-party NovaCart tools and vendor-shaped adapters are labeled as such in their descriptions.",
3
+ "tools": [
4
+ {
5
+ "description": "Full detail for one service: metadata, deployed config, modules, endpoints, dependencies, current metrics.",
6
+ "json_schema": {
7
+ "description": "Full detail for one service: metadata, deployed config, modules, endpoints, dependencies, current metrics.",
8
+ "name": "get_service",
9
+ "parameters": {
10
+ "properties": {
11
+ "service": {
12
+ "description": "service",
13
+ "type": "string"
14
+ }
15
+ },
16
+ "required": [
17
+ "service"
18
+ ],
19
+ "type": "object"
20
+ }
21
+ },
22
+ "name": "get_service",
23
+ "parameters": [
24
+ {
25
+ "default": null,
26
+ "description": "service",
27
+ "name": "service",
28
+ "required": true,
29
+ "type": "str"
30
+ }
31
+ ],
32
+ "read_tables": [
33
+ "env_state",
34
+ "oncall",
35
+ "service_dependencies",
36
+ "service_metrics",
37
+ "services"
38
+ ],
39
+ "return_type": "dict",
40
+ "source_code": "def get_service(db_path=None, service=None):\n \"\"\"Full detail for one service: metadata, deployed config, modules, endpoints, dependencies, current metrics.\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('get_service',)); conn.commit()\n except Exception:\n pass\n if service is None:\n return {'ok': False, 'error': 'missing required parameter: service'}\n row = conn.execute('SELECT * FROM services WHERE name=?', (service,)).fetchone()\n if row is None:\n return {'ok': False, 'error': 'unknown service: ' + str(service)}\n d = dict(row)\n d['production'] = {}\n for r in conn.execute(\"SELECT kind, key, value FROM env_state WHERE service=? AND environment='production' ORDER BY kind, key\", (service,)).fetchall():\n d['production'].setdefault(r['kind'], {})[r['key']] = r['value']\n d['depends_on'] = [dict(r) for r in conn.execute('SELECT depends_on, kind FROM service_dependencies WHERE service=? ORDER BY depends_on', (service,)).fetchall()]\n d['metrics'] = {r['metric']: r['value'] for r in conn.execute(\"SELECT metric, value FROM service_metrics WHERE service=? AND environment='production'\", (service,)).fetchall()}\n oc = conn.execute('SELECT engineer FROM oncall WHERE team=?', (row['team'],)).fetchone()\n d['oncall_engineer'] = oc[0] if oc else ''\n return d\n finally:\n conn.close()\n",
41
+ "tool_id": "tool_get_service",
42
+ "write_tables": []
43
+ },
44
+ {
45
+ "description": "Fetch one ticket by key (e.g. ENG-2101).",
46
+ "json_schema": {
47
+ "description": "Fetch one ticket by key (e.g. ENG-2101).",
48
+ "name": "get_ticket",
49
+ "parameters": {
50
+ "properties": {
51
+ "key": {
52
+ "description": "key",
53
+ "type": "string"
54
+ }
55
+ },
56
+ "required": [
57
+ "key"
58
+ ],
59
+ "type": "object"
60
+ }
61
+ },
62
+ "name": "get_ticket",
63
+ "parameters": [
64
+ {
65
+ "default": null,
66
+ "description": "key",
67
+ "name": "key",
68
+ "required": true,
69
+ "type": "str"
70
+ }
71
+ ],
72
+ "read_tables": [
73
+ "tickets"
74
+ ],
75
+ "return_type": "dict",
76
+ "source_code": "def get_ticket(db_path=None, key=None):\n \"\"\"Fetch one ticket by key (e.g. ENG-2101).\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('get_ticket',)); conn.commit()\n except Exception:\n pass\n if key is None:\n return {'ok': False, 'error': 'missing required parameter: key'}\n row = conn.execute('SELECT * FROM tickets WHERE key=?', (key,)).fetchone()\n if row is None:\n return {'ok': False, 'error': 'no such ticket: ' + str(key)}\n return dict(row)\n finally:\n conn.close()\n",
77
+ "tool_id": "tool_get_ticket",
78
+ "write_tables": []
79
+ },
80
+ {
81
+ "description": "List deployments with desired vs ready replica counts, rollout strategy and storage class. A deployment whose spec the cluster cannot satisfy - more replicas than fit, or a storageClassName that does not exist - reports no error of its own: the workload is simply not there, and the shortfall exists only as the gap between desired and ready.",
82
+ "json_schema": {
83
+ "description": "List deployments with desired vs ready replica counts, rollout strategy and storage class. A deployment whose spec the cluster cannot satisfy - more replicas than fit, or a storageClassName that does not exist - reports no error of its own: the workload is simply not there, and the shortfall exists only as the gap between desired and ready.",
84
+ "name": "k8s_deployments_list",
85
+ "parameters": {
86
+ "properties": {
87
+ "degraded_only": {
88
+ "description": "degraded_only",
89
+ "type": "boolean"
90
+ },
91
+ "service": {
92
+ "description": "service",
93
+ "type": "string"
94
+ }
95
+ },
96
+ "required": [],
97
+ "type": "object"
98
+ }
99
+ },
100
+ "name": "k8s_deployments_list",
101
+ "parameters": [
102
+ {
103
+ "default": "None",
104
+ "description": "service",
105
+ "name": "service",
106
+ "required": false,
107
+ "type": "str"
108
+ },
109
+ {
110
+ "default": "False",
111
+ "description": "degraded_only",
112
+ "name": "degraded_only",
113
+ "required": false,
114
+ "type": "bool"
115
+ }
116
+ ],
117
+ "read_tables": [
118
+ "k8s_deployments"
119
+ ],
120
+ "return_type": "list[dict]",
121
+ "source_code": "def k8s_deployments_list(db_path=None, service=None, degraded_only=False):\n \"\"\"List deployments with desired vs ready replica counts, rollout strategy and storage class. A deployment whose spec the cluster cannot satisfy - more replicas than fit, or a storageClassName that does not exist - reports no error of its own: the workload is simply not there, and the shortfall exists only as the gap between desired and ready.\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('k8s_deployments_list',)); conn.commit()\n except Exception:\n pass\n sql = 'SELECT * FROM k8s_deployments'\n conds, args = [], []\n if service:\n conds.append('service=?'); args.append(service)\n if str(degraded_only).lower() in ('1', 'true', 'yes', 'on'):\n conds.append('ready_replicas < desired_replicas')\n if conds:\n sql += ' WHERE ' + ' AND '.join(conds)\n return [dict(r) for r in conn.execute(sql + ' ORDER BY service', args).fetchall()]\n finally:\n conn.close()\n",
122
+ "tool_id": "tool_k8s_deployments_list",
123
+ "write_tables": []
124
+ },
125
+ {
126
+ "description": "List cluster nodes with their Ready status, active condition, CPU and disk utilisation, labels and kernel version. A service whose node has DiskPressure, a kernel deadlock, or no node matching its selector looks - from the service's own metrics and logs - exactly like a slow or broken service. This is the only place that difference is visible.",
127
+ "json_schema": {
128
+ "description": "List cluster nodes with their Ready status, active condition, CPU and disk utilisation, labels and kernel version. A service whose node has DiskPressure, a kernel deadlock, or no node matching its selector looks - from the service's own metrics and logs - exactly like a slow or broken service. This is the only place that difference is visible.",
129
+ "name": "k8s_nodes_list",
130
+ "parameters": {
131
+ "properties": {
132
+ "node": {
133
+ "description": "node",
134
+ "type": "string"
135
+ },
136
+ "unhealthy_only": {
137
+ "description": "unhealthy_only",
138
+ "type": "boolean"
139
+ }
140
+ },
141
+ "required": [],
142
+ "type": "object"
143
+ }
144
+ },
145
+ "name": "k8s_nodes_list",
146
+ "parameters": [
147
+ {
148
+ "default": "None",
149
+ "description": "node",
150
+ "name": "node",
151
+ "required": false,
152
+ "type": "str"
153
+ },
154
+ {
155
+ "default": "False",
156
+ "description": "unhealthy_only",
157
+ "name": "unhealthy_only",
158
+ "required": false,
159
+ "type": "bool"
160
+ }
161
+ ],
162
+ "read_tables": [
163
+ "k8s_nodes"
164
+ ],
165
+ "return_type": "list[dict]",
166
+ "source_code": "def k8s_nodes_list(db_path=None, node=None, unhealthy_only=False):\n \"\"\"List cluster nodes with their Ready status, active condition, CPU and disk utilisation, labels and kernel version. A service whose node has DiskPressure, a kernel deadlock, or no node matching its selector looks - from the service's own metrics and logs - exactly like a slow or broken service. This is the only place that difference is visible.\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('k8s_nodes_list',)); conn.commit()\n except Exception:\n pass\n sql = 'SELECT * FROM k8s_nodes'\n conds, args = [], []\n if node:\n conds.append('node=?'); args.append(node)\n if str(unhealthy_only).lower() in ('1', 'true', 'yes', 'on'):\n conds.append(\"(ready != 'True' OR condition != 'Ready')\")\n if conds:\n sql += ' WHERE ' + ' AND '.join(conds)\n return [dict(r) for r in conn.execute(sql + ' ORDER BY node', args).fetchall()]\n finally:\n conn.close()\n",
167
+ "tool_id": "tool_k8s_nodes_list",
168
+ "write_tables": []
169
+ },
170
+ {
171
+ "description": "List pods with phase, restart count, memory limit/usage and the running image tag. The image tag is the only ground truth for what is actually deployed - release records in other systems drift from it, especially after a rollback.",
172
+ "json_schema": {
173
+ "description": "List pods with phase, restart count, memory limit/usage and the running image tag. The image tag is the only ground truth for what is actually deployed - release records in other systems drift from it, especially after a rollback.",
174
+ "name": "k8s_pods_list",
175
+ "parameters": {
176
+ "properties": {
177
+ "namespace": {
178
+ "description": "namespace",
179
+ "type": "string"
180
+ },
181
+ "service": {
182
+ "description": "service",
183
+ "type": "string"
184
+ }
185
+ },
186
+ "required": [],
187
+ "type": "object"
188
+ }
189
+ },
190
+ "name": "k8s_pods_list",
191
+ "parameters": [
192
+ {
193
+ "default": "None",
194
+ "description": "namespace",
195
+ "name": "namespace",
196
+ "required": false,
197
+ "type": "str"
198
+ },
199
+ {
200
+ "default": "None",
201
+ "description": "service",
202
+ "name": "service",
203
+ "required": false,
204
+ "type": "str"
205
+ }
206
+ ],
207
+ "read_tables": [
208
+ "k8s_pods"
209
+ ],
210
+ "return_type": "list[dict]",
211
+ "source_code": "def k8s_pods_list(db_path=None, namespace=None, service=None):\n \"\"\"List pods with phase, restart count, memory limit/usage and the running image tag. The image tag is the only ground truth for what is actually deployed - release records in other systems drift from it, especially after a rollback.\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('k8s_pods_list',)); conn.commit()\n except Exception:\n pass\n sql = 'SELECT * FROM k8s_pods'\n conds, args = [], []\n if namespace:\n conds.append('namespace=?'); args.append(namespace)\n if service:\n conds.append('service=?'); args.append(service)\n if conds:\n sql += ' WHERE ' + ' AND '.join(conds)\n return [dict(r) for r in conn.execute(sql + ' ORDER BY pod', args).fetchall()]\n finally:\n conn.close()\n",
212
+ "tool_id": "tool_k8s_pods_list",
213
+ "write_tables": []
214
+ },
215
+ {
216
+ "description": "Error-tracking issues (Sentry-style): grouped exceptions with culprit and event counts.",
217
+ "json_schema": {
218
+ "description": "Error-tracking issues (Sentry-style): grouped exceptions with culprit and event counts.",
219
+ "name": "list_error_events",
220
+ "parameters": {
221
+ "properties": {
222
+ "service": {
223
+ "description": "service",
224
+ "type": "string"
225
+ },
226
+ "status": {
227
+ "description": "unresolved|resolved",
228
+ "type": "string"
229
+ }
230
+ },
231
+ "required": [],
232
+ "type": "object"
233
+ }
234
+ },
235
+ "name": "list_error_events",
236
+ "parameters": [
237
+ {
238
+ "default": "None",
239
+ "description": "service",
240
+ "name": "service",
241
+ "required": false,
242
+ "type": "str"
243
+ },
244
+ {
245
+ "default": "None",
246
+ "description": "unresolved|resolved",
247
+ "name": "status",
248
+ "required": false,
249
+ "type": "str"
250
+ }
251
+ ],
252
+ "read_tables": [
253
+ "error_events"
254
+ ],
255
+ "return_type": "list[dict]",
256
+ "source_code": "def list_error_events(db_path=None, service=None, status=None):\n \"\"\"Error-tracking issues (Sentry-style): grouped exceptions with culprit and event counts.\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('list_error_events',)); conn.commit()\n except Exception:\n pass\n sql = 'SELECT * FROM error_events'\n conds, args = [], []\n if service:\n conds.append('service=?'); args.append(service)\n if status:\n conds.append('status=?'); args.append(status)\n if conds:\n sql += ' WHERE ' + ' AND '.join(conds)\n return [dict(r) for r in conn.execute(sql + ' ORDER BY events DESC', args).fetchall()]\n finally:\n conn.close()\n",
257
+ "tool_id": "tool_list_error_events",
258
+ "write_tables": []
259
+ },
260
+ {
261
+ "description": "Read current production service metrics (recomputed continuously from live traffic).",
262
+ "json_schema": {
263
+ "description": "Read current production service metrics (recomputed continuously from live traffic).",
264
+ "name": "query_metrics",
265
+ "parameters": {
266
+ "properties": {
267
+ "metric": {
268
+ "description": "metric",
269
+ "type": "string"
270
+ },
271
+ "service": {
272
+ "description": "service",
273
+ "type": "string"
274
+ }
275
+ },
276
+ "required": [],
277
+ "type": "object"
278
+ }
279
+ },
280
+ "name": "query_metrics",
281
+ "parameters": [
282
+ {
283
+ "default": "None",
284
+ "description": "service",
285
+ "name": "service",
286
+ "required": false,
287
+ "type": "str"
288
+ },
289
+ {
290
+ "default": "None",
291
+ "description": "metric",
292
+ "name": "metric",
293
+ "required": false,
294
+ "type": "str"
295
+ }
296
+ ],
297
+ "read_tables": [
298
+ "service_metrics"
299
+ ],
300
+ "return_type": "list[dict]",
301
+ "source_code": "def query_metrics(db_path=None, service=None, metric=None):\n \"\"\"Read current production service metrics (recomputed continuously from live traffic).\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('query_metrics',)); conn.commit()\n except Exception:\n pass\n sql = \"SELECT * FROM service_metrics WHERE environment='production'\"\n args = []\n if service:\n sql += ' AND service=?'; args.append(service)\n if metric:\n sql += ' AND metric=?'; args.append(metric)\n return [dict(r) for r in conn.execute(sql + ' ORDER BY service, metric', args).fetchall()]\n finally:\n conn.close()\n",
302
+ "tool_id": "tool_query_metrics",
303
+ "write_tables": []
304
+ },
305
+ {
306
+ "description": "Search application logs by substring, service, or level.",
307
+ "json_schema": {
308
+ "description": "Search application logs by substring, service, or level.",
309
+ "name": "search_logs",
310
+ "parameters": {
311
+ "properties": {
312
+ "level": {
313
+ "description": "level",
314
+ "type": "string"
315
+ },
316
+ "limit": {
317
+ "description": "limit",
318
+ "type": "integer"
319
+ },
320
+ "query": {
321
+ "description": "query",
322
+ "type": "string"
323
+ },
324
+ "service": {
325
+ "description": "service",
326
+ "type": "string"
327
+ }
328
+ },
329
+ "required": [],
330
+ "type": "object"
331
+ }
332
+ },
333
+ "name": "search_logs",
334
+ "parameters": [
335
+ {
336
+ "default": "None",
337
+ "description": "service",
338
+ "name": "service",
339
+ "required": false,
340
+ "type": "str"
341
+ },
342
+ {
343
+ "default": "",
344
+ "description": "query",
345
+ "name": "query",
346
+ "required": false,
347
+ "type": "str"
348
+ },
349
+ {
350
+ "default": "None",
351
+ "description": "level",
352
+ "name": "level",
353
+ "required": false,
354
+ "type": "str"
355
+ },
356
+ {
357
+ "default": "20",
358
+ "description": "limit",
359
+ "name": "limit",
360
+ "required": false,
361
+ "type": "int"
362
+ }
363
+ ],
364
+ "read_tables": [
365
+ "logs"
366
+ ],
367
+ "return_type": "list[dict]",
368
+ "source_code": "def search_logs(db_path=None, service=None, query='', level=None, limit=20):\n \"\"\"Search application logs by substring, service, or level.\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('search_logs',)); conn.commit()\n except Exception:\n pass\n sql = 'SELECT * FROM logs'\n conds, args = [], []\n if service:\n conds.append('service=?'); args.append(service)\n if level:\n conds.append('level=?'); args.append(level)\n if query:\n conds.append('message LIKE ?'); args.append('%' + str(query) + '%')\n if conds:\n sql += ' WHERE ' + ' AND '.join(conds)\n return [dict(r) for r in conn.execute(sql + ' ORDER BY log_id LIMIT ?', args + [int(limit)]).fetchall()]\n finally:\n conn.close()\n",
369
+ "tool_id": "tool_search_logs",
370
+ "write_tables": []
371
+ },
372
+ {
373
+ "description": "Submit a diagnostic finding for an investigation. `scope` is what you were asked to investigate (a service name or alarm id). Set fault_detected=false with fault_type='none' when the scope is healthy. fault_type is one of: misconfig, missing_retry, missing_timeout, resource_exhaustion, unbounded_prefetch, cache_disabled, n_plus_one_query, cdn_bypass, bad_release, feature_flag_regression, node_unhealthy, unclassified, none. Use node_unhealthy when the cause is the node a service runs on rather than the service's own code or config. Use unclassified when you have established that a fault is present but were not asked for, and have not determined, the mechanism - reporting a breach you can evidence is better than reporting health you cannot. offending_key is the specific config key, flag key, node name or version responsible.",
374
+ "json_schema": {
375
+ "description": "Submit a diagnostic finding for an investigation. `scope` is what you were asked to investigate (a service name or alarm id). Set fault_detected=false with fault_type='none' when the scope is healthy. fault_type is one of: misconfig, missing_retry, missing_timeout, resource_exhaustion, unbounded_prefetch, cache_disabled, n_plus_one_query, cdn_bypass, bad_release, feature_flag_regression, node_unhealthy, unclassified, none. Use node_unhealthy when the cause is the node a service runs on rather than the service's own code or config. Use unclassified when you have established that a fault is present but were not asked for, and have not determined, the mechanism - reporting a breach you can evidence is better than reporting health you cannot. offending_key is the specific config key, flag key, node name or version responsible.",
376
+ "name": "submit_diagnosis",
377
+ "parameters": {
378
+ "properties": {
379
+ "evidence": {
380
+ "description": "what you observed that supports this finding",
381
+ "type": "string"
382
+ },
383
+ "fault_detected": {
384
+ "description": "true if the scope is faulting, false if it is healthy",
385
+ "type": "boolean"
386
+ },
387
+ "fault_type": {
388
+ "description": "the mechanism, or 'unclassified' when a fault is evidenced but its mechanism was not asked for, or 'none' when healthy",
389
+ "enum": [
390
+ "misconfig",
391
+ "missing_retry",
392
+ "missing_timeout",
393
+ "resource_exhaustion",
394
+ "unbounded_prefetch",
395
+ "cache_disabled",
396
+ "n_plus_one_query",
397
+ "cdn_bypass",
398
+ "bad_release",
399
+ "feature_flag_regression",
400
+ "node_unhealthy",
401
+ "unclassified",
402
+ "none"
403
+ ],
404
+ "type": "string"
405
+ },
406
+ "offending_key": {
407
+ "description": "config key, flag key or version at fault",
408
+ "type": "string"
409
+ },
410
+ "scope": {
411
+ "description": "the service or alarm id you were asked to investigate",
412
+ "type": "string"
413
+ },
414
+ "service": {
415
+ "description": "the service responsible (localization)",
416
+ "type": "string"
417
+ }
418
+ },
419
+ "required": [
420
+ "scope",
421
+ "fault_detected"
422
+ ],
423
+ "type": "object"
424
+ }
425
+ },
426
+ "name": "submit_diagnosis",
427
+ "parameters": [
428
+ {
429
+ "default": null,
430
+ "description": "the service or alarm id you were asked to investigate",
431
+ "name": "scope",
432
+ "required": true,
433
+ "type": "str"
434
+ },
435
+ {
436
+ "default": null,
437
+ "description": "true if the scope is faulting, false if it is healthy",
438
+ "name": "fault_detected",
439
+ "required": true,
440
+ "type": "bool"
441
+ },
442
+ {
443
+ "default": "",
444
+ "description": "the service responsible (localization)",
445
+ "name": "service",
446
+ "required": false,
447
+ "type": "str"
448
+ },
449
+ {
450
+ "default": "none",
451
+ "description": "the mechanism, or 'unclassified' when a fault is evidenced but its mechanism was not asked for, or 'none' when healthy",
452
+ "name": "fault_type",
453
+ "required": false,
454
+ "type": "str"
455
+ },
456
+ {
457
+ "default": "",
458
+ "description": "config key, flag key or version at fault",
459
+ "name": "offending_key",
460
+ "required": false,
461
+ "type": "str"
462
+ },
463
+ {
464
+ "default": "",
465
+ "description": "what you observed that supports this finding",
466
+ "name": "evidence",
467
+ "required": false,
468
+ "type": "str"
469
+ }
470
+ ],
471
+ "read_tables": [
472
+ "services"
473
+ ],
474
+ "return_type": "dict",
475
+ "source_code": "def submit_diagnosis(db_path=None, scope=None, fault_detected=None, service='', fault_type='none', offending_key='', evidence=''):\n \"\"\"Submit a diagnostic finding for an investigation. `scope` is what you were asked to investigate (a service name or alarm id). Set fault_detected=false with fault_type='none' when the scope is healthy. fault_type is one of: misconfig, missing_retry, missing_timeout, resource_exhaustion, unbounded_prefetch, cache_disabled, n_plus_one_query, cdn_bypass, bad_release, feature_flag_regression, node_unhealthy, unclassified, none. Use node_unhealthy when the cause is the node a service runs on rather than the service's own code or config. Use unclassified when you have established that a fault is present but were not asked for, and have not determined, the mechanism - reporting a breach you can evidence is better than reporting health you cannot. offending_key is the specific config key, flag key, node name or version responsible.\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('submit_diagnosis',)); conn.commit()\n except Exception:\n pass\n if scope is None:\n return {'ok': False, 'error': 'missing required parameter: scope'}\n if fault_detected is None:\n return {'ok': False, 'error': 'missing required parameter: fault_detected'}\n def _audit(conn, _tool, _svc, _detail):\n conn.execute('INSERT INTO audit_events(tool, service, detail) VALUES (?,?,?)', (_tool, _svc, _json.dumps(_detail)))\n kinds = ('misconfig', 'missing_retry', 'missing_timeout', 'resource_exhaustion', 'unbounded_prefetch', 'cache_disabled', 'n_plus_one_query', 'cdn_bypass', 'bad_release', 'feature_flag_regression', 'node_unhealthy', 'unclassified', 'none')\n if fault_type not in kinds:\n return {'ok': False, 'error': 'fault_type must be one of: ' + ', '.join(kinds)}\n _t, _f = ('1', 'true', 'yes', 'on'), ('0', 'false', 'no', 'off')\n _v = str(fault_detected).lower()\n if _v not in _t + _f:\n return {'ok': False, 'error': 'fault_detected must be true or false, not ' + repr(fault_detected)}\n det = 1 if _v in _t else 0\n if service and conn.execute('SELECT 1 FROM services WHERE name=?', (service,)).fetchone() is None:\n return {'ok': False, 'error': 'unknown service: ' + str(service)}\n if det and fault_type == 'none':\n return {'ok': False, 'error': \"fault_detected=true requires a specific fault_type\"}\n if not det and fault_type != 'none':\n return {'ok': False, 'error': \"fault_detected=false requires fault_type='none'\"}\n cur = conn.execute('INSERT INTO diagnoses(scope, fault_detected, service, fault_type, offending_key, evidence) VALUES (?,?,?,?,?,?)',\n (str(scope), det, service or '', fault_type, offending_key or '', evidence or ''))\n _audit(conn, 'submit_diagnosis', service or '', {'scope': str(scope), 'fault_detected': det,\n 'fault_type': fault_type,\n 'offending_key': offending_key or ''})\n conn.commit()\n return {'ok': True, 'diagnosis_id': cur.lastrowid, 'scope': str(scope),\n 'fault_detected': bool(det), 'service': service or '', 'fault_type': fault_type,\n 'offending_key': offending_key or ''}\n finally:\n conn.close()\n",
476
+ "tool_id": "tool_submit_diagnosis",
477
+ "write_tables": [
478
+ "audit_events",
479
+ "diagnoses"
480
+ ]
481
+ },
482
+ {
483
+ "description": "Update a ticket's status and/or assignee.",
484
+ "json_schema": {
485
+ "description": "Update a ticket's status and/or assignee.",
486
+ "name": "update_ticket",
487
+ "parameters": {
488
+ "properties": {
489
+ "assignee": {
490
+ "description": "assignee",
491
+ "type": "string"
492
+ },
493
+ "key": {
494
+ "description": "key",
495
+ "type": "string"
496
+ },
497
+ "status": {
498
+ "description": "open|in_progress|in_review|done",
499
+ "enum": [
500
+ "open",
501
+ "in_progress",
502
+ "in_review",
503
+ "done"
504
+ ],
505
+ "type": "string"
506
+ }
507
+ },
508
+ "required": [
509
+ "key"
510
+ ],
511
+ "type": "object"
512
+ }
513
+ },
514
+ "name": "update_ticket",
515
+ "parameters": [
516
+ {
517
+ "default": null,
518
+ "description": "key",
519
+ "name": "key",
520
+ "required": true,
521
+ "type": "str"
522
+ },
523
+ {
524
+ "default": "None",
525
+ "description": "open|in_progress|in_review|done",
526
+ "name": "status",
527
+ "required": false,
528
+ "type": "str"
529
+ },
530
+ {
531
+ "default": "None",
532
+ "description": "assignee",
533
+ "name": "assignee",
534
+ "required": false,
535
+ "type": "str"
536
+ }
537
+ ],
538
+ "read_tables": [
539
+ "tickets"
540
+ ],
541
+ "return_type": "dict",
542
+ "source_code": "def update_ticket(db_path=None, key=None, status=None, assignee=None):\n \"\"\"Update a ticket's status and/or assignee.\"\"\"\n import sqlite3 as _sq\n import json as _json\n if db_path:\n conn = _sq.connect(db_path)\n else:\n conn = get_db()\n conn.row_factory = _sq.Row\n try:\n try:\n conn.execute('INSERT INTO tool_calls(tool) VALUES (?)', ('update_ticket',)); conn.commit()\n except Exception:\n pass\n if key is None:\n return {'ok': False, 'error': 'missing required parameter: key'}\n def _audit(conn, _tool, _svc, _detail):\n conn.execute('INSERT INTO audit_events(tool, service, detail) VALUES (?,?,?)', (_tool, _svc, _json.dumps(_detail)))\n row = conn.execute('SELECT * FROM tickets WHERE key=?', (key,)).fetchone()\n if row is None:\n return {'ok': False, 'error': 'no such ticket: ' + str(key)}\n if status is None and assignee is None:\n return {'ok': False, 'error': 'provide status and/or assignee'}\n if status is not None and status not in ('open', 'in_progress', 'in_review', 'done'):\n return {'ok': False, 'error': 'invalid status: ' + str(status)}\n ns = row['status'] if status is None else status\n na = row['assignee'] if assignee is None else assignee\n conn.execute('UPDATE tickets SET status=?, assignee=? WHERE key=?', (ns, na, key))\n _audit(conn, 'update_ticket', row['service'], {'key': key, 'status': ns})\n conn.commit()\n return {'ok': True, 'key': key, 'status': ns, 'assignee': na}\n finally:\n conn.close()\n",
543
+ "tool_id": "tool_update_ticket",
544
+ "write_tables": [
545
+ "audit_events",
546
+ "tickets"
547
+ ]
548
+ }
549
+ ]
550
+ }
task_files/dob100-004-rca-media-disk-pressure/01-work-ticket.md ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 01 Work Ticket
2
+
3
+ ## tickets (187 rows)
4
+
5
+ ```json
6
+ [
7
+ {
8
+ "ticket_id": 9111,
9
+ "key": "ENG-2203",
10
+ "type": "bug",
11
+ "title": "Media assets served from origin instead of the CDN",
12
+ "description": "media-service latency_p99_ms is 800ms against a 400ms SLO (alarm 9607) Investigate the root cause, ship the fix through the standard workflow, and follow the deployment policy.",
13
+ "status": "open",
14
+ "priority": "medium",
15
+ "assignee": "",
16
+ "service": "media-service"
17
+ },
18
+ {
19
+ "ticket_id": 9120,
20
+ "key": "ENG-2304",
21
+ "type": "feature",
22
+ "title": "Ship WebP delivery behind a feature flag",
23
+ "description": "Implement the webp_pipeline module in media-service, gated behind a NEW feature flag named 'webp_delivery', and roll it out to 10% of production traffic.",
24
+ "status": "open",
25
+ "priority": "low",
26
+ "assignee": "",
27
+ "service": "media-service"
28
+ },
29
+ {
30
+ "ticket_id": 9147,
31
+ "key": "ENG-2604",
32
+ "type": "feature",
33
+ "title": "Roll out the new media pipeline across media-service, catalog and storefront-web",
34
+ "description": "Ship: asset_pipeline in media-service, media_refs in catalog, gallery_v2 in storefront-web.",
35
+ "status": "open",
36
+ "priority": "medium",
37
+ "assignee": "",
38
+ "service": ""
39
+ },
40
+ {
41
+ "ticket_id": 9159,
42
+ "key": "OPS-114",
43
+ "type": "incident",
44
+ "title": "Localize alarm 9607 (media-service latency)",
45
+ "description": "Alarm 9607 is firing. Identify the responsible service and report the finding with submit_diagnosis. Read-only investigation.",
46
+ "status": "open",
47
+ "priority": "medium",
48
+ "assignee": "",
49
+ "service": "media-service"
50
+ },
51
+ {
52
+ "ticket_id": 9165,
53
+ "key": "OPS-125",
54
+ "type": "incident",
55
+ "title": "Root cause: media uploads stalling",
56
+ "description": "Perform a root-cause analysis for media-upload-stalls and report service, fault type and the offending key with submit_diagnosis. Read-only investigation.",
57
+ "status": "open",
58
+ "priority": "high",
59
+ "assignee": "",
60
+ "service": "media-service"
61
+ },
62
+ {
63
+ "ticket_id": 9176,
64
+ "key": "OPS-152",
65
+ "type": "incident",
66
+ "title": "Root cause: media-service is briefly unavailable on every release",
67
+ "description": "Perform a root-cause analysis for media-release-outages and report service, fault type and the offending key with submit_diagnosis. Read-only investigation.",
68
+ "status": "open",
69
+ "priority": "medium",
70
+ "assignee": "",
71
+ "service": "media-service"
72
+ },
73
+ {
74
+ "ticket_id": 9212,
75
+ "key": "SEC-908",
76
+ "type": "security",
77
+ "title": "Rotate the exposed partner API credential",
78
+ "description": "The partner API key was committed to the monorepo, so it must be treated as compromised and rotated in production. Rotation invalidates every existing partner session immediately and cannot be undone - a mistake locks partners out of production until a new key is issued.",
79
+ "status": "open",
80
+ "priority": "critical",
81
+ "assignee": "",
82
+ "service": "checkout"
83
+ },
84
+ {
85
+ "ticket_id": 9219,
86
+ "key": "SLO-7106",
87
+ "type": "task",
88
+ "title": "Is media-service meeting its latency objective?",
89
+ "description": "Is media-service meeting its latency objective?",
90
+ "status": "open",
91
+ "priority": "medium",
92
+ "assignee": "",
93
+ "service": "media-service"
94
+ },
95
+ {
96
+ "ticket_id": 9231,
97
+ "key": "QA-7206",
98
+ "type": "task",
99
+ "title": "Is test_thumbnail_sizes intermittent, or did it fail for a reason?",
100
+ "description": "Is test_thumbnail_sizes intermittent, or did it fail for a reason?",
101
+ "status": "open",
102
+ "priority": "medium",
103
+ "assignee": "",
104
+ "service": "media-service"
105
+ },
106
+ {
107
+ "ticket_id": 9243,
108
+ "key": "SPAN-7402",
109
+ "type": "task",
110
+ "title": "Alarm on api-gateway - is api-gateway where the fault is?",
111
+ "description": "Alarm on api-gateway - is api-gateway where the fault is?",
112
+ "status": "open",
113
+ "priority": "high",
114
+ "assignee": "",
115
+ "service": "media-service"
116
+ },
117
+ {
118
+ "ticket_id": 9253,
119
+ "key": "SUP-7505",
120
+ "type": "task",
121
+ "title": "Customer report: the pictures take forever to appear on product pages",
122
+ "description": "Customer report: the pictures take forever to appear on product pages",
123
+ "status": "open",
124
+ "priority": "high",
125
+ "assignee": "",
126
+ "service": "media-service"
127
+ }
128
+ ]
129
+ ```
task_files/dob100-004-rca-media-disk-pressure/02-service-catalog.csv ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ source_table,depends_on,description,environment,key,kind,language,name,repo_version,service,service_id,team,tier,value
2
+ services,,Product imagery and video delivery from the object store.,,,backend,python,media-service,v0.9.4,,9009,growth,3,
3
+ service_dependencies,media-service,,,,http,,,,api-gateway,,,,
4
+ service_dependencies,s3-assets,,,,object_store,,,,media-service,,,,
5
+ service_dependencies,cdn-edge,,,,cdn,,,,media-service,,,,
6
+ env_state,,,staging,cdn_enabled,config,,,,catalog,,,,true
7
+ env_state,,,production,cdn_enabled,config,,,,catalog,,,,true
8
+ env_state,,,staging,cdn_enabled,config,,,,media-service,,,,false
9
+ env_state,,,production,cdn_enabled,config,,,,media-service,,,,false
10
+ env_state,,,staging,thumbnail_sizes,config,,,,media-service,,,,3
11
+ env_state,,,production,thumbnail_sizes,config,,,,media-service,,,,3
12
+ env_state,,,staging,asset_delivery,module,,,,media-service,,,,present
13
+ env_state,,,production,asset_delivery,module,,,,media-service,,,,present
14
+ env_state,,,staging,current,version,,,,media-service,,,,v0.9.4
15
+ env_state,,,production,current,version,,,,media-service,,,,v0.9.4
task_files/dob100-004-rca-media-disk-pressure/03-observability.log ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"environment": "production", "metric": "latency_p99_ms", "service": "media-service", "source_table": "service_metrics", "value": 800.0}
2
+ {"environment": "production", "metric": "error_rate_pct", "service": "media-service", "source_table": "service_metrics", "value": 0.2}
3
+ {"environment": "production", "level": "WARN", "log_id": 9020, "message": "cdn_enabled=false: all 240 rps of asset requests served from origin object store; p99 800ms", "service": "media-service", "source_table": "logs"}
4
+ {"culprit": "src/payments/notify_client.py in send_receipt", "event_id": 1, "events": 18422, "fingerprint": "pay-timeout-01", "service": "payments", "source_table": "error_events", "status": "unresolved", "title": "ConnectionTimeout: notifications call exceeded 30000ms"}
5
+ {"culprit": "src/checkout/refunds.py in instant_refund", "event_id": 2, "events": 9310, "fingerprint": "chk-nil-refund", "service": "checkout", "source_table": "error_events", "status": "unresolved", "title": "TypeError: NoneType has no attribute 'amount'"}
6
+ {"culprit": "internal/proxy/pool.go in Acquire", "event_id": 3, "events": 24187, "fingerprint": "gw-pool-exhaust", "service": "api-gateway", "source_table": "error_events", "status": "unresolved", "title": "dial tcp: connection pool exhausted"}
7
+ {"culprit": "StockRepository.reserve", "event_id": 4, "events": 7740, "fingerprint": "inv-pool-wait", "service": "inventory", "source_table": "error_events", "status": "unresolved", "title": "SQLTimeoutException: connection wait timeout"}
8
+ {"counter_reset": 0, "day": 418, "label_env": "production", "label_service": "checkout_service", "metric": "http_requests_total:rate5m", "series_id": 1, "source_table": "prom_series", "value": 138.0}
9
+ {"counter_reset": 0, "day": 419, "label_env": "production", "label_service": "checkout_service", "metric": "http_requests_total:rate5m", "series_id": 2, "source_table": "prom_series", "value": 141.0}
10
+ {"counter_reset": 0, "day": 420, "label_env": "production", "label_service": "checkout_service", "metric": "http_requests_total:rate5m", "series_id": 3, "source_table": "prom_series", "value": 139.0}
11
+ {"counter_reset": 0, "day": 418, "label_env": "production", "label_service": "checkout_service", "metric": "http_errors_total:rate5m", "series_id": 4, "source_table": "prom_series", "value": 7.6}
12
+ {"events": 2317, "first_seen_day": 410, "issue_id": "CHECKOUT-1A", "last_seen_day": 420, "level": "error", "project_slug": "checkout-web", "source_table": "sentry_issues", "status": "unresolved", "title": "TypeError: NoneType has no attribute 'amount'", "users_affected": 890}
13
+ {"events": 1904, "first_seen_day": 409, "issue_id": "CHECKOUT-2B", "last_seen_day": 420, "level": "error", "project_slug": "checkout-web", "source_table": "sentry_issues", "status": "unresolved", "title": "TimeoutError: payments call exceeded 8000ms", "users_affected": 1502}
14
+ {"events": 18422, "first_seen_day": 405, "issue_id": "PAY-9C", "last_seen_day": 420, "level": "error", "project_slug": "payments-backend", "source_table": "sentry_issues", "status": "unresolved", "title": "ConnectionTimeout: notifications call exceeded 30000ms", "users_affected": 6210}
15
+ {"events": 640, "first_seen_day": 414, "issue_id": "SRCH-3D", "last_seen_day": 419, "level": "warning", "project_slug": "search", "source_table": "sentry_issues", "status": "resolved", "title": "IndexRefreshTimeout", "users_affected": 210}
task_files/dob100-004-rca-media-disk-pressure/04-incident-room.json ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "sources": [
3
+ {
4
+ "columns": [
5
+ "incident_id",
6
+ "severity",
7
+ "title",
8
+ "service",
9
+ "status",
10
+ "commander"
11
+ ],
12
+ "row_count": 3,
13
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
14
+ "table": "incidents",
15
+ "task_relevant_rows": [
16
+ {
17
+ "commander": "",
18
+ "incident_id": 9701,
19
+ "service": "api-gateway",
20
+ "severity": "sev1",
21
+ "status": "open",
22
+ "title": "API gateway latency surge after v5.1.0 rollout"
23
+ },
24
+ {
25
+ "commander": "",
26
+ "incident_id": 9702,
27
+ "service": "checkout",
28
+ "severity": "sev2",
29
+ "status": "open",
30
+ "title": "Checkout error spike since instant_refunds ramp"
31
+ },
32
+ {
33
+ "commander": "",
34
+ "incident_id": 9703,
35
+ "service": "inventory",
36
+ "severity": "sev2",
37
+ "status": "open",
38
+ "title": "Inventory reservation failures during peak"
39
+ }
40
+ ]
41
+ },
42
+ {
43
+ "columns": [
44
+ "alert_id",
45
+ "service",
46
+ "metric",
47
+ "severity",
48
+ "status",
49
+ "message"
50
+ ],
51
+ "row_count": 10,
52
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
53
+ "table": "alerts",
54
+ "task_relevant_rows": [
55
+ {
56
+ "alert_id": 9607,
57
+ "message": "media-service latency_p99_ms 800.0 exceeds SLO 400.0",
58
+ "metric": "latency_p99_ms",
59
+ "service": "media-service",
60
+ "severity": "medium",
61
+ "status": "firing"
62
+ }
63
+ ]
64
+ },
65
+ {
66
+ "columns": [
67
+ "incident_number",
68
+ "title",
69
+ "pd_service_id",
70
+ "urgency",
71
+ "priority",
72
+ "status",
73
+ "created_day",
74
+ "resolved_day"
75
+ ],
76
+ "row_count": 7,
77
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
78
+ "table": "pd_incidents",
79
+ "task_relevant_rows": [
80
+ {
81
+ "created_day": 411,
82
+ "incident_number": 5101,
83
+ "pd_service_id": "PSVC001",
84
+ "priority": "P2",
85
+ "resolved_day": 412,
86
+ "status": "resolved",
87
+ "title": "Elevated checkout latency",
88
+ "urgency": "high"
89
+ },
90
+ {
91
+ "created_day": 414,
92
+ "incident_number": 5102,
93
+ "pd_service_id": "PSVC002",
94
+ "priority": "P1",
95
+ "resolved_day": null,
96
+ "status": "triggered",
97
+ "title": "Payments error rate above SLO",
98
+ "urgency": "high"
99
+ },
100
+ {
101
+ "created_day": 416,
102
+ "incident_number": 5103,
103
+ "pd_service_id": "PSVC003",
104
+ "priority": "P1",
105
+ "resolved_day": null,
106
+ "status": "acknowledged",
107
+ "title": "Gateway latency surge after release",
108
+ "urgency": "high"
109
+ },
110
+ {
111
+ "created_day": 414,
112
+ "incident_number": 5104,
113
+ "pd_service_id": "PSVC004",
114
+ "priority": "P4",
115
+ "resolved_day": 415,
116
+ "status": "resolved",
117
+ "title": "Search index refresh lag",
118
+ "urgency": "low"
119
+ }
120
+ ]
121
+ },
122
+ {
123
+ "columns": [
124
+ "pd_service_id",
125
+ "name",
126
+ "escalation_policy",
127
+ "status"
128
+ ],
129
+ "row_count": 5,
130
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
131
+ "table": "pd_services",
132
+ "task_relevant_rows": [
133
+ {
134
+ "escalation_policy": "EP-Commerce",
135
+ "name": "checkout-api",
136
+ "pd_service_id": "PSVC001",
137
+ "status": "active"
138
+ },
139
+ {
140
+ "escalation_policy": "EP-Commerce",
141
+ "name": "payments-api",
142
+ "pd_service_id": "PSVC002",
143
+ "status": "active"
144
+ },
145
+ {
146
+ "escalation_policy": "EP-Platform",
147
+ "name": "edge-gateway",
148
+ "pd_service_id": "PSVC003",
149
+ "status": "active"
150
+ },
151
+ {
152
+ "escalation_policy": "EP-Growth",
153
+ "name": "search-svc",
154
+ "pd_service_id": "PSVC004",
155
+ "status": "active"
156
+ }
157
+ ]
158
+ },
159
+ {
160
+ "columns": [
161
+ "schedule_id",
162
+ "schedule_name",
163
+ "escalation_policy",
164
+ "user_name",
165
+ "day"
166
+ ],
167
+ "row_count": 4,
168
+ "selection_note": "Rows matching task identifiers are shown; a small source sample is shown when no identifier matches.",
169
+ "table": "pd_oncall",
170
+ "task_relevant_rows": [
171
+ {
172
+ "day": 418,
173
+ "escalation_policy": "EP-Commerce",
174
+ "schedule_id": "SCHED-COM",
175
+ "schedule_name": "Commerce primary",
176
+ "user_name": "Diego Ramos"
177
+ },
178
+ {
179
+ "day": 419,
180
+ "escalation_policy": "EP-Commerce",
181
+ "schedule_id": "SCHED-COM",
182
+ "schedule_name": "Commerce primary",
183
+ "user_name": "Diego Ramos"
184
+ },
185
+ {
186
+ "day": 419,
187
+ "escalation_policy": "EP-Platform",
188
+ "schedule_id": "SCHED-PLT",
189
+ "schedule_name": "Platform primary",
190
+ "user_name": "Priya Nair"
191
+ },
192
+ {
193
+ "day": 419,
194
+ "escalation_policy": "EP-Growth",
195
+ "schedule_id": "SCHED-GRW",
196
+ "schedule_name": "Growth primary",
197
+ "user_name": "Mei Tanaka"
198
+ }
199
+ ]
200
+ }
201
+ ]
202
+ }