Six injected leaks. Six alarms. Thirteen false ones — counted, not hidden.
Deterministic margin leaks were replayed into 106 weeks of real Olist contribution margin; STL plus a robust z-score had to find them. It found all six — at the cost of thirteen false alarms, which stay on the record.
1.00recall · 0 missed
.316precision · 6 tp / 13 fp
106weeks · 11 missing, declared
±3.5robust-z alarm threshold
EXHIBIT 01 · ROBUST Z AT EACH INJECTED LEAK WEEKWEEKLY CONTRIBUTION MARGIN · STL PERIOD 13 WK
Week
Robust z
Injected Δ
Status
2016-12-19
-39.45
-97603.75
Detected
2017-04-03
-37.57
-97603.75
Detected
2017-07-17
-38.25
-97603.75
Detected
2017-10-30
-39.32
-97603.75
Detected
2018-02-12
-44.61
-97603.75
Detected
2018-05-28
-30.28
-97603.75
Detected
Promotion depth moves volume by 0.0395 [0.0261, 0.0530] per log unit — but holdout MAPE is 0.759, so the elasticity is reported as descriptive association, not a forecasting tool.
4 governed metrics · gross revenue / net revenue / contribution margin / contribution margin rate label source: Six deterministic fixed-location negative perturbations replayed on observed Mondays in a complete Monday calendar; missing weeks are zero-filled and no manually labeled real anomalies are claimed.
02STL + ROBUST Z-SCORE · 13-WEEK PERIOD
One number decides every alarm.
Contribution margin is first decomposed by STL (a 13-week seasonal period); the residual is converted to a robust z-score (median and MAD, not mean and standard deviation, so a handful of already-anomalous weeks cannot drag the yardstick). Any week where |z| crosses 3.5 fires an alarm — nothing else about the week matters to the detector.
Every one of the six injected leaks (vermilion) lands well past the alarm line; none of the ruler's remaining headroom is occupied by a false negative.
Governed metric registry
Metric
Formula
Grain
Unit
gross_revenue
units * unit_price
week × product × region × channel
synthetic currency units
net_revenue
gross_revenue - discounts - returns
week × product × region × channel
synthetic currency units
contribution_margin
net_revenue - cogs - fulfillment
week × product × region × channel
synthetic currency units
contribution_margin_rate
contribution_margin / gross_revenue
selected analytical slice
ratio
4 metrics, one owner, one provenance line (computed from fixed-seed synthetic dataset v2). Nothing on this page computes a number outside this registry.
03FALSE ALARMS · HOLDOUT HONESTY
Recall cost precision.
6 true positives13 false positives
NEGATIVE RESULT
13 of 19 total alarms (68%) are false positives. Precision is 0.315789; recall is 1.000000 with 0 missed leaks. The ±3.5 threshold was left where it was rather than retuned to flatter precision — both numbers are published together, and the false-positive count is not itemized away.
LIMITATION
The elasticity coefficient (0.0395, 95% CI [0.0261, 0.0530]) is fit on 14,313 analysis rows only. On the 1,496 holdout rows it never trained on, MAPE is 0.759 — a coefficient with error that large is reported as a descriptive association, not offered as a forecasting tool.
04SOURCE · RECEIPTS
Every number opens the same file.
What was verified
The Olist pipeline produces auditable margin, anomaly and elasticity artifacts from a locked dataset.
Evidence class
Pipeline-derived real-data aggregates with deterministic perturbation labels, kept separate from the governed synthetic fixture.
Boundary
Economics use disclosed proxies; false alarms and large elasticity holdout error remain visible. These results establish neither causal impact nor production business outcomes.
SELECT * FROM read_parquet('olist-margin.parquet')
This query re-reads the exact committed Parquet bytes in your browser and checks their SHA-256. The STL decomposition and robust z-scoring behind exhibit 01 run offline in Python (reproduce commands below), not live in this SQL.
olist-margin.parquet, detection-report.json, and elasticity-report.json are produced by the pipeline below from a licensed Olist source lock; metric-registry.json is a hand-authored governance file. docs/evidence/digits-margin.md pins every number on this page to one of these files.
Pinned the Olist owner dataset and verified every transported table against locked byte counts and SHA-256 hashes.
Collapsed 2,961 multi-payment orders to the largest payment-value channel and 547 multi-review orders to the lowest reported score.
Joined order items to orders, customers, categories, payments, and reviews; retained missing categories as explicit unknown values and audited payment-versus-item-plus-freight gaps.
Aggregated only after reconciliation to week × category × state-mapped region × payment channel.
02
Train and estimate
Contribution margin uses observed item price and freight, a prior-only category reference-price discount proxy, a status/review return proxy, and a disclosed 60% COGS proxy. Across categories, 275 item rows fall in their category's first observed week; they use current price and therefore receive zero proxy discount.
Before anomaly evaluation, 95 observed weekly totals are reindexed to a complete 106-Monday calendar. The 11 weeks with no derived Olist cells are explicitly zero-filled; replay labels are placed only on observed Mondays. The detector then applies a 13-week robust STL residual and MAD z-score threshold of 3.5.
Elasticity is HC3 log-log OLS with category, region, and channel fixed effects; it is associational, not causal.
03
Split and prevent leakage
The last eight observed weeks are holdout (1,496 rows); all earlier weeks are analysis (14,313 rows).
Reference prices use shifted expanding medians after the explicit first-observed-category-week current-price fallback; the elasticity coefficient is fit only on analysis rows, while later holdout rows evaluate MAPE only.
04
Outcome / anomaly labels
Six deterministic fixed-location negative perturbations are replayed on observed Mondays within the complete calendar series.
No manual real-anomaly label is claimed, and replay values are never written into the Parquet artifact.
05
Quality controls
The pipeline fails closed on source hashes, unique grain, bounds, and all three accounting identities; verification also reconstructs the complete Monday calendar and both reports from the exact Parquet.
The artifact embeds source URL, license, retrieval date, raw hashes, transform version, missing-week treatment, and proxy boundaries.
What changed with real data
The synthetic walkthrough remains available, but real mode now queries 15,809 reconciled cells. Measured replay precision/recall are 0.316/1.000; the analysis-fit associational log-log price coefficient is +0.040, with 75.85% MAPE on the later eight weeks.
The whole path is mine: the six-table Olist pipeline, the data contracts and source locks that police it, the diagnosis and scenario engine, and the browser UI.
01
Acquire
Lock six licensed Olist source tables by URL, retrieval date, size, and hash.
02
Reconcile
Join orders, items, customers, products, payments, and reviews at a declared weekly grain.
03
Contract
Stop if source hashes, schema, grain, accounting math, or browser artifact drift.
04
Diagnose
Decompose contribution-margin drivers and load artifact-bound detection and elasticity reports.
05
Test
Apply disclosed scenario assumptions, inspect the later holdout, and record an action.
Results & negatives
The default path verifies the committed Olist artifact before rendering, exposes measured detection and elasticity reports, recomputes a bounded scenario, and records a category action for review.
01
The replay detector catches every injected anomaly and cries wolf more often than it is right: 6 true positives, 13 false positives, 0 false negatives — recall 1.000000, precision 0.315789. Roughly two of every three alerts is noise. I left the threshold where it was and wrote both numbers into the audit.
02
Every category's first observed week shows exactly zero discount, and that says nothing about Olist sellers. It is my cold-start rule: with no earlier week to price against, the reference price falls back to the current item price, so the proxy discount collapses to zero. It is documented rather than fixed.
Limitations
01
Synthetic currency and injected anomalies do not show real lift, detection accuracy, or causal impact.
02
The scenario uses a disclosed elasticity assumption and is not a forecast.
03
Olist detection and elasticity results appear only from committed detection-report.json and elasticity-report.json files; missing reports remain visibly pending and never render placeholder results.
04
Detection precision and recall evaluate six deterministic perturbations on observed Mondays after the real totals are reindexed to a complete Monday calendar; 11 weeks with no derived cells are zero-filled. No manually labeled real anomaly is claimed, and neither calendar-completion rows nor perturbations enter the Parquet artifact.
05
The associational elasticity coefficient is fit on the analysis window; the later eight-week holdout evaluates MAPE only. Reference price, return deductions, and 60% COGS are disclosed proxies; no causal lift, audited company margin, forecast, or production decision is claimed.