Skill: Northwind Components ERP Decision Tasks (task_group_007)
Overview
These tasks require querying a shared Northwind ERP API (default http://127.0.0.1:8007) and producing strictly-formatted JSON decisions. The output schema is always defined in input/payloads/answer_template.json and must be matched exactly. Each task is driven by a memo or request file in input/payloads/.
General Workflow
- Read the task prompt (
input/prompt.txt) to identify the decision type. - Read the answer template (
input/payloads/answer_template.json) to learn the exact required keys, types, enums, and sorting rules. - Read any memo/request payload in
input/payloads/for target IDs, date windows, or policy rules. - Start or connect to the ERP API (base URL from prompt/memo, typically
http://127.0.0.1:8007). - Fetch live records for every entity referenced. Do not use cached or assumed inventory snapshots.
- Apply the business rules described in the memo/template, compute derived values, and assemble the JSON.
- Validate: correct keys, correct enum values, all lists sorted per template, currency rounded to 2 decimals, percentages rounded as specified.
- Return only the JSON object.
API Usage Habits
- Base URL: Usually
http://127.0.0.1:8007; may be provided in the memo. Start the environment fromtask_group/task_group_007/envif needed. - Key endpoints (inspect OpenAPI/docs at runtime to confirm paths):
/ordersor/orders/{id}— lines, requested warehouse, quantities./customersor/accounts— status flags:blocked,review_required,fraud_watch,credit_watch./products— SKU master,active/inactivestatus./inventoryor/warehouses/{id}/inventory— on-hand, reserved, quarantined, buffer. Compute effective available as what is truly free for the wave (exclude reserved, quarantined, and normal operating buffer)./purchase_orders— open or confirmed POs by warehouse/SKU for coverage checks./suppliers—quality_status(approved,watch,quality_hold), supplier name./incidents— filter by date range, supplier, severity, type (rma,work_order)./shipping_quotesor/quotes— zone distance, service days, total cost in USD./boms— bill-of-materials lines for kit builds.
- Live data rule: Always use current API records. Never assume a SKU is active/inactive or that stock matches a prior run.
Controlled Vocabularies & Enums
Memorize these common enum sets; the template will reference them but may not repeat the full list:
Inventory Status
readylow_stockshortageinactive_skuinactive_and_shortage
Customer Exception
nonereview_requiredaccount_blockedfraud_watchcredit_watch
Final Decision (Expedite / Allocation)
ship_nowdelayed_releasemanual_reviewbackorderreject_hold
Next Action (Expedite)
release_to_pickdelay_and_monitorsend_account_reviewcreate_backorderhold_credit_or_fraudescalate_product_master
Line Action (Allocation)
shiptransferbackordermanual_review
Primary Reason (Allocation)
noneaccount_blockedaccount_review_requiredfraud_watchinactive_productinsufficient_effective_stock
Component Final Action (Replenishment)
no_action_stockedtransfer_onlypurchase_requiredtimely_po_coveredoverstock_excluded
Exclusion Reason (Replenishment)
nonetarget_overstocktimely_po_covers_gapstocked_no_gap
Supplier Recommendation Code (Scorecard / Quality)
Precedence order matters: evaluate top-to-bottom and stop at first match.
ESCALATE_SUPPLIERPROCESS_REVIEWWATCHLISTMONITOR
Quality Hold Review Decisions
freeze_new_replenishmentbuyer_review_requiredmonitor_only
Supplier Quality Status
approvedwatchquality_hold
Sorting & Ordering Rules
Always sort lists exactly as the answer template specifies. Common patterns:
- By ID ascending:
order_id,sku,supplier_id,po_id,bom_id. - Compound sorts:
- Allocation lines:
order_idasc, thenline_idasc. - Transfer requests (replenishment):
skuasc, thenquantitydesc, thenfrom_warehouse_idasc. - Top escalation suppliers:
incident_countdesc, thentotal_resolution_costdesc, thensupplier_idasc.
- Allocation lines:
- SKU exception lists (shortage, inactive, low_stock): ascending by SKU.
- Incident IDs / PO IDs: ascending string sort.
- Sample lists (e.g., top 5 incident IDs): sort ascending, then truncate to max length.
Rounding & Precision
- Currency (USD): always round to 2 decimal places in the final JSON.
- Percentages: typically 1 decimal place (e.g.,
23.7). - Duration / averages: typically 2 decimal places.
- Use standard rounding (half-up) unless the template states otherwise.
Business Logic Patterns
1. Account / Customer Risk Checks
- Query the customer/account record for the order.
- If
blocked→ decision often becomesreject_holdormanual_reviewwith actionhold_credit_or_fraud. - If
review_required→manual_review/send_account_review. - If
fraud_watchorcredit_watch→ line-levelmanual_reviewwith matching primary reason. - Blocked orders list: include orders where account-level risk stops the entire order, not just a single line.
2. Inventory & SKU Status
- For each order line, read the product master. If
inactive→ include SKU ininactive_skusand set inventory status toinactive_skuorinactive_and_shortage. - Compute effective available at the requested warehouse after excluding reserved, quarantined, and normal operating buffer stock.
- If effective available < requested quantity → shortage. If 0 < effective < requested but not zero → can be
low_stock. - Important: In allocation tasks, transfer only the uncovered quantity from another warehouse; any quantity the requested warehouse can fulfill stays as
ship_quantity.
3. Shipping Quotes
- Always request the quote using the live API with the order’s shipping parameters (speed, zone, weight).
- Include
zone_distance(int),service_days(int),total_cost_usd(number, 2 decimals) even when the final decision is not release.
4. Replenishment / Kit Builds
- Explode BOMs to component-level total required quantities.
- Compute gap = required − effective available at target warehouse.
- Check for timely PO coverage: open or confirmed POs for the same warehouse with delivery before the build date. If a timely PO covers the gap, action =
timely_po_coveredand exclude from purchases. - Check inter-warehouse transfers: source from other warehouses’ unprotected stock (exclude their reserved/buffer). Transfer only what is needed; prefer one or multiple sources as the data allows.
- If effective available > required (overstock) →
overstock_excluded. - Purchase requisition quantity = remaining gap after transfers and timely POs.
extended_cost=quantity×unit_cost, rounded to 2 decimals.
5. Supplier Scorecards
- Filter incidents by the memo’s date window (usually on
open_date, inclusive). - Severity values considered severe:
high,critical. incident_percentage= supplier incident count / total filtered incident count × 100, rounded to 1 decimal.avg_duration_days:- Closed incidents: calendar days from
open_datetoclose_date. - Open incidents: calendar days from
open_datetoanalysis_date.
- Closed incidents: calendar days from
- Apply recommendation policy in strict precedence order; do not fall through to a lower code if a higher one matches.
top_escalation_suppliersincludes only those with codeESCALATE_SUPPLIER, sorted by incident count desc, then cost desc, then supplier_id asc.highest_cost_supplier_id= supplier with greatest total resolution cost in the filtered set.highest_share_supplier_id= supplier with greatest incident count in the filtered set (or use cost if tied, per typical logic; follow template instructions).
6. Quality Hold Review
- Review only the target suppliers listed in the memo.
- Gather incidents in the analysis window, count RMAs, severe/critical incidents, open incidents.
- Collect affected SKUs and up to 5 sample incident IDs (sorted, truncated).
- Collect open or confirmed purchase order IDs for the supplier →
held_po_ids. - Decision mapping example:
quality_hold+ incidents →freeze_new_replenishmentwatch+ incidents →buyer_review_requiredormonitor_onlydepending on severity/open counts- Clean record →
monitor_only
- Summary counts must reconcile with the supplier decisions list.
Common Pitfalls
- Ignoring sorting: many tasks fail if lists are not in the exact order required by the template.
- Using gross inventory instead of effective available: always subtract reserved, quarantined, and buffer.
- Missing transfer requests in allocation: when
actionistransfer, you must emit a corresponding entry intransfer_requests. - Forgetting blocked orders rollup: account-level blocks must appear in both
blocked_ordersand every line of that order set tomanual_reviewwith the appropriate reason. - Currency rounding errors: round at the final output step; do not truncate.
- Not checking product active status: inactive SKUs must be flagged even if there is physical stock.
- Exceeding max list lengths: e.g.,
sample_incident_idslimited to 5; sort first, then slice. - Null vs omitted fields: the template may require
transfer_from: nullrather than omitting the key.
File Conventions
- Task prompt:
input/prompt.txt - Answer template (schema):
input/payloads/answer_template.json - Task-specific memos/requests:
input/payloads/*.jsonor*.md - Output: a single JSON object only, no markdown wrapper.