Atlas Commerce Operations — Analytical Task Skill
When to Use
Invoke this skill when asked to produce a data-analysis answer from the Atlas Commerce Operations workplace: scorecards, reconciliations, quality reviews, productivity reports, or health reviews that require SQL queries against the provided database and submission of a structured JSON answer matching a supplied template.
Core Environment
A workplace service is available at the base URL provided in the task prompt. All requests require the header Authorization: Bearer <token> where <token> is supplied in the prompt or environment. The service exposes these endpoints:
GET /api/schema — table DDL and indexes.
GET /api/data-dictionary — column descriptions, conventions (timestamps are ISO‑8601 UTC, money uses smallest currency units, raw vs canonical fields).
POST /api/sql — read‑only analytical queries. Body: {"sql": "<SQL>", "params": []}.
GET /api/correction-audit — lists applied canonical corrections.
POST /api/sql/transaction — controlled writes (see Correction Workflow below).
Always begin by fetching /api/schema and /api/data-dictionary so you know every table, column, index, and convention before writing any analytical query.
Deduplication (Universal Rule)
Any table whose indexes include a deduplication index named idx_<table>_dedupe on (source_system, external_event_id, ingested_at) must be deduplicated before any other processing:
- Group rows by
(source_system, external_event_id).
- Keep the single row with the maximum
ingested_at.
- Discard all other copies — they are import-retry duplicates.
Tables requiring dedup include: carrier_scans, case_events, refund_attempts, payment_events, inventory_movements, order_events, warehouse_task_events.
The resulting set is the effective rows. All status checks, counts, and time calculations operate on the deduplicated set only.
Effective Final State (Append‑Only Event Tables)
For tables that record an append-only event history (carrier_scans, case_events, warehouse_task_events), determine the effective current state of an entity as follows:
- Deduplicate the event rows first.
- For each entity (shipment, case, task), find the single row with the maximum event timestamp (
canonical_event_at / event_at).
- If multiple rows share the maximum timestamp, tie‑break by taking the maximum row identifier (
scan_row_id / case_event_id / task_event_id).
- The status on that row is the effective final status.
Do not use the denormalised current_status column on header tables (shipments, support_cases, warehouse_tasks) — the data dictionary notes it "may lag append‑only event history." Use the event tables with the dedup‑then‑latest pattern instead.
Money and FX
- All monetary amounts are stored in minor units (cents, pence — divide by 100 for major units).
- Cross‑currency conversion uses
fx_rates.usd_per_unit matched on (rate_date = service_date, currency = row_currency).
- Convert:
amount_usd = (amount_minor / 100.0) * fx_rates.usd_per_unit.
- When both refund and order are in the same non‑USD currency, both are multiplied by the same FX rate for comparison, so the relative comparison is preserved.
- Round final reported USD amounts to the decimal places specified in the answer template.
Correction Workflow
When the task describes a data correction with an approved audit record:
- Identify the exact contradiction from the data (e.g., raw status ≠ canonical status).
- The
/api/sql/transaction endpoint accepts only INSERT statements into the correction_audit table. UPDATE statements against business tables are rejected.
- Insert one audit row containing all required fields:
audit_id, correction_key, entity_type, entity_id, source_row_id, field_name, old_value, new_value, reason_code, corrected_at, actor.
- The audit record is the correction — check
GET /api/correction-audit afterwards to confirm it was recorded.
- When computing post‑correction state, apply the audit record's
new_value as an override for the specified (source_row_id, field_name).
- Set
correction_status to "APPLIED" when exactly one audit row committed and a post‑change query confirms the corrected value through the audit table.
Query Strategy
- The
/api/sql endpoint returns at most 5000 rows. When a result set would exceed this, use aggregation (COUNT, SUM, GROUP BY) to push computation into the database.
- For data that must be fetched row‑by‑row, batch queries using
WHERE … IN ('id1','id2',…) with 500–800 IDs per batch, then merge in the host language.
- Avoid deeply nested subqueries — the endpoint may reject them. Prefer simple
JOIN … GROUP BY patterns or pull data in stages.
- SQLite's
GROUP BY may return an arbitrary value for non‑aggregated columns when a strict mode is not enforced. Always use a deterministic method (row‑id tie‑break after fetching) rather than relying on GROUP BY alone for the status column.
General Workflow
- Read the request payload — it contains the exact business definitions, scope boundaries, rounding rules, and status‑classification rules. Every term in the payload has a precise meaning; do not substitute a generic interpretation.
- Read the answer template — the output must conform exactly to its
required fields, type constraints, enum values, pattern restrictions, and additionalProperties: false.
- Explore the data with small, focused queries before attempting the full computation.
- Build incrementally — verify intermediate counts (e.g., eligible population size, status distributions) before computing derived metrics.
- Match rounding and ordering — round only final reported values to the specified decimal places; use unrounded values for intermediate sorting and comparisons unless the request says otherwise.
- Sort arrays exactly as specified (ascending IDs, ranked metrics with tie‑breaks).
1---2name: reflect-3-attempt-02-643description: Atlas Commerce Operations — Analytical Task Skill4---5# Atlas Commerce Operations — Analytical Task Skill67## When to Use89Invoke this skill when asked to produce a data-analysis answer from the Atlas Commerce Operations workplace: scorecards, reconciliations, quality reviews, productivity reports, or health reviews that require SQL queries against the provided database and submission of a structured JSON answer matching a supplied template.1011## Core Environment1213A workplace service is available at the base URL provided in the task prompt. All requests require the header `Authorization: Bearer <token>` where `<token>` is supplied in the prompt or environment. The service exposes these endpoints:1415- `GET /api/schema` — table DDL and indexes.16- `GET /api/data-dictionary` — column descriptions, conventions (timestamps are ISO‑8601 UTC, money uses smallest currency units, raw vs canonical fields).17- `POST /api/sql` — read‑only analytical queries. Body: `{"sql": "<SQL>", "params": []}`.18- `GET /api/correction-audit` — lists applied canonical corrections.19- `POST /api/sql/transaction` — controlled writes (see Correction Workflow below).2021Always begin by fetching `/api/schema` and `/api/data-dictionary` so you know every table, column, index, and convention before writing any analytical query.2223## Deduplication (Universal Rule)2425Any table whose indexes include a deduplication index named `idx_<table>_dedupe` on `(source_system, external_event_id, ingested_at)` **must** be deduplicated before any other processing:26271. Group rows by `(source_system, external_event_id)`.282. Keep the single row with the **maximum `ingested_at`**.293. Discard all other copies — they are import-retry duplicates.3031Tables requiring dedup include: `carrier_scans`, `case_events`, `refund_attempts`, `payment_events`, `inventory_movements`, `order_events`, `warehouse_task_events`.3233The resulting set is the **effective** rows. All status checks, counts, and time calculations operate on the deduplicated set only.3435## Effective Final State (Append‑Only Event Tables)3637For tables that record an append-only event history (`carrier_scans`, `case_events`, `warehouse_task_events`), determine the effective current state of an entity as follows:38391. Deduplicate the event rows first.402. For each entity (shipment, case, task), find the single row with the **maximum event timestamp** (`canonical_event_at` / `event_at`).413. If multiple rows share the maximum timestamp, tie‑break by taking the **maximum row identifier** (`scan_row_id` / `case_event_id` / `task_event_id`).424. The status on that row is the **effective final status**.4344Do **not** use the denormalised `current_status` column on header tables (`shipments`, `support_cases`, `warehouse_tasks`) — the data dictionary notes it "may lag append‑only event history." Use the event tables with the dedup‑then‑latest pattern instead.4546## Money and FX4748- All monetary amounts are stored in **minor units** (cents, pence — divide by 100 for major units).49- Cross‑currency conversion uses `fx_rates.usd_per_unit` matched on `(rate_date = service_date, currency = row_currency)`.50- Convert: `amount_usd = (amount_minor / 100.0) * fx_rates.usd_per_unit`.51- When both refund and order are in the same non‑USD currency, both are multiplied by the same FX rate for comparison, so the relative comparison is preserved.52- Round final reported USD amounts to the decimal places specified in the answer template.5354## Correction Workflow5556When the task describes a data correction with an approved audit record:57581. Identify the exact contradiction from the data (e.g., raw status ≠ canonical status).592. The `/api/sql/transaction` endpoint accepts only `INSERT` statements into the `correction_audit` table. `UPDATE` statements against business tables are rejected.603. Insert one audit row containing all required fields: `audit_id`, `correction_key`, `entity_type`, `entity_id`, `source_row_id`, `field_name`, `old_value`, `new_value`, `reason_code`, `corrected_at`, `actor`.614. The audit record **is** the correction — check `GET /api/correction-audit` afterwards to confirm it was recorded.625. When computing post‑correction state, apply the audit record's `new_value` as an override for the specified `(source_row_id, field_name)`.636. Set `correction_status` to `"APPLIED"` when exactly one audit row committed and a post‑change query confirms the corrected value through the audit table.6465## Query Strategy6667- The `/api/sql` endpoint returns at most 5000 rows. When a result set would exceed this, use **aggregation** (`COUNT`, `SUM`, `GROUP BY`) to push computation into the database.68- For data that must be fetched row‑by‑row, **batch** queries using `WHERE … IN ('id1','id2',…)` with 500–800 IDs per batch, then merge in the host language.69- Avoid deeply nested subqueries — the endpoint may reject them. Prefer simple `JOIN` … `GROUP BY` patterns or pull data in stages.70- SQLite's `GROUP BY` may return an arbitrary value for non‑aggregated columns when a strict mode is not enforced. Always use a deterministic method (row‑id tie‑break after fetching) rather than relying on `GROUP BY` alone for the status column.7172## General Workflow73741. **Read the request payload** — it contains the exact business definitions, scope boundaries, rounding rules, and status‑classification rules. Every term in the payload has a precise meaning; do not substitute a generic interpretation.752. **Read the answer template** — the output must conform exactly to its `required` fields, `type` constraints, `enum` values, `pattern` restrictions, and `additionalProperties: false`.763. **Explore the data** with small, focused queries before attempting the full computation.774. **Build incrementally** — verify intermediate counts (e.g., eligible population size, status distributions) before computing derived metrics.785. **Match rounding and ordering** — round only final reported values to the specified decimal places; use unrounded values for intermediate sorting and comparisons unless the request says otherwise.796. **Sort arrays** exactly as specified (ascending IDs, ranked metrics with tie‑breaks).