<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Invariants on Brian Faust</title><link>https://vacua.dev/tags/invariants/</link><description>Recent content in Invariants on Brian Faust</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Mon, 01 Jan 0001 00:00:00 +0000</lastBuildDate><atom:link href="https://vacua.dev/tags/invariants/rss.xml" rel="self" type="application/rss+xml"/><item><title>Invalid State Should Be Difficult to Construct</title><link>https://vacua.dev/thoughts/invalid-state-should-be-difficult-to-construct/</link><pubDate>Sat, 01 Feb 2020 00:00:00 +0000</pubDate><guid>https://vacua.dev/thoughts/invalid-state-should-be-difficult-to-construct/</guid><description>&lt;p&gt;A wallet reservation held one amount while a booking was in progress. When the
booking later reached the billing system, an imported record could contain no
price. The reservation knew how much money had been held, but not how that
amount divided into net price and VAT.&lt;/p&gt;
&lt;p&gt;There was no authoritative way to create the final sale from the hold alone.
Inferring a tax rate would turn a guess into accounting data.&lt;/p&gt;</description></item><item><title>Let the Database Reject Impossible State</title><link>https://vacua.dev/thoughts/let-the-database-reject-impossible-state/</link><pubDate>Sun, 01 Jan 2017 00:00:00 +0000</pubDate><guid>https://vacua.dev/thoughts/let-the-database-reject-impossible-state/</guid><description>&lt;p&gt;Two workers asked the same reasonable question: does this owner already have an
active record? Both received the same honest answer: no.&lt;/p&gt;
&lt;p&gt;Each worker created one.&lt;/p&gt;
&lt;p&gt;Nothing in either request was obviously careless. The application checked
first. The insert happened inside a transaction. Tests which ran one request at
a time stayed green. The defect lived in the interval between the check and the
write, where both transactions were allowed to be correct about a state which
had already become stale.&lt;/p&gt;</description></item></channel></rss>