Release FlowBench v3 public split (part 7)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- harbor/tasks/v3_depth6_delay_sla_burden_t10/tests/check_output_shape.py +42 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t10/tests/test.sh +3 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t11/environment/Dockerfile +4 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t11/environment/flowbench_tools.py +311 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t11/environment/task.json +13 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t11/instruction.md +38 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t11/task.toml +28 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t11/tests/check_output_shape.py +42 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t11/tests/test.sh +3 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t12/environment/Dockerfile +4 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t12/environment/flowbench_tools.py +311 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t12/environment/task.json +13 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t12/instruction.md +38 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t12/task.toml +28 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t12/tests/check_output_shape.py +42 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t12/tests/test.sh +3 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t13/environment/Dockerfile +4 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t13/environment/flowbench_tools.py +311 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t13/environment/task.json +13 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t13/instruction.md +38 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t13/task.toml +28 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t13/tests/check_output_shape.py +42 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t13/tests/test.sh +3 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t14/environment/Dockerfile +4 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t14/environment/flowbench_tools.py +311 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t14/environment/task.json +13 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t14/instruction.md +38 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t14/task.toml +28 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t14/tests/check_output_shape.py +42 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t14/tests/test.sh +3 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t15/environment/Dockerfile +4 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t15/environment/flowbench_tools.py +311 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t15/environment/task.json +13 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t15/instruction.md +38 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t15/task.toml +28 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t15/tests/check_output_shape.py +42 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t15/tests/test.sh +3 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t16/environment/Dockerfile +4 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t16/environment/flowbench_tools.py +311 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t16/environment/task.json +13 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t16/instruction.md +38 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t16/task.toml +28 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t16/tests/check_output_shape.py +42 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t16/tests/test.sh +3 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t17/environment/Dockerfile +4 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t17/environment/flowbench_tools.py +311 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t17/environment/task.json +13 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t17/instruction.md +38 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t17/task.toml +28 -0
- harbor/tasks/v3_depth6_delay_sla_burden_t17/tests/check_output_shape.py +42 -0
harbor/tasks/v3_depth6_delay_sla_burden_t10/tests/check_output_shape.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
import re
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def write_reward(score: float, diagnostic: str) -> None:
|
| 11 |
+
log_dir = Path(os.environ.get("LOG_DIR", "/logs/verifier"))
|
| 12 |
+
log_dir.mkdir(parents=True, exist_ok=True)
|
| 13 |
+
(log_dir / "reward.txt").write_text(f"{score:.6g}\n")
|
| 14 |
+
(log_dir / "reward.json").write_text(
|
| 15 |
+
json.dumps({"reward": score, "smoke_only": True}, indent=2) + "\n"
|
| 16 |
+
)
|
| 17 |
+
(log_dir / "diagnostic.txt").write_text(diagnostic + "\n")
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def main() -> int:
|
| 21 |
+
app_dir = Path(os.environ.get("APP_DIR", "/app"))
|
| 22 |
+
task = json.loads((app_dir / "task.json").read_text())
|
| 23 |
+
answer_path = app_dir / "answer.txt"
|
| 24 |
+
if not answer_path.exists():
|
| 25 |
+
write_reward(0.0, "missing /app/answer.txt")
|
| 26 |
+
return 1
|
| 27 |
+
|
| 28 |
+
got = answer_path.read_text().strip()
|
| 29 |
+
if task["answer_format"] == "exact integer":
|
| 30 |
+
ok = bool(re.fullmatch(r"-?\d+", got))
|
| 31 |
+
diagnostic = "valid integer smoke output" if ok else f"not an exact integer: {got!r}"
|
| 32 |
+
else:
|
| 33 |
+
ok = bool(re.fullmatch(r"[A-Za-z]+", got))
|
| 34 |
+
diagnostic = "valid code smoke output" if ok else f"not an exact code: {got!r}"
|
| 35 |
+
|
| 36 |
+
# This is intentionally not official scoring; it only verifies I/O shape.
|
| 37 |
+
write_reward(1.0 if ok else 0.0, diagnostic)
|
| 38 |
+
return 0 if ok else 1
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
if __name__ == "__main__":
|
| 42 |
+
raise SystemExit(main())
|
harbor/tasks/v3_depth6_delay_sla_burden_t10/tests/test.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -u
|
| 3 |
+
python /tests/check_output_shape.py
|
harbor/tasks/v3_depth6_delay_sla_burden_t11/environment/Dockerfile
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.12-slim
|
| 2 |
+
WORKDIR /app
|
| 3 |
+
COPY flowbench_tools.py /app/flowbench_tools.py
|
| 4 |
+
COPY task.json /app/task.json
|
harbor/tasks/v3_depth6_delay_sla_burden_t11/environment/flowbench_tools.py
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Deterministic FlowBench v3 tools. This file contains no task answers."""
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
REGIONS = ["NA", "EU", "APAC", "LATAM"]
|
| 5 |
+
CATEGORIES = ["A", "B", "C", "D"]
|
| 6 |
+
CURRENCIES = {"NA": "USD", "EU": "EUR", "APAC": "JPY", "LATAM": "BRL"}
|
| 7 |
+
FX_TO_USD_BP = {"USD": 10000, "EUR": 10900, "JPY": 67, "BRL": 1850}
|
| 8 |
+
TIERS = ["std", "gold", "plat"]
|
| 9 |
+
DISCOUNT_PCT = {"std": 0, "gold": 10, "plat": 20}
|
| 10 |
+
CHANNELS = ["web", "store", "partner"]
|
| 11 |
+
MONTHS = [202601, 202602, 202603, 202604, 202605, 202606]
|
| 12 |
+
|
| 13 |
+
N_CUSTOMERS = 72
|
| 14 |
+
N_PRODUCTS = 48
|
| 15 |
+
N_ORDERS = 720
|
| 16 |
+
N_TICKETS = 260
|
| 17 |
+
N_RETURNS = 180
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def _h(*xs):
|
| 21 |
+
import hashlib
|
| 22 |
+
s = "|".join(str(x) for x in xs).encode()
|
| 23 |
+
return int.from_bytes(hashlib.sha256(s).digest()[:8], "big") & 0x7FFFFFFF
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def build_data():
|
| 27 |
+
customers = []
|
| 28 |
+
for cid in range(N_CUSTOMERS):
|
| 29 |
+
region = REGIONS[_h("region", cid) % len(REGIONS)]
|
| 30 |
+
customers.append({
|
| 31 |
+
"customer_id": cid,
|
| 32 |
+
"region": region,
|
| 33 |
+
"tier": TIERS[_h("tier", cid) % len(TIERS)],
|
| 34 |
+
"segment": ["consumer", "smb", "enterprise"][_h("segment", cid) % 3],
|
| 35 |
+
})
|
| 36 |
+
|
| 37 |
+
products = []
|
| 38 |
+
for pid in range(N_PRODUCTS):
|
| 39 |
+
cat = CATEGORIES[_h("cat", pid) % len(CATEGORIES)]
|
| 40 |
+
unit_price = 12 + _h("price", pid) % 240
|
| 41 |
+
cogs = unit_price * (45 + _h("margin", pid) % 35) // 100
|
| 42 |
+
products.append({
|
| 43 |
+
"product_id": pid,
|
| 44 |
+
"category": cat,
|
| 45 |
+
"unit_price_usd": unit_price,
|
| 46 |
+
"unit_cogs_usd": cogs,
|
| 47 |
+
"lead_time_days": 3 + _h("lead", pid) % 18,
|
| 48 |
+
})
|
| 49 |
+
|
| 50 |
+
inventory = []
|
| 51 |
+
for pid in range(N_PRODUCTS):
|
| 52 |
+
for region in REGIONS:
|
| 53 |
+
inventory.append({
|
| 54 |
+
"product_id": pid,
|
| 55 |
+
"region": region,
|
| 56 |
+
"on_hand": 10 + _h("onhand", pid, region) % 140,
|
| 57 |
+
"reserved": _h("reserved", pid, region) % 28,
|
| 58 |
+
"inbound": _h("inbound", pid, region) % 85,
|
| 59 |
+
})
|
| 60 |
+
|
| 61 |
+
orders = []
|
| 62 |
+
for oid in range(N_ORDERS):
|
| 63 |
+
customer_id = _h("ocust", oid) % N_CUSTOMERS
|
| 64 |
+
product_id = _h("oprod", oid) % N_PRODUCTS
|
| 65 |
+
month = MONTHS[_h("month", oid) % len(MONTHS)]
|
| 66 |
+
qty = 1 + _h("qty", oid) % 9
|
| 67 |
+
ship_days = 1 + _h("shipdays", oid) % 16
|
| 68 |
+
promised_days = 3 + _h("promise", oid) % 9
|
| 69 |
+
status = ["paid", "paid", "paid", "paid", "cancelled", "refunded"][
|
| 70 |
+
_h("status", oid) % 6]
|
| 71 |
+
orders.append({
|
| 72 |
+
"order_id": oid,
|
| 73 |
+
"customer_id": customer_id,
|
| 74 |
+
"product_id": product_id,
|
| 75 |
+
"month": month,
|
| 76 |
+
"qty": qty,
|
| 77 |
+
"status": status,
|
| 78 |
+
"channel": CHANNELS[_h("channel", oid) % len(CHANNELS)],
|
| 79 |
+
"ship_days": ship_days,
|
| 80 |
+
"promised_days": promised_days,
|
| 81 |
+
})
|
| 82 |
+
|
| 83 |
+
returns = []
|
| 84 |
+
for rid in range(N_RETURNS):
|
| 85 |
+
oid = _h("roid", rid) % N_ORDERS
|
| 86 |
+
order = orders[oid]
|
| 87 |
+
if order["status"] == "cancelled":
|
| 88 |
+
continue
|
| 89 |
+
returned_qty = 1 + _h("rqty", rid) % max(1, order["qty"])
|
| 90 |
+
reason = ["defect", "late", "changed_mind", "wrong_item"][_h("reason", rid) % 4]
|
| 91 |
+
returns.append({
|
| 92 |
+
"return_id": rid,
|
| 93 |
+
"order_id": oid,
|
| 94 |
+
"month": MONTHS[_h("rmonth", rid) % len(MONTHS)],
|
| 95 |
+
"returned_qty": returned_qty,
|
| 96 |
+
"reason": reason,
|
| 97 |
+
})
|
| 98 |
+
|
| 99 |
+
tickets = []
|
| 100 |
+
for tid in range(N_TICKETS):
|
| 101 |
+
oid = _h("toid", tid) % N_ORDERS
|
| 102 |
+
severity = ["low", "medium", "high", "critical"][_h("sev", tid) % 4]
|
| 103 |
+
opened = MONTHS[_h("tmonth", tid) % len(MONTHS)]
|
| 104 |
+
first_response_hours = 1 + _h("resp", tid) % 96
|
| 105 |
+
resolution_hours = first_response_hours + _h("res", tid) % 240
|
| 106 |
+
tickets.append({
|
| 107 |
+
"ticket_id": tid,
|
| 108 |
+
"order_id": oid,
|
| 109 |
+
"opened_month": opened,
|
| 110 |
+
"severity": severity,
|
| 111 |
+
"first_response_hours": first_response_hours,
|
| 112 |
+
"resolution_hours": resolution_hours,
|
| 113 |
+
})
|
| 114 |
+
|
| 115 |
+
return {
|
| 116 |
+
"customers": customers,
|
| 117 |
+
"products": products,
|
| 118 |
+
"inventory": inventory,
|
| 119 |
+
"orders": orders,
|
| 120 |
+
"returns": returns,
|
| 121 |
+
"tickets": tickets,
|
| 122 |
+
"fx_to_usd_bp": FX_TO_USD_BP,
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
DATA = build_data()
|
| 127 |
+
CUSTOMERS = {c["customer_id"]: c for c in DATA["customers"]}
|
| 128 |
+
PRODUCTS = {p["product_id"]: p for p in DATA["products"]}
|
| 129 |
+
ORDERS = {o["order_id"]: o for o in DATA["orders"]}
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
def region_currency(region: str) -> str:
|
| 133 |
+
return CURRENCIES[region]
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
def get_orders(region: str, category: str, month_start: int, month_end: int) -> list:
|
| 137 |
+
"""Paid/refunded order ids in a region/category/month window."""
|
| 138 |
+
out = []
|
| 139 |
+
for o in DATA["orders"]:
|
| 140 |
+
if o["status"] not in ("paid", "refunded"):
|
| 141 |
+
continue
|
| 142 |
+
c = CUSTOMERS[o["customer_id"]]
|
| 143 |
+
p = PRODUCTS[o["product_id"]]
|
| 144 |
+
if c["region"] == region and p["category"] == category and month_start <= o["month"] <= month_end:
|
| 145 |
+
out.append(o["order_id"])
|
| 146 |
+
return sorted(out)
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def order_gross_usd(order_id: int) -> int:
|
| 150 |
+
o = ORDERS[order_id]
|
| 151 |
+
p = PRODUCTS[o["product_id"]]
|
| 152 |
+
return o["qty"] * p["unit_price_usd"]
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
def order_margin_usd(order_id: int) -> int:
|
| 156 |
+
o = ORDERS[order_id]
|
| 157 |
+
p = PRODUCTS[o["product_id"]]
|
| 158 |
+
return o["qty"] * (p["unit_price_usd"] - p["unit_cogs_usd"])
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
def refund_usd(order_id: int) -> int:
|
| 162 |
+
o = ORDERS[order_id]
|
| 163 |
+
p = PRODUCTS[o["product_id"]]
|
| 164 |
+
qty = sum(r["returned_qty"] for r in DATA["returns"] if r["order_id"] == order_id)
|
| 165 |
+
qty = min(qty, o["qty"])
|
| 166 |
+
return qty * p["unit_price_usd"]
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def customer_tier(order_id: int) -> str:
|
| 170 |
+
o = ORDERS[order_id]
|
| 171 |
+
return CUSTOMERS[o["customer_id"]]["tier"]
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
def apply_discount(amount_usd: int, tier: str) -> int:
|
| 175 |
+
return amount_usd * (100 - DISCOUNT_PCT[tier]) // 100
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
def net_revenue_usd(order_id: int) -> int:
|
| 179 |
+
gross = apply_discount(order_gross_usd(order_id), customer_tier(order_id))
|
| 180 |
+
return max(0, gross - refund_usd(order_id))
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
def to_local(amount_usd: int, currency: str) -> int:
|
| 184 |
+
return amount_usd * 10000 // FX_TO_USD_BP[currency]
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def inventory_position(product_id: int, region: str) -> int:
|
| 188 |
+
row = next(x for x in DATA["inventory"]
|
| 189 |
+
if x["product_id"] == product_id and x["region"] == region)
|
| 190 |
+
return row["on_hand"] - row["reserved"] + row["inbound"]
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
def product_lead_time(product_id: int) -> int:
|
| 194 |
+
return PRODUCTS[product_id]["lead_time_days"]
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
def product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int:
|
| 198 |
+
totals = {}
|
| 199 |
+
for oid in get_orders(region, category, month_start, month_end):
|
| 200 |
+
o = ORDERS[oid]
|
| 201 |
+
totals[o["product_id"]] = totals.get(o["product_id"], 0) + o["qty"]
|
| 202 |
+
if not totals:
|
| 203 |
+
return -1
|
| 204 |
+
return min((-qty, pid) for pid, qty in totals.items())[1]
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
def units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int:
|
| 208 |
+
total = 0
|
| 209 |
+
for o in DATA["orders"]:
|
| 210 |
+
if o["product_id"] != product_id or o["status"] not in ("paid", "refunded"):
|
| 211 |
+
continue
|
| 212 |
+
c = CUSTOMERS[o["customer_id"]]
|
| 213 |
+
if c["region"] == region and month_start <= o["month"] <= month_end:
|
| 214 |
+
total += o["qty"]
|
| 215 |
+
return total
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def tickets_for_orders(order_ids: list, severity: str) -> list:
|
| 219 |
+
s = set(order_ids)
|
| 220 |
+
return sorted(t["ticket_id"] for t in DATA["tickets"]
|
| 221 |
+
if t["order_id"] in s and t["severity"] == severity)
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
def ticket_order_id(ticket_id: int) -> int:
|
| 225 |
+
return next(t["order_id"] for t in DATA["tickets"] if t["ticket_id"] == ticket_id)
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
def sla_breached(ticket_id: int, first_response_limit_hours: int,
|
| 229 |
+
resolution_limit_hours: int) -> bool:
|
| 230 |
+
t = next(x for x in DATA["tickets"] if x["ticket_id"] == ticket_id)
|
| 231 |
+
return (t["first_response_hours"] > first_response_limit_hours or
|
| 232 |
+
t["resolution_hours"] > resolution_limit_hours)
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
def delayed_orders(order_ids: list) -> list:
|
| 236 |
+
s = set(order_ids)
|
| 237 |
+
return sorted(o["order_id"] for o in DATA["orders"]
|
| 238 |
+
if o["order_id"] in s and o["ship_days"] > o["promised_days"])
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
def unique_customers(order_ids: list) -> list:
|
| 242 |
+
return sorted({ORDERS[oid]["customer_id"] for oid in order_ids})
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
def count_items(values: list) -> int:
|
| 246 |
+
return len(values)
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
def sum_values(values: list) -> int:
|
| 250 |
+
return sum(values)
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
def count_true(values: list) -> int:
|
| 254 |
+
return sum(1 for v in values if bool(v))
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
def count_below(values: list, threshold: int) -> int:
|
| 258 |
+
return sum(1 for v in values if v < threshold)
|
| 259 |
+
|
| 260 |
+
|
| 261 |
+
TOOLS = {
|
| 262 |
+
"region_currency": ("region_currency(region: str) -> str",
|
| 263 |
+
"ISO currency code for a region.", region_currency),
|
| 264 |
+
"get_orders": ("get_orders(region: str, category: str, month_start: int, month_end: int) -> list[int]",
|
| 265 |
+
"Paid/refunded order ids for a region, product category, and inclusive month window.",
|
| 266 |
+
get_orders),
|
| 267 |
+
"order_gross_usd": ("order_gross_usd(order_id: int) -> int",
|
| 268 |
+
"Gross order revenue in USD before discounts/refunds.", order_gross_usd),
|
| 269 |
+
"order_margin_usd": ("order_margin_usd(order_id: int) -> int",
|
| 270 |
+
"Gross order margin in USD before discounts/refunds.", order_margin_usd),
|
| 271 |
+
"refund_usd": ("refund_usd(order_id: int) -> int",
|
| 272 |
+
"Refund amount in USD for returned quantity on an order.", refund_usd),
|
| 273 |
+
"customer_tier": ("customer_tier(order_id: int) -> str",
|
| 274 |
+
"Customer loyalty tier for an order.", customer_tier),
|
| 275 |
+
"apply_discount": ("apply_discount(amount_usd: int, tier: str) -> int",
|
| 276 |
+
"Apply the order customer's loyalty discount to a USD amount.", apply_discount),
|
| 277 |
+
"net_revenue_usd": ("net_revenue_usd(order_id: int) -> int",
|
| 278 |
+
"Net USD revenue after loyalty discount and refunds.", net_revenue_usd),
|
| 279 |
+
"to_local": ("to_local(amount_usd: int, currency: str) -> int",
|
| 280 |
+
"Convert a USD integer amount to a local-currency integer.", to_local),
|
| 281 |
+
"inventory_position": ("inventory_position(product_id: int, region: str) -> int",
|
| 282 |
+
"Available inventory position: on_hand - reserved + inbound.",
|
| 283 |
+
inventory_position),
|
| 284 |
+
"product_lead_time": ("product_lead_time(product_id: int) -> int",
|
| 285 |
+
"Supplier lead time in days for a product.", product_lead_time),
|
| 286 |
+
"product_id_for_top_seller": (
|
| 287 |
+
"product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int",
|
| 288 |
+
"Product id with the highest units sold in a region/category/month window.",
|
| 289 |
+
product_id_for_top_seller),
|
| 290 |
+
"units_sold": ("units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int",
|
| 291 |
+
"Units sold for one product in a region and month window.", units_sold),
|
| 292 |
+
"tickets_for_orders": ("tickets_for_orders(order_ids: list[int], severity: str) -> list[int]",
|
| 293 |
+
"Support ticket ids for given orders and severity.", tickets_for_orders),
|
| 294 |
+
"ticket_order_id": ("ticket_order_id(ticket_id: int) -> int",
|
| 295 |
+
"Order id associated with a support ticket.", ticket_order_id),
|
| 296 |
+
"sla_breached": (
|
| 297 |
+
"sla_breached(ticket_id: int, first_response_limit_hours: int, resolution_limit_hours: int) -> bool",
|
| 298 |
+
"Whether a support ticket breaches first-response or resolution SLA.",
|
| 299 |
+
sla_breached),
|
| 300 |
+
"delayed_orders": ("delayed_orders(order_ids: list[int]) -> list[int]",
|
| 301 |
+
"Subset of order ids whose ship_days exceeded promised_days.", delayed_orders),
|
| 302 |
+
"unique_customers": ("unique_customers(order_ids: list[int]) -> list[int]",
|
| 303 |
+
"Unique customer ids among the given orders.", unique_customers),
|
| 304 |
+
"count_items": ("count_items(values: list) -> int", "Length of a list.", count_items),
|
| 305 |
+
"sum_values": ("sum_values(values: list[int]) -> int", "Sum a list of integers.", sum_values),
|
| 306 |
+
"count_true": ("count_true(values: list[bool]) -> int", "Count true values.", count_true),
|
| 307 |
+
"count_below": ("count_below(values: list[int], threshold: int) -> int",
|
| 308 |
+
"Count values below a threshold.", count_below),
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
__all__ = [name for name in TOOLS.keys()] + ['TOOLS']
|
harbor/tasks/v3_depth6_delay_sla_burden_t11/environment/task.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"task_id": "v3_depth6_delay_sla_burden_t11",
|
| 3 |
+
"depth": 6,
|
| 4 |
+
"family": "delay_sla_burden",
|
| 5 |
+
"params": {
|
| 6 |
+
"region": "LATAM",
|
| 7 |
+
"category": "A",
|
| 8 |
+
"month_start": 202601,
|
| 9 |
+
"month_end": 202603
|
| 10 |
+
},
|
| 11 |
+
"question": "For region LATAM, category A, months 202601-202603: get the orders, count delayed orders where ship_days exceeded promised_days, find high and critical support tickets for those orders, count tickets that breach a 24-hour first-response or 120-hour resolution SLA, and report delayed_order_count + breached_ticket_count.",
|
| 12 |
+
"answer_format": "exact integer"
|
| 13 |
+
}
|
harbor/tasks/v3_depth6_delay_sla_burden_t11/instruction.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FlowBench v3 Public Task
|
| 2 |
+
|
| 3 |
+
You are in `/app`. The file `/app/flowbench_tools.py` contains deterministic
|
| 4 |
+
Python tools over a synthetic business-operations dataset. Use those tools
|
| 5 |
+
to compute the requested value, then write the final output to
|
| 6 |
+
`/app/answer.txt`.
|
| 7 |
+
|
| 8 |
+
Required output:
|
| 9 |
+
- `/app/answer.txt` must contain only the exact integer.
|
| 10 |
+
- Use integer arithmetic for currency and counts. Do not use floating point
|
| 11 |
+
arithmetic.
|
| 12 |
+
|
| 13 |
+
Task:
|
| 14 |
+
For region LATAM, category A, months 202601-202603: get the orders, count delayed orders where ship_days exceeded promised_days, find high and critical support tickets for those orders, count tickets that breach a 24-hour first-response or 120-hour resolution SLA, and report delayed_order_count + breached_ticket_count.
|
| 15 |
+
|
| 16 |
+
Available tools:
|
| 17 |
+
- `region_currency(region: str) -> str`: ISO currency code for a region.
|
| 18 |
+
- `get_orders(region: str, category: str, month_start: int, month_end: int) -> list[int]`: Paid/refunded order ids for a region, product category, and inclusive month window.
|
| 19 |
+
- `order_gross_usd(order_id: int) -> int`: Gross order revenue in USD before discounts/refunds.
|
| 20 |
+
- `order_margin_usd(order_id: int) -> int`: Gross order margin in USD before discounts/refunds.
|
| 21 |
+
- `refund_usd(order_id: int) -> int`: Refund amount in USD for returned quantity on an order.
|
| 22 |
+
- `customer_tier(order_id: int) -> str`: Customer loyalty tier for an order.
|
| 23 |
+
- `apply_discount(amount_usd: int, tier: str) -> int`: Apply the order customer's loyalty discount to a USD amount.
|
| 24 |
+
- `net_revenue_usd(order_id: int) -> int`: Net USD revenue after loyalty discount and refunds.
|
| 25 |
+
- `to_local(amount_usd: int, currency: str) -> int`: Convert a USD integer amount to a local-currency integer.
|
| 26 |
+
- `inventory_position(product_id: int, region: str) -> int`: Available inventory position: on_hand - reserved + inbound.
|
| 27 |
+
- `product_lead_time(product_id: int) -> int`: Supplier lead time in days for a product.
|
| 28 |
+
- `product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int`: Product id with the highest units sold in a region/category/month window.
|
| 29 |
+
- `units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int`: Units sold for one product in a region and month window.
|
| 30 |
+
- `tickets_for_orders(order_ids: list[int], severity: str) -> list[int]`: Support ticket ids for given orders and severity.
|
| 31 |
+
- `ticket_order_id(ticket_id: int) -> int`: Order id associated with a support ticket.
|
| 32 |
+
- `sla_breached(ticket_id: int, first_response_limit_hours: int, resolution_limit_hours: int) -> bool`: Whether a support ticket breaches first-response or resolution SLA.
|
| 33 |
+
- `delayed_orders(order_ids: list[int]) -> list[int]`: Subset of order ids whose ship_days exceeded promised_days.
|
| 34 |
+
- `unique_customers(order_ids: list[int]) -> list[int]`: Unique customer ids among the given orders.
|
| 35 |
+
- `count_items(values: list) -> int`: Length of a list.
|
| 36 |
+
- `sum_values(values: list[int]) -> int`: Sum a list of integers.
|
| 37 |
+
- `count_true(values: list[bool]) -> int`: Count true values.
|
| 38 |
+
- `count_below(values: list[int], threshold: int) -> int`: Count values below a threshold.
|
harbor/tasks/v3_depth6_delay_sla_burden_t11/task.toml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.3"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "mindlab/v3_depth6_delay_sla_burden_t11"
|
| 5 |
+
description = "FlowBench v3 public task metadata. Public verifier is smoke-only."
|
| 6 |
+
authors = [{ name = "Mind Lab", email = "contact@mindlab.ltd" }]
|
| 7 |
+
keywords = ["flowbench", "tool-use", "data-orchestration", "operations"]
|
| 8 |
+
|
| 9 |
+
[metadata]
|
| 10 |
+
benchmark = "FlowBench-v3"
|
| 11 |
+
split = "public-task-only"
|
| 12 |
+
category = "data-processing"
|
| 13 |
+
depth = 6
|
| 14 |
+
|
| 15 |
+
[verifier]
|
| 16 |
+
timeout_sec = 120.0
|
| 17 |
+
|
| 18 |
+
[agent]
|
| 19 |
+
timeout_sec = 900.0
|
| 20 |
+
|
| 21 |
+
[environment]
|
| 22 |
+
network_mode = "no-network"
|
| 23 |
+
build_timeout_sec = 600.0
|
| 24 |
+
os = "linux"
|
| 25 |
+
cpus = 1
|
| 26 |
+
memory_mb = 2048
|
| 27 |
+
storage_mb = 2048
|
| 28 |
+
gpus = 0
|
harbor/tasks/v3_depth6_delay_sla_burden_t11/tests/check_output_shape.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
import re
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def write_reward(score: float, diagnostic: str) -> None:
|
| 11 |
+
log_dir = Path(os.environ.get("LOG_DIR", "/logs/verifier"))
|
| 12 |
+
log_dir.mkdir(parents=True, exist_ok=True)
|
| 13 |
+
(log_dir / "reward.txt").write_text(f"{score:.6g}\n")
|
| 14 |
+
(log_dir / "reward.json").write_text(
|
| 15 |
+
json.dumps({"reward": score, "smoke_only": True}, indent=2) + "\n"
|
| 16 |
+
)
|
| 17 |
+
(log_dir / "diagnostic.txt").write_text(diagnostic + "\n")
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def main() -> int:
|
| 21 |
+
app_dir = Path(os.environ.get("APP_DIR", "/app"))
|
| 22 |
+
task = json.loads((app_dir / "task.json").read_text())
|
| 23 |
+
answer_path = app_dir / "answer.txt"
|
| 24 |
+
if not answer_path.exists():
|
| 25 |
+
write_reward(0.0, "missing /app/answer.txt")
|
| 26 |
+
return 1
|
| 27 |
+
|
| 28 |
+
got = answer_path.read_text().strip()
|
| 29 |
+
if task["answer_format"] == "exact integer":
|
| 30 |
+
ok = bool(re.fullmatch(r"-?\d+", got))
|
| 31 |
+
diagnostic = "valid integer smoke output" if ok else f"not an exact integer: {got!r}"
|
| 32 |
+
else:
|
| 33 |
+
ok = bool(re.fullmatch(r"[A-Za-z]+", got))
|
| 34 |
+
diagnostic = "valid code smoke output" if ok else f"not an exact code: {got!r}"
|
| 35 |
+
|
| 36 |
+
# This is intentionally not official scoring; it only verifies I/O shape.
|
| 37 |
+
write_reward(1.0 if ok else 0.0, diagnostic)
|
| 38 |
+
return 0 if ok else 1
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
if __name__ == "__main__":
|
| 42 |
+
raise SystemExit(main())
|
harbor/tasks/v3_depth6_delay_sla_burden_t11/tests/test.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -u
|
| 3 |
+
python /tests/check_output_shape.py
|
harbor/tasks/v3_depth6_delay_sla_burden_t12/environment/Dockerfile
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.12-slim
|
| 2 |
+
WORKDIR /app
|
| 3 |
+
COPY flowbench_tools.py /app/flowbench_tools.py
|
| 4 |
+
COPY task.json /app/task.json
|
harbor/tasks/v3_depth6_delay_sla_burden_t12/environment/flowbench_tools.py
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Deterministic FlowBench v3 tools. This file contains no task answers."""
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
REGIONS = ["NA", "EU", "APAC", "LATAM"]
|
| 5 |
+
CATEGORIES = ["A", "B", "C", "D"]
|
| 6 |
+
CURRENCIES = {"NA": "USD", "EU": "EUR", "APAC": "JPY", "LATAM": "BRL"}
|
| 7 |
+
FX_TO_USD_BP = {"USD": 10000, "EUR": 10900, "JPY": 67, "BRL": 1850}
|
| 8 |
+
TIERS = ["std", "gold", "plat"]
|
| 9 |
+
DISCOUNT_PCT = {"std": 0, "gold": 10, "plat": 20}
|
| 10 |
+
CHANNELS = ["web", "store", "partner"]
|
| 11 |
+
MONTHS = [202601, 202602, 202603, 202604, 202605, 202606]
|
| 12 |
+
|
| 13 |
+
N_CUSTOMERS = 72
|
| 14 |
+
N_PRODUCTS = 48
|
| 15 |
+
N_ORDERS = 720
|
| 16 |
+
N_TICKETS = 260
|
| 17 |
+
N_RETURNS = 180
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def _h(*xs):
|
| 21 |
+
import hashlib
|
| 22 |
+
s = "|".join(str(x) for x in xs).encode()
|
| 23 |
+
return int.from_bytes(hashlib.sha256(s).digest()[:8], "big") & 0x7FFFFFFF
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def build_data():
|
| 27 |
+
customers = []
|
| 28 |
+
for cid in range(N_CUSTOMERS):
|
| 29 |
+
region = REGIONS[_h("region", cid) % len(REGIONS)]
|
| 30 |
+
customers.append({
|
| 31 |
+
"customer_id": cid,
|
| 32 |
+
"region": region,
|
| 33 |
+
"tier": TIERS[_h("tier", cid) % len(TIERS)],
|
| 34 |
+
"segment": ["consumer", "smb", "enterprise"][_h("segment", cid) % 3],
|
| 35 |
+
})
|
| 36 |
+
|
| 37 |
+
products = []
|
| 38 |
+
for pid in range(N_PRODUCTS):
|
| 39 |
+
cat = CATEGORIES[_h("cat", pid) % len(CATEGORIES)]
|
| 40 |
+
unit_price = 12 + _h("price", pid) % 240
|
| 41 |
+
cogs = unit_price * (45 + _h("margin", pid) % 35) // 100
|
| 42 |
+
products.append({
|
| 43 |
+
"product_id": pid,
|
| 44 |
+
"category": cat,
|
| 45 |
+
"unit_price_usd": unit_price,
|
| 46 |
+
"unit_cogs_usd": cogs,
|
| 47 |
+
"lead_time_days": 3 + _h("lead", pid) % 18,
|
| 48 |
+
})
|
| 49 |
+
|
| 50 |
+
inventory = []
|
| 51 |
+
for pid in range(N_PRODUCTS):
|
| 52 |
+
for region in REGIONS:
|
| 53 |
+
inventory.append({
|
| 54 |
+
"product_id": pid,
|
| 55 |
+
"region": region,
|
| 56 |
+
"on_hand": 10 + _h("onhand", pid, region) % 140,
|
| 57 |
+
"reserved": _h("reserved", pid, region) % 28,
|
| 58 |
+
"inbound": _h("inbound", pid, region) % 85,
|
| 59 |
+
})
|
| 60 |
+
|
| 61 |
+
orders = []
|
| 62 |
+
for oid in range(N_ORDERS):
|
| 63 |
+
customer_id = _h("ocust", oid) % N_CUSTOMERS
|
| 64 |
+
product_id = _h("oprod", oid) % N_PRODUCTS
|
| 65 |
+
month = MONTHS[_h("month", oid) % len(MONTHS)]
|
| 66 |
+
qty = 1 + _h("qty", oid) % 9
|
| 67 |
+
ship_days = 1 + _h("shipdays", oid) % 16
|
| 68 |
+
promised_days = 3 + _h("promise", oid) % 9
|
| 69 |
+
status = ["paid", "paid", "paid", "paid", "cancelled", "refunded"][
|
| 70 |
+
_h("status", oid) % 6]
|
| 71 |
+
orders.append({
|
| 72 |
+
"order_id": oid,
|
| 73 |
+
"customer_id": customer_id,
|
| 74 |
+
"product_id": product_id,
|
| 75 |
+
"month": month,
|
| 76 |
+
"qty": qty,
|
| 77 |
+
"status": status,
|
| 78 |
+
"channel": CHANNELS[_h("channel", oid) % len(CHANNELS)],
|
| 79 |
+
"ship_days": ship_days,
|
| 80 |
+
"promised_days": promised_days,
|
| 81 |
+
})
|
| 82 |
+
|
| 83 |
+
returns = []
|
| 84 |
+
for rid in range(N_RETURNS):
|
| 85 |
+
oid = _h("roid", rid) % N_ORDERS
|
| 86 |
+
order = orders[oid]
|
| 87 |
+
if order["status"] == "cancelled":
|
| 88 |
+
continue
|
| 89 |
+
returned_qty = 1 + _h("rqty", rid) % max(1, order["qty"])
|
| 90 |
+
reason = ["defect", "late", "changed_mind", "wrong_item"][_h("reason", rid) % 4]
|
| 91 |
+
returns.append({
|
| 92 |
+
"return_id": rid,
|
| 93 |
+
"order_id": oid,
|
| 94 |
+
"month": MONTHS[_h("rmonth", rid) % len(MONTHS)],
|
| 95 |
+
"returned_qty": returned_qty,
|
| 96 |
+
"reason": reason,
|
| 97 |
+
})
|
| 98 |
+
|
| 99 |
+
tickets = []
|
| 100 |
+
for tid in range(N_TICKETS):
|
| 101 |
+
oid = _h("toid", tid) % N_ORDERS
|
| 102 |
+
severity = ["low", "medium", "high", "critical"][_h("sev", tid) % 4]
|
| 103 |
+
opened = MONTHS[_h("tmonth", tid) % len(MONTHS)]
|
| 104 |
+
first_response_hours = 1 + _h("resp", tid) % 96
|
| 105 |
+
resolution_hours = first_response_hours + _h("res", tid) % 240
|
| 106 |
+
tickets.append({
|
| 107 |
+
"ticket_id": tid,
|
| 108 |
+
"order_id": oid,
|
| 109 |
+
"opened_month": opened,
|
| 110 |
+
"severity": severity,
|
| 111 |
+
"first_response_hours": first_response_hours,
|
| 112 |
+
"resolution_hours": resolution_hours,
|
| 113 |
+
})
|
| 114 |
+
|
| 115 |
+
return {
|
| 116 |
+
"customers": customers,
|
| 117 |
+
"products": products,
|
| 118 |
+
"inventory": inventory,
|
| 119 |
+
"orders": orders,
|
| 120 |
+
"returns": returns,
|
| 121 |
+
"tickets": tickets,
|
| 122 |
+
"fx_to_usd_bp": FX_TO_USD_BP,
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
DATA = build_data()
|
| 127 |
+
CUSTOMERS = {c["customer_id"]: c for c in DATA["customers"]}
|
| 128 |
+
PRODUCTS = {p["product_id"]: p for p in DATA["products"]}
|
| 129 |
+
ORDERS = {o["order_id"]: o for o in DATA["orders"]}
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
def region_currency(region: str) -> str:
|
| 133 |
+
return CURRENCIES[region]
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
def get_orders(region: str, category: str, month_start: int, month_end: int) -> list:
|
| 137 |
+
"""Paid/refunded order ids in a region/category/month window."""
|
| 138 |
+
out = []
|
| 139 |
+
for o in DATA["orders"]:
|
| 140 |
+
if o["status"] not in ("paid", "refunded"):
|
| 141 |
+
continue
|
| 142 |
+
c = CUSTOMERS[o["customer_id"]]
|
| 143 |
+
p = PRODUCTS[o["product_id"]]
|
| 144 |
+
if c["region"] == region and p["category"] == category and month_start <= o["month"] <= month_end:
|
| 145 |
+
out.append(o["order_id"])
|
| 146 |
+
return sorted(out)
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def order_gross_usd(order_id: int) -> int:
|
| 150 |
+
o = ORDERS[order_id]
|
| 151 |
+
p = PRODUCTS[o["product_id"]]
|
| 152 |
+
return o["qty"] * p["unit_price_usd"]
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
def order_margin_usd(order_id: int) -> int:
|
| 156 |
+
o = ORDERS[order_id]
|
| 157 |
+
p = PRODUCTS[o["product_id"]]
|
| 158 |
+
return o["qty"] * (p["unit_price_usd"] - p["unit_cogs_usd"])
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
def refund_usd(order_id: int) -> int:
|
| 162 |
+
o = ORDERS[order_id]
|
| 163 |
+
p = PRODUCTS[o["product_id"]]
|
| 164 |
+
qty = sum(r["returned_qty"] for r in DATA["returns"] if r["order_id"] == order_id)
|
| 165 |
+
qty = min(qty, o["qty"])
|
| 166 |
+
return qty * p["unit_price_usd"]
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def customer_tier(order_id: int) -> str:
|
| 170 |
+
o = ORDERS[order_id]
|
| 171 |
+
return CUSTOMERS[o["customer_id"]]["tier"]
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
def apply_discount(amount_usd: int, tier: str) -> int:
|
| 175 |
+
return amount_usd * (100 - DISCOUNT_PCT[tier]) // 100
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
def net_revenue_usd(order_id: int) -> int:
|
| 179 |
+
gross = apply_discount(order_gross_usd(order_id), customer_tier(order_id))
|
| 180 |
+
return max(0, gross - refund_usd(order_id))
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
def to_local(amount_usd: int, currency: str) -> int:
|
| 184 |
+
return amount_usd * 10000 // FX_TO_USD_BP[currency]
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def inventory_position(product_id: int, region: str) -> int:
|
| 188 |
+
row = next(x for x in DATA["inventory"]
|
| 189 |
+
if x["product_id"] == product_id and x["region"] == region)
|
| 190 |
+
return row["on_hand"] - row["reserved"] + row["inbound"]
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
def product_lead_time(product_id: int) -> int:
|
| 194 |
+
return PRODUCTS[product_id]["lead_time_days"]
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
def product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int:
|
| 198 |
+
totals = {}
|
| 199 |
+
for oid in get_orders(region, category, month_start, month_end):
|
| 200 |
+
o = ORDERS[oid]
|
| 201 |
+
totals[o["product_id"]] = totals.get(o["product_id"], 0) + o["qty"]
|
| 202 |
+
if not totals:
|
| 203 |
+
return -1
|
| 204 |
+
return min((-qty, pid) for pid, qty in totals.items())[1]
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
def units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int:
|
| 208 |
+
total = 0
|
| 209 |
+
for o in DATA["orders"]:
|
| 210 |
+
if o["product_id"] != product_id or o["status"] not in ("paid", "refunded"):
|
| 211 |
+
continue
|
| 212 |
+
c = CUSTOMERS[o["customer_id"]]
|
| 213 |
+
if c["region"] == region and month_start <= o["month"] <= month_end:
|
| 214 |
+
total += o["qty"]
|
| 215 |
+
return total
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def tickets_for_orders(order_ids: list, severity: str) -> list:
|
| 219 |
+
s = set(order_ids)
|
| 220 |
+
return sorted(t["ticket_id"] for t in DATA["tickets"]
|
| 221 |
+
if t["order_id"] in s and t["severity"] == severity)
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
def ticket_order_id(ticket_id: int) -> int:
|
| 225 |
+
return next(t["order_id"] for t in DATA["tickets"] if t["ticket_id"] == ticket_id)
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
def sla_breached(ticket_id: int, first_response_limit_hours: int,
|
| 229 |
+
resolution_limit_hours: int) -> bool:
|
| 230 |
+
t = next(x for x in DATA["tickets"] if x["ticket_id"] == ticket_id)
|
| 231 |
+
return (t["first_response_hours"] > first_response_limit_hours or
|
| 232 |
+
t["resolution_hours"] > resolution_limit_hours)
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
def delayed_orders(order_ids: list) -> list:
|
| 236 |
+
s = set(order_ids)
|
| 237 |
+
return sorted(o["order_id"] for o in DATA["orders"]
|
| 238 |
+
if o["order_id"] in s and o["ship_days"] > o["promised_days"])
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
def unique_customers(order_ids: list) -> list:
|
| 242 |
+
return sorted({ORDERS[oid]["customer_id"] for oid in order_ids})
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
def count_items(values: list) -> int:
|
| 246 |
+
return len(values)
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
def sum_values(values: list) -> int:
|
| 250 |
+
return sum(values)
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
def count_true(values: list) -> int:
|
| 254 |
+
return sum(1 for v in values if bool(v))
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
def count_below(values: list, threshold: int) -> int:
|
| 258 |
+
return sum(1 for v in values if v < threshold)
|
| 259 |
+
|
| 260 |
+
|
| 261 |
+
TOOLS = {
|
| 262 |
+
"region_currency": ("region_currency(region: str) -> str",
|
| 263 |
+
"ISO currency code for a region.", region_currency),
|
| 264 |
+
"get_orders": ("get_orders(region: str, category: str, month_start: int, month_end: int) -> list[int]",
|
| 265 |
+
"Paid/refunded order ids for a region, product category, and inclusive month window.",
|
| 266 |
+
get_orders),
|
| 267 |
+
"order_gross_usd": ("order_gross_usd(order_id: int) -> int",
|
| 268 |
+
"Gross order revenue in USD before discounts/refunds.", order_gross_usd),
|
| 269 |
+
"order_margin_usd": ("order_margin_usd(order_id: int) -> int",
|
| 270 |
+
"Gross order margin in USD before discounts/refunds.", order_margin_usd),
|
| 271 |
+
"refund_usd": ("refund_usd(order_id: int) -> int",
|
| 272 |
+
"Refund amount in USD for returned quantity on an order.", refund_usd),
|
| 273 |
+
"customer_tier": ("customer_tier(order_id: int) -> str",
|
| 274 |
+
"Customer loyalty tier for an order.", customer_tier),
|
| 275 |
+
"apply_discount": ("apply_discount(amount_usd: int, tier: str) -> int",
|
| 276 |
+
"Apply the order customer's loyalty discount to a USD amount.", apply_discount),
|
| 277 |
+
"net_revenue_usd": ("net_revenue_usd(order_id: int) -> int",
|
| 278 |
+
"Net USD revenue after loyalty discount and refunds.", net_revenue_usd),
|
| 279 |
+
"to_local": ("to_local(amount_usd: int, currency: str) -> int",
|
| 280 |
+
"Convert a USD integer amount to a local-currency integer.", to_local),
|
| 281 |
+
"inventory_position": ("inventory_position(product_id: int, region: str) -> int",
|
| 282 |
+
"Available inventory position: on_hand - reserved + inbound.",
|
| 283 |
+
inventory_position),
|
| 284 |
+
"product_lead_time": ("product_lead_time(product_id: int) -> int",
|
| 285 |
+
"Supplier lead time in days for a product.", product_lead_time),
|
| 286 |
+
"product_id_for_top_seller": (
|
| 287 |
+
"product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int",
|
| 288 |
+
"Product id with the highest units sold in a region/category/month window.",
|
| 289 |
+
product_id_for_top_seller),
|
| 290 |
+
"units_sold": ("units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int",
|
| 291 |
+
"Units sold for one product in a region and month window.", units_sold),
|
| 292 |
+
"tickets_for_orders": ("tickets_for_orders(order_ids: list[int], severity: str) -> list[int]",
|
| 293 |
+
"Support ticket ids for given orders and severity.", tickets_for_orders),
|
| 294 |
+
"ticket_order_id": ("ticket_order_id(ticket_id: int) -> int",
|
| 295 |
+
"Order id associated with a support ticket.", ticket_order_id),
|
| 296 |
+
"sla_breached": (
|
| 297 |
+
"sla_breached(ticket_id: int, first_response_limit_hours: int, resolution_limit_hours: int) -> bool",
|
| 298 |
+
"Whether a support ticket breaches first-response or resolution SLA.",
|
| 299 |
+
sla_breached),
|
| 300 |
+
"delayed_orders": ("delayed_orders(order_ids: list[int]) -> list[int]",
|
| 301 |
+
"Subset of order ids whose ship_days exceeded promised_days.", delayed_orders),
|
| 302 |
+
"unique_customers": ("unique_customers(order_ids: list[int]) -> list[int]",
|
| 303 |
+
"Unique customer ids among the given orders.", unique_customers),
|
| 304 |
+
"count_items": ("count_items(values: list) -> int", "Length of a list.", count_items),
|
| 305 |
+
"sum_values": ("sum_values(values: list[int]) -> int", "Sum a list of integers.", sum_values),
|
| 306 |
+
"count_true": ("count_true(values: list[bool]) -> int", "Count true values.", count_true),
|
| 307 |
+
"count_below": ("count_below(values: list[int], threshold: int) -> int",
|
| 308 |
+
"Count values below a threshold.", count_below),
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
__all__ = [name for name in TOOLS.keys()] + ['TOOLS']
|
harbor/tasks/v3_depth6_delay_sla_burden_t12/environment/task.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"task_id": "v3_depth6_delay_sla_burden_t12",
|
| 3 |
+
"depth": 6,
|
| 4 |
+
"family": "delay_sla_burden",
|
| 5 |
+
"params": {
|
| 6 |
+
"region": "NA",
|
| 7 |
+
"category": "C",
|
| 8 |
+
"month_start": 202601,
|
| 9 |
+
"month_end": 202606
|
| 10 |
+
},
|
| 11 |
+
"question": "For region NA, category C, months 202601-202606: get the orders, count delayed orders where ship_days exceeded promised_days, find high and critical support tickets for those orders, count tickets that breach a 24-hour first-response or 120-hour resolution SLA, and report delayed_order_count + breached_ticket_count.",
|
| 12 |
+
"answer_format": "exact integer"
|
| 13 |
+
}
|
harbor/tasks/v3_depth6_delay_sla_burden_t12/instruction.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FlowBench v3 Public Task
|
| 2 |
+
|
| 3 |
+
You are in `/app`. The file `/app/flowbench_tools.py` contains deterministic
|
| 4 |
+
Python tools over a synthetic business-operations dataset. Use those tools
|
| 5 |
+
to compute the requested value, then write the final output to
|
| 6 |
+
`/app/answer.txt`.
|
| 7 |
+
|
| 8 |
+
Required output:
|
| 9 |
+
- `/app/answer.txt` must contain only the exact integer.
|
| 10 |
+
- Use integer arithmetic for currency and counts. Do not use floating point
|
| 11 |
+
arithmetic.
|
| 12 |
+
|
| 13 |
+
Task:
|
| 14 |
+
For region NA, category C, months 202601-202606: get the orders, count delayed orders where ship_days exceeded promised_days, find high and critical support tickets for those orders, count tickets that breach a 24-hour first-response or 120-hour resolution SLA, and report delayed_order_count + breached_ticket_count.
|
| 15 |
+
|
| 16 |
+
Available tools:
|
| 17 |
+
- `region_currency(region: str) -> str`: ISO currency code for a region.
|
| 18 |
+
- `get_orders(region: str, category: str, month_start: int, month_end: int) -> list[int]`: Paid/refunded order ids for a region, product category, and inclusive month window.
|
| 19 |
+
- `order_gross_usd(order_id: int) -> int`: Gross order revenue in USD before discounts/refunds.
|
| 20 |
+
- `order_margin_usd(order_id: int) -> int`: Gross order margin in USD before discounts/refunds.
|
| 21 |
+
- `refund_usd(order_id: int) -> int`: Refund amount in USD for returned quantity on an order.
|
| 22 |
+
- `customer_tier(order_id: int) -> str`: Customer loyalty tier for an order.
|
| 23 |
+
- `apply_discount(amount_usd: int, tier: str) -> int`: Apply the order customer's loyalty discount to a USD amount.
|
| 24 |
+
- `net_revenue_usd(order_id: int) -> int`: Net USD revenue after loyalty discount and refunds.
|
| 25 |
+
- `to_local(amount_usd: int, currency: str) -> int`: Convert a USD integer amount to a local-currency integer.
|
| 26 |
+
- `inventory_position(product_id: int, region: str) -> int`: Available inventory position: on_hand - reserved + inbound.
|
| 27 |
+
- `product_lead_time(product_id: int) -> int`: Supplier lead time in days for a product.
|
| 28 |
+
- `product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int`: Product id with the highest units sold in a region/category/month window.
|
| 29 |
+
- `units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int`: Units sold for one product in a region and month window.
|
| 30 |
+
- `tickets_for_orders(order_ids: list[int], severity: str) -> list[int]`: Support ticket ids for given orders and severity.
|
| 31 |
+
- `ticket_order_id(ticket_id: int) -> int`: Order id associated with a support ticket.
|
| 32 |
+
- `sla_breached(ticket_id: int, first_response_limit_hours: int, resolution_limit_hours: int) -> bool`: Whether a support ticket breaches first-response or resolution SLA.
|
| 33 |
+
- `delayed_orders(order_ids: list[int]) -> list[int]`: Subset of order ids whose ship_days exceeded promised_days.
|
| 34 |
+
- `unique_customers(order_ids: list[int]) -> list[int]`: Unique customer ids among the given orders.
|
| 35 |
+
- `count_items(values: list) -> int`: Length of a list.
|
| 36 |
+
- `sum_values(values: list[int]) -> int`: Sum a list of integers.
|
| 37 |
+
- `count_true(values: list[bool]) -> int`: Count true values.
|
| 38 |
+
- `count_below(values: list[int], threshold: int) -> int`: Count values below a threshold.
|
harbor/tasks/v3_depth6_delay_sla_burden_t12/task.toml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.3"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "mindlab/v3_depth6_delay_sla_burden_t12"
|
| 5 |
+
description = "FlowBench v3 public task metadata. Public verifier is smoke-only."
|
| 6 |
+
authors = [{ name = "Mind Lab", email = "contact@mindlab.ltd" }]
|
| 7 |
+
keywords = ["flowbench", "tool-use", "data-orchestration", "operations"]
|
| 8 |
+
|
| 9 |
+
[metadata]
|
| 10 |
+
benchmark = "FlowBench-v3"
|
| 11 |
+
split = "public-task-only"
|
| 12 |
+
category = "data-processing"
|
| 13 |
+
depth = 6
|
| 14 |
+
|
| 15 |
+
[verifier]
|
| 16 |
+
timeout_sec = 120.0
|
| 17 |
+
|
| 18 |
+
[agent]
|
| 19 |
+
timeout_sec = 900.0
|
| 20 |
+
|
| 21 |
+
[environment]
|
| 22 |
+
network_mode = "no-network"
|
| 23 |
+
build_timeout_sec = 600.0
|
| 24 |
+
os = "linux"
|
| 25 |
+
cpus = 1
|
| 26 |
+
memory_mb = 2048
|
| 27 |
+
storage_mb = 2048
|
| 28 |
+
gpus = 0
|
harbor/tasks/v3_depth6_delay_sla_burden_t12/tests/check_output_shape.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
import re
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def write_reward(score: float, diagnostic: str) -> None:
|
| 11 |
+
log_dir = Path(os.environ.get("LOG_DIR", "/logs/verifier"))
|
| 12 |
+
log_dir.mkdir(parents=True, exist_ok=True)
|
| 13 |
+
(log_dir / "reward.txt").write_text(f"{score:.6g}\n")
|
| 14 |
+
(log_dir / "reward.json").write_text(
|
| 15 |
+
json.dumps({"reward": score, "smoke_only": True}, indent=2) + "\n"
|
| 16 |
+
)
|
| 17 |
+
(log_dir / "diagnostic.txt").write_text(diagnostic + "\n")
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def main() -> int:
|
| 21 |
+
app_dir = Path(os.environ.get("APP_DIR", "/app"))
|
| 22 |
+
task = json.loads((app_dir / "task.json").read_text())
|
| 23 |
+
answer_path = app_dir / "answer.txt"
|
| 24 |
+
if not answer_path.exists():
|
| 25 |
+
write_reward(0.0, "missing /app/answer.txt")
|
| 26 |
+
return 1
|
| 27 |
+
|
| 28 |
+
got = answer_path.read_text().strip()
|
| 29 |
+
if task["answer_format"] == "exact integer":
|
| 30 |
+
ok = bool(re.fullmatch(r"-?\d+", got))
|
| 31 |
+
diagnostic = "valid integer smoke output" if ok else f"not an exact integer: {got!r}"
|
| 32 |
+
else:
|
| 33 |
+
ok = bool(re.fullmatch(r"[A-Za-z]+", got))
|
| 34 |
+
diagnostic = "valid code smoke output" if ok else f"not an exact code: {got!r}"
|
| 35 |
+
|
| 36 |
+
# This is intentionally not official scoring; it only verifies I/O shape.
|
| 37 |
+
write_reward(1.0 if ok else 0.0, diagnostic)
|
| 38 |
+
return 0 if ok else 1
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
if __name__ == "__main__":
|
| 42 |
+
raise SystemExit(main())
|
harbor/tasks/v3_depth6_delay_sla_burden_t12/tests/test.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -u
|
| 3 |
+
python /tests/check_output_shape.py
|
harbor/tasks/v3_depth6_delay_sla_burden_t13/environment/Dockerfile
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.12-slim
|
| 2 |
+
WORKDIR /app
|
| 3 |
+
COPY flowbench_tools.py /app/flowbench_tools.py
|
| 4 |
+
COPY task.json /app/task.json
|
harbor/tasks/v3_depth6_delay_sla_burden_t13/environment/flowbench_tools.py
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Deterministic FlowBench v3 tools. This file contains no task answers."""
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
REGIONS = ["NA", "EU", "APAC", "LATAM"]
|
| 5 |
+
CATEGORIES = ["A", "B", "C", "D"]
|
| 6 |
+
CURRENCIES = {"NA": "USD", "EU": "EUR", "APAC": "JPY", "LATAM": "BRL"}
|
| 7 |
+
FX_TO_USD_BP = {"USD": 10000, "EUR": 10900, "JPY": 67, "BRL": 1850}
|
| 8 |
+
TIERS = ["std", "gold", "plat"]
|
| 9 |
+
DISCOUNT_PCT = {"std": 0, "gold": 10, "plat": 20}
|
| 10 |
+
CHANNELS = ["web", "store", "partner"]
|
| 11 |
+
MONTHS = [202601, 202602, 202603, 202604, 202605, 202606]
|
| 12 |
+
|
| 13 |
+
N_CUSTOMERS = 72
|
| 14 |
+
N_PRODUCTS = 48
|
| 15 |
+
N_ORDERS = 720
|
| 16 |
+
N_TICKETS = 260
|
| 17 |
+
N_RETURNS = 180
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def _h(*xs):
|
| 21 |
+
import hashlib
|
| 22 |
+
s = "|".join(str(x) for x in xs).encode()
|
| 23 |
+
return int.from_bytes(hashlib.sha256(s).digest()[:8], "big") & 0x7FFFFFFF
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def build_data():
|
| 27 |
+
customers = []
|
| 28 |
+
for cid in range(N_CUSTOMERS):
|
| 29 |
+
region = REGIONS[_h("region", cid) % len(REGIONS)]
|
| 30 |
+
customers.append({
|
| 31 |
+
"customer_id": cid,
|
| 32 |
+
"region": region,
|
| 33 |
+
"tier": TIERS[_h("tier", cid) % len(TIERS)],
|
| 34 |
+
"segment": ["consumer", "smb", "enterprise"][_h("segment", cid) % 3],
|
| 35 |
+
})
|
| 36 |
+
|
| 37 |
+
products = []
|
| 38 |
+
for pid in range(N_PRODUCTS):
|
| 39 |
+
cat = CATEGORIES[_h("cat", pid) % len(CATEGORIES)]
|
| 40 |
+
unit_price = 12 + _h("price", pid) % 240
|
| 41 |
+
cogs = unit_price * (45 + _h("margin", pid) % 35) // 100
|
| 42 |
+
products.append({
|
| 43 |
+
"product_id": pid,
|
| 44 |
+
"category": cat,
|
| 45 |
+
"unit_price_usd": unit_price,
|
| 46 |
+
"unit_cogs_usd": cogs,
|
| 47 |
+
"lead_time_days": 3 + _h("lead", pid) % 18,
|
| 48 |
+
})
|
| 49 |
+
|
| 50 |
+
inventory = []
|
| 51 |
+
for pid in range(N_PRODUCTS):
|
| 52 |
+
for region in REGIONS:
|
| 53 |
+
inventory.append({
|
| 54 |
+
"product_id": pid,
|
| 55 |
+
"region": region,
|
| 56 |
+
"on_hand": 10 + _h("onhand", pid, region) % 140,
|
| 57 |
+
"reserved": _h("reserved", pid, region) % 28,
|
| 58 |
+
"inbound": _h("inbound", pid, region) % 85,
|
| 59 |
+
})
|
| 60 |
+
|
| 61 |
+
orders = []
|
| 62 |
+
for oid in range(N_ORDERS):
|
| 63 |
+
customer_id = _h("ocust", oid) % N_CUSTOMERS
|
| 64 |
+
product_id = _h("oprod", oid) % N_PRODUCTS
|
| 65 |
+
month = MONTHS[_h("month", oid) % len(MONTHS)]
|
| 66 |
+
qty = 1 + _h("qty", oid) % 9
|
| 67 |
+
ship_days = 1 + _h("shipdays", oid) % 16
|
| 68 |
+
promised_days = 3 + _h("promise", oid) % 9
|
| 69 |
+
status = ["paid", "paid", "paid", "paid", "cancelled", "refunded"][
|
| 70 |
+
_h("status", oid) % 6]
|
| 71 |
+
orders.append({
|
| 72 |
+
"order_id": oid,
|
| 73 |
+
"customer_id": customer_id,
|
| 74 |
+
"product_id": product_id,
|
| 75 |
+
"month": month,
|
| 76 |
+
"qty": qty,
|
| 77 |
+
"status": status,
|
| 78 |
+
"channel": CHANNELS[_h("channel", oid) % len(CHANNELS)],
|
| 79 |
+
"ship_days": ship_days,
|
| 80 |
+
"promised_days": promised_days,
|
| 81 |
+
})
|
| 82 |
+
|
| 83 |
+
returns = []
|
| 84 |
+
for rid in range(N_RETURNS):
|
| 85 |
+
oid = _h("roid", rid) % N_ORDERS
|
| 86 |
+
order = orders[oid]
|
| 87 |
+
if order["status"] == "cancelled":
|
| 88 |
+
continue
|
| 89 |
+
returned_qty = 1 + _h("rqty", rid) % max(1, order["qty"])
|
| 90 |
+
reason = ["defect", "late", "changed_mind", "wrong_item"][_h("reason", rid) % 4]
|
| 91 |
+
returns.append({
|
| 92 |
+
"return_id": rid,
|
| 93 |
+
"order_id": oid,
|
| 94 |
+
"month": MONTHS[_h("rmonth", rid) % len(MONTHS)],
|
| 95 |
+
"returned_qty": returned_qty,
|
| 96 |
+
"reason": reason,
|
| 97 |
+
})
|
| 98 |
+
|
| 99 |
+
tickets = []
|
| 100 |
+
for tid in range(N_TICKETS):
|
| 101 |
+
oid = _h("toid", tid) % N_ORDERS
|
| 102 |
+
severity = ["low", "medium", "high", "critical"][_h("sev", tid) % 4]
|
| 103 |
+
opened = MONTHS[_h("tmonth", tid) % len(MONTHS)]
|
| 104 |
+
first_response_hours = 1 + _h("resp", tid) % 96
|
| 105 |
+
resolution_hours = first_response_hours + _h("res", tid) % 240
|
| 106 |
+
tickets.append({
|
| 107 |
+
"ticket_id": tid,
|
| 108 |
+
"order_id": oid,
|
| 109 |
+
"opened_month": opened,
|
| 110 |
+
"severity": severity,
|
| 111 |
+
"first_response_hours": first_response_hours,
|
| 112 |
+
"resolution_hours": resolution_hours,
|
| 113 |
+
})
|
| 114 |
+
|
| 115 |
+
return {
|
| 116 |
+
"customers": customers,
|
| 117 |
+
"products": products,
|
| 118 |
+
"inventory": inventory,
|
| 119 |
+
"orders": orders,
|
| 120 |
+
"returns": returns,
|
| 121 |
+
"tickets": tickets,
|
| 122 |
+
"fx_to_usd_bp": FX_TO_USD_BP,
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
DATA = build_data()
|
| 127 |
+
CUSTOMERS = {c["customer_id"]: c for c in DATA["customers"]}
|
| 128 |
+
PRODUCTS = {p["product_id"]: p for p in DATA["products"]}
|
| 129 |
+
ORDERS = {o["order_id"]: o for o in DATA["orders"]}
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
def region_currency(region: str) -> str:
|
| 133 |
+
return CURRENCIES[region]
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
def get_orders(region: str, category: str, month_start: int, month_end: int) -> list:
|
| 137 |
+
"""Paid/refunded order ids in a region/category/month window."""
|
| 138 |
+
out = []
|
| 139 |
+
for o in DATA["orders"]:
|
| 140 |
+
if o["status"] not in ("paid", "refunded"):
|
| 141 |
+
continue
|
| 142 |
+
c = CUSTOMERS[o["customer_id"]]
|
| 143 |
+
p = PRODUCTS[o["product_id"]]
|
| 144 |
+
if c["region"] == region and p["category"] == category and month_start <= o["month"] <= month_end:
|
| 145 |
+
out.append(o["order_id"])
|
| 146 |
+
return sorted(out)
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def order_gross_usd(order_id: int) -> int:
|
| 150 |
+
o = ORDERS[order_id]
|
| 151 |
+
p = PRODUCTS[o["product_id"]]
|
| 152 |
+
return o["qty"] * p["unit_price_usd"]
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
def order_margin_usd(order_id: int) -> int:
|
| 156 |
+
o = ORDERS[order_id]
|
| 157 |
+
p = PRODUCTS[o["product_id"]]
|
| 158 |
+
return o["qty"] * (p["unit_price_usd"] - p["unit_cogs_usd"])
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
def refund_usd(order_id: int) -> int:
|
| 162 |
+
o = ORDERS[order_id]
|
| 163 |
+
p = PRODUCTS[o["product_id"]]
|
| 164 |
+
qty = sum(r["returned_qty"] for r in DATA["returns"] if r["order_id"] == order_id)
|
| 165 |
+
qty = min(qty, o["qty"])
|
| 166 |
+
return qty * p["unit_price_usd"]
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def customer_tier(order_id: int) -> str:
|
| 170 |
+
o = ORDERS[order_id]
|
| 171 |
+
return CUSTOMERS[o["customer_id"]]["tier"]
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
def apply_discount(amount_usd: int, tier: str) -> int:
|
| 175 |
+
return amount_usd * (100 - DISCOUNT_PCT[tier]) // 100
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
def net_revenue_usd(order_id: int) -> int:
|
| 179 |
+
gross = apply_discount(order_gross_usd(order_id), customer_tier(order_id))
|
| 180 |
+
return max(0, gross - refund_usd(order_id))
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
def to_local(amount_usd: int, currency: str) -> int:
|
| 184 |
+
return amount_usd * 10000 // FX_TO_USD_BP[currency]
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def inventory_position(product_id: int, region: str) -> int:
|
| 188 |
+
row = next(x for x in DATA["inventory"]
|
| 189 |
+
if x["product_id"] == product_id and x["region"] == region)
|
| 190 |
+
return row["on_hand"] - row["reserved"] + row["inbound"]
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
def product_lead_time(product_id: int) -> int:
|
| 194 |
+
return PRODUCTS[product_id]["lead_time_days"]
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
def product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int:
|
| 198 |
+
totals = {}
|
| 199 |
+
for oid in get_orders(region, category, month_start, month_end):
|
| 200 |
+
o = ORDERS[oid]
|
| 201 |
+
totals[o["product_id"]] = totals.get(o["product_id"], 0) + o["qty"]
|
| 202 |
+
if not totals:
|
| 203 |
+
return -1
|
| 204 |
+
return min((-qty, pid) for pid, qty in totals.items())[1]
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
def units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int:
|
| 208 |
+
total = 0
|
| 209 |
+
for o in DATA["orders"]:
|
| 210 |
+
if o["product_id"] != product_id or o["status"] not in ("paid", "refunded"):
|
| 211 |
+
continue
|
| 212 |
+
c = CUSTOMERS[o["customer_id"]]
|
| 213 |
+
if c["region"] == region and month_start <= o["month"] <= month_end:
|
| 214 |
+
total += o["qty"]
|
| 215 |
+
return total
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def tickets_for_orders(order_ids: list, severity: str) -> list:
|
| 219 |
+
s = set(order_ids)
|
| 220 |
+
return sorted(t["ticket_id"] for t in DATA["tickets"]
|
| 221 |
+
if t["order_id"] in s and t["severity"] == severity)
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
def ticket_order_id(ticket_id: int) -> int:
|
| 225 |
+
return next(t["order_id"] for t in DATA["tickets"] if t["ticket_id"] == ticket_id)
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
def sla_breached(ticket_id: int, first_response_limit_hours: int,
|
| 229 |
+
resolution_limit_hours: int) -> bool:
|
| 230 |
+
t = next(x for x in DATA["tickets"] if x["ticket_id"] == ticket_id)
|
| 231 |
+
return (t["first_response_hours"] > first_response_limit_hours or
|
| 232 |
+
t["resolution_hours"] > resolution_limit_hours)
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
def delayed_orders(order_ids: list) -> list:
|
| 236 |
+
s = set(order_ids)
|
| 237 |
+
return sorted(o["order_id"] for o in DATA["orders"]
|
| 238 |
+
if o["order_id"] in s and o["ship_days"] > o["promised_days"])
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
def unique_customers(order_ids: list) -> list:
|
| 242 |
+
return sorted({ORDERS[oid]["customer_id"] for oid in order_ids})
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
def count_items(values: list) -> int:
|
| 246 |
+
return len(values)
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
def sum_values(values: list) -> int:
|
| 250 |
+
return sum(values)
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
def count_true(values: list) -> int:
|
| 254 |
+
return sum(1 for v in values if bool(v))
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
def count_below(values: list, threshold: int) -> int:
|
| 258 |
+
return sum(1 for v in values if v < threshold)
|
| 259 |
+
|
| 260 |
+
|
| 261 |
+
TOOLS = {
|
| 262 |
+
"region_currency": ("region_currency(region: str) -> str",
|
| 263 |
+
"ISO currency code for a region.", region_currency),
|
| 264 |
+
"get_orders": ("get_orders(region: str, category: str, month_start: int, month_end: int) -> list[int]",
|
| 265 |
+
"Paid/refunded order ids for a region, product category, and inclusive month window.",
|
| 266 |
+
get_orders),
|
| 267 |
+
"order_gross_usd": ("order_gross_usd(order_id: int) -> int",
|
| 268 |
+
"Gross order revenue in USD before discounts/refunds.", order_gross_usd),
|
| 269 |
+
"order_margin_usd": ("order_margin_usd(order_id: int) -> int",
|
| 270 |
+
"Gross order margin in USD before discounts/refunds.", order_margin_usd),
|
| 271 |
+
"refund_usd": ("refund_usd(order_id: int) -> int",
|
| 272 |
+
"Refund amount in USD for returned quantity on an order.", refund_usd),
|
| 273 |
+
"customer_tier": ("customer_tier(order_id: int) -> str",
|
| 274 |
+
"Customer loyalty tier for an order.", customer_tier),
|
| 275 |
+
"apply_discount": ("apply_discount(amount_usd: int, tier: str) -> int",
|
| 276 |
+
"Apply the order customer's loyalty discount to a USD amount.", apply_discount),
|
| 277 |
+
"net_revenue_usd": ("net_revenue_usd(order_id: int) -> int",
|
| 278 |
+
"Net USD revenue after loyalty discount and refunds.", net_revenue_usd),
|
| 279 |
+
"to_local": ("to_local(amount_usd: int, currency: str) -> int",
|
| 280 |
+
"Convert a USD integer amount to a local-currency integer.", to_local),
|
| 281 |
+
"inventory_position": ("inventory_position(product_id: int, region: str) -> int",
|
| 282 |
+
"Available inventory position: on_hand - reserved + inbound.",
|
| 283 |
+
inventory_position),
|
| 284 |
+
"product_lead_time": ("product_lead_time(product_id: int) -> int",
|
| 285 |
+
"Supplier lead time in days for a product.", product_lead_time),
|
| 286 |
+
"product_id_for_top_seller": (
|
| 287 |
+
"product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int",
|
| 288 |
+
"Product id with the highest units sold in a region/category/month window.",
|
| 289 |
+
product_id_for_top_seller),
|
| 290 |
+
"units_sold": ("units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int",
|
| 291 |
+
"Units sold for one product in a region and month window.", units_sold),
|
| 292 |
+
"tickets_for_orders": ("tickets_for_orders(order_ids: list[int], severity: str) -> list[int]",
|
| 293 |
+
"Support ticket ids for given orders and severity.", tickets_for_orders),
|
| 294 |
+
"ticket_order_id": ("ticket_order_id(ticket_id: int) -> int",
|
| 295 |
+
"Order id associated with a support ticket.", ticket_order_id),
|
| 296 |
+
"sla_breached": (
|
| 297 |
+
"sla_breached(ticket_id: int, first_response_limit_hours: int, resolution_limit_hours: int) -> bool",
|
| 298 |
+
"Whether a support ticket breaches first-response or resolution SLA.",
|
| 299 |
+
sla_breached),
|
| 300 |
+
"delayed_orders": ("delayed_orders(order_ids: list[int]) -> list[int]",
|
| 301 |
+
"Subset of order ids whose ship_days exceeded promised_days.", delayed_orders),
|
| 302 |
+
"unique_customers": ("unique_customers(order_ids: list[int]) -> list[int]",
|
| 303 |
+
"Unique customer ids among the given orders.", unique_customers),
|
| 304 |
+
"count_items": ("count_items(values: list) -> int", "Length of a list.", count_items),
|
| 305 |
+
"sum_values": ("sum_values(values: list[int]) -> int", "Sum a list of integers.", sum_values),
|
| 306 |
+
"count_true": ("count_true(values: list[bool]) -> int", "Count true values.", count_true),
|
| 307 |
+
"count_below": ("count_below(values: list[int], threshold: int) -> int",
|
| 308 |
+
"Count values below a threshold.", count_below),
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
__all__ = [name for name in TOOLS.keys()] + ['TOOLS']
|
harbor/tasks/v3_depth6_delay_sla_burden_t13/environment/task.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"task_id": "v3_depth6_delay_sla_burden_t13",
|
| 3 |
+
"depth": 6,
|
| 4 |
+
"family": "delay_sla_burden",
|
| 5 |
+
"params": {
|
| 6 |
+
"region": "EU",
|
| 7 |
+
"category": "B",
|
| 8 |
+
"month_start": 202601,
|
| 9 |
+
"month_end": 202603
|
| 10 |
+
},
|
| 11 |
+
"question": "For region EU, category B, months 202601-202603: get the orders, count delayed orders where ship_days exceeded promised_days, find high and critical support tickets for those orders, count tickets that breach a 24-hour first-response or 120-hour resolution SLA, and report delayed_order_count + breached_ticket_count.",
|
| 12 |
+
"answer_format": "exact integer"
|
| 13 |
+
}
|
harbor/tasks/v3_depth6_delay_sla_burden_t13/instruction.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FlowBench v3 Public Task
|
| 2 |
+
|
| 3 |
+
You are in `/app`. The file `/app/flowbench_tools.py` contains deterministic
|
| 4 |
+
Python tools over a synthetic business-operations dataset. Use those tools
|
| 5 |
+
to compute the requested value, then write the final output to
|
| 6 |
+
`/app/answer.txt`.
|
| 7 |
+
|
| 8 |
+
Required output:
|
| 9 |
+
- `/app/answer.txt` must contain only the exact integer.
|
| 10 |
+
- Use integer arithmetic for currency and counts. Do not use floating point
|
| 11 |
+
arithmetic.
|
| 12 |
+
|
| 13 |
+
Task:
|
| 14 |
+
For region EU, category B, months 202601-202603: get the orders, count delayed orders where ship_days exceeded promised_days, find high and critical support tickets for those orders, count tickets that breach a 24-hour first-response or 120-hour resolution SLA, and report delayed_order_count + breached_ticket_count.
|
| 15 |
+
|
| 16 |
+
Available tools:
|
| 17 |
+
- `region_currency(region: str) -> str`: ISO currency code for a region.
|
| 18 |
+
- `get_orders(region: str, category: str, month_start: int, month_end: int) -> list[int]`: Paid/refunded order ids for a region, product category, and inclusive month window.
|
| 19 |
+
- `order_gross_usd(order_id: int) -> int`: Gross order revenue in USD before discounts/refunds.
|
| 20 |
+
- `order_margin_usd(order_id: int) -> int`: Gross order margin in USD before discounts/refunds.
|
| 21 |
+
- `refund_usd(order_id: int) -> int`: Refund amount in USD for returned quantity on an order.
|
| 22 |
+
- `customer_tier(order_id: int) -> str`: Customer loyalty tier for an order.
|
| 23 |
+
- `apply_discount(amount_usd: int, tier: str) -> int`: Apply the order customer's loyalty discount to a USD amount.
|
| 24 |
+
- `net_revenue_usd(order_id: int) -> int`: Net USD revenue after loyalty discount and refunds.
|
| 25 |
+
- `to_local(amount_usd: int, currency: str) -> int`: Convert a USD integer amount to a local-currency integer.
|
| 26 |
+
- `inventory_position(product_id: int, region: str) -> int`: Available inventory position: on_hand - reserved + inbound.
|
| 27 |
+
- `product_lead_time(product_id: int) -> int`: Supplier lead time in days for a product.
|
| 28 |
+
- `product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int`: Product id with the highest units sold in a region/category/month window.
|
| 29 |
+
- `units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int`: Units sold for one product in a region and month window.
|
| 30 |
+
- `tickets_for_orders(order_ids: list[int], severity: str) -> list[int]`: Support ticket ids for given orders and severity.
|
| 31 |
+
- `ticket_order_id(ticket_id: int) -> int`: Order id associated with a support ticket.
|
| 32 |
+
- `sla_breached(ticket_id: int, first_response_limit_hours: int, resolution_limit_hours: int) -> bool`: Whether a support ticket breaches first-response or resolution SLA.
|
| 33 |
+
- `delayed_orders(order_ids: list[int]) -> list[int]`: Subset of order ids whose ship_days exceeded promised_days.
|
| 34 |
+
- `unique_customers(order_ids: list[int]) -> list[int]`: Unique customer ids among the given orders.
|
| 35 |
+
- `count_items(values: list) -> int`: Length of a list.
|
| 36 |
+
- `sum_values(values: list[int]) -> int`: Sum a list of integers.
|
| 37 |
+
- `count_true(values: list[bool]) -> int`: Count true values.
|
| 38 |
+
- `count_below(values: list[int], threshold: int) -> int`: Count values below a threshold.
|
harbor/tasks/v3_depth6_delay_sla_burden_t13/task.toml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.3"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "mindlab/v3_depth6_delay_sla_burden_t13"
|
| 5 |
+
description = "FlowBench v3 public task metadata. Public verifier is smoke-only."
|
| 6 |
+
authors = [{ name = "Mind Lab", email = "contact@mindlab.ltd" }]
|
| 7 |
+
keywords = ["flowbench", "tool-use", "data-orchestration", "operations"]
|
| 8 |
+
|
| 9 |
+
[metadata]
|
| 10 |
+
benchmark = "FlowBench-v3"
|
| 11 |
+
split = "public-task-only"
|
| 12 |
+
category = "data-processing"
|
| 13 |
+
depth = 6
|
| 14 |
+
|
| 15 |
+
[verifier]
|
| 16 |
+
timeout_sec = 120.0
|
| 17 |
+
|
| 18 |
+
[agent]
|
| 19 |
+
timeout_sec = 900.0
|
| 20 |
+
|
| 21 |
+
[environment]
|
| 22 |
+
network_mode = "no-network"
|
| 23 |
+
build_timeout_sec = 600.0
|
| 24 |
+
os = "linux"
|
| 25 |
+
cpus = 1
|
| 26 |
+
memory_mb = 2048
|
| 27 |
+
storage_mb = 2048
|
| 28 |
+
gpus = 0
|
harbor/tasks/v3_depth6_delay_sla_burden_t13/tests/check_output_shape.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
import re
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def write_reward(score: float, diagnostic: str) -> None:
|
| 11 |
+
log_dir = Path(os.environ.get("LOG_DIR", "/logs/verifier"))
|
| 12 |
+
log_dir.mkdir(parents=True, exist_ok=True)
|
| 13 |
+
(log_dir / "reward.txt").write_text(f"{score:.6g}\n")
|
| 14 |
+
(log_dir / "reward.json").write_text(
|
| 15 |
+
json.dumps({"reward": score, "smoke_only": True}, indent=2) + "\n"
|
| 16 |
+
)
|
| 17 |
+
(log_dir / "diagnostic.txt").write_text(diagnostic + "\n")
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def main() -> int:
|
| 21 |
+
app_dir = Path(os.environ.get("APP_DIR", "/app"))
|
| 22 |
+
task = json.loads((app_dir / "task.json").read_text())
|
| 23 |
+
answer_path = app_dir / "answer.txt"
|
| 24 |
+
if not answer_path.exists():
|
| 25 |
+
write_reward(0.0, "missing /app/answer.txt")
|
| 26 |
+
return 1
|
| 27 |
+
|
| 28 |
+
got = answer_path.read_text().strip()
|
| 29 |
+
if task["answer_format"] == "exact integer":
|
| 30 |
+
ok = bool(re.fullmatch(r"-?\d+", got))
|
| 31 |
+
diagnostic = "valid integer smoke output" if ok else f"not an exact integer: {got!r}"
|
| 32 |
+
else:
|
| 33 |
+
ok = bool(re.fullmatch(r"[A-Za-z]+", got))
|
| 34 |
+
diagnostic = "valid code smoke output" if ok else f"not an exact code: {got!r}"
|
| 35 |
+
|
| 36 |
+
# This is intentionally not official scoring; it only verifies I/O shape.
|
| 37 |
+
write_reward(1.0 if ok else 0.0, diagnostic)
|
| 38 |
+
return 0 if ok else 1
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
if __name__ == "__main__":
|
| 42 |
+
raise SystemExit(main())
|
harbor/tasks/v3_depth6_delay_sla_burden_t13/tests/test.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -u
|
| 3 |
+
python /tests/check_output_shape.py
|
harbor/tasks/v3_depth6_delay_sla_burden_t14/environment/Dockerfile
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.12-slim
|
| 2 |
+
WORKDIR /app
|
| 3 |
+
COPY flowbench_tools.py /app/flowbench_tools.py
|
| 4 |
+
COPY task.json /app/task.json
|
harbor/tasks/v3_depth6_delay_sla_burden_t14/environment/flowbench_tools.py
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Deterministic FlowBench v3 tools. This file contains no task answers."""
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
REGIONS = ["NA", "EU", "APAC", "LATAM"]
|
| 5 |
+
CATEGORIES = ["A", "B", "C", "D"]
|
| 6 |
+
CURRENCIES = {"NA": "USD", "EU": "EUR", "APAC": "JPY", "LATAM": "BRL"}
|
| 7 |
+
FX_TO_USD_BP = {"USD": 10000, "EUR": 10900, "JPY": 67, "BRL": 1850}
|
| 8 |
+
TIERS = ["std", "gold", "plat"]
|
| 9 |
+
DISCOUNT_PCT = {"std": 0, "gold": 10, "plat": 20}
|
| 10 |
+
CHANNELS = ["web", "store", "partner"]
|
| 11 |
+
MONTHS = [202601, 202602, 202603, 202604, 202605, 202606]
|
| 12 |
+
|
| 13 |
+
N_CUSTOMERS = 72
|
| 14 |
+
N_PRODUCTS = 48
|
| 15 |
+
N_ORDERS = 720
|
| 16 |
+
N_TICKETS = 260
|
| 17 |
+
N_RETURNS = 180
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def _h(*xs):
|
| 21 |
+
import hashlib
|
| 22 |
+
s = "|".join(str(x) for x in xs).encode()
|
| 23 |
+
return int.from_bytes(hashlib.sha256(s).digest()[:8], "big") & 0x7FFFFFFF
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def build_data():
|
| 27 |
+
customers = []
|
| 28 |
+
for cid in range(N_CUSTOMERS):
|
| 29 |
+
region = REGIONS[_h("region", cid) % len(REGIONS)]
|
| 30 |
+
customers.append({
|
| 31 |
+
"customer_id": cid,
|
| 32 |
+
"region": region,
|
| 33 |
+
"tier": TIERS[_h("tier", cid) % len(TIERS)],
|
| 34 |
+
"segment": ["consumer", "smb", "enterprise"][_h("segment", cid) % 3],
|
| 35 |
+
})
|
| 36 |
+
|
| 37 |
+
products = []
|
| 38 |
+
for pid in range(N_PRODUCTS):
|
| 39 |
+
cat = CATEGORIES[_h("cat", pid) % len(CATEGORIES)]
|
| 40 |
+
unit_price = 12 + _h("price", pid) % 240
|
| 41 |
+
cogs = unit_price * (45 + _h("margin", pid) % 35) // 100
|
| 42 |
+
products.append({
|
| 43 |
+
"product_id": pid,
|
| 44 |
+
"category": cat,
|
| 45 |
+
"unit_price_usd": unit_price,
|
| 46 |
+
"unit_cogs_usd": cogs,
|
| 47 |
+
"lead_time_days": 3 + _h("lead", pid) % 18,
|
| 48 |
+
})
|
| 49 |
+
|
| 50 |
+
inventory = []
|
| 51 |
+
for pid in range(N_PRODUCTS):
|
| 52 |
+
for region in REGIONS:
|
| 53 |
+
inventory.append({
|
| 54 |
+
"product_id": pid,
|
| 55 |
+
"region": region,
|
| 56 |
+
"on_hand": 10 + _h("onhand", pid, region) % 140,
|
| 57 |
+
"reserved": _h("reserved", pid, region) % 28,
|
| 58 |
+
"inbound": _h("inbound", pid, region) % 85,
|
| 59 |
+
})
|
| 60 |
+
|
| 61 |
+
orders = []
|
| 62 |
+
for oid in range(N_ORDERS):
|
| 63 |
+
customer_id = _h("ocust", oid) % N_CUSTOMERS
|
| 64 |
+
product_id = _h("oprod", oid) % N_PRODUCTS
|
| 65 |
+
month = MONTHS[_h("month", oid) % len(MONTHS)]
|
| 66 |
+
qty = 1 + _h("qty", oid) % 9
|
| 67 |
+
ship_days = 1 + _h("shipdays", oid) % 16
|
| 68 |
+
promised_days = 3 + _h("promise", oid) % 9
|
| 69 |
+
status = ["paid", "paid", "paid", "paid", "cancelled", "refunded"][
|
| 70 |
+
_h("status", oid) % 6]
|
| 71 |
+
orders.append({
|
| 72 |
+
"order_id": oid,
|
| 73 |
+
"customer_id": customer_id,
|
| 74 |
+
"product_id": product_id,
|
| 75 |
+
"month": month,
|
| 76 |
+
"qty": qty,
|
| 77 |
+
"status": status,
|
| 78 |
+
"channel": CHANNELS[_h("channel", oid) % len(CHANNELS)],
|
| 79 |
+
"ship_days": ship_days,
|
| 80 |
+
"promised_days": promised_days,
|
| 81 |
+
})
|
| 82 |
+
|
| 83 |
+
returns = []
|
| 84 |
+
for rid in range(N_RETURNS):
|
| 85 |
+
oid = _h("roid", rid) % N_ORDERS
|
| 86 |
+
order = orders[oid]
|
| 87 |
+
if order["status"] == "cancelled":
|
| 88 |
+
continue
|
| 89 |
+
returned_qty = 1 + _h("rqty", rid) % max(1, order["qty"])
|
| 90 |
+
reason = ["defect", "late", "changed_mind", "wrong_item"][_h("reason", rid) % 4]
|
| 91 |
+
returns.append({
|
| 92 |
+
"return_id": rid,
|
| 93 |
+
"order_id": oid,
|
| 94 |
+
"month": MONTHS[_h("rmonth", rid) % len(MONTHS)],
|
| 95 |
+
"returned_qty": returned_qty,
|
| 96 |
+
"reason": reason,
|
| 97 |
+
})
|
| 98 |
+
|
| 99 |
+
tickets = []
|
| 100 |
+
for tid in range(N_TICKETS):
|
| 101 |
+
oid = _h("toid", tid) % N_ORDERS
|
| 102 |
+
severity = ["low", "medium", "high", "critical"][_h("sev", tid) % 4]
|
| 103 |
+
opened = MONTHS[_h("tmonth", tid) % len(MONTHS)]
|
| 104 |
+
first_response_hours = 1 + _h("resp", tid) % 96
|
| 105 |
+
resolution_hours = first_response_hours + _h("res", tid) % 240
|
| 106 |
+
tickets.append({
|
| 107 |
+
"ticket_id": tid,
|
| 108 |
+
"order_id": oid,
|
| 109 |
+
"opened_month": opened,
|
| 110 |
+
"severity": severity,
|
| 111 |
+
"first_response_hours": first_response_hours,
|
| 112 |
+
"resolution_hours": resolution_hours,
|
| 113 |
+
})
|
| 114 |
+
|
| 115 |
+
return {
|
| 116 |
+
"customers": customers,
|
| 117 |
+
"products": products,
|
| 118 |
+
"inventory": inventory,
|
| 119 |
+
"orders": orders,
|
| 120 |
+
"returns": returns,
|
| 121 |
+
"tickets": tickets,
|
| 122 |
+
"fx_to_usd_bp": FX_TO_USD_BP,
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
DATA = build_data()
|
| 127 |
+
CUSTOMERS = {c["customer_id"]: c for c in DATA["customers"]}
|
| 128 |
+
PRODUCTS = {p["product_id"]: p for p in DATA["products"]}
|
| 129 |
+
ORDERS = {o["order_id"]: o for o in DATA["orders"]}
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
def region_currency(region: str) -> str:
|
| 133 |
+
return CURRENCIES[region]
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
def get_orders(region: str, category: str, month_start: int, month_end: int) -> list:
|
| 137 |
+
"""Paid/refunded order ids in a region/category/month window."""
|
| 138 |
+
out = []
|
| 139 |
+
for o in DATA["orders"]:
|
| 140 |
+
if o["status"] not in ("paid", "refunded"):
|
| 141 |
+
continue
|
| 142 |
+
c = CUSTOMERS[o["customer_id"]]
|
| 143 |
+
p = PRODUCTS[o["product_id"]]
|
| 144 |
+
if c["region"] == region and p["category"] == category and month_start <= o["month"] <= month_end:
|
| 145 |
+
out.append(o["order_id"])
|
| 146 |
+
return sorted(out)
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def order_gross_usd(order_id: int) -> int:
|
| 150 |
+
o = ORDERS[order_id]
|
| 151 |
+
p = PRODUCTS[o["product_id"]]
|
| 152 |
+
return o["qty"] * p["unit_price_usd"]
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
def order_margin_usd(order_id: int) -> int:
|
| 156 |
+
o = ORDERS[order_id]
|
| 157 |
+
p = PRODUCTS[o["product_id"]]
|
| 158 |
+
return o["qty"] * (p["unit_price_usd"] - p["unit_cogs_usd"])
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
def refund_usd(order_id: int) -> int:
|
| 162 |
+
o = ORDERS[order_id]
|
| 163 |
+
p = PRODUCTS[o["product_id"]]
|
| 164 |
+
qty = sum(r["returned_qty"] for r in DATA["returns"] if r["order_id"] == order_id)
|
| 165 |
+
qty = min(qty, o["qty"])
|
| 166 |
+
return qty * p["unit_price_usd"]
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def customer_tier(order_id: int) -> str:
|
| 170 |
+
o = ORDERS[order_id]
|
| 171 |
+
return CUSTOMERS[o["customer_id"]]["tier"]
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
def apply_discount(amount_usd: int, tier: str) -> int:
|
| 175 |
+
return amount_usd * (100 - DISCOUNT_PCT[tier]) // 100
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
def net_revenue_usd(order_id: int) -> int:
|
| 179 |
+
gross = apply_discount(order_gross_usd(order_id), customer_tier(order_id))
|
| 180 |
+
return max(0, gross - refund_usd(order_id))
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
def to_local(amount_usd: int, currency: str) -> int:
|
| 184 |
+
return amount_usd * 10000 // FX_TO_USD_BP[currency]
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def inventory_position(product_id: int, region: str) -> int:
|
| 188 |
+
row = next(x for x in DATA["inventory"]
|
| 189 |
+
if x["product_id"] == product_id and x["region"] == region)
|
| 190 |
+
return row["on_hand"] - row["reserved"] + row["inbound"]
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
def product_lead_time(product_id: int) -> int:
|
| 194 |
+
return PRODUCTS[product_id]["lead_time_days"]
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
def product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int:
|
| 198 |
+
totals = {}
|
| 199 |
+
for oid in get_orders(region, category, month_start, month_end):
|
| 200 |
+
o = ORDERS[oid]
|
| 201 |
+
totals[o["product_id"]] = totals.get(o["product_id"], 0) + o["qty"]
|
| 202 |
+
if not totals:
|
| 203 |
+
return -1
|
| 204 |
+
return min((-qty, pid) for pid, qty in totals.items())[1]
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
def units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int:
|
| 208 |
+
total = 0
|
| 209 |
+
for o in DATA["orders"]:
|
| 210 |
+
if o["product_id"] != product_id or o["status"] not in ("paid", "refunded"):
|
| 211 |
+
continue
|
| 212 |
+
c = CUSTOMERS[o["customer_id"]]
|
| 213 |
+
if c["region"] == region and month_start <= o["month"] <= month_end:
|
| 214 |
+
total += o["qty"]
|
| 215 |
+
return total
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def tickets_for_orders(order_ids: list, severity: str) -> list:
|
| 219 |
+
s = set(order_ids)
|
| 220 |
+
return sorted(t["ticket_id"] for t in DATA["tickets"]
|
| 221 |
+
if t["order_id"] in s and t["severity"] == severity)
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
def ticket_order_id(ticket_id: int) -> int:
|
| 225 |
+
return next(t["order_id"] for t in DATA["tickets"] if t["ticket_id"] == ticket_id)
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
def sla_breached(ticket_id: int, first_response_limit_hours: int,
|
| 229 |
+
resolution_limit_hours: int) -> bool:
|
| 230 |
+
t = next(x for x in DATA["tickets"] if x["ticket_id"] == ticket_id)
|
| 231 |
+
return (t["first_response_hours"] > first_response_limit_hours or
|
| 232 |
+
t["resolution_hours"] > resolution_limit_hours)
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
def delayed_orders(order_ids: list) -> list:
|
| 236 |
+
s = set(order_ids)
|
| 237 |
+
return sorted(o["order_id"] for o in DATA["orders"]
|
| 238 |
+
if o["order_id"] in s and o["ship_days"] > o["promised_days"])
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
def unique_customers(order_ids: list) -> list:
|
| 242 |
+
return sorted({ORDERS[oid]["customer_id"] for oid in order_ids})
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
def count_items(values: list) -> int:
|
| 246 |
+
return len(values)
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
def sum_values(values: list) -> int:
|
| 250 |
+
return sum(values)
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
def count_true(values: list) -> int:
|
| 254 |
+
return sum(1 for v in values if bool(v))
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
def count_below(values: list, threshold: int) -> int:
|
| 258 |
+
return sum(1 for v in values if v < threshold)
|
| 259 |
+
|
| 260 |
+
|
| 261 |
+
TOOLS = {
|
| 262 |
+
"region_currency": ("region_currency(region: str) -> str",
|
| 263 |
+
"ISO currency code for a region.", region_currency),
|
| 264 |
+
"get_orders": ("get_orders(region: str, category: str, month_start: int, month_end: int) -> list[int]",
|
| 265 |
+
"Paid/refunded order ids for a region, product category, and inclusive month window.",
|
| 266 |
+
get_orders),
|
| 267 |
+
"order_gross_usd": ("order_gross_usd(order_id: int) -> int",
|
| 268 |
+
"Gross order revenue in USD before discounts/refunds.", order_gross_usd),
|
| 269 |
+
"order_margin_usd": ("order_margin_usd(order_id: int) -> int",
|
| 270 |
+
"Gross order margin in USD before discounts/refunds.", order_margin_usd),
|
| 271 |
+
"refund_usd": ("refund_usd(order_id: int) -> int",
|
| 272 |
+
"Refund amount in USD for returned quantity on an order.", refund_usd),
|
| 273 |
+
"customer_tier": ("customer_tier(order_id: int) -> str",
|
| 274 |
+
"Customer loyalty tier for an order.", customer_tier),
|
| 275 |
+
"apply_discount": ("apply_discount(amount_usd: int, tier: str) -> int",
|
| 276 |
+
"Apply the order customer's loyalty discount to a USD amount.", apply_discount),
|
| 277 |
+
"net_revenue_usd": ("net_revenue_usd(order_id: int) -> int",
|
| 278 |
+
"Net USD revenue after loyalty discount and refunds.", net_revenue_usd),
|
| 279 |
+
"to_local": ("to_local(amount_usd: int, currency: str) -> int",
|
| 280 |
+
"Convert a USD integer amount to a local-currency integer.", to_local),
|
| 281 |
+
"inventory_position": ("inventory_position(product_id: int, region: str) -> int",
|
| 282 |
+
"Available inventory position: on_hand - reserved + inbound.",
|
| 283 |
+
inventory_position),
|
| 284 |
+
"product_lead_time": ("product_lead_time(product_id: int) -> int",
|
| 285 |
+
"Supplier lead time in days for a product.", product_lead_time),
|
| 286 |
+
"product_id_for_top_seller": (
|
| 287 |
+
"product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int",
|
| 288 |
+
"Product id with the highest units sold in a region/category/month window.",
|
| 289 |
+
product_id_for_top_seller),
|
| 290 |
+
"units_sold": ("units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int",
|
| 291 |
+
"Units sold for one product in a region and month window.", units_sold),
|
| 292 |
+
"tickets_for_orders": ("tickets_for_orders(order_ids: list[int], severity: str) -> list[int]",
|
| 293 |
+
"Support ticket ids for given orders and severity.", tickets_for_orders),
|
| 294 |
+
"ticket_order_id": ("ticket_order_id(ticket_id: int) -> int",
|
| 295 |
+
"Order id associated with a support ticket.", ticket_order_id),
|
| 296 |
+
"sla_breached": (
|
| 297 |
+
"sla_breached(ticket_id: int, first_response_limit_hours: int, resolution_limit_hours: int) -> bool",
|
| 298 |
+
"Whether a support ticket breaches first-response or resolution SLA.",
|
| 299 |
+
sla_breached),
|
| 300 |
+
"delayed_orders": ("delayed_orders(order_ids: list[int]) -> list[int]",
|
| 301 |
+
"Subset of order ids whose ship_days exceeded promised_days.", delayed_orders),
|
| 302 |
+
"unique_customers": ("unique_customers(order_ids: list[int]) -> list[int]",
|
| 303 |
+
"Unique customer ids among the given orders.", unique_customers),
|
| 304 |
+
"count_items": ("count_items(values: list) -> int", "Length of a list.", count_items),
|
| 305 |
+
"sum_values": ("sum_values(values: list[int]) -> int", "Sum a list of integers.", sum_values),
|
| 306 |
+
"count_true": ("count_true(values: list[bool]) -> int", "Count true values.", count_true),
|
| 307 |
+
"count_below": ("count_below(values: list[int], threshold: int) -> int",
|
| 308 |
+
"Count values below a threshold.", count_below),
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
__all__ = [name for name in TOOLS.keys()] + ['TOOLS']
|
harbor/tasks/v3_depth6_delay_sla_burden_t14/environment/task.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"task_id": "v3_depth6_delay_sla_burden_t14",
|
| 3 |
+
"depth": 6,
|
| 4 |
+
"family": "delay_sla_burden",
|
| 5 |
+
"params": {
|
| 6 |
+
"region": "APAC",
|
| 7 |
+
"category": "C",
|
| 8 |
+
"month_start": 202602,
|
| 9 |
+
"month_end": 202606
|
| 10 |
+
},
|
| 11 |
+
"question": "For region APAC, category C, months 202602-202606: get the orders, count delayed orders where ship_days exceeded promised_days, find high and critical support tickets for those orders, count tickets that breach a 24-hour first-response or 120-hour resolution SLA, and report delayed_order_count + breached_ticket_count.",
|
| 12 |
+
"answer_format": "exact integer"
|
| 13 |
+
}
|
harbor/tasks/v3_depth6_delay_sla_burden_t14/instruction.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FlowBench v3 Public Task
|
| 2 |
+
|
| 3 |
+
You are in `/app`. The file `/app/flowbench_tools.py` contains deterministic
|
| 4 |
+
Python tools over a synthetic business-operations dataset. Use those tools
|
| 5 |
+
to compute the requested value, then write the final output to
|
| 6 |
+
`/app/answer.txt`.
|
| 7 |
+
|
| 8 |
+
Required output:
|
| 9 |
+
- `/app/answer.txt` must contain only the exact integer.
|
| 10 |
+
- Use integer arithmetic for currency and counts. Do not use floating point
|
| 11 |
+
arithmetic.
|
| 12 |
+
|
| 13 |
+
Task:
|
| 14 |
+
For region APAC, category C, months 202602-202606: get the orders, count delayed orders where ship_days exceeded promised_days, find high and critical support tickets for those orders, count tickets that breach a 24-hour first-response or 120-hour resolution SLA, and report delayed_order_count + breached_ticket_count.
|
| 15 |
+
|
| 16 |
+
Available tools:
|
| 17 |
+
- `region_currency(region: str) -> str`: ISO currency code for a region.
|
| 18 |
+
- `get_orders(region: str, category: str, month_start: int, month_end: int) -> list[int]`: Paid/refunded order ids for a region, product category, and inclusive month window.
|
| 19 |
+
- `order_gross_usd(order_id: int) -> int`: Gross order revenue in USD before discounts/refunds.
|
| 20 |
+
- `order_margin_usd(order_id: int) -> int`: Gross order margin in USD before discounts/refunds.
|
| 21 |
+
- `refund_usd(order_id: int) -> int`: Refund amount in USD for returned quantity on an order.
|
| 22 |
+
- `customer_tier(order_id: int) -> str`: Customer loyalty tier for an order.
|
| 23 |
+
- `apply_discount(amount_usd: int, tier: str) -> int`: Apply the order customer's loyalty discount to a USD amount.
|
| 24 |
+
- `net_revenue_usd(order_id: int) -> int`: Net USD revenue after loyalty discount and refunds.
|
| 25 |
+
- `to_local(amount_usd: int, currency: str) -> int`: Convert a USD integer amount to a local-currency integer.
|
| 26 |
+
- `inventory_position(product_id: int, region: str) -> int`: Available inventory position: on_hand - reserved + inbound.
|
| 27 |
+
- `product_lead_time(product_id: int) -> int`: Supplier lead time in days for a product.
|
| 28 |
+
- `product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int`: Product id with the highest units sold in a region/category/month window.
|
| 29 |
+
- `units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int`: Units sold for one product in a region and month window.
|
| 30 |
+
- `tickets_for_orders(order_ids: list[int], severity: str) -> list[int]`: Support ticket ids for given orders and severity.
|
| 31 |
+
- `ticket_order_id(ticket_id: int) -> int`: Order id associated with a support ticket.
|
| 32 |
+
- `sla_breached(ticket_id: int, first_response_limit_hours: int, resolution_limit_hours: int) -> bool`: Whether a support ticket breaches first-response or resolution SLA.
|
| 33 |
+
- `delayed_orders(order_ids: list[int]) -> list[int]`: Subset of order ids whose ship_days exceeded promised_days.
|
| 34 |
+
- `unique_customers(order_ids: list[int]) -> list[int]`: Unique customer ids among the given orders.
|
| 35 |
+
- `count_items(values: list) -> int`: Length of a list.
|
| 36 |
+
- `sum_values(values: list[int]) -> int`: Sum a list of integers.
|
| 37 |
+
- `count_true(values: list[bool]) -> int`: Count true values.
|
| 38 |
+
- `count_below(values: list[int], threshold: int) -> int`: Count values below a threshold.
|
harbor/tasks/v3_depth6_delay_sla_burden_t14/task.toml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.3"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "mindlab/v3_depth6_delay_sla_burden_t14"
|
| 5 |
+
description = "FlowBench v3 public task metadata. Public verifier is smoke-only."
|
| 6 |
+
authors = [{ name = "Mind Lab", email = "contact@mindlab.ltd" }]
|
| 7 |
+
keywords = ["flowbench", "tool-use", "data-orchestration", "operations"]
|
| 8 |
+
|
| 9 |
+
[metadata]
|
| 10 |
+
benchmark = "FlowBench-v3"
|
| 11 |
+
split = "public-task-only"
|
| 12 |
+
category = "data-processing"
|
| 13 |
+
depth = 6
|
| 14 |
+
|
| 15 |
+
[verifier]
|
| 16 |
+
timeout_sec = 120.0
|
| 17 |
+
|
| 18 |
+
[agent]
|
| 19 |
+
timeout_sec = 900.0
|
| 20 |
+
|
| 21 |
+
[environment]
|
| 22 |
+
network_mode = "no-network"
|
| 23 |
+
build_timeout_sec = 600.0
|
| 24 |
+
os = "linux"
|
| 25 |
+
cpus = 1
|
| 26 |
+
memory_mb = 2048
|
| 27 |
+
storage_mb = 2048
|
| 28 |
+
gpus = 0
|
harbor/tasks/v3_depth6_delay_sla_burden_t14/tests/check_output_shape.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
import re
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def write_reward(score: float, diagnostic: str) -> None:
|
| 11 |
+
log_dir = Path(os.environ.get("LOG_DIR", "/logs/verifier"))
|
| 12 |
+
log_dir.mkdir(parents=True, exist_ok=True)
|
| 13 |
+
(log_dir / "reward.txt").write_text(f"{score:.6g}\n")
|
| 14 |
+
(log_dir / "reward.json").write_text(
|
| 15 |
+
json.dumps({"reward": score, "smoke_only": True}, indent=2) + "\n"
|
| 16 |
+
)
|
| 17 |
+
(log_dir / "diagnostic.txt").write_text(diagnostic + "\n")
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def main() -> int:
|
| 21 |
+
app_dir = Path(os.environ.get("APP_DIR", "/app"))
|
| 22 |
+
task = json.loads((app_dir / "task.json").read_text())
|
| 23 |
+
answer_path = app_dir / "answer.txt"
|
| 24 |
+
if not answer_path.exists():
|
| 25 |
+
write_reward(0.0, "missing /app/answer.txt")
|
| 26 |
+
return 1
|
| 27 |
+
|
| 28 |
+
got = answer_path.read_text().strip()
|
| 29 |
+
if task["answer_format"] == "exact integer":
|
| 30 |
+
ok = bool(re.fullmatch(r"-?\d+", got))
|
| 31 |
+
diagnostic = "valid integer smoke output" if ok else f"not an exact integer: {got!r}"
|
| 32 |
+
else:
|
| 33 |
+
ok = bool(re.fullmatch(r"[A-Za-z]+", got))
|
| 34 |
+
diagnostic = "valid code smoke output" if ok else f"not an exact code: {got!r}"
|
| 35 |
+
|
| 36 |
+
# This is intentionally not official scoring; it only verifies I/O shape.
|
| 37 |
+
write_reward(1.0 if ok else 0.0, diagnostic)
|
| 38 |
+
return 0 if ok else 1
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
if __name__ == "__main__":
|
| 42 |
+
raise SystemExit(main())
|
harbor/tasks/v3_depth6_delay_sla_burden_t14/tests/test.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -u
|
| 3 |
+
python /tests/check_output_shape.py
|
harbor/tasks/v3_depth6_delay_sla_burden_t15/environment/Dockerfile
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.12-slim
|
| 2 |
+
WORKDIR /app
|
| 3 |
+
COPY flowbench_tools.py /app/flowbench_tools.py
|
| 4 |
+
COPY task.json /app/task.json
|
harbor/tasks/v3_depth6_delay_sla_burden_t15/environment/flowbench_tools.py
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Deterministic FlowBench v3 tools. This file contains no task answers."""
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
REGIONS = ["NA", "EU", "APAC", "LATAM"]
|
| 5 |
+
CATEGORIES = ["A", "B", "C", "D"]
|
| 6 |
+
CURRENCIES = {"NA": "USD", "EU": "EUR", "APAC": "JPY", "LATAM": "BRL"}
|
| 7 |
+
FX_TO_USD_BP = {"USD": 10000, "EUR": 10900, "JPY": 67, "BRL": 1850}
|
| 8 |
+
TIERS = ["std", "gold", "plat"]
|
| 9 |
+
DISCOUNT_PCT = {"std": 0, "gold": 10, "plat": 20}
|
| 10 |
+
CHANNELS = ["web", "store", "partner"]
|
| 11 |
+
MONTHS = [202601, 202602, 202603, 202604, 202605, 202606]
|
| 12 |
+
|
| 13 |
+
N_CUSTOMERS = 72
|
| 14 |
+
N_PRODUCTS = 48
|
| 15 |
+
N_ORDERS = 720
|
| 16 |
+
N_TICKETS = 260
|
| 17 |
+
N_RETURNS = 180
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def _h(*xs):
|
| 21 |
+
import hashlib
|
| 22 |
+
s = "|".join(str(x) for x in xs).encode()
|
| 23 |
+
return int.from_bytes(hashlib.sha256(s).digest()[:8], "big") & 0x7FFFFFFF
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def build_data():
|
| 27 |
+
customers = []
|
| 28 |
+
for cid in range(N_CUSTOMERS):
|
| 29 |
+
region = REGIONS[_h("region", cid) % len(REGIONS)]
|
| 30 |
+
customers.append({
|
| 31 |
+
"customer_id": cid,
|
| 32 |
+
"region": region,
|
| 33 |
+
"tier": TIERS[_h("tier", cid) % len(TIERS)],
|
| 34 |
+
"segment": ["consumer", "smb", "enterprise"][_h("segment", cid) % 3],
|
| 35 |
+
})
|
| 36 |
+
|
| 37 |
+
products = []
|
| 38 |
+
for pid in range(N_PRODUCTS):
|
| 39 |
+
cat = CATEGORIES[_h("cat", pid) % len(CATEGORIES)]
|
| 40 |
+
unit_price = 12 + _h("price", pid) % 240
|
| 41 |
+
cogs = unit_price * (45 + _h("margin", pid) % 35) // 100
|
| 42 |
+
products.append({
|
| 43 |
+
"product_id": pid,
|
| 44 |
+
"category": cat,
|
| 45 |
+
"unit_price_usd": unit_price,
|
| 46 |
+
"unit_cogs_usd": cogs,
|
| 47 |
+
"lead_time_days": 3 + _h("lead", pid) % 18,
|
| 48 |
+
})
|
| 49 |
+
|
| 50 |
+
inventory = []
|
| 51 |
+
for pid in range(N_PRODUCTS):
|
| 52 |
+
for region in REGIONS:
|
| 53 |
+
inventory.append({
|
| 54 |
+
"product_id": pid,
|
| 55 |
+
"region": region,
|
| 56 |
+
"on_hand": 10 + _h("onhand", pid, region) % 140,
|
| 57 |
+
"reserved": _h("reserved", pid, region) % 28,
|
| 58 |
+
"inbound": _h("inbound", pid, region) % 85,
|
| 59 |
+
})
|
| 60 |
+
|
| 61 |
+
orders = []
|
| 62 |
+
for oid in range(N_ORDERS):
|
| 63 |
+
customer_id = _h("ocust", oid) % N_CUSTOMERS
|
| 64 |
+
product_id = _h("oprod", oid) % N_PRODUCTS
|
| 65 |
+
month = MONTHS[_h("month", oid) % len(MONTHS)]
|
| 66 |
+
qty = 1 + _h("qty", oid) % 9
|
| 67 |
+
ship_days = 1 + _h("shipdays", oid) % 16
|
| 68 |
+
promised_days = 3 + _h("promise", oid) % 9
|
| 69 |
+
status = ["paid", "paid", "paid", "paid", "cancelled", "refunded"][
|
| 70 |
+
_h("status", oid) % 6]
|
| 71 |
+
orders.append({
|
| 72 |
+
"order_id": oid,
|
| 73 |
+
"customer_id": customer_id,
|
| 74 |
+
"product_id": product_id,
|
| 75 |
+
"month": month,
|
| 76 |
+
"qty": qty,
|
| 77 |
+
"status": status,
|
| 78 |
+
"channel": CHANNELS[_h("channel", oid) % len(CHANNELS)],
|
| 79 |
+
"ship_days": ship_days,
|
| 80 |
+
"promised_days": promised_days,
|
| 81 |
+
})
|
| 82 |
+
|
| 83 |
+
returns = []
|
| 84 |
+
for rid in range(N_RETURNS):
|
| 85 |
+
oid = _h("roid", rid) % N_ORDERS
|
| 86 |
+
order = orders[oid]
|
| 87 |
+
if order["status"] == "cancelled":
|
| 88 |
+
continue
|
| 89 |
+
returned_qty = 1 + _h("rqty", rid) % max(1, order["qty"])
|
| 90 |
+
reason = ["defect", "late", "changed_mind", "wrong_item"][_h("reason", rid) % 4]
|
| 91 |
+
returns.append({
|
| 92 |
+
"return_id": rid,
|
| 93 |
+
"order_id": oid,
|
| 94 |
+
"month": MONTHS[_h("rmonth", rid) % len(MONTHS)],
|
| 95 |
+
"returned_qty": returned_qty,
|
| 96 |
+
"reason": reason,
|
| 97 |
+
})
|
| 98 |
+
|
| 99 |
+
tickets = []
|
| 100 |
+
for tid in range(N_TICKETS):
|
| 101 |
+
oid = _h("toid", tid) % N_ORDERS
|
| 102 |
+
severity = ["low", "medium", "high", "critical"][_h("sev", tid) % 4]
|
| 103 |
+
opened = MONTHS[_h("tmonth", tid) % len(MONTHS)]
|
| 104 |
+
first_response_hours = 1 + _h("resp", tid) % 96
|
| 105 |
+
resolution_hours = first_response_hours + _h("res", tid) % 240
|
| 106 |
+
tickets.append({
|
| 107 |
+
"ticket_id": tid,
|
| 108 |
+
"order_id": oid,
|
| 109 |
+
"opened_month": opened,
|
| 110 |
+
"severity": severity,
|
| 111 |
+
"first_response_hours": first_response_hours,
|
| 112 |
+
"resolution_hours": resolution_hours,
|
| 113 |
+
})
|
| 114 |
+
|
| 115 |
+
return {
|
| 116 |
+
"customers": customers,
|
| 117 |
+
"products": products,
|
| 118 |
+
"inventory": inventory,
|
| 119 |
+
"orders": orders,
|
| 120 |
+
"returns": returns,
|
| 121 |
+
"tickets": tickets,
|
| 122 |
+
"fx_to_usd_bp": FX_TO_USD_BP,
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
DATA = build_data()
|
| 127 |
+
CUSTOMERS = {c["customer_id"]: c for c in DATA["customers"]}
|
| 128 |
+
PRODUCTS = {p["product_id"]: p for p in DATA["products"]}
|
| 129 |
+
ORDERS = {o["order_id"]: o for o in DATA["orders"]}
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
def region_currency(region: str) -> str:
|
| 133 |
+
return CURRENCIES[region]
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
def get_orders(region: str, category: str, month_start: int, month_end: int) -> list:
|
| 137 |
+
"""Paid/refunded order ids in a region/category/month window."""
|
| 138 |
+
out = []
|
| 139 |
+
for o in DATA["orders"]:
|
| 140 |
+
if o["status"] not in ("paid", "refunded"):
|
| 141 |
+
continue
|
| 142 |
+
c = CUSTOMERS[o["customer_id"]]
|
| 143 |
+
p = PRODUCTS[o["product_id"]]
|
| 144 |
+
if c["region"] == region and p["category"] == category and month_start <= o["month"] <= month_end:
|
| 145 |
+
out.append(o["order_id"])
|
| 146 |
+
return sorted(out)
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def order_gross_usd(order_id: int) -> int:
|
| 150 |
+
o = ORDERS[order_id]
|
| 151 |
+
p = PRODUCTS[o["product_id"]]
|
| 152 |
+
return o["qty"] * p["unit_price_usd"]
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
def order_margin_usd(order_id: int) -> int:
|
| 156 |
+
o = ORDERS[order_id]
|
| 157 |
+
p = PRODUCTS[o["product_id"]]
|
| 158 |
+
return o["qty"] * (p["unit_price_usd"] - p["unit_cogs_usd"])
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
def refund_usd(order_id: int) -> int:
|
| 162 |
+
o = ORDERS[order_id]
|
| 163 |
+
p = PRODUCTS[o["product_id"]]
|
| 164 |
+
qty = sum(r["returned_qty"] for r in DATA["returns"] if r["order_id"] == order_id)
|
| 165 |
+
qty = min(qty, o["qty"])
|
| 166 |
+
return qty * p["unit_price_usd"]
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def customer_tier(order_id: int) -> str:
|
| 170 |
+
o = ORDERS[order_id]
|
| 171 |
+
return CUSTOMERS[o["customer_id"]]["tier"]
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
def apply_discount(amount_usd: int, tier: str) -> int:
|
| 175 |
+
return amount_usd * (100 - DISCOUNT_PCT[tier]) // 100
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
def net_revenue_usd(order_id: int) -> int:
|
| 179 |
+
gross = apply_discount(order_gross_usd(order_id), customer_tier(order_id))
|
| 180 |
+
return max(0, gross - refund_usd(order_id))
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
def to_local(amount_usd: int, currency: str) -> int:
|
| 184 |
+
return amount_usd * 10000 // FX_TO_USD_BP[currency]
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def inventory_position(product_id: int, region: str) -> int:
|
| 188 |
+
row = next(x for x in DATA["inventory"]
|
| 189 |
+
if x["product_id"] == product_id and x["region"] == region)
|
| 190 |
+
return row["on_hand"] - row["reserved"] + row["inbound"]
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
def product_lead_time(product_id: int) -> int:
|
| 194 |
+
return PRODUCTS[product_id]["lead_time_days"]
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
def product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int:
|
| 198 |
+
totals = {}
|
| 199 |
+
for oid in get_orders(region, category, month_start, month_end):
|
| 200 |
+
o = ORDERS[oid]
|
| 201 |
+
totals[o["product_id"]] = totals.get(o["product_id"], 0) + o["qty"]
|
| 202 |
+
if not totals:
|
| 203 |
+
return -1
|
| 204 |
+
return min((-qty, pid) for pid, qty in totals.items())[1]
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
def units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int:
|
| 208 |
+
total = 0
|
| 209 |
+
for o in DATA["orders"]:
|
| 210 |
+
if o["product_id"] != product_id or o["status"] not in ("paid", "refunded"):
|
| 211 |
+
continue
|
| 212 |
+
c = CUSTOMERS[o["customer_id"]]
|
| 213 |
+
if c["region"] == region and month_start <= o["month"] <= month_end:
|
| 214 |
+
total += o["qty"]
|
| 215 |
+
return total
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def tickets_for_orders(order_ids: list, severity: str) -> list:
|
| 219 |
+
s = set(order_ids)
|
| 220 |
+
return sorted(t["ticket_id"] for t in DATA["tickets"]
|
| 221 |
+
if t["order_id"] in s and t["severity"] == severity)
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
def ticket_order_id(ticket_id: int) -> int:
|
| 225 |
+
return next(t["order_id"] for t in DATA["tickets"] if t["ticket_id"] == ticket_id)
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
def sla_breached(ticket_id: int, first_response_limit_hours: int,
|
| 229 |
+
resolution_limit_hours: int) -> bool:
|
| 230 |
+
t = next(x for x in DATA["tickets"] if x["ticket_id"] == ticket_id)
|
| 231 |
+
return (t["first_response_hours"] > first_response_limit_hours or
|
| 232 |
+
t["resolution_hours"] > resolution_limit_hours)
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
def delayed_orders(order_ids: list) -> list:
|
| 236 |
+
s = set(order_ids)
|
| 237 |
+
return sorted(o["order_id"] for o in DATA["orders"]
|
| 238 |
+
if o["order_id"] in s and o["ship_days"] > o["promised_days"])
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
def unique_customers(order_ids: list) -> list:
|
| 242 |
+
return sorted({ORDERS[oid]["customer_id"] for oid in order_ids})
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
def count_items(values: list) -> int:
|
| 246 |
+
return len(values)
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
def sum_values(values: list) -> int:
|
| 250 |
+
return sum(values)
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
def count_true(values: list) -> int:
|
| 254 |
+
return sum(1 for v in values if bool(v))
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
def count_below(values: list, threshold: int) -> int:
|
| 258 |
+
return sum(1 for v in values if v < threshold)
|
| 259 |
+
|
| 260 |
+
|
| 261 |
+
TOOLS = {
|
| 262 |
+
"region_currency": ("region_currency(region: str) -> str",
|
| 263 |
+
"ISO currency code for a region.", region_currency),
|
| 264 |
+
"get_orders": ("get_orders(region: str, category: str, month_start: int, month_end: int) -> list[int]",
|
| 265 |
+
"Paid/refunded order ids for a region, product category, and inclusive month window.",
|
| 266 |
+
get_orders),
|
| 267 |
+
"order_gross_usd": ("order_gross_usd(order_id: int) -> int",
|
| 268 |
+
"Gross order revenue in USD before discounts/refunds.", order_gross_usd),
|
| 269 |
+
"order_margin_usd": ("order_margin_usd(order_id: int) -> int",
|
| 270 |
+
"Gross order margin in USD before discounts/refunds.", order_margin_usd),
|
| 271 |
+
"refund_usd": ("refund_usd(order_id: int) -> int",
|
| 272 |
+
"Refund amount in USD for returned quantity on an order.", refund_usd),
|
| 273 |
+
"customer_tier": ("customer_tier(order_id: int) -> str",
|
| 274 |
+
"Customer loyalty tier for an order.", customer_tier),
|
| 275 |
+
"apply_discount": ("apply_discount(amount_usd: int, tier: str) -> int",
|
| 276 |
+
"Apply the order customer's loyalty discount to a USD amount.", apply_discount),
|
| 277 |
+
"net_revenue_usd": ("net_revenue_usd(order_id: int) -> int",
|
| 278 |
+
"Net USD revenue after loyalty discount and refunds.", net_revenue_usd),
|
| 279 |
+
"to_local": ("to_local(amount_usd: int, currency: str) -> int",
|
| 280 |
+
"Convert a USD integer amount to a local-currency integer.", to_local),
|
| 281 |
+
"inventory_position": ("inventory_position(product_id: int, region: str) -> int",
|
| 282 |
+
"Available inventory position: on_hand - reserved + inbound.",
|
| 283 |
+
inventory_position),
|
| 284 |
+
"product_lead_time": ("product_lead_time(product_id: int) -> int",
|
| 285 |
+
"Supplier lead time in days for a product.", product_lead_time),
|
| 286 |
+
"product_id_for_top_seller": (
|
| 287 |
+
"product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int",
|
| 288 |
+
"Product id with the highest units sold in a region/category/month window.",
|
| 289 |
+
product_id_for_top_seller),
|
| 290 |
+
"units_sold": ("units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int",
|
| 291 |
+
"Units sold for one product in a region and month window.", units_sold),
|
| 292 |
+
"tickets_for_orders": ("tickets_for_orders(order_ids: list[int], severity: str) -> list[int]",
|
| 293 |
+
"Support ticket ids for given orders and severity.", tickets_for_orders),
|
| 294 |
+
"ticket_order_id": ("ticket_order_id(ticket_id: int) -> int",
|
| 295 |
+
"Order id associated with a support ticket.", ticket_order_id),
|
| 296 |
+
"sla_breached": (
|
| 297 |
+
"sla_breached(ticket_id: int, first_response_limit_hours: int, resolution_limit_hours: int) -> bool",
|
| 298 |
+
"Whether a support ticket breaches first-response or resolution SLA.",
|
| 299 |
+
sla_breached),
|
| 300 |
+
"delayed_orders": ("delayed_orders(order_ids: list[int]) -> list[int]",
|
| 301 |
+
"Subset of order ids whose ship_days exceeded promised_days.", delayed_orders),
|
| 302 |
+
"unique_customers": ("unique_customers(order_ids: list[int]) -> list[int]",
|
| 303 |
+
"Unique customer ids among the given orders.", unique_customers),
|
| 304 |
+
"count_items": ("count_items(values: list) -> int", "Length of a list.", count_items),
|
| 305 |
+
"sum_values": ("sum_values(values: list[int]) -> int", "Sum a list of integers.", sum_values),
|
| 306 |
+
"count_true": ("count_true(values: list[bool]) -> int", "Count true values.", count_true),
|
| 307 |
+
"count_below": ("count_below(values: list[int], threshold: int) -> int",
|
| 308 |
+
"Count values below a threshold.", count_below),
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
__all__ = [name for name in TOOLS.keys()] + ['TOOLS']
|
harbor/tasks/v3_depth6_delay_sla_burden_t15/environment/task.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"task_id": "v3_depth6_delay_sla_burden_t15",
|
| 3 |
+
"depth": 6,
|
| 4 |
+
"family": "delay_sla_burden",
|
| 5 |
+
"params": {
|
| 6 |
+
"region": "LATAM",
|
| 7 |
+
"category": "D",
|
| 8 |
+
"month_start": 202601,
|
| 9 |
+
"month_end": 202605
|
| 10 |
+
},
|
| 11 |
+
"question": "For region LATAM, category D, months 202601-202605: get the orders, count delayed orders where ship_days exceeded promised_days, find high and critical support tickets for those orders, count tickets that breach a 24-hour first-response or 120-hour resolution SLA, and report delayed_order_count + breached_ticket_count.",
|
| 12 |
+
"answer_format": "exact integer"
|
| 13 |
+
}
|
harbor/tasks/v3_depth6_delay_sla_burden_t15/instruction.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FlowBench v3 Public Task
|
| 2 |
+
|
| 3 |
+
You are in `/app`. The file `/app/flowbench_tools.py` contains deterministic
|
| 4 |
+
Python tools over a synthetic business-operations dataset. Use those tools
|
| 5 |
+
to compute the requested value, then write the final output to
|
| 6 |
+
`/app/answer.txt`.
|
| 7 |
+
|
| 8 |
+
Required output:
|
| 9 |
+
- `/app/answer.txt` must contain only the exact integer.
|
| 10 |
+
- Use integer arithmetic for currency and counts. Do not use floating point
|
| 11 |
+
arithmetic.
|
| 12 |
+
|
| 13 |
+
Task:
|
| 14 |
+
For region LATAM, category D, months 202601-202605: get the orders, count delayed orders where ship_days exceeded promised_days, find high and critical support tickets for those orders, count tickets that breach a 24-hour first-response or 120-hour resolution SLA, and report delayed_order_count + breached_ticket_count.
|
| 15 |
+
|
| 16 |
+
Available tools:
|
| 17 |
+
- `region_currency(region: str) -> str`: ISO currency code for a region.
|
| 18 |
+
- `get_orders(region: str, category: str, month_start: int, month_end: int) -> list[int]`: Paid/refunded order ids for a region, product category, and inclusive month window.
|
| 19 |
+
- `order_gross_usd(order_id: int) -> int`: Gross order revenue in USD before discounts/refunds.
|
| 20 |
+
- `order_margin_usd(order_id: int) -> int`: Gross order margin in USD before discounts/refunds.
|
| 21 |
+
- `refund_usd(order_id: int) -> int`: Refund amount in USD for returned quantity on an order.
|
| 22 |
+
- `customer_tier(order_id: int) -> str`: Customer loyalty tier for an order.
|
| 23 |
+
- `apply_discount(amount_usd: int, tier: str) -> int`: Apply the order customer's loyalty discount to a USD amount.
|
| 24 |
+
- `net_revenue_usd(order_id: int) -> int`: Net USD revenue after loyalty discount and refunds.
|
| 25 |
+
- `to_local(amount_usd: int, currency: str) -> int`: Convert a USD integer amount to a local-currency integer.
|
| 26 |
+
- `inventory_position(product_id: int, region: str) -> int`: Available inventory position: on_hand - reserved + inbound.
|
| 27 |
+
- `product_lead_time(product_id: int) -> int`: Supplier lead time in days for a product.
|
| 28 |
+
- `product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int`: Product id with the highest units sold in a region/category/month window.
|
| 29 |
+
- `units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int`: Units sold for one product in a region and month window.
|
| 30 |
+
- `tickets_for_orders(order_ids: list[int], severity: str) -> list[int]`: Support ticket ids for given orders and severity.
|
| 31 |
+
- `ticket_order_id(ticket_id: int) -> int`: Order id associated with a support ticket.
|
| 32 |
+
- `sla_breached(ticket_id: int, first_response_limit_hours: int, resolution_limit_hours: int) -> bool`: Whether a support ticket breaches first-response or resolution SLA.
|
| 33 |
+
- `delayed_orders(order_ids: list[int]) -> list[int]`: Subset of order ids whose ship_days exceeded promised_days.
|
| 34 |
+
- `unique_customers(order_ids: list[int]) -> list[int]`: Unique customer ids among the given orders.
|
| 35 |
+
- `count_items(values: list) -> int`: Length of a list.
|
| 36 |
+
- `sum_values(values: list[int]) -> int`: Sum a list of integers.
|
| 37 |
+
- `count_true(values: list[bool]) -> int`: Count true values.
|
| 38 |
+
- `count_below(values: list[int], threshold: int) -> int`: Count values below a threshold.
|
harbor/tasks/v3_depth6_delay_sla_burden_t15/task.toml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.3"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "mindlab/v3_depth6_delay_sla_burden_t15"
|
| 5 |
+
description = "FlowBench v3 public task metadata. Public verifier is smoke-only."
|
| 6 |
+
authors = [{ name = "Mind Lab", email = "contact@mindlab.ltd" }]
|
| 7 |
+
keywords = ["flowbench", "tool-use", "data-orchestration", "operations"]
|
| 8 |
+
|
| 9 |
+
[metadata]
|
| 10 |
+
benchmark = "FlowBench-v3"
|
| 11 |
+
split = "public-task-only"
|
| 12 |
+
category = "data-processing"
|
| 13 |
+
depth = 6
|
| 14 |
+
|
| 15 |
+
[verifier]
|
| 16 |
+
timeout_sec = 120.0
|
| 17 |
+
|
| 18 |
+
[agent]
|
| 19 |
+
timeout_sec = 900.0
|
| 20 |
+
|
| 21 |
+
[environment]
|
| 22 |
+
network_mode = "no-network"
|
| 23 |
+
build_timeout_sec = 600.0
|
| 24 |
+
os = "linux"
|
| 25 |
+
cpus = 1
|
| 26 |
+
memory_mb = 2048
|
| 27 |
+
storage_mb = 2048
|
| 28 |
+
gpus = 0
|
harbor/tasks/v3_depth6_delay_sla_burden_t15/tests/check_output_shape.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
import re
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def write_reward(score: float, diagnostic: str) -> None:
|
| 11 |
+
log_dir = Path(os.environ.get("LOG_DIR", "/logs/verifier"))
|
| 12 |
+
log_dir.mkdir(parents=True, exist_ok=True)
|
| 13 |
+
(log_dir / "reward.txt").write_text(f"{score:.6g}\n")
|
| 14 |
+
(log_dir / "reward.json").write_text(
|
| 15 |
+
json.dumps({"reward": score, "smoke_only": True}, indent=2) + "\n"
|
| 16 |
+
)
|
| 17 |
+
(log_dir / "diagnostic.txt").write_text(diagnostic + "\n")
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def main() -> int:
|
| 21 |
+
app_dir = Path(os.environ.get("APP_DIR", "/app"))
|
| 22 |
+
task = json.loads((app_dir / "task.json").read_text())
|
| 23 |
+
answer_path = app_dir / "answer.txt"
|
| 24 |
+
if not answer_path.exists():
|
| 25 |
+
write_reward(0.0, "missing /app/answer.txt")
|
| 26 |
+
return 1
|
| 27 |
+
|
| 28 |
+
got = answer_path.read_text().strip()
|
| 29 |
+
if task["answer_format"] == "exact integer":
|
| 30 |
+
ok = bool(re.fullmatch(r"-?\d+", got))
|
| 31 |
+
diagnostic = "valid integer smoke output" if ok else f"not an exact integer: {got!r}"
|
| 32 |
+
else:
|
| 33 |
+
ok = bool(re.fullmatch(r"[A-Za-z]+", got))
|
| 34 |
+
diagnostic = "valid code smoke output" if ok else f"not an exact code: {got!r}"
|
| 35 |
+
|
| 36 |
+
# This is intentionally not official scoring; it only verifies I/O shape.
|
| 37 |
+
write_reward(1.0 if ok else 0.0, diagnostic)
|
| 38 |
+
return 0 if ok else 1
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
if __name__ == "__main__":
|
| 42 |
+
raise SystemExit(main())
|
harbor/tasks/v3_depth6_delay_sla_burden_t15/tests/test.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -u
|
| 3 |
+
python /tests/check_output_shape.py
|
harbor/tasks/v3_depth6_delay_sla_burden_t16/environment/Dockerfile
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.12-slim
|
| 2 |
+
WORKDIR /app
|
| 3 |
+
COPY flowbench_tools.py /app/flowbench_tools.py
|
| 4 |
+
COPY task.json /app/task.json
|
harbor/tasks/v3_depth6_delay_sla_burden_t16/environment/flowbench_tools.py
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Deterministic FlowBench v3 tools. This file contains no task answers."""
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
REGIONS = ["NA", "EU", "APAC", "LATAM"]
|
| 5 |
+
CATEGORIES = ["A", "B", "C", "D"]
|
| 6 |
+
CURRENCIES = {"NA": "USD", "EU": "EUR", "APAC": "JPY", "LATAM": "BRL"}
|
| 7 |
+
FX_TO_USD_BP = {"USD": 10000, "EUR": 10900, "JPY": 67, "BRL": 1850}
|
| 8 |
+
TIERS = ["std", "gold", "plat"]
|
| 9 |
+
DISCOUNT_PCT = {"std": 0, "gold": 10, "plat": 20}
|
| 10 |
+
CHANNELS = ["web", "store", "partner"]
|
| 11 |
+
MONTHS = [202601, 202602, 202603, 202604, 202605, 202606]
|
| 12 |
+
|
| 13 |
+
N_CUSTOMERS = 72
|
| 14 |
+
N_PRODUCTS = 48
|
| 15 |
+
N_ORDERS = 720
|
| 16 |
+
N_TICKETS = 260
|
| 17 |
+
N_RETURNS = 180
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def _h(*xs):
|
| 21 |
+
import hashlib
|
| 22 |
+
s = "|".join(str(x) for x in xs).encode()
|
| 23 |
+
return int.from_bytes(hashlib.sha256(s).digest()[:8], "big") & 0x7FFFFFFF
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def build_data():
|
| 27 |
+
customers = []
|
| 28 |
+
for cid in range(N_CUSTOMERS):
|
| 29 |
+
region = REGIONS[_h("region", cid) % len(REGIONS)]
|
| 30 |
+
customers.append({
|
| 31 |
+
"customer_id": cid,
|
| 32 |
+
"region": region,
|
| 33 |
+
"tier": TIERS[_h("tier", cid) % len(TIERS)],
|
| 34 |
+
"segment": ["consumer", "smb", "enterprise"][_h("segment", cid) % 3],
|
| 35 |
+
})
|
| 36 |
+
|
| 37 |
+
products = []
|
| 38 |
+
for pid in range(N_PRODUCTS):
|
| 39 |
+
cat = CATEGORIES[_h("cat", pid) % len(CATEGORIES)]
|
| 40 |
+
unit_price = 12 + _h("price", pid) % 240
|
| 41 |
+
cogs = unit_price * (45 + _h("margin", pid) % 35) // 100
|
| 42 |
+
products.append({
|
| 43 |
+
"product_id": pid,
|
| 44 |
+
"category": cat,
|
| 45 |
+
"unit_price_usd": unit_price,
|
| 46 |
+
"unit_cogs_usd": cogs,
|
| 47 |
+
"lead_time_days": 3 + _h("lead", pid) % 18,
|
| 48 |
+
})
|
| 49 |
+
|
| 50 |
+
inventory = []
|
| 51 |
+
for pid in range(N_PRODUCTS):
|
| 52 |
+
for region in REGIONS:
|
| 53 |
+
inventory.append({
|
| 54 |
+
"product_id": pid,
|
| 55 |
+
"region": region,
|
| 56 |
+
"on_hand": 10 + _h("onhand", pid, region) % 140,
|
| 57 |
+
"reserved": _h("reserved", pid, region) % 28,
|
| 58 |
+
"inbound": _h("inbound", pid, region) % 85,
|
| 59 |
+
})
|
| 60 |
+
|
| 61 |
+
orders = []
|
| 62 |
+
for oid in range(N_ORDERS):
|
| 63 |
+
customer_id = _h("ocust", oid) % N_CUSTOMERS
|
| 64 |
+
product_id = _h("oprod", oid) % N_PRODUCTS
|
| 65 |
+
month = MONTHS[_h("month", oid) % len(MONTHS)]
|
| 66 |
+
qty = 1 + _h("qty", oid) % 9
|
| 67 |
+
ship_days = 1 + _h("shipdays", oid) % 16
|
| 68 |
+
promised_days = 3 + _h("promise", oid) % 9
|
| 69 |
+
status = ["paid", "paid", "paid", "paid", "cancelled", "refunded"][
|
| 70 |
+
_h("status", oid) % 6]
|
| 71 |
+
orders.append({
|
| 72 |
+
"order_id": oid,
|
| 73 |
+
"customer_id": customer_id,
|
| 74 |
+
"product_id": product_id,
|
| 75 |
+
"month": month,
|
| 76 |
+
"qty": qty,
|
| 77 |
+
"status": status,
|
| 78 |
+
"channel": CHANNELS[_h("channel", oid) % len(CHANNELS)],
|
| 79 |
+
"ship_days": ship_days,
|
| 80 |
+
"promised_days": promised_days,
|
| 81 |
+
})
|
| 82 |
+
|
| 83 |
+
returns = []
|
| 84 |
+
for rid in range(N_RETURNS):
|
| 85 |
+
oid = _h("roid", rid) % N_ORDERS
|
| 86 |
+
order = orders[oid]
|
| 87 |
+
if order["status"] == "cancelled":
|
| 88 |
+
continue
|
| 89 |
+
returned_qty = 1 + _h("rqty", rid) % max(1, order["qty"])
|
| 90 |
+
reason = ["defect", "late", "changed_mind", "wrong_item"][_h("reason", rid) % 4]
|
| 91 |
+
returns.append({
|
| 92 |
+
"return_id": rid,
|
| 93 |
+
"order_id": oid,
|
| 94 |
+
"month": MONTHS[_h("rmonth", rid) % len(MONTHS)],
|
| 95 |
+
"returned_qty": returned_qty,
|
| 96 |
+
"reason": reason,
|
| 97 |
+
})
|
| 98 |
+
|
| 99 |
+
tickets = []
|
| 100 |
+
for tid in range(N_TICKETS):
|
| 101 |
+
oid = _h("toid", tid) % N_ORDERS
|
| 102 |
+
severity = ["low", "medium", "high", "critical"][_h("sev", tid) % 4]
|
| 103 |
+
opened = MONTHS[_h("tmonth", tid) % len(MONTHS)]
|
| 104 |
+
first_response_hours = 1 + _h("resp", tid) % 96
|
| 105 |
+
resolution_hours = first_response_hours + _h("res", tid) % 240
|
| 106 |
+
tickets.append({
|
| 107 |
+
"ticket_id": tid,
|
| 108 |
+
"order_id": oid,
|
| 109 |
+
"opened_month": opened,
|
| 110 |
+
"severity": severity,
|
| 111 |
+
"first_response_hours": first_response_hours,
|
| 112 |
+
"resolution_hours": resolution_hours,
|
| 113 |
+
})
|
| 114 |
+
|
| 115 |
+
return {
|
| 116 |
+
"customers": customers,
|
| 117 |
+
"products": products,
|
| 118 |
+
"inventory": inventory,
|
| 119 |
+
"orders": orders,
|
| 120 |
+
"returns": returns,
|
| 121 |
+
"tickets": tickets,
|
| 122 |
+
"fx_to_usd_bp": FX_TO_USD_BP,
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
DATA = build_data()
|
| 127 |
+
CUSTOMERS = {c["customer_id"]: c for c in DATA["customers"]}
|
| 128 |
+
PRODUCTS = {p["product_id"]: p for p in DATA["products"]}
|
| 129 |
+
ORDERS = {o["order_id"]: o for o in DATA["orders"]}
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
def region_currency(region: str) -> str:
|
| 133 |
+
return CURRENCIES[region]
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
def get_orders(region: str, category: str, month_start: int, month_end: int) -> list:
|
| 137 |
+
"""Paid/refunded order ids in a region/category/month window."""
|
| 138 |
+
out = []
|
| 139 |
+
for o in DATA["orders"]:
|
| 140 |
+
if o["status"] not in ("paid", "refunded"):
|
| 141 |
+
continue
|
| 142 |
+
c = CUSTOMERS[o["customer_id"]]
|
| 143 |
+
p = PRODUCTS[o["product_id"]]
|
| 144 |
+
if c["region"] == region and p["category"] == category and month_start <= o["month"] <= month_end:
|
| 145 |
+
out.append(o["order_id"])
|
| 146 |
+
return sorted(out)
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def order_gross_usd(order_id: int) -> int:
|
| 150 |
+
o = ORDERS[order_id]
|
| 151 |
+
p = PRODUCTS[o["product_id"]]
|
| 152 |
+
return o["qty"] * p["unit_price_usd"]
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
def order_margin_usd(order_id: int) -> int:
|
| 156 |
+
o = ORDERS[order_id]
|
| 157 |
+
p = PRODUCTS[o["product_id"]]
|
| 158 |
+
return o["qty"] * (p["unit_price_usd"] - p["unit_cogs_usd"])
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
def refund_usd(order_id: int) -> int:
|
| 162 |
+
o = ORDERS[order_id]
|
| 163 |
+
p = PRODUCTS[o["product_id"]]
|
| 164 |
+
qty = sum(r["returned_qty"] for r in DATA["returns"] if r["order_id"] == order_id)
|
| 165 |
+
qty = min(qty, o["qty"])
|
| 166 |
+
return qty * p["unit_price_usd"]
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def customer_tier(order_id: int) -> str:
|
| 170 |
+
o = ORDERS[order_id]
|
| 171 |
+
return CUSTOMERS[o["customer_id"]]["tier"]
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
def apply_discount(amount_usd: int, tier: str) -> int:
|
| 175 |
+
return amount_usd * (100 - DISCOUNT_PCT[tier]) // 100
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
def net_revenue_usd(order_id: int) -> int:
|
| 179 |
+
gross = apply_discount(order_gross_usd(order_id), customer_tier(order_id))
|
| 180 |
+
return max(0, gross - refund_usd(order_id))
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
def to_local(amount_usd: int, currency: str) -> int:
|
| 184 |
+
return amount_usd * 10000 // FX_TO_USD_BP[currency]
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def inventory_position(product_id: int, region: str) -> int:
|
| 188 |
+
row = next(x for x in DATA["inventory"]
|
| 189 |
+
if x["product_id"] == product_id and x["region"] == region)
|
| 190 |
+
return row["on_hand"] - row["reserved"] + row["inbound"]
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
def product_lead_time(product_id: int) -> int:
|
| 194 |
+
return PRODUCTS[product_id]["lead_time_days"]
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
def product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int:
|
| 198 |
+
totals = {}
|
| 199 |
+
for oid in get_orders(region, category, month_start, month_end):
|
| 200 |
+
o = ORDERS[oid]
|
| 201 |
+
totals[o["product_id"]] = totals.get(o["product_id"], 0) + o["qty"]
|
| 202 |
+
if not totals:
|
| 203 |
+
return -1
|
| 204 |
+
return min((-qty, pid) for pid, qty in totals.items())[1]
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
def units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int:
|
| 208 |
+
total = 0
|
| 209 |
+
for o in DATA["orders"]:
|
| 210 |
+
if o["product_id"] != product_id or o["status"] not in ("paid", "refunded"):
|
| 211 |
+
continue
|
| 212 |
+
c = CUSTOMERS[o["customer_id"]]
|
| 213 |
+
if c["region"] == region and month_start <= o["month"] <= month_end:
|
| 214 |
+
total += o["qty"]
|
| 215 |
+
return total
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def tickets_for_orders(order_ids: list, severity: str) -> list:
|
| 219 |
+
s = set(order_ids)
|
| 220 |
+
return sorted(t["ticket_id"] for t in DATA["tickets"]
|
| 221 |
+
if t["order_id"] in s and t["severity"] == severity)
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
def ticket_order_id(ticket_id: int) -> int:
|
| 225 |
+
return next(t["order_id"] for t in DATA["tickets"] if t["ticket_id"] == ticket_id)
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
def sla_breached(ticket_id: int, first_response_limit_hours: int,
|
| 229 |
+
resolution_limit_hours: int) -> bool:
|
| 230 |
+
t = next(x for x in DATA["tickets"] if x["ticket_id"] == ticket_id)
|
| 231 |
+
return (t["first_response_hours"] > first_response_limit_hours or
|
| 232 |
+
t["resolution_hours"] > resolution_limit_hours)
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
def delayed_orders(order_ids: list) -> list:
|
| 236 |
+
s = set(order_ids)
|
| 237 |
+
return sorted(o["order_id"] for o in DATA["orders"]
|
| 238 |
+
if o["order_id"] in s and o["ship_days"] > o["promised_days"])
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
def unique_customers(order_ids: list) -> list:
|
| 242 |
+
return sorted({ORDERS[oid]["customer_id"] for oid in order_ids})
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
def count_items(values: list) -> int:
|
| 246 |
+
return len(values)
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
def sum_values(values: list) -> int:
|
| 250 |
+
return sum(values)
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
def count_true(values: list) -> int:
|
| 254 |
+
return sum(1 for v in values if bool(v))
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
def count_below(values: list, threshold: int) -> int:
|
| 258 |
+
return sum(1 for v in values if v < threshold)
|
| 259 |
+
|
| 260 |
+
|
| 261 |
+
TOOLS = {
|
| 262 |
+
"region_currency": ("region_currency(region: str) -> str",
|
| 263 |
+
"ISO currency code for a region.", region_currency),
|
| 264 |
+
"get_orders": ("get_orders(region: str, category: str, month_start: int, month_end: int) -> list[int]",
|
| 265 |
+
"Paid/refunded order ids for a region, product category, and inclusive month window.",
|
| 266 |
+
get_orders),
|
| 267 |
+
"order_gross_usd": ("order_gross_usd(order_id: int) -> int",
|
| 268 |
+
"Gross order revenue in USD before discounts/refunds.", order_gross_usd),
|
| 269 |
+
"order_margin_usd": ("order_margin_usd(order_id: int) -> int",
|
| 270 |
+
"Gross order margin in USD before discounts/refunds.", order_margin_usd),
|
| 271 |
+
"refund_usd": ("refund_usd(order_id: int) -> int",
|
| 272 |
+
"Refund amount in USD for returned quantity on an order.", refund_usd),
|
| 273 |
+
"customer_tier": ("customer_tier(order_id: int) -> str",
|
| 274 |
+
"Customer loyalty tier for an order.", customer_tier),
|
| 275 |
+
"apply_discount": ("apply_discount(amount_usd: int, tier: str) -> int",
|
| 276 |
+
"Apply the order customer's loyalty discount to a USD amount.", apply_discount),
|
| 277 |
+
"net_revenue_usd": ("net_revenue_usd(order_id: int) -> int",
|
| 278 |
+
"Net USD revenue after loyalty discount and refunds.", net_revenue_usd),
|
| 279 |
+
"to_local": ("to_local(amount_usd: int, currency: str) -> int",
|
| 280 |
+
"Convert a USD integer amount to a local-currency integer.", to_local),
|
| 281 |
+
"inventory_position": ("inventory_position(product_id: int, region: str) -> int",
|
| 282 |
+
"Available inventory position: on_hand - reserved + inbound.",
|
| 283 |
+
inventory_position),
|
| 284 |
+
"product_lead_time": ("product_lead_time(product_id: int) -> int",
|
| 285 |
+
"Supplier lead time in days for a product.", product_lead_time),
|
| 286 |
+
"product_id_for_top_seller": (
|
| 287 |
+
"product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int",
|
| 288 |
+
"Product id with the highest units sold in a region/category/month window.",
|
| 289 |
+
product_id_for_top_seller),
|
| 290 |
+
"units_sold": ("units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int",
|
| 291 |
+
"Units sold for one product in a region and month window.", units_sold),
|
| 292 |
+
"tickets_for_orders": ("tickets_for_orders(order_ids: list[int], severity: str) -> list[int]",
|
| 293 |
+
"Support ticket ids for given orders and severity.", tickets_for_orders),
|
| 294 |
+
"ticket_order_id": ("ticket_order_id(ticket_id: int) -> int",
|
| 295 |
+
"Order id associated with a support ticket.", ticket_order_id),
|
| 296 |
+
"sla_breached": (
|
| 297 |
+
"sla_breached(ticket_id: int, first_response_limit_hours: int, resolution_limit_hours: int) -> bool",
|
| 298 |
+
"Whether a support ticket breaches first-response or resolution SLA.",
|
| 299 |
+
sla_breached),
|
| 300 |
+
"delayed_orders": ("delayed_orders(order_ids: list[int]) -> list[int]",
|
| 301 |
+
"Subset of order ids whose ship_days exceeded promised_days.", delayed_orders),
|
| 302 |
+
"unique_customers": ("unique_customers(order_ids: list[int]) -> list[int]",
|
| 303 |
+
"Unique customer ids among the given orders.", unique_customers),
|
| 304 |
+
"count_items": ("count_items(values: list) -> int", "Length of a list.", count_items),
|
| 305 |
+
"sum_values": ("sum_values(values: list[int]) -> int", "Sum a list of integers.", sum_values),
|
| 306 |
+
"count_true": ("count_true(values: list[bool]) -> int", "Count true values.", count_true),
|
| 307 |
+
"count_below": ("count_below(values: list[int], threshold: int) -> int",
|
| 308 |
+
"Count values below a threshold.", count_below),
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
__all__ = [name for name in TOOLS.keys()] + ['TOOLS']
|
harbor/tasks/v3_depth6_delay_sla_burden_t16/environment/task.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"task_id": "v3_depth6_delay_sla_burden_t16",
|
| 3 |
+
"depth": 6,
|
| 4 |
+
"family": "delay_sla_burden",
|
| 5 |
+
"params": {
|
| 6 |
+
"region": "NA",
|
| 7 |
+
"category": "A",
|
| 8 |
+
"month_start": 202604,
|
| 9 |
+
"month_end": 202606
|
| 10 |
+
},
|
| 11 |
+
"question": "For region NA, category A, months 202604-202606: get the orders, count delayed orders where ship_days exceeded promised_days, find high and critical support tickets for those orders, count tickets that breach a 24-hour first-response or 120-hour resolution SLA, and report delayed_order_count + breached_ticket_count.",
|
| 12 |
+
"answer_format": "exact integer"
|
| 13 |
+
}
|
harbor/tasks/v3_depth6_delay_sla_burden_t16/instruction.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FlowBench v3 Public Task
|
| 2 |
+
|
| 3 |
+
You are in `/app`. The file `/app/flowbench_tools.py` contains deterministic
|
| 4 |
+
Python tools over a synthetic business-operations dataset. Use those tools
|
| 5 |
+
to compute the requested value, then write the final output to
|
| 6 |
+
`/app/answer.txt`.
|
| 7 |
+
|
| 8 |
+
Required output:
|
| 9 |
+
- `/app/answer.txt` must contain only the exact integer.
|
| 10 |
+
- Use integer arithmetic for currency and counts. Do not use floating point
|
| 11 |
+
arithmetic.
|
| 12 |
+
|
| 13 |
+
Task:
|
| 14 |
+
For region NA, category A, months 202604-202606: get the orders, count delayed orders where ship_days exceeded promised_days, find high and critical support tickets for those orders, count tickets that breach a 24-hour first-response or 120-hour resolution SLA, and report delayed_order_count + breached_ticket_count.
|
| 15 |
+
|
| 16 |
+
Available tools:
|
| 17 |
+
- `region_currency(region: str) -> str`: ISO currency code for a region.
|
| 18 |
+
- `get_orders(region: str, category: str, month_start: int, month_end: int) -> list[int]`: Paid/refunded order ids for a region, product category, and inclusive month window.
|
| 19 |
+
- `order_gross_usd(order_id: int) -> int`: Gross order revenue in USD before discounts/refunds.
|
| 20 |
+
- `order_margin_usd(order_id: int) -> int`: Gross order margin in USD before discounts/refunds.
|
| 21 |
+
- `refund_usd(order_id: int) -> int`: Refund amount in USD for returned quantity on an order.
|
| 22 |
+
- `customer_tier(order_id: int) -> str`: Customer loyalty tier for an order.
|
| 23 |
+
- `apply_discount(amount_usd: int, tier: str) -> int`: Apply the order customer's loyalty discount to a USD amount.
|
| 24 |
+
- `net_revenue_usd(order_id: int) -> int`: Net USD revenue after loyalty discount and refunds.
|
| 25 |
+
- `to_local(amount_usd: int, currency: str) -> int`: Convert a USD integer amount to a local-currency integer.
|
| 26 |
+
- `inventory_position(product_id: int, region: str) -> int`: Available inventory position: on_hand - reserved + inbound.
|
| 27 |
+
- `product_lead_time(product_id: int) -> int`: Supplier lead time in days for a product.
|
| 28 |
+
- `product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int`: Product id with the highest units sold in a region/category/month window.
|
| 29 |
+
- `units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int`: Units sold for one product in a region and month window.
|
| 30 |
+
- `tickets_for_orders(order_ids: list[int], severity: str) -> list[int]`: Support ticket ids for given orders and severity.
|
| 31 |
+
- `ticket_order_id(ticket_id: int) -> int`: Order id associated with a support ticket.
|
| 32 |
+
- `sla_breached(ticket_id: int, first_response_limit_hours: int, resolution_limit_hours: int) -> bool`: Whether a support ticket breaches first-response or resolution SLA.
|
| 33 |
+
- `delayed_orders(order_ids: list[int]) -> list[int]`: Subset of order ids whose ship_days exceeded promised_days.
|
| 34 |
+
- `unique_customers(order_ids: list[int]) -> list[int]`: Unique customer ids among the given orders.
|
| 35 |
+
- `count_items(values: list) -> int`: Length of a list.
|
| 36 |
+
- `sum_values(values: list[int]) -> int`: Sum a list of integers.
|
| 37 |
+
- `count_true(values: list[bool]) -> int`: Count true values.
|
| 38 |
+
- `count_below(values: list[int], threshold: int) -> int`: Count values below a threshold.
|
harbor/tasks/v3_depth6_delay_sla_burden_t16/task.toml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.3"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "mindlab/v3_depth6_delay_sla_burden_t16"
|
| 5 |
+
description = "FlowBench v3 public task metadata. Public verifier is smoke-only."
|
| 6 |
+
authors = [{ name = "Mind Lab", email = "contact@mindlab.ltd" }]
|
| 7 |
+
keywords = ["flowbench", "tool-use", "data-orchestration", "operations"]
|
| 8 |
+
|
| 9 |
+
[metadata]
|
| 10 |
+
benchmark = "FlowBench-v3"
|
| 11 |
+
split = "public-task-only"
|
| 12 |
+
category = "data-processing"
|
| 13 |
+
depth = 6
|
| 14 |
+
|
| 15 |
+
[verifier]
|
| 16 |
+
timeout_sec = 120.0
|
| 17 |
+
|
| 18 |
+
[agent]
|
| 19 |
+
timeout_sec = 900.0
|
| 20 |
+
|
| 21 |
+
[environment]
|
| 22 |
+
network_mode = "no-network"
|
| 23 |
+
build_timeout_sec = 600.0
|
| 24 |
+
os = "linux"
|
| 25 |
+
cpus = 1
|
| 26 |
+
memory_mb = 2048
|
| 27 |
+
storage_mb = 2048
|
| 28 |
+
gpus = 0
|
harbor/tasks/v3_depth6_delay_sla_burden_t16/tests/check_output_shape.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
import re
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def write_reward(score: float, diagnostic: str) -> None:
|
| 11 |
+
log_dir = Path(os.environ.get("LOG_DIR", "/logs/verifier"))
|
| 12 |
+
log_dir.mkdir(parents=True, exist_ok=True)
|
| 13 |
+
(log_dir / "reward.txt").write_text(f"{score:.6g}\n")
|
| 14 |
+
(log_dir / "reward.json").write_text(
|
| 15 |
+
json.dumps({"reward": score, "smoke_only": True}, indent=2) + "\n"
|
| 16 |
+
)
|
| 17 |
+
(log_dir / "diagnostic.txt").write_text(diagnostic + "\n")
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def main() -> int:
|
| 21 |
+
app_dir = Path(os.environ.get("APP_DIR", "/app"))
|
| 22 |
+
task = json.loads((app_dir / "task.json").read_text())
|
| 23 |
+
answer_path = app_dir / "answer.txt"
|
| 24 |
+
if not answer_path.exists():
|
| 25 |
+
write_reward(0.0, "missing /app/answer.txt")
|
| 26 |
+
return 1
|
| 27 |
+
|
| 28 |
+
got = answer_path.read_text().strip()
|
| 29 |
+
if task["answer_format"] == "exact integer":
|
| 30 |
+
ok = bool(re.fullmatch(r"-?\d+", got))
|
| 31 |
+
diagnostic = "valid integer smoke output" if ok else f"not an exact integer: {got!r}"
|
| 32 |
+
else:
|
| 33 |
+
ok = bool(re.fullmatch(r"[A-Za-z]+", got))
|
| 34 |
+
diagnostic = "valid code smoke output" if ok else f"not an exact code: {got!r}"
|
| 35 |
+
|
| 36 |
+
# This is intentionally not official scoring; it only verifies I/O shape.
|
| 37 |
+
write_reward(1.0 if ok else 0.0, diagnostic)
|
| 38 |
+
return 0 if ok else 1
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
if __name__ == "__main__":
|
| 42 |
+
raise SystemExit(main())
|
harbor/tasks/v3_depth6_delay_sla_burden_t16/tests/test.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -u
|
| 3 |
+
python /tests/check_output_shape.py
|
harbor/tasks/v3_depth6_delay_sla_burden_t17/environment/Dockerfile
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.12-slim
|
| 2 |
+
WORKDIR /app
|
| 3 |
+
COPY flowbench_tools.py /app/flowbench_tools.py
|
| 4 |
+
COPY task.json /app/task.json
|
harbor/tasks/v3_depth6_delay_sla_burden_t17/environment/flowbench_tools.py
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Deterministic FlowBench v3 tools. This file contains no task answers."""
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
REGIONS = ["NA", "EU", "APAC", "LATAM"]
|
| 5 |
+
CATEGORIES = ["A", "B", "C", "D"]
|
| 6 |
+
CURRENCIES = {"NA": "USD", "EU": "EUR", "APAC": "JPY", "LATAM": "BRL"}
|
| 7 |
+
FX_TO_USD_BP = {"USD": 10000, "EUR": 10900, "JPY": 67, "BRL": 1850}
|
| 8 |
+
TIERS = ["std", "gold", "plat"]
|
| 9 |
+
DISCOUNT_PCT = {"std": 0, "gold": 10, "plat": 20}
|
| 10 |
+
CHANNELS = ["web", "store", "partner"]
|
| 11 |
+
MONTHS = [202601, 202602, 202603, 202604, 202605, 202606]
|
| 12 |
+
|
| 13 |
+
N_CUSTOMERS = 72
|
| 14 |
+
N_PRODUCTS = 48
|
| 15 |
+
N_ORDERS = 720
|
| 16 |
+
N_TICKETS = 260
|
| 17 |
+
N_RETURNS = 180
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def _h(*xs):
|
| 21 |
+
import hashlib
|
| 22 |
+
s = "|".join(str(x) for x in xs).encode()
|
| 23 |
+
return int.from_bytes(hashlib.sha256(s).digest()[:8], "big") & 0x7FFFFFFF
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def build_data():
|
| 27 |
+
customers = []
|
| 28 |
+
for cid in range(N_CUSTOMERS):
|
| 29 |
+
region = REGIONS[_h("region", cid) % len(REGIONS)]
|
| 30 |
+
customers.append({
|
| 31 |
+
"customer_id": cid,
|
| 32 |
+
"region": region,
|
| 33 |
+
"tier": TIERS[_h("tier", cid) % len(TIERS)],
|
| 34 |
+
"segment": ["consumer", "smb", "enterprise"][_h("segment", cid) % 3],
|
| 35 |
+
})
|
| 36 |
+
|
| 37 |
+
products = []
|
| 38 |
+
for pid in range(N_PRODUCTS):
|
| 39 |
+
cat = CATEGORIES[_h("cat", pid) % len(CATEGORIES)]
|
| 40 |
+
unit_price = 12 + _h("price", pid) % 240
|
| 41 |
+
cogs = unit_price * (45 + _h("margin", pid) % 35) // 100
|
| 42 |
+
products.append({
|
| 43 |
+
"product_id": pid,
|
| 44 |
+
"category": cat,
|
| 45 |
+
"unit_price_usd": unit_price,
|
| 46 |
+
"unit_cogs_usd": cogs,
|
| 47 |
+
"lead_time_days": 3 + _h("lead", pid) % 18,
|
| 48 |
+
})
|
| 49 |
+
|
| 50 |
+
inventory = []
|
| 51 |
+
for pid in range(N_PRODUCTS):
|
| 52 |
+
for region in REGIONS:
|
| 53 |
+
inventory.append({
|
| 54 |
+
"product_id": pid,
|
| 55 |
+
"region": region,
|
| 56 |
+
"on_hand": 10 + _h("onhand", pid, region) % 140,
|
| 57 |
+
"reserved": _h("reserved", pid, region) % 28,
|
| 58 |
+
"inbound": _h("inbound", pid, region) % 85,
|
| 59 |
+
})
|
| 60 |
+
|
| 61 |
+
orders = []
|
| 62 |
+
for oid in range(N_ORDERS):
|
| 63 |
+
customer_id = _h("ocust", oid) % N_CUSTOMERS
|
| 64 |
+
product_id = _h("oprod", oid) % N_PRODUCTS
|
| 65 |
+
month = MONTHS[_h("month", oid) % len(MONTHS)]
|
| 66 |
+
qty = 1 + _h("qty", oid) % 9
|
| 67 |
+
ship_days = 1 + _h("shipdays", oid) % 16
|
| 68 |
+
promised_days = 3 + _h("promise", oid) % 9
|
| 69 |
+
status = ["paid", "paid", "paid", "paid", "cancelled", "refunded"][
|
| 70 |
+
_h("status", oid) % 6]
|
| 71 |
+
orders.append({
|
| 72 |
+
"order_id": oid,
|
| 73 |
+
"customer_id": customer_id,
|
| 74 |
+
"product_id": product_id,
|
| 75 |
+
"month": month,
|
| 76 |
+
"qty": qty,
|
| 77 |
+
"status": status,
|
| 78 |
+
"channel": CHANNELS[_h("channel", oid) % len(CHANNELS)],
|
| 79 |
+
"ship_days": ship_days,
|
| 80 |
+
"promised_days": promised_days,
|
| 81 |
+
})
|
| 82 |
+
|
| 83 |
+
returns = []
|
| 84 |
+
for rid in range(N_RETURNS):
|
| 85 |
+
oid = _h("roid", rid) % N_ORDERS
|
| 86 |
+
order = orders[oid]
|
| 87 |
+
if order["status"] == "cancelled":
|
| 88 |
+
continue
|
| 89 |
+
returned_qty = 1 + _h("rqty", rid) % max(1, order["qty"])
|
| 90 |
+
reason = ["defect", "late", "changed_mind", "wrong_item"][_h("reason", rid) % 4]
|
| 91 |
+
returns.append({
|
| 92 |
+
"return_id": rid,
|
| 93 |
+
"order_id": oid,
|
| 94 |
+
"month": MONTHS[_h("rmonth", rid) % len(MONTHS)],
|
| 95 |
+
"returned_qty": returned_qty,
|
| 96 |
+
"reason": reason,
|
| 97 |
+
})
|
| 98 |
+
|
| 99 |
+
tickets = []
|
| 100 |
+
for tid in range(N_TICKETS):
|
| 101 |
+
oid = _h("toid", tid) % N_ORDERS
|
| 102 |
+
severity = ["low", "medium", "high", "critical"][_h("sev", tid) % 4]
|
| 103 |
+
opened = MONTHS[_h("tmonth", tid) % len(MONTHS)]
|
| 104 |
+
first_response_hours = 1 + _h("resp", tid) % 96
|
| 105 |
+
resolution_hours = first_response_hours + _h("res", tid) % 240
|
| 106 |
+
tickets.append({
|
| 107 |
+
"ticket_id": tid,
|
| 108 |
+
"order_id": oid,
|
| 109 |
+
"opened_month": opened,
|
| 110 |
+
"severity": severity,
|
| 111 |
+
"first_response_hours": first_response_hours,
|
| 112 |
+
"resolution_hours": resolution_hours,
|
| 113 |
+
})
|
| 114 |
+
|
| 115 |
+
return {
|
| 116 |
+
"customers": customers,
|
| 117 |
+
"products": products,
|
| 118 |
+
"inventory": inventory,
|
| 119 |
+
"orders": orders,
|
| 120 |
+
"returns": returns,
|
| 121 |
+
"tickets": tickets,
|
| 122 |
+
"fx_to_usd_bp": FX_TO_USD_BP,
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
DATA = build_data()
|
| 127 |
+
CUSTOMERS = {c["customer_id"]: c for c in DATA["customers"]}
|
| 128 |
+
PRODUCTS = {p["product_id"]: p for p in DATA["products"]}
|
| 129 |
+
ORDERS = {o["order_id"]: o for o in DATA["orders"]}
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
def region_currency(region: str) -> str:
|
| 133 |
+
return CURRENCIES[region]
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
def get_orders(region: str, category: str, month_start: int, month_end: int) -> list:
|
| 137 |
+
"""Paid/refunded order ids in a region/category/month window."""
|
| 138 |
+
out = []
|
| 139 |
+
for o in DATA["orders"]:
|
| 140 |
+
if o["status"] not in ("paid", "refunded"):
|
| 141 |
+
continue
|
| 142 |
+
c = CUSTOMERS[o["customer_id"]]
|
| 143 |
+
p = PRODUCTS[o["product_id"]]
|
| 144 |
+
if c["region"] == region and p["category"] == category and month_start <= o["month"] <= month_end:
|
| 145 |
+
out.append(o["order_id"])
|
| 146 |
+
return sorted(out)
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def order_gross_usd(order_id: int) -> int:
|
| 150 |
+
o = ORDERS[order_id]
|
| 151 |
+
p = PRODUCTS[o["product_id"]]
|
| 152 |
+
return o["qty"] * p["unit_price_usd"]
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
def order_margin_usd(order_id: int) -> int:
|
| 156 |
+
o = ORDERS[order_id]
|
| 157 |
+
p = PRODUCTS[o["product_id"]]
|
| 158 |
+
return o["qty"] * (p["unit_price_usd"] - p["unit_cogs_usd"])
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
def refund_usd(order_id: int) -> int:
|
| 162 |
+
o = ORDERS[order_id]
|
| 163 |
+
p = PRODUCTS[o["product_id"]]
|
| 164 |
+
qty = sum(r["returned_qty"] for r in DATA["returns"] if r["order_id"] == order_id)
|
| 165 |
+
qty = min(qty, o["qty"])
|
| 166 |
+
return qty * p["unit_price_usd"]
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def customer_tier(order_id: int) -> str:
|
| 170 |
+
o = ORDERS[order_id]
|
| 171 |
+
return CUSTOMERS[o["customer_id"]]["tier"]
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
def apply_discount(amount_usd: int, tier: str) -> int:
|
| 175 |
+
return amount_usd * (100 - DISCOUNT_PCT[tier]) // 100
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
def net_revenue_usd(order_id: int) -> int:
|
| 179 |
+
gross = apply_discount(order_gross_usd(order_id), customer_tier(order_id))
|
| 180 |
+
return max(0, gross - refund_usd(order_id))
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
def to_local(amount_usd: int, currency: str) -> int:
|
| 184 |
+
return amount_usd * 10000 // FX_TO_USD_BP[currency]
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def inventory_position(product_id: int, region: str) -> int:
|
| 188 |
+
row = next(x for x in DATA["inventory"]
|
| 189 |
+
if x["product_id"] == product_id and x["region"] == region)
|
| 190 |
+
return row["on_hand"] - row["reserved"] + row["inbound"]
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
def product_lead_time(product_id: int) -> int:
|
| 194 |
+
return PRODUCTS[product_id]["lead_time_days"]
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
def product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int:
|
| 198 |
+
totals = {}
|
| 199 |
+
for oid in get_orders(region, category, month_start, month_end):
|
| 200 |
+
o = ORDERS[oid]
|
| 201 |
+
totals[o["product_id"]] = totals.get(o["product_id"], 0) + o["qty"]
|
| 202 |
+
if not totals:
|
| 203 |
+
return -1
|
| 204 |
+
return min((-qty, pid) for pid, qty in totals.items())[1]
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
def units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int:
|
| 208 |
+
total = 0
|
| 209 |
+
for o in DATA["orders"]:
|
| 210 |
+
if o["product_id"] != product_id or o["status"] not in ("paid", "refunded"):
|
| 211 |
+
continue
|
| 212 |
+
c = CUSTOMERS[o["customer_id"]]
|
| 213 |
+
if c["region"] == region and month_start <= o["month"] <= month_end:
|
| 214 |
+
total += o["qty"]
|
| 215 |
+
return total
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def tickets_for_orders(order_ids: list, severity: str) -> list:
|
| 219 |
+
s = set(order_ids)
|
| 220 |
+
return sorted(t["ticket_id"] for t in DATA["tickets"]
|
| 221 |
+
if t["order_id"] in s and t["severity"] == severity)
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
def ticket_order_id(ticket_id: int) -> int:
|
| 225 |
+
return next(t["order_id"] for t in DATA["tickets"] if t["ticket_id"] == ticket_id)
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
def sla_breached(ticket_id: int, first_response_limit_hours: int,
|
| 229 |
+
resolution_limit_hours: int) -> bool:
|
| 230 |
+
t = next(x for x in DATA["tickets"] if x["ticket_id"] == ticket_id)
|
| 231 |
+
return (t["first_response_hours"] > first_response_limit_hours or
|
| 232 |
+
t["resolution_hours"] > resolution_limit_hours)
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
def delayed_orders(order_ids: list) -> list:
|
| 236 |
+
s = set(order_ids)
|
| 237 |
+
return sorted(o["order_id"] for o in DATA["orders"]
|
| 238 |
+
if o["order_id"] in s and o["ship_days"] > o["promised_days"])
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
def unique_customers(order_ids: list) -> list:
|
| 242 |
+
return sorted({ORDERS[oid]["customer_id"] for oid in order_ids})
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
def count_items(values: list) -> int:
|
| 246 |
+
return len(values)
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
def sum_values(values: list) -> int:
|
| 250 |
+
return sum(values)
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
def count_true(values: list) -> int:
|
| 254 |
+
return sum(1 for v in values if bool(v))
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
def count_below(values: list, threshold: int) -> int:
|
| 258 |
+
return sum(1 for v in values if v < threshold)
|
| 259 |
+
|
| 260 |
+
|
| 261 |
+
TOOLS = {
|
| 262 |
+
"region_currency": ("region_currency(region: str) -> str",
|
| 263 |
+
"ISO currency code for a region.", region_currency),
|
| 264 |
+
"get_orders": ("get_orders(region: str, category: str, month_start: int, month_end: int) -> list[int]",
|
| 265 |
+
"Paid/refunded order ids for a region, product category, and inclusive month window.",
|
| 266 |
+
get_orders),
|
| 267 |
+
"order_gross_usd": ("order_gross_usd(order_id: int) -> int",
|
| 268 |
+
"Gross order revenue in USD before discounts/refunds.", order_gross_usd),
|
| 269 |
+
"order_margin_usd": ("order_margin_usd(order_id: int) -> int",
|
| 270 |
+
"Gross order margin in USD before discounts/refunds.", order_margin_usd),
|
| 271 |
+
"refund_usd": ("refund_usd(order_id: int) -> int",
|
| 272 |
+
"Refund amount in USD for returned quantity on an order.", refund_usd),
|
| 273 |
+
"customer_tier": ("customer_tier(order_id: int) -> str",
|
| 274 |
+
"Customer loyalty tier for an order.", customer_tier),
|
| 275 |
+
"apply_discount": ("apply_discount(amount_usd: int, tier: str) -> int",
|
| 276 |
+
"Apply the order customer's loyalty discount to a USD amount.", apply_discount),
|
| 277 |
+
"net_revenue_usd": ("net_revenue_usd(order_id: int) -> int",
|
| 278 |
+
"Net USD revenue after loyalty discount and refunds.", net_revenue_usd),
|
| 279 |
+
"to_local": ("to_local(amount_usd: int, currency: str) -> int",
|
| 280 |
+
"Convert a USD integer amount to a local-currency integer.", to_local),
|
| 281 |
+
"inventory_position": ("inventory_position(product_id: int, region: str) -> int",
|
| 282 |
+
"Available inventory position: on_hand - reserved + inbound.",
|
| 283 |
+
inventory_position),
|
| 284 |
+
"product_lead_time": ("product_lead_time(product_id: int) -> int",
|
| 285 |
+
"Supplier lead time in days for a product.", product_lead_time),
|
| 286 |
+
"product_id_for_top_seller": (
|
| 287 |
+
"product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int",
|
| 288 |
+
"Product id with the highest units sold in a region/category/month window.",
|
| 289 |
+
product_id_for_top_seller),
|
| 290 |
+
"units_sold": ("units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int",
|
| 291 |
+
"Units sold for one product in a region and month window.", units_sold),
|
| 292 |
+
"tickets_for_orders": ("tickets_for_orders(order_ids: list[int], severity: str) -> list[int]",
|
| 293 |
+
"Support ticket ids for given orders and severity.", tickets_for_orders),
|
| 294 |
+
"ticket_order_id": ("ticket_order_id(ticket_id: int) -> int",
|
| 295 |
+
"Order id associated with a support ticket.", ticket_order_id),
|
| 296 |
+
"sla_breached": (
|
| 297 |
+
"sla_breached(ticket_id: int, first_response_limit_hours: int, resolution_limit_hours: int) -> bool",
|
| 298 |
+
"Whether a support ticket breaches first-response or resolution SLA.",
|
| 299 |
+
sla_breached),
|
| 300 |
+
"delayed_orders": ("delayed_orders(order_ids: list[int]) -> list[int]",
|
| 301 |
+
"Subset of order ids whose ship_days exceeded promised_days.", delayed_orders),
|
| 302 |
+
"unique_customers": ("unique_customers(order_ids: list[int]) -> list[int]",
|
| 303 |
+
"Unique customer ids among the given orders.", unique_customers),
|
| 304 |
+
"count_items": ("count_items(values: list) -> int", "Length of a list.", count_items),
|
| 305 |
+
"sum_values": ("sum_values(values: list[int]) -> int", "Sum a list of integers.", sum_values),
|
| 306 |
+
"count_true": ("count_true(values: list[bool]) -> int", "Count true values.", count_true),
|
| 307 |
+
"count_below": ("count_below(values: list[int], threshold: int) -> int",
|
| 308 |
+
"Count values below a threshold.", count_below),
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
__all__ = [name for name in TOOLS.keys()] + ['TOOLS']
|
harbor/tasks/v3_depth6_delay_sla_burden_t17/environment/task.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"task_id": "v3_depth6_delay_sla_burden_t17",
|
| 3 |
+
"depth": 6,
|
| 4 |
+
"family": "delay_sla_burden",
|
| 5 |
+
"params": {
|
| 6 |
+
"region": "EU",
|
| 7 |
+
"category": "D",
|
| 8 |
+
"month_start": 202601,
|
| 9 |
+
"month_end": 202602
|
| 10 |
+
},
|
| 11 |
+
"question": "For region EU, category D, months 202601-202602: get the orders, count delayed orders where ship_days exceeded promised_days, find high and critical support tickets for those orders, count tickets that breach a 24-hour first-response or 120-hour resolution SLA, and report delayed_order_count + breached_ticket_count.",
|
| 12 |
+
"answer_format": "exact integer"
|
| 13 |
+
}
|
harbor/tasks/v3_depth6_delay_sla_burden_t17/instruction.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FlowBench v3 Public Task
|
| 2 |
+
|
| 3 |
+
You are in `/app`. The file `/app/flowbench_tools.py` contains deterministic
|
| 4 |
+
Python tools over a synthetic business-operations dataset. Use those tools
|
| 5 |
+
to compute the requested value, then write the final output to
|
| 6 |
+
`/app/answer.txt`.
|
| 7 |
+
|
| 8 |
+
Required output:
|
| 9 |
+
- `/app/answer.txt` must contain only the exact integer.
|
| 10 |
+
- Use integer arithmetic for currency and counts. Do not use floating point
|
| 11 |
+
arithmetic.
|
| 12 |
+
|
| 13 |
+
Task:
|
| 14 |
+
For region EU, category D, months 202601-202602: get the orders, count delayed orders where ship_days exceeded promised_days, find high and critical support tickets for those orders, count tickets that breach a 24-hour first-response or 120-hour resolution SLA, and report delayed_order_count + breached_ticket_count.
|
| 15 |
+
|
| 16 |
+
Available tools:
|
| 17 |
+
- `region_currency(region: str) -> str`: ISO currency code for a region.
|
| 18 |
+
- `get_orders(region: str, category: str, month_start: int, month_end: int) -> list[int]`: Paid/refunded order ids for a region, product category, and inclusive month window.
|
| 19 |
+
- `order_gross_usd(order_id: int) -> int`: Gross order revenue in USD before discounts/refunds.
|
| 20 |
+
- `order_margin_usd(order_id: int) -> int`: Gross order margin in USD before discounts/refunds.
|
| 21 |
+
- `refund_usd(order_id: int) -> int`: Refund amount in USD for returned quantity on an order.
|
| 22 |
+
- `customer_tier(order_id: int) -> str`: Customer loyalty tier for an order.
|
| 23 |
+
- `apply_discount(amount_usd: int, tier: str) -> int`: Apply the order customer's loyalty discount to a USD amount.
|
| 24 |
+
- `net_revenue_usd(order_id: int) -> int`: Net USD revenue after loyalty discount and refunds.
|
| 25 |
+
- `to_local(amount_usd: int, currency: str) -> int`: Convert a USD integer amount to a local-currency integer.
|
| 26 |
+
- `inventory_position(product_id: int, region: str) -> int`: Available inventory position: on_hand - reserved + inbound.
|
| 27 |
+
- `product_lead_time(product_id: int) -> int`: Supplier lead time in days for a product.
|
| 28 |
+
- `product_id_for_top_seller(region: str, category: str, month_start: int, month_end: int) -> int`: Product id with the highest units sold in a region/category/month window.
|
| 29 |
+
- `units_sold(product_id: int, region: str, month_start: int, month_end: int) -> int`: Units sold for one product in a region and month window.
|
| 30 |
+
- `tickets_for_orders(order_ids: list[int], severity: str) -> list[int]`: Support ticket ids for given orders and severity.
|
| 31 |
+
- `ticket_order_id(ticket_id: int) -> int`: Order id associated with a support ticket.
|
| 32 |
+
- `sla_breached(ticket_id: int, first_response_limit_hours: int, resolution_limit_hours: int) -> bool`: Whether a support ticket breaches first-response or resolution SLA.
|
| 33 |
+
- `delayed_orders(order_ids: list[int]) -> list[int]`: Subset of order ids whose ship_days exceeded promised_days.
|
| 34 |
+
- `unique_customers(order_ids: list[int]) -> list[int]`: Unique customer ids among the given orders.
|
| 35 |
+
- `count_items(values: list) -> int`: Length of a list.
|
| 36 |
+
- `sum_values(values: list[int]) -> int`: Sum a list of integers.
|
| 37 |
+
- `count_true(values: list[bool]) -> int`: Count true values.
|
| 38 |
+
- `count_below(values: list[int], threshold: int) -> int`: Count values below a threshold.
|
harbor/tasks/v3_depth6_delay_sla_burden_t17/task.toml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.3"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "mindlab/v3_depth6_delay_sla_burden_t17"
|
| 5 |
+
description = "FlowBench v3 public task metadata. Public verifier is smoke-only."
|
| 6 |
+
authors = [{ name = "Mind Lab", email = "contact@mindlab.ltd" }]
|
| 7 |
+
keywords = ["flowbench", "tool-use", "data-orchestration", "operations"]
|
| 8 |
+
|
| 9 |
+
[metadata]
|
| 10 |
+
benchmark = "FlowBench-v3"
|
| 11 |
+
split = "public-task-only"
|
| 12 |
+
category = "data-processing"
|
| 13 |
+
depth = 6
|
| 14 |
+
|
| 15 |
+
[verifier]
|
| 16 |
+
timeout_sec = 120.0
|
| 17 |
+
|
| 18 |
+
[agent]
|
| 19 |
+
timeout_sec = 900.0
|
| 20 |
+
|
| 21 |
+
[environment]
|
| 22 |
+
network_mode = "no-network"
|
| 23 |
+
build_timeout_sec = 600.0
|
| 24 |
+
os = "linux"
|
| 25 |
+
cpus = 1
|
| 26 |
+
memory_mb = 2048
|
| 27 |
+
storage_mb = 2048
|
| 28 |
+
gpus = 0
|
harbor/tasks/v3_depth6_delay_sla_burden_t17/tests/check_output_shape.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
import re
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def write_reward(score: float, diagnostic: str) -> None:
|
| 11 |
+
log_dir = Path(os.environ.get("LOG_DIR", "/logs/verifier"))
|
| 12 |
+
log_dir.mkdir(parents=True, exist_ok=True)
|
| 13 |
+
(log_dir / "reward.txt").write_text(f"{score:.6g}\n")
|
| 14 |
+
(log_dir / "reward.json").write_text(
|
| 15 |
+
json.dumps({"reward": score, "smoke_only": True}, indent=2) + "\n"
|
| 16 |
+
)
|
| 17 |
+
(log_dir / "diagnostic.txt").write_text(diagnostic + "\n")
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def main() -> int:
|
| 21 |
+
app_dir = Path(os.environ.get("APP_DIR", "/app"))
|
| 22 |
+
task = json.loads((app_dir / "task.json").read_text())
|
| 23 |
+
answer_path = app_dir / "answer.txt"
|
| 24 |
+
if not answer_path.exists():
|
| 25 |
+
write_reward(0.0, "missing /app/answer.txt")
|
| 26 |
+
return 1
|
| 27 |
+
|
| 28 |
+
got = answer_path.read_text().strip()
|
| 29 |
+
if task["answer_format"] == "exact integer":
|
| 30 |
+
ok = bool(re.fullmatch(r"-?\d+", got))
|
| 31 |
+
diagnostic = "valid integer smoke output" if ok else f"not an exact integer: {got!r}"
|
| 32 |
+
else:
|
| 33 |
+
ok = bool(re.fullmatch(r"[A-Za-z]+", got))
|
| 34 |
+
diagnostic = "valid code smoke output" if ok else f"not an exact code: {got!r}"
|
| 35 |
+
|
| 36 |
+
# This is intentionally not official scoring; it only verifies I/O shape.
|
| 37 |
+
write_reward(1.0 if ok else 0.0, diagnostic)
|
| 38 |
+
return 0 if ok else 1
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
if __name__ == "__main__":
|
| 42 |
+
raise SystemExit(main())
|