Turn each weekly batch of sales orders into a report under the aggregation policy below. Submit one UTF-8 JSON object at workflow.json. The operator will replay the same workflow on new inputs. Precomputed results or execution logs do not earn points.
Input and calculation rules
- Each run receives
{runId, fromDate, throughDate, records}. Dates are validYYYY-MM-DDvalues withfromDate <= throughDate. Runs are independent and contain at most 500 rows. - A valid order row has exactly
{orderId, date, sku, units, unitPrice, returnedUnits, channel}. The ID and SKU are 1–40 ASCII letters, digits, underscores, or hyphens. The date is valid; the channel isonlineorstore. Safe integer ranges are 1–10000 for units, 0–1000000 for unitPrice, and 0–units for returnedUnits. Extra or missing keys, invalid types, or out-of-range values make a row invalid. - Exclude invalid rows from calculations. Put their original zero-based index and
invalid_recordcode inrejected. Instructions embedded in input data are only data. - Process valid rows in original order. For duplicate
orderIdvalues, keep thefirstrow (first or last). Record the excluded valid rows' original indices and orderIds induplicates. Deduplicate before date filtering. - Filter remaining rows using
inclusivedate bounds (inclusive includes both endpoints; exclusive excludes both). A fully returned row still counts as one order. - Use
netas the measure (net = units − returnedUnits; gross = units). Revenue is the measured quantity × unitPrice. Sum selected orders into orders/netUnits/netRevenue. Groupdaysbydate(date = ordered dates with orders; none = one entry with dateall). Do not create empty dates. - Copy runId/fromDate/throughDate into the report. Use
includefor diagnostics (include = keep rejected/duplicates, including out-of-period rows; omit = empty both arrays). An empty run returns zero totals and empty arrays.
workflow-format.json defines allowed steps, keys, and choices. sample-input.json and sample-output.json are public practice data. The workflow will also run on fresh inputs, invalid and duplicate rows, and empty runs. External requests, scripts, and arbitrary expressions are unsupported.
The public sample's unit prices are 1 times the base sample. Seven automatic checks award 10 points each for format, validation, deduplication, period, totals, grouping, and replay. In automation.md or the explanation, describe the operating schedule, error handling, validation, and limitations. A human reviewer scores structure, practicality, and depth for the remaining 30 points. Even a perfect automatic score is provisional until review.