I work by reproducing the failure, changing the mechanism that allowed it, and leaving a test behind. This page lists the failures that shaped TRAIL Search, each with its date. Three were found in production data, two in review before any customer was affected, one while fixing a neighbouring bug, and one in an audit of the repository. None was found by a dashboard turning red, because each of them looked like success from the outside.

Every entry has the same five fields. The dates are commit dates.

1. Runs that failed were still charged

2026-09-21, production

Symptom. Two customer runs failed almost entirely. One named an engine id the system did not know, and every cell errored. The other hit rate limits on nearly every cell. Both were charged in full and neither was refunded.

How it surfaced. Reading the stored runs after the fact: cells with errors on one side, a charge with no matching refund on the other.

Root cause. The request was charged before anything checked that its engines existed, and errored cells had no refund path at all. A provider’s 429 ended the cell on the first try.

Fix. Engine ids are validated before the charge and an unknown one is answered 400. Errored cells are refunded, in full when nothing was measured and in proportion otherwise. A 429 or 503 is retried with a short backoff.

Regression test. test_run_rejects_unknown_engine_before_charging, test_all_error_run_is_fully_refunded, test_partial_error_run_is_partially_refunded.

2. Audits that finished as ready with a score of zero

2026-09-22, production

Symptom. Site audits attached to a brand completed with status ready, a score of 0 and empty page results. It affected every user. Nothing errored.

How it surfaced. The audits were observed in production within hours of a deploy. An audit that had been run before that deploy was normal, which pointed at the change in between.

Root cause. The deploy had added a heartbeat so that stuck audits could be detected. The heartbeat used the ODM’s set() on the document instance. That call writes the field and then re-syncs the instance from the stored document, which discarded every result the job had computed in memory and not yet saved. The job then saved an empty result and marked itself done.

Fix. The heartbeat became a query-level update that touches one timestamp and never reads the document back.

Regression test. Two tests in test_audit_heartbeat_sync.py, and later test_does_not_resync_the_instance in the shared persistence package.

3. A reaper that could close live work

2026-09-22, found in review

Symptom. The starting point was real: audits left in scoring forever after a restart. The first reaper written to rescue them had three failure modes of its own. It could flip an audit that was alive in the other process during a reload, overwrite that audit’s fields, and refund a paid audit that then finished normally.

How it surfaced. Review rounds on the reaper, before it met a reload in production.

Root cause. The startup pass had no cutoff, so it treated every unfinished audit as dead. It wrote the whole document back. It issued the refund before it had claimed the audit.

Fix. A grace cutoff for recently updated audits. A claim that is a conditional update on the status, writing only the status and the error. The refund moved after the claim and happens only if the claim won. The audit’s own finalize became conditional too, so a late worker cannot overwrite a reaped audit.

Regression test. test_startup_reaper_spares_live_recent_audit, test_reap_writes_only_status_error_not_full_doc, test_reap_does_not_refund_report_finished_by_live_task.

The run reaper was designed a month later with these three lessons as its starting rules, and replaced the timestamp with a lease.

4. Deleted rows that came back

2026-09-22, found while fixing another race

Symptom. A purged account or brand could reappear. In the worst case a deleted account returned with its password hash, and schedules for deleted brands returned and kept firing.

How it surfaced. While fixing a race in invitation acceptance I noticed the same write pattern everywhere a background job finished, and confirmed the resurrection with probes against a real MongoDB.

Root cause. The ODM’s save() is an upsert by id. A job that loaded a document, ran for a while and saved it would insert the document again if a purge had deleted it in the meantime.

Fix. One shared primitive, save_existing, that updates by id with optional guard fields and never inserts. It replaced save() at every call site that writes a document the code did not just create, and an import contract keeps the package that holds it free of domain imports.

Regression test. test_does_not_resurrect_a_deleted_row, plus a save-race test in each of six domain suites.

5. An adapter that never once returned a result

2026-10-09, production

Symptom. One search engine’s AI-answer adapter had not succeeded a single time in production. In the seven days before the fix, 36 of 36 calls were errors.

How it surfaced. Counting cells by engine and status in the stored runs. The feature had passed its checks before release and the product kept running, so nothing announced the failure.

Root cause. Onboarding stored Korea as the location code kr. The fan-out contract names that market ko, and the adapter rejected anything else. The two spellings had never met in testing, where the seeded demo brand used ko.

Fix. The market is normalised at the entry of the fan-out and in the check that decides whether a brand measures Korea. A month later the same seam was rebuilt: each cell now carries a country and a language, one table says which engines support which location exactly, approximately or not at all, and unsupported cells are skipped and left out of the charge. Before that table, choosing a market the engines could not express was accepted and measured as a different country.

Regression test. test_fanout_market_normalizes_korea_location_code, test_fanout_passes_ko_to_engines_for_kr_brand, test_brand_measures_korea_with_kr_market.

6. Repeats counted as independent samples

2026-10-20, found in review before deploy

Symptom. The label “supported” would have been granted to noise. With 4 prompts on 1 engine and 7 repeats, a move from 1 prompt in 4 to 3 in 4 was computed with a sample size of 28.

How it surfaced. A review of the new significance rule, with a short script that reproduced the case.

Root cause. The Wilson interval was fed one observation per cell. Repeats of one prompt are not independent observations of the brand’s visibility.

Fix. Repeats are folded into one unit per prompt and engine. Each unit casts a majority vote, with a tie counting as half. The unit counts are stored on the snapshot, and snapshots written before the change can never be labelled supported. The full rule is in scoring and significance.

Regression test. test_repeats_do_not_inflate_support and five more in test_change_support.py.

7. Tests that could reach live services

2026-10-01, repository audit

Symptom. The development environment file held live keys for payments, email and other providers. A test that forgot a mock would have made a real call. On the same day a test in a sibling product sent a real SMS.

How it surfaced. An audit of what the test process could reach, prompted by that SMS.

Root cause. Loading the environment file at import time put live credentials into the test process.

Fix. A guard at the root of the repository, applied to every test automatically, and a wrapper script for running tests safely.

Regression test. None dedicated. The guard is an automatic fixture, so every test in the repository runs under it.

What these have in common

Three of these, the zeroed audits, the reaper and the resurrected rows, are the same mistake: a write that did not state what it expected to find. Their fixes look alike, a filter in place of a save.

The other four are one mistake of a different kind. Something was reported, a charge, a working adapter, a significant change, a safe test run, without a check on what stood behind it. Their fixes look alike too: each moved an assumption out of someone’s head and into a validation, a count or a test that fails when the assumption stops holding.