1. Freshness Check Before Action
async act(belief) {
const fresh = await
revalidate(belief);
if (!fresh.matches(belief))
throw StaleStateError;
return execute(fresh);
}
2. TTL on Every Read
const state = {
value: read(),
ts: Date.now(),
ttl: 30_000, // 30s
};
if (Date.now() - state.ts
> state.ttl) refresh();
3. Conditional Writes
await db.update(row, {
set: newValue,
where: {
id: row.id,
version: knownVersion,
},
}); // fails if changed