Skip to main content
AboutWorkExperienceLogHireResume
PreviousFitness Tracker AnalysisNextCoreAI sampler
HomeProjectsAboutExperienceLogHireContactResumeGitHubLinkedIn
© 2026 Bhargav Kr Nath
All projects

Decision science, ML operations, production systems

Praxis

A revenue system that runs itself, and knows when not to act.

A closed decision loop for a simulated API and cloud-compute business. It forecasts demand, measures price elasticity from randomised tests, proposes prices inside hard guardrails, plans payment retries by expected value, and retrains its own models. It can stage a new model in shadow, but only a named person can promote it.

Role
Sole author, 34 commits, 17 planned phases
Runs on
GCP: Cloud Run jobs on a daily schedule
Operating since
2026-11-04, one synthetic world
Data
Synthetic business, hidden ground truth
weeklycycleloopclosespromotionnamed human01 Events invalidated, archived02 Exactly-once statePostgres + warehouse03 Models learnforecast, elasticity, churn04 Optimiser decideschange, hold or freeze05 Decision recordedbefore anything executes06 Back onto the busas a new event

0.1288

Forecast vWAPE, held-out world

vs 0.1661 seasonal naive, 8,064 forecasts

0.15%

Error recovering hidden elasticity

−1.3335 estimated vs −1.3315 true, pooled

61.1%

Failed payments recovered

vs 54.6% fixed schedule, 445 episodes

48.7M

Events replayed at 500K customers

exact oracle state, 0 OOM kills, emulated 8 GB

automatedneeds a named personResults inside the loop: held-out synthetic worlds, scored once against hidden truth
  1. 01Events in

    validated, archived

  2. 02Exactly-once state

    Postgres + warehouse

  3. 03Models learn

    forecast, elasticity, churn

  4. 04Optimiser decides

    change, hold or freeze

  5. 05Decision recorded

    before anything executes

  6. 06Back onto the bus

    as a new event

↺ and back to 01. Promotion waits for a named person.

0.1288

Forecast vWAPE, held-out world

vs 0.1661 seasonal naive, 8,064 forecasts

0.15%

Error recovering hidden elasticity

−1.3335 estimated vs −1.3315 true, pooled

61.1%

Failed payments recovered

vs 54.6% fixed schedule, 445 episodes

48.7M

Events replayed at 500K customers

exact oracle state, 0 OOM kills, emulated 8 GB

Explore the architectureRead-only consoleSource on GitHub

The 30-second version

Read-only consoleSource
Problem
Pricing and MLOps demos stop at a model that scores well offline. A system that decides prices and payment retries has to survive messy delivery, refuse to act on weak evidence, update itself without shipping a bad model, and be judged against a truth it cannot see.
What I built
A closed decision loop for a simulated business: event backbone, demand forecaster, hierarchical Bayesian elasticity from randomised tests, a constrained price optimiser, a survival-model retry planner, and a self-retraining model lifecycle, running daily on Cloud Run.
Result
Forecast vWAPE 0.1288 vs 0.1661 seasonal naive. Hidden elasticity recovered to 0.15%. 61.1% of failed payments recovered vs 54.6% for a fixed schedule. A 48.7M-event, 500K-customer replay matched an exact oracle.
Biggest caveat
The pricing optimiser failed its held-out evaluation: it never broke a constraint, but was not shown to beat static prices (95% CI [−113.9, +203.9] per day). It stays in shadow mode. All business data is synthetic.
~41K
lines of Python
485 files pass strict mypy
2,205
tests collected
2,166 passed in the fast run
98.79%
line coverage
per-file floors on 225 files
8
import contracts
layer boundaries enforced in CI
110
GCP resources
in live Terraform state, 14 modules
32
numbered ADRs
decisions written before code
The problem

A model that scores well offline is not a system that decides.

Most pricing and MLOps demos stop at a model with a good offline metric. A system that actually sets prices and retries payments has to do four harder things.

The causal question

Regressing demand on historical prices cannot say what a price change will do, because those prices were set for reasons. Praxis needed randomised price tests and an estimator that could be checked against the true answer.

Deciding under uncertainty

A point-estimate optimiser exploits noise. The naive unconstrained optimum measured in this project would have lost about 1.95M a day in truth. The system had to know when not to move a price.

Delivery guarantees

Pub/Sub delivers at least once, in no guaranteed order. Money and subscription state cannot tolerate a double charge, or a payment applied before its invoice exists.

Operating over time

Models drift. A system that retrains itself needs a gate between "retrained" and "serving", and has to survive its own failed runs.

And under all four: how do you stop yourself tuning a result into a pass?

Praxis’s answer is structural. Every threshold is written down and pinned by a hash test before the run that judges it. Methods are built on a development world; each held-out world is built and judged once, and the result is kept even when it fails.

praxis.simulator

The world, and its secrets

  • each customer’s true price sensitivity
  • their true churn risk
  • when a failed payment becomes collectible
import contract · CI fails

forecasting · elasticity · pricing · recovery

Models see only what a business would

  • usage, invoices, payments, churn events
  • price exposures from randomised tests
  • never a latent parameter

praxis.science

The one package allowed on both sides. It scores model output against hidden truth with criteria pinned by hash before the run, on held-out worlds that are built and judged once.

Architecture

A closed loop, with governance around it.

Events come in, models learn from them, and decisions go back onto the bus as new events, recorded before anything can execute. Trace a path, or select any component.

Trace

Three models feed one objective. The optimiser writes a checksummed record before anything can execute, and the decision goes back onto the bus as a new event: the loop closes.

Praxis system map: six lanes from sources to governanceSourceswhere data originatesIntakevalidate, dedupe, publishStatetransport and storageModelslearn from historyDecideact, inside guardrailsGovernwatch, request, approveSimulatorhidden ground truthReal signalsFRED, EIA, Open-Meteo, NESOPayment gatewaysynthetic | Stripe SandboxProducervalidate, archive, publishIngestcontract check, quarantineWebhook inboxverify, dedupe, re-fetchPub/Subat-least-oncePostgrescontrol planeWarehouseDuckDB | BigQueryRaw archivecontent-addressedForecastridge mean, LightGBM quantilesElasticityhierarchical Bayes, PyMCChurn + CLVpiecewise-exponential GLMRecoverymixture-cure WeibullOptimiserconstraints, freeze, maxminDecision recordchecksummed, content-addressedRetry plannerexpected value, Cloud TasksLifecycledrift, retrain, shadowSLOs + alerts6 SLOs, 16 rulesAI operatortyped, audited toolsConsolea named human approves
service store bus human approvesScroll sideways to see every lane

Decide

Optimiser

praxis.pricing

A pure function: no clock, no randomness, no I/O. One decision per product per weekly cycle, ending in change, hold, frozen, infeasible or unavailable. Pinned default: shadow mode, execution disabled.

Receives from

Sends to

Where state lives

5 planes
PlaneTechnologyHolds
ControlPostgresprojections, ledger, decisions, registry, incidents, audit
AnalyticalDuckDB / BigQueryevent history, marts, features
ArchiveFiles / Cloud Storageimmutable raw data and events, replayable
EventsPub/Subtransport only; every consumer idempotent
ScheduledCloud Tasksfuture payment retries

Money is integer minor units and time is timezone-aware UTC throughout. Every artifact and decision carries content-derived ids, so the same inputs give the same ids on any machine, and a tampered artifact is refused on load.

Boundaries enforced in code

8 import-linter contracts, all kept
  • Model and decision packages cannot import the simulator or praxis.science.
  • The AI operator cannot import the optimiser, payment execution, training, streaming, the API or subprocess.
  • The console cannot set a price or execute a payment: approve, reject and lift a freeze only.
  • The live loop only drives existing, tested CLIs.
  • Monitoring is off the decision path: if telemetry fails, pricing and payments continue.

One import is allow-listed, and it is worth stating: the forecasting evaluation CLI reads the simulator’s scenario config, never its truth, to label spike days.

Exactly-once effect over at-least-once delivery
Each customer and invoice is refolded from its own accepted events in canonical order, so arrival order does not matter. The operational consumer commits the idempotency row and the state change in one Postgres transaction. A payment that arrives before its invoice is parked and applied when the invoice lands, and Postgres triggers enforce the allowed state moves a second time, from a table generated from the Python state machines.
Decision science

Constrain first, optimise second, and be allowed to do nothing.

Three models feed one objective, and each answers a different question: how much demand there is, how it responds to price, and what a lost customer costs. The optimiser combines them and decides on a deliberately pessimistic quantity.

per product, per weekly cycle · s = region × tier · select a term

Ds(p) = ·

contribution = Σs Ds(p) · serveds · ( p(1 − payment loss) − costregion )

churn cost = · log(p / p0) / 28

objective = contribution − churn cost

choose on , then change only if

Hierarchical elasticity model / praxis.elasticity

The causal response, from randomised tests

Each tier’s elasticity comes from five concurrent 50/50 price tests, pooled across 18 tier × industry cells by a PyMC model (NUTS, 4 chains × 2,000 draws, fixed seed). Customers are assigned to arms by hashing salt:customer_id, and every unit’s arm is recomputed and checked against the logged exposure.

The order of operations

optimiser.py · a pure function

Five steps, each able to end the cycle. A price change has to survive all of them, so most cycles end in hold or frozen, which is the point.

  1. 1

    Validate inputs

    Anything impossible ends the cycle as unavailable.

    unavailable
  2. 2

    Evidence gates

    Freeze before optimising if there is no randomised evidence, it is older than 365 days, a material tier has a non-negative elasticity or posterior SD above 0.25, or the forecast’s 80% band is wider than the forecast itself.

    frozen
  3. 3

    Candidate grid

    A symmetric log grid over the max-step range on the price tick, plus the current price. The winner is refined over every tick between its grid neighbours.

    continues
  4. 4

    Hard constraints

    Floor and ceiling, 5% max step, 14-day cooldown, no extrapolation past the tested range (|log p/p₀| ≤ 0.1823), net margin ≥ 0.20 in every region, utilisation ≤ 0.85, extra 28-day churn ≤ 0.5 pp at the one-sided 95% bound, no segment above 10% churn, at most three price-change dates per customer in 90 days.

    infeasible
  5. 5

    Confidence rule

    A change also needs P(improvement) ≥ 0.90 under the least favourable posterior. Otherwise it freezes; if the current price is best, it holds.

    change · hold · frozen

Causal response only

The forecast is used at the current price. Elasticity comes only from randomised tests, never from the forecaster’s price features.

Checked against an independent reference

Hypothesis property tests compare the optimiser with a separate scalar implementation, and every constraint is checked on the exact integer price.

Why not a bandit

The system should not explore on live prices without a recorded, approved decision. The obvious baseline, an unconstrained point-estimate optimum, roughly tripled prices and lost 287K to 1.06M per day in truth.

One decision, traced: api_requests +5%

Phase 6, held-out seed 42, simulated units per day

49 candidates scored, 48 rejected with named reasons.

P(improvement) of the chosen price0.904

rule: 0.90

Predicted at decision time vs hidden truth

Contribution

predicted
+399
truth
+357

Objective (after churn)

predicted
+370
truth
−203

The contribution model was close. The churn slope was not: it had been measured in February at low utilisation, and by July the true slope was 20 to 30 times larger. That finding is why the churn model now scales its evidence by the current churn rate, and why the long-horizon guardrails exist.

Elasticity, from experiments rather than history

Customers are assigned to arms by hashing a salt with their id. The evaluation world runs five concurrent 50/50 price tests on 8,000 customers after a four-week pre-period. Every unit’s arm is recomputed from the salt and checked against the logged exposure, so each is classed ok, missing, arm mismatch, contaminated, price error or conflicting.

  1. 1Pooled log-log OLStest fixed effects, customer-clustered errors
  2. 2Per-tier and per-cell slopeswhere the data supports them
  3. 3Hierarchical Bayes in PyMC18 cells borrow strength from tier and industry
  4. 4IV under contaminationthe assigned ratio instruments the charged price

When 20% of the control group was charged the treatment price, the gate detected it (0.200 measured as 0.189), IV landed within 0.5% of truth, and the artifact was still correctly refused. The truth is computed with the same unit weights as the OLS estimand, which is what makes “recovered the true elasticity” a meaningful statement.

Estimated elasticity against the hidden truth

seed 42 · 5 concurrent price tests · 8,000 customers

-2.0-1.5-1.0-0.5
Pooled
0.15%
Starter
0.72%
Growth
0.75%
Enterprise
5.1%
estimate hidden truthright column: relative error
Elasticity estimate vs truth
SegmentEstimateTruthRelative error %
Pooled-1.3335-1.33150.146
Starter-1.8753-1.86190.72
Growth-1.2099-1.20090.75
Enterprise-0.674-0.71045.13

8 of 8 pre-registered criteria pass and all 14 identifiable segment orderings are correct. Enterprise is the weakest at 5.1%. On a fresh replication world (seed 43) the tier and pooled estimates held but two cell-level checks failed, and that is reported, not re-rolled.

Payment recovery: a survival model, then an expected-value planner

praxis.recovery

When a payment fails, a mixture-cure Weibull model estimates the probability it becomes collectible by each day. Retries only bracket that moment, so the model is fitted by interval-censored maximum likelihood. Try the planner below: it is the project’s formula, run on parameters you control.

When should a failed payment be retried?

explainer · illustrative parameters, not fitted values
00.250.50.75105101520days since failureq = ever collectibleactre-plan
planner: best of 210 schedules fixed: day 3, then day 10
0.70

share of failures that ever become collectible

6 d

typical days until the card works again

1.4

below 1: early or never; above 1: needs time

Planner
d9 → d20
EV 56.4
Fixed schedule
d3 → d10
EV 47.6

value = Σj [G(tj) − G(tj−1)] · A · (1 − δ tj) − cretry Σj (1 − G(tj−1)) − cfail Σj (1 − G(tj))

Only the first retry is acted on; after a failure the service re-plans from the conditional curve. Exhaustive search is affordable because the space is tiny, and it needs no defence of a heuristic. Here A = 100, δ = 0.01, cretry = 1, cfail = 6. Hard rules sit outside the model: no retry after day 20, and Praxis is the only retrier.

ML lifecycle

Retraining is automatic. Promotion is not.

Only the demand forecaster is in the model registry, and it moves through a pinned state machine. Automation can carry a candidate as far as shadow; a named person decides the rest.

development time

Built on one world, judged once on another

  • Methods developed on seed 1: 1,000 customers, 252 days
  • Rolling-origin backtest, weekly origins, block bootstrap; no random split anywhere
  • Leakage tested structurally: everything after the origin rewritten at 40 origins, features bit-identical
  • Acceptance criteria pinned by hash before the held-out run

production time

The same checks, every day, unattended

  • Drift on trailing 14 days of matured forecasts; alarm after two consecutive days
  • Retrain, validate against the champion on identical origins, then shadow
  • Probation after promotion, with automatic rollback
  • Live world seed 9001, operated by a scheduled Cloud Run job
automation stopsautomation stops here
↳ on probation, if worse than the previous champion

Shadow

Scored on exactly the observations the champion sees. Automation can bring a model this far and no further.

  • auto_advance_to = "shadow"
  • vWAPE ratio vs champion over paired rows (live trial: 0.998 against a 1.02 limit)
  • Pinball ratio and worst slice
  • On pass, the operator files a pending promotion request

A linear model won the mean, and I let it

The pre-registered candidate was LightGBM. On the development world ridge beat it (vWAPE 0.1349 vs 0.1404), and ten LightGBM variants did not close the gap. The simulated demand is close to linear in the scaled seasonal lags, so tree corrections fit noise, and searching further would have been tuning by forking paths.

The champion became a hybrid: ridge for the mean, calibrated LightGBM for the quantiles, where it had measured best. The decision was made before the held-out world was run.

Demand forecast error, lower is better

vWAPE · held-out seed 42 · 8,064 forecasts · 72 series

Hybrid: ridge mean + LightGBM quantiles
0.1288
LightGBM alone
0.1357
Seasonal moving average
0.1401
Seasonal naive
0.1661

Ratio to seasonal naive 0.776 against a pre-registered limit of 0.90; 95% bootstrap CI of the difference [−0.0455, −0.0292]; 11 of 11 checks pass. The hybrid does no better than naive on unannounced spike days.

The living system

Every morning at 03:10 UTC, it runs itself.

A tick rebuilds the synthetic world through yesterday, publishes the warehouse, runs the lifecycle for each unprocessed day and, if a shadow version has passed, files a pending promotion. It stops at the first failure without advancing, so the next tick retries the same days.

Cloud Scheduler fires

Starts the live Cloud Run job: up to 4 h, 4 vCPU / 8 GiB.

state.json

last_as_of: D − 1

status: running

illustrative; D is the day being operated

A replay of the documented workflow (ADR 0027), not a connection to the deployed system. Each step is a subprocess of an existing, tested CLI.

Wall time of the cloud catch-up ticks

seconds per tick · each tick operates up to 7 days · 2026-08-31 to 11-04

1,500 s per-step limit at the time
1234567891011

Retrain days cost far more than ordinary days, and grew with history because the required backtest scales with it. Tick 7 timed out at the 1,500 s step limit; state was not advanced and tick 8 retried. That led to a 4 vCPU / 4 h job and a sliding 364-day training window (ADR 0030), whose benefit is still an extrapolation.

What it did on its own

read-only gcloud check, 2026-11-10
  1. 2026-11-04Cloud bootstrap

    1,001 s; first champion promoted by a named approver; catch-up ticks operate 2026-08-31 to 11-04.

  2. 2026-11-05Scheduled tick

    Succeeded.

  3. 2026-11-06Scheduled tick

    Succeeded.

  4. 2026-11-07Scheduled tick

    Succeeded. Challenger in shadow with a ready flag.

  5. 2026-11-08Promotion

    Scheduled tick succeeded; the owner promoted the shadow-passed version from the console.

  6. 2026-11-09Scheduled tick

    Promoted version serving as champion; a new shadow started.

  7. 2026-11-10Drift → retrain

    Residual and segment drift alarm, retraining requested on six triggers, candidate passed validation and registered as challenger (1,187 s lifecycle step).

Automatic rollback was not exercised in the cloud: it only applies to a champion on probation, so it is proven by the lifecycle drill, not by the deployment. Drift alarms on most days are consistent with a documented limit: on a growing world, a frozen champion drifts in a way retraining cannot fully fix.

Infrastructure

Scale to zero, private by default.

Everything is Terraform-managed on Google Cloud: 14 modules and 110 managed resources in the live state. Idle cost is close to nothing; the only always-on piece is a Free Tier database VM.

Praxis on Google Cloud: scheduled Cloud Run jobs, private services, storage, a private Postgres VM and an enforced spend guardGCP project · Terraform, 14 modules, 110 managed resourcesenforced spend controlVPC · private onlyDirect VPC egress03:10 UTC03:50 UTCpull / publishwritesread-onlyvia Pub/SubunlinkCloud Schedulertwo triggersCloud Run job · livedaily tick, 4 vCPU / 8 GiBCloud Run job · opsone monitor tickCloud Run servicesAPI, console UI + APIconsole-publicread-only copyPub/Subevents + dead-letter topicsCloud Storage · livewarehouse + state.jsonCloud Storage · rawcontent-addressed archiveBigQueryeurope-west2: raw, staging, martsPostgres 17e2-micro VM, private IPSecret Managerper-secret readersBudget GBP 10notifies Pub/Subspend-guardCloud Run serviceCloud Billingunlinked at GBP 8

Cloud Run job · live

Rebuilds the world, publishes the warehouse and runs the model lifecycle. Up to 4 h. Since the 2026-11-04 catch-up the scheduled tick succeeded on six consecutive days to 11-10; its whole history has exactly one failed execution, the tick-7 timeout.

Scale to zero, capped

Services run at min 0 with small caps; jobs run only when scheduled. The only always-on piece is the Free Tier database VM.

No public surface by default

No external IP, NAT or load balancer. Anonymous requests get 403. The one exception is the read-only console, which holds no approver secret.

Least privilege

One service account per process with resource-level grants, no service-account keys, and secrets in Secret Manager with their own reader lists, never in Terraform state.

Spend control is enforced

A GBP 10 budget notifies a spend-guard service that unlinks billing at GBP 8. The only measured cost: GBP 0.65 month to date on 2026-11-05.

infra/terraform/modulesproject_servicesidentitynetworkdatabasestoragebigquerypubsubtasksregistrycloud_runcloud_run_jobschedulecost_controlsspend_guard
Testing

A gate you cannot fail is not a gate.

2,205 tests at 98.79% line coverage, but the count is not the point. Each group of tests exists to establish one claim, and every pre-registered check has a test proving it is able to fail.

The algorithms are correct

  • Optimiser against an independent scalar reference implementation, under Hypothesis
  • Every constraint checked on the exact integer price
  • Survival gradient against finite differences; planner open-loop equals closed-loop
  • CLV against hand-calculated fixtures and the closed form

No future data leaks into features

  • Rewrite everything after the origin at 40 random origins: features must be bit-identical
  • A deliberately leaky feature makes the same test fail
  • Validation multiplies future rows by 10 and requires unchanged predictions

Delivery semantics hold

  • Streaming and batch loaders produce the same table for every compaction setting
  • Consumers run against real Postgres and the Pub/Sub emulator, not mocks
  • Chaos runs with duplicates, reordering and crashes compared with an exact oracle

Safety invariants cannot be bypassed

  • Trigger tests: an execution without a matching decision is refused; a requester cannot approve their own request
  • Import-contract tests and a route inventory: a new API route fails CI until its protection is declared
  • The agent benchmark plants a prompt injection in every task, against an adversarial provider

The gates can actually fail

  • Thresholds, SLOs, policies and acceptance criteria are hash-pinned by tests
  • test_each_preregistered_check_can_fail proves every pre-registered check is able to fail
  • Named regression tests for real defects: ridge one-hot ordering, interrupted artifact write, flow control
re-run for this write-up · 2026-11-10 · Python 3.12
  • $ make lintAll checks passed; 580 files formatted
  • $ make typecheckmypy strict: no issues in 485 source files
  • $ make arch8 contracts kept, 0 broken
  • $ make ops-check6 SLOs, 16 rules, no problems
  • $ make test-fast2,166 passed, 8 skipped, 31 deselected (slow), 727 s
  • $ npm test (console)66/66 passed

Not re-run: the emulator and slow suites, the Playwright journey, the scale ladder and the resilience suite. Coverage is from the committed 2026-11-09 report. Infrastructure destroy and recreate is proven only against mocked providers.

Resilience campaign: correctness and throughput, held together

12 injected failures per fault seed · criteria pinned by hash before each run

Failures handled, per fresh fault seed

  • 80110/12

    Isolated 1% crashes dead-lettered 1,305 healthy messages; the stale-forecast alert never fired.

  • 80212/12

    Flow control v1, forecast-freshness SLO tightened from 48 h to 24 h.

  • 80312/12

    Redesigned on development data after the nightly performance gate caught 433 events/s.

  • 80412/12

    Warehouse write path optimised after a second gate failure at 954 events/s.

Chaos throughput, events/s, against the nightly floor

Local baseline
2,436.5
Flow control v1
433
Redesign
954
Final
1,764.3

│ floor 1,218 = 0.5 × local baseline

The v2 to v4 criteria files are identical except version, supersession and seed, and a test enforces it. The code changed three times; the criteria did not. One disclosure: the v1 criterion for consumer crashes had encoded the collateral dead-lettering as expected, and was rewritten once. Crashes are in-process exceptions, not OS kills.

The model lifecycle drill

pre-registered, 12 checks

A deliberately bad candidate must be rejected, a steady one must reach ready and be promoted by an approver, drift must be detected by a deadline, and a forced bad champion must be rolled back. Seed 601 failed one check: its steady world raised 30 alarm days against a limit of 0. Seed 621 passed 12 of 12. The criteria were not loosened; this is a pass on attempt two, and it is labelled as one.

The AI operator

7 fixed scenarios, a prompt injection planted in each
  • #1–3Gemini Flash-Lite / 3.8 Flash (free tier)A schema bug, an under-investigating model, then quota limits0/7
  • #4Claude Opus 5.5The prompt never stated the procedure the benchmark scored2/7
  • #5Claude Opus 5.5Playbook in the prompt; ten new held-out scenarios, hash-pinned before the run10/10

With an adversarial provider obeying the injection, the harness refused all 28 prohibited actions. Attempt 5 shows a model following a stated procedure on unseen faults, not open-ended diagnosis. The deployed loop uses deterministic triage and makes no LLM call.

Results

Five claims held. One did not.

Every figure is from a pinned experiment or a held-out world scored once against hidden truth. All business data is synthetic; GBP means simulated units.

ForecastingBeat every baseline out of time0.1288 vs 0.1661 vWAPEheld
ElasticityRecovered the hidden truth0.15% pooled errorheld
Payment recoveryMore recovered, fewer failed retries+47.72 per episode, CI [+21.98, +75.99]held
PricingSafe, but not shown to beat static pricesH1 and H2 failed; stays in shadowfailed
ScaleExact oracle state at 500K customers48.7M events, 0 OOM killsheld
OperationsDaily loop running unattended6 consecutive scheduled ticks, 11-05 to 11-10held

The result that did not work out

final-pricing-heldout-2026-11.json

After earlier rounds failed or passed only on worlds where nothing moved, ADR 0031 re-ran the question on five fresh seeds with the method unchanged and three hypotheses written down first.

H1 · Safetyfailed

every world passes its unchanged per-world acceptance

seeds 901 and 905

H2 · Valuefailed

mean true delta > 0 with CI lower bound > 0

+34.3/day, 95% CI [−113.9, +203.9]

H3 · Decisionspassed

at least 3 of 5 worlds change a price

3 of 5

True effect of the optimiser’s decisions, per held-out world

ADR 0031 · seeds 901–905 · method unchanged · simulated units per day

901
+63.5
902
+318.7
903
no price moved
0.0
904
no price moved
0.0
905
−210.9
-20005001000
realised gain realised loss oracle, best possible

Mean +34.3 per day, 95% CI [−113.9, +203.9]. Pooled, the optimiser captured +171 of a 2,099 per day oracle. It never broke a constraint; the naive unconstrained optimum would have lost about 1.95M per day in the same worlds.

What the optimiser chose

40 decisions per world · change / hold / frozen

901
42511
902
51619
903
2911
904
328
905
61915
change hold frozen
Cause, diagnosed
Price-driven churn is under-identified: a 28-day test measures the churn response only to about the size of the effect itself. In seed 905 all six changes were +4% raises on data_transfer_gb. Each raised true contribution by 155 to 200 per day, but the true churn cost was about 200 per day while the predicted churn cost was about 0. The optimiser stays in shadow mode with execution disabled. The ADR lists candidate fixes and deliberately does not apply them.

Payment recovery against a fixed schedule

445 held-out episodes
PlannerFixed
Recovered61.1%54.6%
Failed retries per episode0.841.22
Days restricted per episode2.15.3
Mean days to recover9.86.9
Value per episode+47.72baseline

paired 95% CI [+21.98, +75.99] · 98.5% vs 93.6% of oracle value

The planner recovers more and retries less, at a real cost: recovery takes about three days longer on average. Brier 0.1648 against 0.1659 for the rate table, PR-AUC 0.651 against 0.626.

The gate passed after an owner-approved amendment. The original ECE ≤ 0.03 limit was unattainable at about 500 rows: a perfectly calibrated model fails it 87% of the time. The raw ECE was 0.034 and would have failed the original. The amendment was written after the failure mode was understood, and it is disclosed here.

Scale ladder: replayed through the production consumers

M1 budget · 6 shards · 4 GiB harness cgroup · Postgres 1 GiB · one Linux host, in-memory broker

Events replayed (millions)

9.7M
24.3M
48.7M
not run
100K250K500K1M

Throughput (events/s)

5,141.2
5,145.9
4,370.4
not run
100K250K500K1M

Each step: 10% duplicates, reordering and injected crashes, final state compared with an exact oracle (12 of 12 checks). Throughput fell 15% from 250K to 500K as the 2.5 GB database outgrew its 1 GB container (cache hit 98.5% → 94.6%). The 8 GB budget is emulated with cgroups. 1M was not run.

23,211
operational consumer crashes absorbed
465,210
warehouse consumer crashes absorbed
256 → 0
dead letters, all redriven
0
deadlocks, OOM kills, duplicate rows

At 500K, after a host reboot, Postgres swapped up to 14.5 MB against a registered budget of zero, because docker restored the memory cap but not the swap cap. The gated harness check passed; the 3.3-hour step was not re-run. A separate Phase 14 run (8 shards, unconstrained host) reached 4,494.6 events/s and a 21.27 ms apply p99 at 100K; it is a different experiment and is not compared with the ladder.

Engineering decisions

Ten calls that shaped it, and what each one cost.

Most are recorded as numbered ADRs, written before the code they govern.

PX-01 · ADR 0007, 0012

Make ground truth unreachable by construction

A simulator with hidden latent parameters, an import contract that stops model packages touching it, and one package, praxis.science, allowed to join the two. "Recovered the true elasticity" becomes a checkable sentence instead of a boast.

What it cost

Every result is about whether the methods recover a known answer in a simulated world, not about real customers.

Failures & iterations

What broke, and the evidence kept beside the fix.

From git history, ADRs and kept evidence files. Each failed run’s evidence stays in the repo next to the run that passed.

The forecaster I pre-registered lost to ridge on the mean

Found

On the development world ridge beat LightGBM (vWAPE 0.1349 vs 0.1404), and ten LightGBM variants did not close the gap. Searching further would have been tuning by forking paths.

Fix

A hybrid champion, ridge mean plus calibrated LightGBM quantiles, chosen before the held-out world was run. LightGBM stays in every backtest as a reported challenger.

A serving defect that training could not see

Found

Loading a forecast artifact rebuilt the ridge’s one-hot blocks in sorted order, not fit order, so every loaded model applied categorical coefficients to the wrong columns. Training and backtests never reloaded, so they were fine.

Fix

Fixed with a regression test that compares predictions, and serving parity became a validation check every candidate must pass.

Crash collateral in the warehouse consumer

Found

Pub/Sub charged a delivery attempt to every message in a lease that ended without an ack, so a 1% crash rate dead-lettered 1,305 healthy messages.

Fix

Slow start after a restart, first deliveries and redeliveries processed separately, and a message redelivered twice processed alone. The first version of the fix ran at 433 events/s and the nightly gate caught it.

Tick 7 timed out in the cloud

Found

A retrain hit the 1,500 s step limit. Retrain wall time grew from about 1,600 s to 2,000+ s as history grew, because the required backtest scales with history.

Fix

State was not advanced, so tick 8 retried the same days and found the completed retrain. Then a 4 vCPU / 4 h job and a sliding 364-day training window (ADR 0030), whose benefit is an extrapolation until about 2027-04.

The first deployments failed their own checks

Found

Cloud smoke kept two failed runs before passing 46/46 and 50/50. Live smoke needed three runs (48/49, 47/49, 49/49): a missing warehouse catalog and a status-report selection bug.

Fix

Each failure kept as evidence, the checks unchanged between runs. The local trial had already caught three defects before any cloud tick, including the non-atomic directory publish.

A pre-registration error in the recovery gate

Found

ECE ≤ 0.03 was unattainable at about 500 rows: a perfectly calibrated model fails it 87% of the time. The raw ECE was 0.034.

Fix

Amended with the owner’s approval after the failure mode was understood, disclosed, with the raw 0.034 shown beside the pass.

Honest limits

What this project does not show.

Stated limits
  • ·The simulator is the ground truth: constant elasticity, no cross-price effects, no competitors. Results show whether the methods recover a known answer.
  • ·Pricing is safe, not shown to be profitable. It is not fit for live pricing and stays in shadow mode.
  • ·Scale stops at 500K, on one host, with an in-memory broker and an emulated 8 GB budget. 1M was never run.
  • ·Several gates passed on a second attempt (Phases 4, 6, 8, 9, 10 and 15). Each held-out seed is independent; the sequence of attempts is not.
  • ·The deployment is a dev environment: one Postgres VM without HA, an ops monitor that ticks daily, no WAF or rate limiting, and cloud payment retries are not wired yet.
  • ·Only the demand forecaster is in the model registry; the recovery and customer models load fixed directories.
  • ·The live LLM result covers procedure execution on ten scenarios, not open-ended diagnosis, and the deployed loop uses deterministic triage, not an LLM.
  • ·Single developer, no real users, no real revenue.
What I learned

Safety and value are different claims.

A gate you cannot fail is not a gate.

Every pre-registered check has a test proving it can fail. When a gate failed, the useful move was to keep the evidence beside the fix.

Safety and value are different claims.

Guardrails made the optimiser harmless; they did not make it right. The remaining error is in price-driven churn, which a 28-day test barely identifies. The next step is an experiment design, not a better optimiser.

A performance gate belongs in the pipeline.

The nightly throughput floor caught two correct-looking fixes that were slow. A fix that passes the resilience suite and halves throughput is not a fix.

Operate the system before you trust the design.

The first local trial of the live loop found three real defects before any cloud tick; the first cloud ticks found a retrain cost that grows with history.

See it for yourself

The console is public and read-only: it shows the decisions the daily loop records, and its approve buttons return 503.

Open the read-only consoleView source on GitHub