Trace a dairy alarm to its lots, pallets and customers
Dairy Digital Twin: better records, not better models.
Do you like cheese? Personally, I love it. I live in France, where there are more than a thousand different kinds of it.
One pack of cheese
The ministry of agriculture counts about 1,200 kinds, and says the French eat 26 kg of cheese per person a year [1]. I do my share.
But here is a question I could not answer until recently. Do you know how many kilometres a cheese travels before it reaches you? And how many stops it makes on the way?
I am not a dairy person. I am an engineer, and I build AI agents for a living. So to find out, I built a dairy. More exactly, a digital twin of one: a fictional plant on the real map of Denmark, with 103 packing days of synthetic records. Then I followed one lot of sliced cheese through it, from the farms to the customers.
- 12farmsone night
- 7tanker rounds522 km
- 1silo
- 3vatsthe next day
- 6weeks of ripening
- 1lot32,760 packs
- 30pallets
- 4trucks351 km for three
- 4customersfour kinds
About 870 km on the model's routes before the customers' doors, the importer's leg not counted.
That lot is 32,760 packs. Its milk came from 12 farms in one September night, by 7 tanker rounds. It became cheese in three vats, ripened for six weeks, and left on 30 pallets in four trucks, for four kinds of customer. On the model's routes that is nine steps and about 870 km before the customers' doors, the importer's leg not counted.
Now turn the pack over. The lot code fits under your thumb. It does not say which farms filled the tanker, which machine cut the block, or where the trimmings went.
So here is the question that started this project. Suppose something is wrong with that cheese. How do we find where the problem came from: a farm, the tanker, a machine in the dairy? And which other packs went the same way?
If the dairy cannot retrace the journey, it has only one safe answer left: recall everything it made in the same period. That costs a lot. So the twin joins the plant's records, a fixed rule proposes the list of lots, AI agents read the evidence, and a person signs. But first, a real case.
Sixty-one days
In the summer of 2025, here in France, a family dairy had to answer those questions for real. A routine test found a bacterium, Listeria monocytogenes, in one of its soft cheeses. The dates in the drawing are public [2][3][4][5].
By 13 August the public health agency counted 21 patients in France, two of whom had died, with "a possible link" to the cheeses [2]. Four more cases were reported abroad [6]. The Paris prosecutor was investigating; the last public reports I found mention no charge [5]. On 1 August, documents showed positive surface samples from 2024; nothing public links them to the patients [5]. The first two notices, in June, named one lot each. The last one, sixty-one days after the first positive result, was drawn by a date: everything made before 23 June. I do not know how this dairy traced its product, and I am not claiming that any system would have changed these sixty-one days.
Not only France
France is not a special case, and cheese is not a special food. The map shows thirteen incidents since 2008, in ten countries [14]. Several have the same shape: a first narrow recall, then a much wider one. In Denmark in 2014, one lot of deli meat was withdrawn in May and every product of the company in August [8].
Recorded illness is rare: of the 666 public alert records I read for milk products from 2020 to 2025, 20 record an illness and most leave that field empty [7].
The records exist, but the decision cannot reach them
Why does a recall grow like that? For Listeria, what ties one lot to another is shared equipment. Pasteurisation kills the bacterium, but contamination can return afterwards, from a slicer or a conveyor, and Danish official guidance says a business may then have to withdraw every lot made on that machine between two cleanings [9]. A faster search does not shrink that scope. Only written evidence does, and a dairy keeps it, but not in one place:
- The cleaning sheet of each machine: which clean, which steps, who signed. In my model plant it is paper.
- The swab results. Listeria swabs are taken during production, because a swab straight after cleaning is no guarantee [10]. The answer comes a day or two later for a rapid screen, four to seven days for the reference method [11], as a report or an e-mail.
- The offcut sheet: which trimmings of a slicer went into which grated lot. Paper again.
So the evidence for a clean arrives days after the clean, in another system. Now picture the person who must decide a scope at three in the afternoon. The answer they need is spread over a binder, a mailbox and a laboratory portal.
And some records are never written at all: in one history of my model plant, 55 of 206 grated lots have no offcut sheet. That share is my assumption, not a measured rate.
The digital twin
So this is what I am building: a digital twin of the dairy. The pictures are its real screens. The dairy is fictional, and every date, lot, sample and machine code on them is invented.
The plant on the map, and in 3D. The twin shows the dairy twice: on the real map, with its farms, its tanker rounds and its customers, and in 3D, from the reception bays to the loading dock. Every figure on the screen is read from the records as they stood at the time on the twin's clock. Where there is no record, the screen says so. When I move the clock, the tankers, the vats, the pallets and the trucks change with it.
One lot, and everything behind it. Remember the pack from the beginning? In the twin it belongs to a lot of 32,760 packs, sliced on a Sunday morning. I did not pick it by chance: two days later, the laboratory's result for a swab of its slicer came back positive. When I click that lot, the page opens its card: where it ran, when, and what the rule says of it, here "affected". Under that word come the records behind it.
Map: OpenFreeMap © OpenMapTiles Data from OpenStreetMap.
A fixed rule. The plant's records are joined in one tracking model, and a rule proposes the list. It is written in the plant's own procedure documents, and fixed code applies it. The scope starts at the machine's last verified deep clean. Offcuts carry the problem to the grater. Each lot gets a state, with a reason a person can read: affected when the records tie it to the problem, uncertain when they cannot clear it, as with a missing offcut sheet.
A record is never corrected in place: a correction is a new row, and every row keeps when the thing happened and when it was written down. So I can replay an alarm exactly as the dairy knew it at that hour. And a signature is tied to a hash of the lots in each state, a short fingerprint of the list: if one lot changes state, the signature no longer holds.
This is the rule's answer at the minute the laboratory's result arrives.
Look at the last card. The swab was taken on Sunday morning and its result came on Tuesday afternoon, and the slicer went on running in between. By the alarm, 347 pallets of the lots in scope had already left, and 34 were still in the cold store.
Six agents, and a supervisor. One agent reads the laboratory's e-mail and proposes which sample it is about. One audits the evidence behind the list. One proposes likely causes. Two write the drafts: the notices, and the instructions for each customer. The sixth answers questions about the case. They call a language model in Microsoft Foundry, and they have reading tools only: none can change the list. Why not let a model choose the lots? I admit that was my first idea. I dropped it because the list a person signs must be the same every time for the same records: on one case, the same agent gave 3, 5 and 6 findings in three runs.
The supervisor follows the written recall procedure and starts the agents in its order. No model decides that order. It keeps an agent's statement only if every identifier, date, time and figure of two digits or more appears in a reading that the statement cites, and it shows how many it dropped. That proves the quotation, not the reasoning. And four things wait for a named person: confirming what the laboratory's mail says, the first notice to the authority, the signature of the scope, and each kind of action that follows, notices included. The drawing shows who acts and what waits.
How I built it. I work alone, so I built the twin with AI coding agents: one session for each part, and a lead session that plans, briefs and checks. Its history holds 307 commits in thirteen days. The research ran beside the code: the French case read at its sources, 666 alert records, thirteen incidents across Europe, and how a dairy samples, tests and cleans. Each source went into a register and each claim into a ledger, more than 500 sources and about 1,000 claims by now.
It did not go straight. My first version was a simulator: I had written the alarm and its answer myself, so it could only show what I already knew. I started again from the records, so that nothing about an alarm exists before the laboratory's result arrives. My first plant had ten farms where the milk I had invented needs about seventy; it now has 66. And when I tested the rule on 50 invented histories with a hidden truth, it missed no contaminated lot after a machine swab, but after a positive pack it was too narrow, and the auditing agent named none of the lots the rule had left outside the scope. The method and the results are in the technical appendix.
The target architecture
A real plant keeps its records in its own systems. So here is the architecture the twin is built for, on Microsoft Fabric, Microsoft's data platform, and Microsoft Foundry, its service for models and agents. There are two drawings: first the data, then the decisions.
Every system into one base. Read the first drawing from the top. The dairy's systems are of four families: supply, production, quality and logistics. Some are databases, some send signals, and some are paper: a slicer is cleaned by hand, so its cleaning sheet is the record. A database is mirrored, or copied on a schedule; a scanned sheet is read by a tool that proposes its fields; machines send their events as a stream [15]. I hesitated between mirroring and streaming. I would start with mirroring and scheduled copies: the laboratory needs days for its answer, so a minute of lag changes no scope.
The history keeper. This is the part I would build first. A mirror shows a table as it is now and keeps only a short history [15]. So each change is captured into tables where rows are only added, each with the time it was recorded. That is what lets every read be "as known at a time". And what is read from a scan or from free text can add lots, never remove them, until a person confirms it.
From a laboratory result to signed actions. Follow the numbers of the second drawing. A rule on each laboratory result starts the supervisor (1), which asks the trace engine for the list (2). The trace engine is the rule of the twin, run as a service: still the only part that decides which lots are on the list. At once (3), the listed stock still in the dairy is held, automatically and reversibly, and the first notice to the food authority is drafted for a named sign-off. The six agents read through their tools and give opinions and drafts (4). The quality manager signs a version of the scope, which is the assumptions, the snapshot of the data, the version of the rule and the lots together, in Microsoft Teams, under their own sign-in (5). Where a Teams card cannot ask for a fresh sign-in, the signature stays on the twin's page. Then a recall case is opened with a child case per customer (6), notices go to the customers and to their own agents (7), and each signed version is written once to storage that cannot be changed (9). Identity, governance and monitoring run across all of it (8).
A supervisor agent on a workflow. The supervisor is an agent built as a workflow, with Microsoft Agent Framework [15]. The workflow is the fixed part: it takes the order of the steps from the written procedure, and at a gate it stops until the named person has decided. Its gates are code: no notice to a customer without a signed scope, and one approval for each kind of action. No agent decides the order, an approval or the list. The hold inside the dairy is the only action that waits for nobody. No message leaves the dairy without a person's decision.
If the language model fails, the list does not: the rule, the hold, the signature and the approvals need no model. The technical appendix, section H, lists each building block with the trap I noted.
What it is worth
I count four things: lots, money, the confidence of customers and, above all, people. Take the alarm you saw on the twin's screens. There are three ways to draw its scope.
Lots. A dairy that cannot retrace the journey has the first row: 60 lots. With the records joined, the rule lists 24, each with its reason. For the other 36, no record ties them to this slicer. The smallest scope is not the goal, though: the scope by line is smaller still, and it leaves out 12 grated lots, eight that the records tie to this slicer and four that they cannot clear.
Money. A scope by date covers 1,462,660 packs, the rule's scope 417,140. The difference is 1,045,520 packs. I do not know what a pack in a recall costs a dairy, so I assume EUR 2: the cheese itself and, once it has left, the transport back and the destruction. That makes about EUR 2.1 million for this one alarm. The price is my assumption and the alarm is synthetic: this is a potential, not a saving I measured. For comparison, for the infant formula recall of January 2026, one maker booked an estimated CHF 75 million of sales returns and CHF 110 million of stock written off [13].
The confidence of customers. A retailer must know which of its pallets to block, and why. In this alarm 379,280 packs had already left for nine customers, and the twin lists for each of them the lots and pallets it received. In New Zealand in 2013, one customer received 17 different totals of affected product during 16 days of tracing [12]. A customer cannot act on a list that keeps moving.
People. This is the one that matters most, and the one a simulation cannot count. Every day a contaminated lot stays on a shelf, someone can eat it. In my tests on synthetic histories, when a machine swab raised the alarm, the list was ready within seconds of the laboratory's result and it missed none of the contaminated lots. If the notices leave the same day, fewer people can eat those packs: fewer fall ill, and fewer die. That is a mechanism, not a measurement, and the twin does nothing for the days before the alarm. It is still the reason to build it.
What to do next
If you run a food plant, here are five questions from an engineer. None needs new technology. No food-safety professional has reviewed this article yet, so take the answers to your own quality team.
- For each machine that touches product after pasteurisation, which last clean can you prove with a signed sheet and negative Listeria swabs, and how many lots have run since?
- On a Friday evening, who takes the laboratory's call, and does that person see the machine's cleaning sheets and last swabs the same evening?
- Of ten lots made with offcuts or rework last month, for how many does a record written that day name the lots they came from?
- Starting from one pack, how long does it take to list every lot that shared a machine, a brine or a rework bin with it, and every customer's pallets?
- Which lots leave your dock before their results are back, and which later result would make you widen the scope?
Then run your next mock withdrawal twice on the same evidence: once the usual way, once with the records joined and a fixed rule. Compare the lots missed first, then the time to a signed scope, then the lots listed without need.
If you are an architect, I think this is not only about food. Wherever a person must sign a list that a system prepared, eight lines are worth copying:
- Name the one output a person signs.
- Write its rule from the written procedure, with a reason for every item.
- Put two clocks on every row: when it happened, and when it was recorded.
- Store decisions; calculate answers.
- Give the agents reading tools only.
- Check every quotation of an agent against the readings it cites, and show how many you dropped.
- Keep the steps as data, each with a named role, and tie the signature to a hash of the list.
- Test with a hidden truth, and count the misses first.
The digital twin shows the twin and the target architecture its architecture, and the technical appendix has two contracts you can reuse.
I started with a pack of cheese and a question about kilometres. The kilometres turned out to be the easy part. The hard part sits in binders, mailboxes and offcut sheets. A better model does not give a quality manager a scope she can defend. Better records do, whichever way the scope moves.
I still love cheese.
References
The method behind the numbers, the results of my tests and the limits are in the technical appendix.
- Ministère de l'Agriculture et de la Souveraineté alimentaire, "Infographie: production et consommation de lait et produits laitiers", March 2026. https://agriculture.gouv.fr/infographie-production-et-consommation-de-lait-et-produits-laitiers
- Santé publique France, "Cas de listériose en lien possible avec la consommation de fromages au lait pasteurisé", 13 August 2025. https://www.santepubliquefrance.fr/les-actualites/cas-de-listeriose-en-lien-possible-avec-la-consommation-de-fromages-au-lait-pasteurise-produit-par
- French government and Santé publique France, joint press release, 12 August 2025. https://agriculture.gouv.fr/telecharger/150787
- RappelConso, recall notices 2025-06-0086 (13 June 2025), https://rappel.conso.gouv.fr/fiche-rappel/18504/interne , and 2025-06-0098 (16 June 2025), https://rappel.conso.gouv.fr/fiche-rappel/18516/interne ; and the notices of 9 to 12 August 2025.
- France 3 Nouvelle-Aquitaine, report of 24 September 2025 with the Paris prosecutor's chronology, https://france3-regions.franceinfo.fr/nouvelle-aquitaine/creuse/gueret/listeria-dans-des-fromages-ce-que-l-on-sait-de-l-enquete-du-parquet-de-paris-concernant-l-entreprise-chavegrand-en-creuse-3222476.html ; and franceinfo, the company's statement, 24 September 2025, https://www.franceinfo.fr/sante/alimentation/fromages-rappeles-pour-soupcon-de-listeria-a-aucun-stade-il-n-y-a-eu-de-volonte-de-dissimulation-assure-la-fromagerie-chavegrand_7511689.html
- ECDC, Communicable Disease Threats Report, week 33, 2025. https://www.ecdc.europa.eu/sites/default/files/documents/communicable-disease-threats-report-week-33-2025.pdf
- European Commission, RASFF Window, public notifications for milk and milk products, 2020 to 2025; the author's own count, with its method in the appendix.
- Statens Serum Institut, "Udbrud af listeria i Danmark i 2013-14". https://www.ssi.dk/sygdomme-beredskab-og-forskning/sygdomsudbrud/arkiv/listeriaudbrud ; Kvistholm Jensen and others, Clinical Infectious Diseases 63(1), 2016. https://doi.org/10.1093/cid/ciw192
- Fødevarestyrelsen, guidance on the withdrawal of food, VEJ nr 9078 of 10 February 2021. https://www.retsinformation.dk/api/pdf/220942
- EU Reference Laboratory for Listeria monocytogenes, Technical Guidance Document, version 4, 3 October 2023, page 8. https://zenodo.org/records/8406616
- On detection times: Applied and Environmental Microbiology, 2021, https://pmc.ncbi.nlm.nih.gov/articles/PMC8612253/ ; Pathogens, 2024, https://pmc.ncbi.nlm.nih.gov/articles/PMC10892580/
- Government Inquiry into the Whey Protein Concentrate Contamination Incident, New Zealand, November 2014. https://www.dia.govt.nz/vwluResources/Government-Whey-Inquiry-Report-November-2014/$file/Government-Whey-Inquiry-Report-November-2014.PDF
- Nestlé, full-year results 2025, press release of 19 February 2026. https://www.nestle.com/sites/default/files/2026-02/full-year-results-press-release-2025-en.pdf
- The thirteen incidents of the map: the reports of the authorities and public auditors, listed with their addresses in the technical appendix, section G.
- Microsoft Learn, Microsoft's product documentation, read on 30 November 2026. Mirroring: https://learn.microsoft.com/fabric/mirroring/overview ; its change data feed: https://learn.microsoft.com/fabric/mirroring/extended-capabilities-delta-change-data-feed ; copy job: https://learn.microsoft.com/fabric/data-factory/what-is-copy-job ; event streams: https://learn.microsoft.com/fabric/real-time-intelligence/event-streams/overview ; scanned sheets: https://learn.microsoft.com/azure/ai-services/content-understanding/overview ; reading a table as it was earlier: https://learn.microsoft.com/fabric/data-engineering/delta-lake-time-travel ; Microsoft Agent Framework: https://learn.microsoft.com/agent-framework/overview/ ; workflows as agents: https://learn.microsoft.com/agent-framework/workflows/as-agents ; checkpoints: https://learn.microsoft.com/agent-framework/workflows/checkpoints ; waiting for a person: https://learn.microsoft.com/agent-framework/workflows/human-in-the-loop ; hosted agents: https://learn.microsoft.com/azure/foundry/agents/concepts/hosted-agents ; an agent's tools: https://learn.microsoft.com/azure/foundry/agents/how-to/tools/model-context-protocol . The two drawings mark what this documentation called a preview on that day. Check each capability when you build.