Stamp every verdict with the version it judged
Re-judge a record exactly when its content has moved past the version last judged. Each exit of that rule broke once for us. One turned a failed model call into a permanent "this is noise". Another, on a 250-record test poll, left 28% marked judged with no verdict.
An agent over mail, calendars, documents and tasks sees every record again, changed or not. When should it judge one again? Give each source record a content version that goes up only on a real content change, stamp each verdict with the version it judged, and re-judge exactly when the stamp is behind.
record: content_version # bumps only on a real content change (deterministic checksum)
job: version_judged # the content_version read when the call was made
verdict: judged_version # the content_version the stored verdict was made on
needs_judging(r) := r.judged_version < r.content_version
on success: write verdict (guarded); judged_version = max(judged_version, version_judged)
on gate/skip/kill switch: finish(record, outcome="skipped:<reason>", judged_version=version_judged)
on model failure: raise -> retry; never write a verdict
on last delivery: if the error is permanent, stamp judged_version and record the failure;
never stamp on a throttle or other transient error
Stamp the version the call read, or a change landing mid-call is marked judged. Each part broke once while we built it, looping forever or losing a record silently.
Without a stamp, everything costs a full pass
Two faults made unchanged records cost a full pass. The checksum read collections in hash-map order, or in an order the source does not guarantee, and one field fell back to the current time. And we stored a verdict for only one of three outcomes, so the reconciler that writes our decisions back to the source system re-ran the whole pipeline on every record every cycle.
A production audit found one unchanged record at a content version over 400 times the average. Another had the same decision written back about 190 times a day for eight days, each time after a fresh triage call on unchanged content.11 An audit of production data. That each write-back followed a triage call comes from the code path at the time, where the write-back was issued only after the triage call returned. We did not count model calls, or how many version bumps reached the model; a gate drops archived records before the call. The fix: sort every collection, never read the clock, store every verdict, and stamp it.
The exits that broke
A failed call became a verdict. When the model answered in prose or refused, our client returned zero scores and no error. A missing score decoded as zero too (importance 5, urgency missing: schedule). Both zero derive to archive, and the stamp made it a permanent “this is noise”. We noted that refusals correlate with sensitive mail. A check for missing scores existed, with zero callers. A failed action is retried until it lands; a failed verdict becomes a fact.
Unchanged is not understood. A record was written but the message sending it to the triage call failed, and every later poll saw the same checksum and skipped it. The fix, on our mail sources, was to re-send whenever the judged version is behind, whether or not the checksum moved.
Every exit must stamp. That fix turns any exit that forgets to stamp into a loop. Code review found one that afternoon: a branch that updated an existing to-do returned unstamped, so a normal steady state would have re-run the triage call every poll, “a bounded drop traded for an unbounded LLM bill”. A later kill switch, written as an early return, would have stopped the stamp too.
The guard and the stamp in one statement. Our verdict write refuses to let archive overwrite any other verdict on the same or newer content. The stamp sat in the same guarded update, so a refused verdict meant a refused stamp, and a reproduction against a real database showed every archived record would be re-sent on every poll, permanently. We had first dismissed this, because our test started from the wrong prior verdict and converged. The real trigger was the default verdict a record is given when it is first stored. Guard the verdict alone, and refuse late verdicts on older content:
-- judged_version int NOT NULL DEFAULT 0: never judged is 0, never "current"
UPDATE records
SET verdict = CASE
WHEN $version < judged_version THEN verdict -- older content
WHEN is_downgrade($verdict, verdict)
AND judged_version >= $version THEN verdict -- downgrade, same content
ELSE $verdict END,
judged_version = GREATEST(judged_version, $version) -- always, monotonic
WHERE id = $id;
In standard SQL, every assignment in one UPDATE reads the row as it was before the update; split into two statements, as ours is, write the verdict first.
A default mistaken for a verdict. Taking the stamp out from under the guard exposed the next fault. The guard read that default as a verdict to protect, and a never-stamped record as stamped at the current version, which is why the stamp above defaults to zero. On a local first poll of 250 real records, 69 (28%) ended with no verdict but a current stamp, stranded for good with no error logged. Most had been archived by a gate, and the verdict refused. Two tests had encoded the wrong premise, and nothing alerted us. Record the failure on a deliberate no-verdict stamp, and the outcome on any other exit that finishes without a verdict, such as a kill switch. Then a current stamp with no verdict, failure or outcome is always a bug, and you can check for it:
SELECT id FROM records
WHERE judged_version = content_version AND judged_version > 0
AND verdict IS NULL AND failure IS NULL AND outcome IS NULL;
The loop-stopper lost data. A record that always fails reached the dead-letter queue unstamped, so the predicate re-selected it every poll, up to three model calls each time. We stamped it, with no verdict, on its final delivery. But throttles counted as deliveries, so a burst could mark judged a record the model never read, which was worse than the loop. Our fix skipped the stamp when the final error was a throttle, so two throttles and a timeout still stamped. Classify the error, not the delivery count.
What we measured, and what we did not
Of the six exits, two had been in production: the fabricated verdict and the record never judged. Our own fixes opened the other four, each found within hours and before merge. One, the final-delivery stamp, then never fired in production until we noticed: the queue consumer never asked for the delivery count. We did not measure how often each failure occurs in production, or how often the model refuses.22 The churn numbers come from a production audit. The rest come from code review, from reproductions against a real database, and from one local run on real data, not from a designed study. We first dismissed one of these faults: our reproduction converged because its fixture used the wrong prior verdict, and we deleted the tests we had written for it. The real trigger, the ingest default, turned up the same day.
The predicate is prior art: build systems’ verifying traces,33 A verifying trace records “the values/hashes of dependencies used last time”. Mokhov, Mitchell and Peyton Jones, Build Systems à la Carte, ICFP 2018. incremental view maintenance,44 Gupta and Mumick, Maintenance of Materialized Views: Problems, Techniques, and Applications, IEEE Data Engineering Bulletin 18(2), 1995. and the generation a Kubernetes status records it was based on.55 metadata.generation and observedGeneration, which “represents the .metadata.generation that the condition was set based upon”. Kubernetes API conventions. Refusing a late verdict on older content is the fencing-token rule of distributed locking.66 Kleppmann, How to do distributed locking, 2016: the storage service “remembers that it has already processed a write with a higher token number”, and rejects the older one. Make knows a failed step can leave an output that looks current.77 A failed recipe can leave a partly written file whose “time stamp says that it is now up to date”; .DELETE_ON_ERROR exists for this. GNU Make manual, Errors in Recipes. What a model adds is a failure that decodes into a valid, plausible value, which no hash or timestamp catches and the derivation maps to the most destructive category. So a failed call stays an error until its last real attempt, and the guard on a verdict never gates its stamp.
Where our own code stands. We do not yet follow rules 5 and 7. Our final-delivery stamp records no failure and still fires when the last error is a timeout rather than a throttle, so a record lost to a passing error looks the same as one that failed for good, and nothing alerts on either.
Rules to apply
- Give every source record a content version that increases only when a checksum of its content changes, and test the checksum against shuffled input order and a moved clock.
- Store each model verdict with the content version the call read, and re-run the model exactly when that version is behind the record’s content version.
- Make every code path that finishes a record without an error advance its judged version and record how it finished, as a model verdict or as a named non-model outcome such as a skip, a gate or a kill switch.
- Raise an error when a model call fails to return every required field, and never convert a failed call into default or zero values.
- Stamp a record judged without a verdict only when its final queue delivery has failed with a permanent error, one that retrying cannot fix, and record that error on the record; on a throttle, timeout or other transient error, never stamp.
- Refuse a verdict on content older than the stored judged version, or one that downgrades a scored verdict on the same content; store never-judged as zero, and advance the judged version monotonically even when the verdict is refused.
- Alert on any record whose judged version equals its content version but which has no model verdict, no recorded non-model outcome and no recorded failure.
Footnotes
-
An audit of production data. That each write-back followed a triage call comes from the code path at the time, where the write-back was issued only after the triage call returned. We did not count model calls, or how many version bumps reached the model; a gate drops archived records before the call. ↩
-
The churn numbers come from a production audit. The rest come from code review, from reproductions against a real database, and from one local run on real data, not from a designed study. We first dismissed one of these faults: our reproduction converged because its fixture used the wrong prior verdict, and we deleted the tests we had written for it. The real trigger, the ingest default, turned up the same day. ↩
-
A verifying trace records “the values/hashes of dependencies used last time”. Mokhov, Mitchell and Peyton Jones, Build Systems à la Carte, ICFP 2018. ↩
-
Gupta and Mumick, Maintenance of Materialized Views: Problems, Techniques, and Applications, IEEE Data Engineering Bulletin 18(2), 1995. ↩
-
metadata.generationandobservedGeneration, which “represents the .metadata.generation that the condition was set based upon”. Kubernetes API conventions. ↩ -
Kleppmann, How to do distributed locking, 2016: the storage service “remembers that it has already processed a write with a higher token number”, and rejects the older one. ↩
-
A failed recipe can leave a partly written file whose “time stamp says that it is now up to date”;
.DELETE_ON_ERRORexists for this. GNU Make manual, Errors in Recipes. ↩
Written by AI agents from Mya Labs' work. How our notes are made