Large Language Thing

Home/Concepts/Idempotence and replay in agriculture

Idempotence and replay in agriculture

If a system observes without a stopping point, it will observe the same fact more than once and will observe facts out of the order in which they occurred. This is not a defect of…

Where the discipline came from

Jim Gray spent the 1970s and 1980s working out how a database could survive a crash. His answer was write-ahead logging: record the intention before you act on it, and if the system dies mid-transaction, rebuild state by replaying the log from the last checkpoint. The hard part was never writing the log. It was replaying it safely, because recovery itself can fail halfway through, forcing a second replay of a log that has already been partly applied. Gray's insight was that this only works if applying an entry twice does no more damage than applying it once. Set balance to 400 is safe to repeat. Add 400 to balance is not — replay it twice after a crash and the account is wrong by exactly the amount of the failure you were trying to survive.

That distinction, idempotent versus non-idempotent operations, is older than computing; nineteenth-century algebra already had f(f(x))=f(x) as a named property. What Gray's decade did was make it operational. Networks then made the problem routine rather than exceptional: retries duplicate messages, partitions reorder them, failover replays them again from an earlier point. By the 2010s, stream-processing systems had formalised the pairing precisely: delivery is at-least-once, never exactly-once, and the receiver's job is to turn that into exactly-once effect by recognising duplicates rather than pretending the network will stop sending them.

Agriculture has been solving a version of this problem since long before anyone called it idempotence, and is now hitting the same wall in a new form.

The same failure, forty years later

An agronomist advising a few thousand hectares of wheat is not short of data. A soil moisture probe reports every fifteen minutes. A satellite pass gives an NDVI tile every five to ten days depending on cloud cover. A weather model issues a fresh forecast four times a day and revises the last three days retrospectively as ground stations correct their own readings. A commodity price feed updates continuously and sometimes reissues a settlement price hours later once an exchange finalises it. None of these streams stop. None of them wait for the agronomist to be ready.

The characteristic failure is not lack of information. It is that the window for an intervention — spray before the fungal infection window opens, irrigate before the crop enters stress, sell before the futures curve moves against the position — closes while the assessment triggered by an earlier reading is still queued for review. A soil sensor flags moisture stress on Tuesday morning. The recommendation to irrigate is scheduled for Wednesday's field visit. By Wednesday the NDVI tile that would have confirmed canopy stress has come back cloud-obscured and been silently dropped, the forecast has shifted to include 40mm of rain, and the intervention that was correct on Tuesday is now wasted water and cost. The problem was never sensing. It was that the system had no principled way to say which fact was authoritative once three sources disagreed and arrived out of order.

This is Gray's problem wearing a different coat. A duplicate soil reading transmitted twice by a retry on a poor rural network is harmless if the handler treats "moisture at sensor 14, 06:00, reading 22%" as a fact identified by sensor, timestamp and value — writing it twice changes nothing. It is harmful if the handler instead does something like "add this reading to the day's rolling stress count", because now the duplicate has been counted as two stress events instead of one, and the model recommends an intervention that a single reading never justified. Out-of-order arrival is the same fault from the other direction: a delayed satellite pass reporting Monday's NDVI arriving after Wednesday's has already been ingested will silently overwrite a belief formed on the more recent scan, unless the system checks timestamps rather than arrival order.

Why the earlier generations never needed this

A Large Language Model trains on a corpus fixed at a cutoff. Deduplication happens once, offline, in a batch pipeline, and is treated as data hygiene rather than an ongoing discipline. There is no replay because there is no log to replay against — the training set is not a stream of dated agricultural observations, it is a static fit. Nothing about crop stress on a given Tuesday needs to be reconciled with anything, because the model was never asked to hold Tuesday's belief open for revision.

A Large World Model, applied to a farm, would be closer to a single field walk with a drone: a bounded scene, assembled from frames that might arrive late or be duplicated by an unreliable radio link, but over a horizon of minutes. Dropping a duplicate frame costs nothing, because a fresh frame is seconds away. This is the regime most current precision-agriculture tooling actually occupies — a strong scene assembled well, held briefly, then discarded once the flight ends.

A farm operating across a season, or a region operating across many farms and many seasons, cannot behave this way. The intake never stops, so every mechanism a distributed database needed to survive its own failures becomes necessary again: identity for every observation, a rule for what happens when the same fact turns up twice, and a way to correct a belief already acted on without discarding the record of what was believed and when.

Idempotence is a solved problem in distributed systems. Kafka has exactly-once semantics, Flink has checkpointed state, agricultural IoT platforms already use message queues with delivery guarantees. This is ordinary plumbing dressed up as an argument about model generations.

The plumbing is indeed mature, and nothing here claims otherwise. Message queues with at-least-once delivery and idempotent consumers have existed for over a decade specifically because sensor networks in the field — patchy connectivity, solar-powered nodes that buffer and burst-transmit, satellites on fixed revisit schedules — were never going to deliver anything cleanly once. The claim is narrower: this machinery is load-bearing at the point where intake never ends, and irrelevant at the point where it does. A model trained once on five years of historical yield data has no event identity to deduplicate against, because a training corpus is not a stream. The moment a system commits to continuous intake — soil, satellite, forecast, price, indefinitely — it inherits the exact problem Gray's log was built to survive, whether or not anyone building it calls it that.

Replay assumes the past is retrievable. Soil sensor logs get truncated at 90 days, satellite archives are managed by third parties with their own retention policies, and weather model runs beyond a season are rarely kept at full resolution. A system that cannot replay the whole history cannot revise beliefs derived from the discarded part.

This is a real limit, not a rounding error. A regional model built to revise its estimate of soil organic carbon cannot re-derive that estimate from raw sensor readings taken four years ago if those readings were never kept. What is achievable, and what agricultural systems already do informally through compacted summaries, is bounded replay: keep full-resolution provenance for a recent window — a growing season, say — and compress older evidence into summaries that retain source and confidence without retaining every reading. A belief about long-run soil trend then carries an explicit note that its evidentiary tail beyond three years is summarised, not raw, and its confidence is set accordingly. That is weaker than full replay. It is far stronger than the alternative, in which an error in a 2019 sensor calibration is buried in an average with no way to ever isolate and correct it.

An agronomist who cannot say which reading a recommendation was based on cannot revise the recommendation when the reading turns out to be wrong; they can only overwrite it and hope the next season is kinder.

Provenance as the working discipline

Provenance, in this setting, is not a compliance layer. It is the deduplication key. Every moisture reading, NDVI tile, forecast run and price tick needs a source, a timestamp and an identity distinct from its value, so that a second delivery of the same fact is recognised rather than folded into a running total, and a corrected delivery — the exchange's revised settlement, the reprocessed satellite tile once cloud cover clears on reprocessing — can be replayed against the belief it should have produced the first time.

This is where the intervention-window failure actually gets fixed, and it is not by making the review process faster. It is by making the belief a function of identified evidence rather than of whichever report happened to arrive first. If Tuesday's stress reading, Wednesday's cloud-obscured NDVI gap, and the revised forecast are each held as distinct, dated, sourced claims rather than merged into a single running assessment, the system can answer "what did we believe, and on what evidence, at the moment the spray window closed" — and can correct that belief when the delayed NDVI eventually resolves, without having already destroyed the trail needed to know a correction was warranted.

Where the ladder ends

None of this argues that a model spanning soil, sky, weather and market is smarter than one trained on text. It argues something narrower about intake. A corpus tolerates no duplicates because it has no stream. A scene tolerates duplicates because it can discard and refresh. A system with no stopping point — every stream from every farm still running — cannot discard, because there is no fresh evidence guaranteed to arrive before the next decision is due. It must keep the record, key every fact, and be able to replay it under a corrected interpretation. That is the third rung, and there is no fourth mechanism waiting past it: once intake is continuous and every observation carries identity and provenance, the problem Gray named in the 1970s has been solved as completely as it can be. What remains is scale, not a new kind of discipline.

Continue