Atlas Commerce Operations Analytical Task Solver
This skill solves a class of analytical/operational tasks against the Atlas Commerce Operations workplace database. Each task presents a business request (prompt + JSON request payload) plus a strict JSON output contract (answer_template.json), and asks you to compute the answer from live database records and write a single answer.json.
The rules here are reusable operating methodology. They contain no task-specific final values, thresholds, IDs, or dates — those always come from the request payload of the specific task. Apply the rules to whatever request you are given.
When to use
Use this skill when a task matches this shape:
- A prompt references the Atlas Commerce Operations workplace at
<TASK_ENV_BASE_URL> and asks for a JSON result written to answer.json.
- An
input/payloads/<something>_request.json supplies the business scope, definitions, scope windows, cutoffs, and classification/risk policy.
- An
input/payloads/answer_template.json defines the exact output contract (required fields, types, enum values, array sizes, ordering, rounding).
- The prompt says the request is analytical / read-only, OR (one variant) asks for an approved minimal canonical correction with an audit record.
The four-phase procedure
Run every task in this order. Do not skip phases.
Phase 1 — Read everything before touching the API
- Read the prompt and every payload file under
input/payloads/ (the request JSON and the answer template JSON). The answer template is a binding contract, not a suggestion.
- From the request payload, extract in writing:
- the cohort / population / membership definition (which rows are eligible),
- every scope window and cutoff as exact UTC boundaries (note inclusive vs exclusive, start vs end),
- every business definition (what counts as complete / on-time / breached / severe / candidate, etc.) — quoted from the payload,
- every formula (rate numerators and denominators, per-unit/per-hour math, ratios),
- every ranking / ordering rule (sort keys, ascending/descending, tie-breakers, result sizes),
- every rounding rule (which fields round, to how many decimals, and whether ranks use rounded or unrounded values),
- every status / risk classification policy (the ordered rules and their numeric thresholds).
- From the answer template, extract:
- the exact required field names and their JSON types,
- array
minItems/maxItems and ordering constraints,
- enum value strings (must match exactly, including case),
- any
multipleOf / precision / decimal_places that encode rounding,
additionalProperties: false — the output must contain only the required fields, nothing extra.
The payload's prose definitions are authoritative. When a payload definition and the answer template description disagree on wording, follow the payload definition for the computation and the template for field shape/format only.
Phase 2 — Ground yourself in the live schema (read-only)
Use the documented environment endpoints (see environment_access.md for the base URL and bearer token; use that file only for network access). All headers require Authorization: Bearer <token>.
GET /api/schema — table DDL (column names, types, CHECK constraints, foreign keys).
GET /api/data-dictionary — column descriptions and the global conventions (timestamps are ISO-8601 UTC ending in Z; dates are YYYY-MM-DD; monetary minor fields are the smallest unit of the row currency; FX rates are USD per currency unit; raw fields preserve source values, canonical fields hold normalized operational values).
POST /api/sql — read-only analysis. Body {"sql": "<SELECT or WITH>", "params": [...]}.
GET /api/correction-audit — the public audit view (columns + rows; starts empty).
POST /api/sql/transaction — controlled writes, only for the correction variant (see Phase 4).
Before writing business SQL, SELECT the columns you will rely on and sample a few rows. Confirm:
- which columns are
*_minor integers (money / amounts in the row currency's smallest unit) vs. REAL (FX rates),
- which timestamp/date columns bound the cohort and cutoffs,
- which
is_internal / is_test flags exclude non-production rows (treat 1 as true, 0 as false),
- raw vs. canonical columns (analytics use canonical; raw is preserved as-is and never changes).
Phase 3 — Compute with read-only SQL (analytical tasks)
Work in small verified queries. Build the result bottom-up: define the eligible cohort first, then derive counts, rates, rankings, and classifications from that same cohort so every output field is consistent with one another.
Operating rules that recur across every analytical task:
- Build the eligible set once, then reuse it. Every count and every rate's denominator comes from the same eligible cohort defined by the payload. Express it as a CTE (
WITH eligible AS (...)) and join back to it. A rate numerator that silently uses a different population than its denominator is the most common failure.
- Match the cohort exactly. Apply the population filter (e.g. production accounts/orders, not test/internal), the scope window (inclusive boundaries unless the payload says otherwise), and any membership condition (e.g. "has at least one effective scan in the named batch at or before the cutoff"). Re-check membership predicates against the payload wording.
- Respect raw vs. canonical. Use canonical fields for operational analytics. Raw fields are source-of-truth inputs that you do not alter.
- Money: convert via daily FX to USD. For any USD amount, take the refund/reversal/payment service date (or the date the payload names) and the row currency, then join
fx_rates on (rate_date, currency) and multiply the minor-unit amount by usd_per_unit. Divide minor amounts by 100 to get major units before/after FX as the payload's money policy dictates. Use the same FX basis for both sides of any comparison (e.g. refund value vs. order gross) so the comparison is apples-to-apples.
- Settle / net using linked reversals. When a payload talks about "effective settled ... after reversals" or "net", follow the linkage column (
linked_event_id / linked_refund_id) to subtract reversed rows from their parent rows. A row and its reversal are not independent.
- Rank exactly as specified. Apply every sort key in order with the stated direction, and break ties with the stated tie-breaker. Return exactly the
result_size / limit rows — no more, no fewer. Where a payload ranks by a rate, decide from its wording whether to rank on the unrounded rate (typical for "worst/lowest by rate") and round only the reported value.
- Round only where the payload says. "Round only final reported rates to N decimals" means: compute and compare on full-precision values; round only at the moment you emit the field. Honor the template's
multipleOf (e.g. 0.0001 = 4 decimals, 0.01 = 2 decimals) as the rounding grid.
- Classify with the first matching ordered rule. Status/risk policies are ordered (e.g. HEALTHY → WATCH → CRITICAL, or LOW → MODERATE → HIGH, or CONTROLLED → ELEVATED → SEVERE). Evaluate in the listed order and take the first rule whose conditions all hold; fall through to the "otherwise/all other" bucket when none match. A "both conditions must hold" rule is satisfied only when both hold.
- Sort ID lists ascending and de-duplicate. Where the template requires a sorted unique list of IDs (orders, cases, tasks, accounts),
DISTINCT + ascending sort. Preserve the exact ID pattern; do not strip prefixes.
- Medians: handle even counts by averaging the two central values. For a median over a resolved/closed population, sort ascending; for an even count average the two middle values; round the result to the decimals the template/payload specify.
Phase 4 — Correction variant (only when the payload asks for an approved minimal canonical correction)
One task type asks you to apply a correction, not just analyze. The payload states there is exactly one raw/canonical contradiction and supplies an approved_correction block (reason_code, actor, audit_id, correction_key, corrected_at) plus a correction_status_rule.
- Identify the one contradiction. Query the in-scope rows (named batch + warehouse + at/before cutoff as the payload defines) and find the single scan/shipment row whose
raw_* value contradicts its canonical_* value in the way the payload describes. Do not "fix" any other row.
- Correct the minimal canonical field only. The correction scope is
MINIMAL_CANONICAL_FIELD_ONLY: change exactly one canonical column on exactly one business row so the canonical value becomes correct. Never change a raw/source value, a source identity field, or any unrelated business row.
- Use the controlled transaction endpoint. Submit a single
POST /api/sql/transaction with:
- a guarded
UPDATE on carrier_scans (or inventory_movements) limited to the one target row, setting the canonical field, corrected_at, and correction_reason;
- an
INSERT INTO correction_audit carrying all audit columns (audit_id, correction_key, entity_type, entity_id, source_row_id, field_name, old_value, new_value, reason_code, corrected_at, actor) exactly as the payload's approved_correction plus the observed old/new values;
expected_total_changes set to the business-rows-changed count the rule requires.
Re-read environment_access.md for the exact allowed SQL shapes (SELECT/WITH; guarded UPDATE on carrier_scans/inventory_movements; INSERT INTO correction_audit with all audit columns) and the constraints on statements (1–6) and expected_total_changes (0–12).
- Verify post-change, then report what you actually observed. Run a read-only query to confirm the canonical value now holds. The
correction_status is APPLIED only when both (a) exactly one business row and one audit row committed and (b) a post-change query confirms the corrected canonical value — exactly the payload's success rule. If the transaction rejected, changed a different count, or the post-check fails, report NOT_APPLIED with the counts actually observed. Never claim APPLIED for a transaction you could not fully verify. GET /api/correction-audit should now contain your audit row.
- Report backlog/analysis around the correction as observed. Compute pre- and post-correction backlog counts (and any delta/delivered counts the template wants) from the same cohort/membership definition the payload gave, using the cutoff exactly once each side of the correction.
Phase 5 — Emit exactly the contract, nothing more
- Produce a single JSON object. Field names, types, nesting, enums, and array sizes must match
answer_template.json exactly. additionalProperties: false means no extra keys, no commentary, no trailing fields.
- Round each numeric field to its template grid (
multipleOf / decimal_places / precision).
- Sort every ordered array exactly as the template specifies (note
x-list-ordering / ordering / order constraints; some templates forbid arrays entirely).
- Write the object to
answer.json with no text outside the JSON document — no prose, no markdown fence, no explanation. The file is the answer.
- Validate against the template before finishing: required fields present, types correct, enums matched, array lengths within bounds, additionalProperties satisfied. A well-formed but non-conforming object is a wrong answer.
Notes & guardrails
- Read-only unless explicitly correcting. If the prompt says analytical/read-only (no data correction requested), use only
GET and POST /api/sql. Never call the transaction endpoint.
- Trust the payload's exact wording over assumption. Edge cases ("an incomplete order with no shipment promise does not satisfy the first condition"; "an unresponded case uses active elapsed time at the cutoff") are deliberate and must be implemented literally.
- Keep numbers consistent. Derive counts and rates from the same cohort CTE. Cross-check that
complete + incomplete == eligible (or the analogous decomposition) and that a status classification uses the same rate you reported.
- Network only via
environment_access.md. Use the base URL and bearer token documented there; do not invent endpoints or credentials. If the env var form of the base URL is empty, use the literal URL printed in environment_access.md.
- Don't hardcode task-specific values into shared logic. Thresholds, windows, IDs, and result sizes are inputs read from the payload at runtime.
Supporting references
skill/reference/endpoints.md — endpoint bodies, headers, request/response shapes, and SQL allowed-lists, lifted from environment_access.md.
skill/reference/schema_map.md — table inventory and the raw-vs-canonical / minor-money / FX conventions that recur across tasks.
skill/reference/task_patterns.md — the five recurring analytical patterns (cohort rate scorecard, settlement reconciliation, carrier quality correction, warehouse productivity, support health) as checklists, without specific values.
1---2name: self-attempt-02-213description: Atlas Commerce Operations Analytical Task Solver4---5# Atlas Commerce Operations Analytical Task Solver67This skill solves a class of analytical/operational tasks against the **Atlas Commerce Operations** workplace database. Each task presents a business request (prompt + JSON request payload) plus a strict JSON output contract (`answer_template.json`), and asks you to compute the answer from live database records and write a single `answer.json`.89The rules here are *reusable operating methodology*. They contain **no task-specific final values**, thresholds, IDs, or dates — those always come from the request payload of the specific task. Apply the rules to whatever request you are given.1011## When to use1213Use this skill when a task matches this shape:1415- A prompt references the Atlas Commerce Operations workplace at `<TASK_ENV_BASE_URL>` and asks for a JSON result written to `answer.json`.16- An `input/payloads/<something>_request.json` supplies the business scope, definitions, scope windows, cutoffs, and classification/risk policy.17- An `input/payloads/answer_template.json` defines the exact output contract (required fields, types, enum values, array sizes, ordering, rounding).18- The prompt says the request is analytical / read-only, OR (one variant) asks for an approved minimal canonical correction with an audit record.1920## The four-phase procedure2122Run every task in this order. Do not skip phases.2324### Phase 1 — Read everything before touching the API25261. Read the prompt and **every payload file** under `input/payloads/` (the request JSON **and** the answer template JSON). The answer template is a binding contract, not a suggestion.272. From the request payload, extract in writing:28 - the **cohort / population / membership** definition (which rows are eligible),29 - every **scope window and cutoff** as exact UTC boundaries (note inclusive vs exclusive, start vs end),30 - every **business definition** (what counts as complete / on-time / breached / severe / candidate, etc.) — quoted from the payload,31 - every **formula** (rate numerators and denominators, per-unit/per-hour math, ratios),32 - every **ranking / ordering rule** (sort keys, ascending/descending, tie-breakers, result sizes),33 - every **rounding rule** (which fields round, to how many decimals, and whether ranks use rounded or unrounded values),34 - every **status / risk classification policy** (the ordered rules and their numeric thresholds).353. From the answer template, extract:36 - the exact required field names and their JSON types,37 - array `minItems`/`maxItems` and ordering constraints,38 - enum value strings (must match exactly, including case),39 - any `multipleOf` / `precision` / `decimal_places` that encode rounding,40 - `additionalProperties: false` — the output must contain **only** the required fields, nothing extra.4142The payload's prose definitions are authoritative. When a payload definition and the answer template description disagree on wording, follow the **payload definition** for the computation and the **template** for field shape/format only.4344### Phase 2 — Ground yourself in the live schema (read-only)4546Use the documented environment endpoints (see `environment_access.md` for the base URL and bearer token; use that file **only** for network access). All headers require `Authorization: Bearer <token>`.4748- `GET /api/schema` — table DDL (column names, types, CHECK constraints, foreign keys).49- `GET /api/data-dictionary` — column descriptions and the global **conventions** (timestamps are ISO-8601 UTC ending in `Z`; dates are `YYYY-MM-DD`; monetary minor fields are the smallest unit of the **row currency**; FX rates are USD per currency unit; **raw** fields preserve source values, **canonical** fields hold normalized operational values).50- `POST /api/sql` — read-only analysis. Body `{"sql": "<SELECT or WITH>", "params": [...]}`.51- `GET /api/correction-audit` — the public audit view (columns + rows; starts empty).52- `POST /api/sql/transaction` — controlled writes, **only** for the correction variant (see Phase 4).5354Before writing business SQL, `SELECT` the columns you will rely on and sample a few rows. **Confirm**:5556- which columns are `*_minor` integers (money / amounts in the row currency's smallest unit) vs. `REAL` (FX rates),57- which timestamp/date columns bound the cohort and cutoffs,58- which `is_internal` / `is_test` flags exclude non-production rows (treat `1` as true, `0` as false),59- raw vs. canonical columns (analytics use **canonical**; raw is preserved as-is and never changes).6061### Phase 3 — Compute with read-only SQL (analytical tasks)6263Work in small verified queries. Build the result bottom-up: define the eligible cohort first, then derive counts, rates, rankings, and classifications from that same cohort so every output field is consistent with one another.6465Operating rules that recur across every analytical task:66671. **Build the eligible set once, then reuse it.** Every count and every rate's denominator comes from the same eligible cohort defined by the payload. Express it as a CTE (`WITH eligible AS (...)`) and join back to it. A rate numerator that silently uses a different population than its denominator is the most common failure.682. **Match the cohort exactly.** Apply the population filter (e.g. production accounts/orders, not test/internal), the scope window (inclusive boundaries unless the payload says otherwise), and any membership condition (e.g. "has at least one effective scan in the named batch at or before the cutoff"). Re-check membership predicates against the payload wording.693. **Respect raw vs. canonical.** Use canonical fields for operational analytics. Raw fields are source-of-truth inputs that you do not alter.704. **Money: convert via daily FX to USD.** For any USD amount, take the refund/reversal/payment **service date** (or the date the payload names) and the row **currency**, then join `fx_rates` on `(rate_date, currency)` and multiply the minor-unit amount by `usd_per_unit`. Divide minor amounts by 100 to get major units before/after FX as the payload's money policy dictates. Use the same FX basis for both sides of any comparison (e.g. refund value vs. order gross) so the comparison is apples-to-apples.715. **Settle / net using linked reversals.** When a payload talks about "effective settled ... after reversals" or "net", follow the linkage column (`linked_event_id` / `linked_refund_id`) to subtract reversed rows from their parent rows. A row and its reversal are not independent.726. **Rank exactly as specified.** Apply every sort key in order with the stated direction, and break ties with the stated tie-breaker. Return exactly the `result_size` / `limit` rows — no more, no fewer. Where a payload ranks by a rate, decide from its wording whether to rank on the **unrounded** rate (typical for "worst/lowest by rate") and round only the reported value.737. **Round only where the payload says.** "Round only final reported rates to N decimals" means: compute and compare on full-precision values; round only at the moment you emit the field. Honor the template's `multipleOf` (e.g. `0.0001` = 4 decimals, `0.01` = 2 decimals) as the rounding grid.748. **Classify with the first matching ordered rule.** Status/risk policies are ordered (e.g. HEALTHY → WATCH → CRITICAL, or LOW → MODERATE → HIGH, or CONTROLLED → ELEVATED → SEVERE). Evaluate in the listed order and take the **first** rule whose conditions all hold; fall through to the "otherwise/all other" bucket when none match. A "both conditions must hold" rule is satisfied only when *both* hold.759. **Sort ID lists ascending and de-duplicate.** Where the template requires a sorted unique list of IDs (orders, cases, tasks, accounts), `DISTINCT` + ascending sort. Preserve the exact ID pattern; do not strip prefixes.7610. **Medians: handle even counts by averaging the two central values.** For a median over a resolved/closed population, sort ascending; for an even count average the two middle values; round the result to the decimals the template/payload specify.7778### Phase 4 — Correction variant (only when the payload asks for an approved minimal canonical correction)7980One task type asks you to apply a correction, not just analyze. The payload states there is exactly one raw/canonical contradiction and supplies an `approved_correction` block (reason_code, actor, audit_id, correction_key, corrected_at) plus a `correction_status_rule`.81821. **Identify the one contradiction.** Query the in-scope rows (named batch + warehouse + at/before cutoff as the payload defines) and find the single scan/shipment row whose `raw_*` value contradicts its `canonical_*` value in the way the payload describes. Do not "fix" any other row.832. **Correct the minimal canonical field only.** The correction scope is `MINIMAL_CANONICAL_FIELD_ONLY`: change exactly one canonical column on exactly one business row so the canonical value becomes correct. Never change a raw/source value, a source identity field, or any unrelated business row.843. **Use the controlled transaction endpoint.** Submit a single `POST /api/sql/transaction` with:85 - a guarded `UPDATE` on `carrier_scans` (or `inventory_movements`) limited to the one target row, setting the canonical field, `corrected_at`, and `correction_reason`;86 - an `INSERT INTO correction_audit` carrying **all** audit columns (audit_id, correction_key, entity_type, entity_id, source_row_id, field_name, old_value, new_value, reason_code, corrected_at, actor) exactly as the payload's `approved_correction` plus the observed old/new values;87 - `expected_total_changes` set to the business-rows-changed count the rule requires.88 Re-read `environment_access.md` for the exact allowed SQL shapes (`SELECT/WITH`; guarded `UPDATE` on `carrier_scans`/`inventory_movements`; `INSERT INTO correction_audit` with all audit columns) and the constraints on `statements` (1–6) and `expected_total_changes` (0–12).894. **Verify post-change, then report what you actually observed.** Run a read-only query to confirm the canonical value now holds. The `correction_status` is `APPLIED` only when **both** (a) exactly one business row and one audit row committed and (b) a post-change query confirms the corrected canonical value — exactly the payload's success rule. If the transaction rejected, changed a different count, or the post-check fails, report `NOT_APPLIED` with the counts actually observed. Never claim `APPLIED` for a transaction you could not fully verify. `GET /api/correction-audit` should now contain your audit row.905. **Report backlog/analysis around the correction as observed.** Compute pre- and post-correction backlog counts (and any delta/delivered counts the template wants) from the same cohort/membership definition the payload gave, using the cutoff exactly once each side of the correction.9192### Phase 5 — Emit exactly the contract, nothing more93941. Produce a single JSON object. Field names, types, nesting, enums, and array sizes must match `answer_template.json` exactly. `additionalProperties: false` means no extra keys, no commentary, no trailing fields.952. Round each numeric field to its template grid (`multipleOf` / `decimal_places` / `precision`).963. Sort every ordered array exactly as the template specifies (note `x-list-ordering` / `ordering` / `order` constraints; some templates forbid arrays entirely).974. Write the object to `answer.json` with **no text outside the JSON document** — no prose, no markdown fence, no explanation. The file is the answer.985. Validate against the template before finishing: required fields present, types correct, enums matched, array lengths within bounds, additionalProperties satisfied. A well-formed but non-conforming object is a wrong answer.99100## Notes & guardrails101102- **Read-only unless explicitly correcting.** If the prompt says analytical/read-only (no data correction requested), use only `GET` and `POST /api/sql`. Never call the transaction endpoint.103- **Trust the payload's exact wording over assumption.** Edge cases ("an incomplete order with no shipment promise does not satisfy the first condition"; "an unresponded case uses active elapsed time at the cutoff") are deliberate and must be implemented literally.104- **Keep numbers consistent.** Derive counts and rates from the same cohort CTE. Cross-check that `complete + incomplete == eligible` (or the analogous decomposition) and that a status classification uses the same rate you reported.105- **Network only via `environment_access.md`.** Use the base URL and bearer token documented there; do not invent endpoints or credentials. If the env var form of the base URL is empty, use the literal URL printed in `environment_access.md`.106- **Don't hardcode task-specific values into shared logic.** Thresholds, windows, IDs, and result sizes are inputs read from the payload at runtime.107108## Supporting references109110- `skill/reference/endpoints.md` — endpoint bodies, headers, request/response shapes, and SQL allowed-lists, lifted from `environment_access.md`.111- `skill/reference/schema_map.md` — table inventory and the raw-vs-canonical / minor-money / FX conventions that recur across tasks.112- `skill/reference/task_patterns.md` — the five recurring analytical patterns (cohort rate scorecard, settlement reconciliation, carrier quality correction, warehouse productivity, support health) as checklists, without specific values.