<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jess Trochet on Medium]]></title>
        <description><![CDATA[Stories by Jess Trochet on Medium]]></description>
        <link>https://medium.com/@transgingerjess?source=rss-44663d5275a4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*l8lvzr4g5-G9Be_hS7_aPA.jpeg</url>
            <title>Stories by Jess Trochet on Medium</title>
            <link>https://medium.com/@transgingerjess?source=rss-44663d5275a4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 14:30:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@transgingerjess/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[You Could Have Prevented This Happening To You If You Weren’t Such A Bad Person]]></title>
            <link>https://medium.com/@transgingerjess/you-could-have-prevented-this-happening-to-you-if-you-werent-such-a-bad-person-0709f760300d?source=rss-44663d5275a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/0709f760300d</guid>
            <dc:creator><![CDATA[Jess Trochet]]></dc:creator>
            <pubDate>Sun, 11 Jan 2026 03:56:46 GMT</pubDate>
            <atom:updated>2026-01-11T04:02:43.588Z</atom:updated>
            <content:encoded><![CDATA[<p>Lately I’ve been thinking about data breaches.</p><p>The classic case is a credit reporting agency like Equifax, Experian, or Transunion (or one of their partners) accidentally leaving a CSV full of names, addresses, and social security numbers on an S3 bucket set to be publicly-readable.</p><p>After it happens (read: after someone in the press finds out it happened), there’s much upcry and wringing of hands and outcry among various actors about how this latest breach leaves everyone in the public so vulnerable to fraud, identity theft, fake credit lines being opened, and so on.</p><p>What very few people say is this: that the way we verify people is fundamentally fucked. You need a recent address, a phone number, and a Social Security number? Give me a name, and I can get those inside a couple hours (an hour and a half of that will be for a Bitcoin transaction to settle).</p><p>What very few people say is this: that given such a fundamentally broken system, it should be the responsibility of banks, of credit agencies, of landlords, of employers, to avoid being the victims of fraud. Someone’s got my Social Security number? I don’t care. Bank of America should care. Capital One should care. Why? Because someone who can impersonate me to them can steal a lot of money. Not from me: from those banks.</p><p>But that’s not how the dialogue goes. There’s a breach, everyone’s impacted, here’s 12 months of credit monitoring. Better watch out; don’t let someone <em>steal your identity</em>. Oh, and remember to cancel before you get charged for the second year. There’s a breach, everyone’s impacted, oops, the company is bankrupt, so no credit monitoring this time. Better freeze your credit (and hope nobody figures out the oh-so-secret information it takes to unfreeze it). Don’t want to get caught with your pants down.</p><p>And what I realized yesterday was that it’s not just “identity theft” we’ve done this to.</p><p>Oh, he had a gun? Did you cringe correctly? Did you perform obeisance to the man in a mask? Did you fuck only and always the right gender? Did you hide against the wall on the correct side of the classroom? Did you never get divorced? Did you correctly remember the steps from your “Run, Hide, Fight” training? Did you keep the idea of “pronouns” out of your mouth and away from your Instagram profile? Did you wait for the proper all-clear from law enforcement? Did you correctly avoid being a “fucking bitch”?</p><p>No? Well. That’s on you, then.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0709f760300d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Essential Complexity]]></title>
            <link>https://medium.com/@transgingerjess/essential-complexity-95727086aeda?source=rss-44663d5275a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/95727086aeda</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[geometry]]></category>
            <category><![CDATA[maps]]></category>
            <category><![CDATA[complexity]]></category>
            <dc:creator><![CDATA[Jess Trochet]]></dc:creator>
            <pubDate>Mon, 15 Sep 2025 19:28:48 GMT</pubDate>
            <atom:updated>2025-09-15T19:28:48.275Z</atom:updated>
            <content:encoded><![CDATA[<p>I saw a graphic today that broke my brain a little bit. It was in the context of a silly Instagram post — you know the type, “which would you choose?” In this case, the choice was the world sliced up into eight apparently equally-sized pieces, with the question “where would you eat food from?” It looked like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*gbHyWeiO-ypyxmSZFjSeGQ.png" /></figure><p>Setting aside how to answer that question, what stuck in my head was wondering: what are the land areas covered by these segments? Are they equal in surface area, the way they appear to be in the picture? We know that different projections of the (not-quite) spherical Earth have different distortions in play; how do those affect this image.</p><p>Well. That took me down a rabbit hole.</p><p>Taken simply, a rectangular view of the Earth is a projection. There are many different projections, but the simplest possible projection is one where you wrap a cylinder around the Earth (so that it’s wrapped around the equator, with an open top and bottom), project the different features of the Earth onto that cylinder, choose a vertical line to cut the cylinder, and then flatten the cylinder onto a surface.</p><p>When we think about the resulting rectangular projection of the (not-quite-but-close-enough) spherical earth, there are a couple important attributes to note.</p><p>First, all the points at the top and bottom edges of the rectangle map to the original north and south poles. So lines that strike the top and bottom edges at different points actually all reach the north and south poles, with no distance between them. Second, the left and right edges of the rectangular projection (where we made our cut) both correspond to 180º of longitude — either east or west; it doesn’t matter.</p><p>So with those notes, what do we know?</p><ul><li>Lines A, B, and H all meet at the North Pole</li><li>Lines D, E, and F all meet at the South Pole</li><li>Lines B and H meet at the North Pole at the 180º antimeridian</li><li>Lines C and G meet on the equator at the 180º antimeridian</li><li>Lines D and F meet at the South Pole at the 180º antimeridian</li></ul><p>Let’s take a look at what that actually looks like in practice. Instead of looking at one projection of the sphere, let’s look at it from different angles, not trying to warp it to fit all the information into one rectangle. Remember, any viewpoint of a sphere looks like a circle.</p><p>From the front, it looks very familiar. You have the A and E lines reaching the north and south poles, C and G heading east and west, and B, D, F, H heading along the diagonals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*WyJmnIquEJq9ymHIR0rPMg.png" /></figure><p>It’s the right side view that starts to get weird. We can’t really see the A or E lines from this view, because they’re on the very far-left edge of the circle. We have the C line continuing straight along the equator, but the B and D lines do something very odd:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*91eJeXbmcbw0BNQNe6YO4Q.png" /></figure><p>Remember how the entire top line of our rectangular projection maps back to the North Pole? Here’s where that comes into play. The B and D lines that seemed to be going straight at first end up curving around towards the poles, such that by the time they reach 180º longitude (the right side of this circular view of the sphere), they’ve also reached the poles.</p><p>You can see that even more clearly from the polar view. The two sections bounded by lines H, A, and B don’t really reach back into the opposite side of the origin much at all. Instead, they wrap around and meet at the pole, closing in those sections. In comparison, the sections bounded on the outside by lines G and C around the equator continue all the way around, until the meet on the back of the planet (the red dotted line, corresponding to where we sliced our cylindrical projection, and the right/left edges of the map):</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*jYa7PXaxOpqONkAZPepFwg.png" /></figure><p>To close it out, here’s the back view of the sphere. You can see how, on the backside, the segments that cover the top and bottom edges of the map reach up to the poles, and how the segments that cover the left and right edges of the map cover almost the entire back half of the sphere, reaching the 180º antimeridian:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*iTyT8N7KIJX2PWVHP-43JA.png" /></figure><p>So what’s the lesson? Straightforwardly, it’s hard to use a flat map of a spherical object and have the things that are true on that map hold true in the real world. Slashing a map into eight equal segments doesn’t mean those segments will be truly equal on a globe.</p><p>But on a higher level, that inaccuracy is because a flat map discards some of the essential complexity of the spherical world in order in favor of the perceived simplicity of a flat surface.</p><p>In software, we make tradeoffs between complexity and simplicity all the time. And just as a flat map can’t be used to accurately convey surface area, an abstraction that hides some parameters of an algorithm prevents exploring some areas of that algorithm’s problem space.</p><p>We need to be continually conscious of what complexities are reasonable to abstract away or hide, and what complexities are essential to the problem space. And when we do choose to hide complexity in the search of a more user-friendly solution, we need to be sure we’re doing it in a way that won’t surprise us later.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95727086aeda" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating Trust]]></title>
            <link>https://medium.com/@transgingerjess/migrating-trust-8ffd2c73fd1a?source=rss-44663d5275a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ffd2c73fd1a</guid>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[trust]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[authorization]]></category>
            <dc:creator><![CDATA[Jess Trochet]]></dc:creator>
            <pubDate>Wed, 13 Aug 2025 16:08:45 GMT</pubDate>
            <atom:updated>2025-08-13T16:08:45.068Z</atom:updated>
            <content:encoded><![CDATA[<p>I had a new grad reach out recently asking for advice on how to pursue a cybersecurity career. One of the questions they asked was how I go about pursuing trust handoffs in high-assurance systems. The truth is, it’s not that different from any other migration between load-bearing systems. It isn’t sufficient to switch from one piece of software to another: we need the new system to have the trust of the organization in the same way the old one did.</p><p>You start with an existing system in place. Let’s call it Old Busted. Old Busted, to some extent, works. If it didn’t work, we’d just shut it off and introduce New Hotness with no migration required. We can’t take Old Busted’s existing workability for granted, either: its correctness in the context where it exists is hard won, and likely the result of a lot of hard work over time. And no matter how much your team hates maintaining Old Busted, a lot of other teams likely rely on it every day; some even love it!</p><p>We need to be honest with ourselves and the rest of the organization about whether we’re pursuing a migration away from Old Busted for the right reasons. If we’re saying “Old Busted is unscalable; we need New Hotness to handle the load,” we need evidence. How do we actually know that getting New Hotness up and running will be less toil than adjusting Old Busted to handle this scale? If we say “Old Busted is insecure at an architectural level and can’t be fixed,” then we need to do our due diligence. How are we validating that New Hotness doesn’t have its own similar architectural failings?</p><p>Anyway, there’s a lot of work to do before we even start talking about the nuts and bolts of a migration. This work is useful though; it helps us ensure that we understand where we want to be, and how this change will help get us there. There’ll be some migrations we just don’t do as a result of this step, and that’s also good and useful! It means that we weren’t actually going to get the win we thought we were going to, and we saved a lot of time and effort!</p><p>But suppose that we’ve decided we really do need to fully replace Old Busted, and that New Hotness is the correct replacement. I start by looking at the overall shape of New Hotness. How does it integrate? What data does it need in order to be a 1:1 swap-in? For an authorization primitive, what are its enforcement and decision points?</p><p>My first engineering step, is <em>not</em> to wire New Hotness in, though. Having built a sense of what New Hotness will look like in my context, I look into refactoring Old Busted to fit the new scheme. Is there data that isn’t feeding into it? Are there places where New Hotness will be applied that Old Busted just doesn’t exist? If I can mold Old Busted to be <em>shaped</em> like New Hotness, I can hold onto Old Busted’s earned trust for longer.</p><p>At this point, I’ve basically created an interface that Old Busted slots into, but which I can also slot New Hotness into. So I get to work with New Hotness for the first time, building the shims to slot it into the same place as Old Busted. I don’t swap them out, though; not for authorization code, at least. I <em>still</em> don’t want to give up the earned trust Old Busted has. So I run them both, with New Hotness running in an observable but not enforcing mode.</p><p>The next part is what makes the migration as seamless as possible. I run the two pieces of software, side-by-side, comparing and observing their outputs. Old Busted is still enforcing policy, so I haven’t yet lost anything from a trust perspective. Instead, I’m gathering information that lets me be confident that, configured with the same policy, New Hotness and Old Busted <em>agree</em> about what the policy decision should be.</p><p>There’ll likely be some differences. Some of those differences are attributable to different defaults in configuration; we can change those. Some of those differences are desirable in the long term; New Hotness is capable of enforcing a policy that Old Busted can’t. But for right now, we want to do as close to a 1:1 swap as possible, and that means reconciling those discrepancies. We need to understand them, and where possible, resolve them. For those that are irreconcilable, we can at least suppress observation of the difference for specific cases.</p><p>Our goal is having a null delta over the enforcement decisions Old Busted and New Hotness want to make. That indicates that, ideally, nothing unexpected will happen when we make the swap, with no interruption to the existing workflows that Old Busted has historically enabled. Our job is to minimize the drama; to make the moment of the swap appear easy, because we did all the work ahead of time.</p><p>Once I’m reasonably certain that there are no unexplained deltas (you can never be 100%, but you can get close enough to use your personal judgement and discretion as an engineer to make a call), I can turn on enforcement for New Hotness. Typically I would do this using a feature flag or similar feature that can be toggled on and off without an intermediate deploy. Although we’re confident that the policies agree, there are potential side effects to adding this new enforcement layer, and we want to be able to back up quickly.</p><p>Beginning weeks or months ahead of time, I’ll be messaging to the organization that a migration is in process, and I’ll ramp up that messaging ahead of this dual-enforcement period. I want people who are experiencing unexpected failures of their typical use cases to come straight to me. And I’ll have configured New Hotness to enforce loudly and obnoxiously, giving people a link to complain to me. Because I don’t <em>expect</em> people to experience policy enforcement at this point only from New Hotness (they should be getting blocked by Old Busted first), an enforcement action by New Hotness should be treated as atypical and a symptom of a faulty migration, not as indicative of a missing piece of access.</p><p>Again, I need to make a judgement call about when I believe that I have good signal that New Hotness and Old Busted are operating on par. And, as before, I still don’t have complete information. Up until this point, Old Busted has been running consistently, which means I haven’t risked any loss of <em>integrity</em> or <em>confidentiality</em>; just loss of availability. And there are likely systems out there that still rely on the unique side effects of Old Busted. But we have to keep moving forward; a <em>perfect</em> migration is impossible, but we can implement a <em>flexible</em> one.</p><p>The next step is to turn off Old Busted. Again, this is done using a feature flag that can be turned back on quickly. We make New Hotness enforcement less obnoxious and more in line with the existing prompts to request/renew access. We make big announcements throughout this process so that system owners who relied on side effects of Old Busted can correlate new failure modes with our rollout timeline and reach out to us. As system owners reach out, we err on the side of switching Old Busted back on so that we can observe and replicate its side effects in New Hotness.</p><p>This particular part of the process can take a while due to the expected back-and-forth of the rollout. However, we’ll reach a point where we’re stable with Old Busted off and New Hotness on for longer and longer periods, and that’s the point where we need to make our final judgement call: we declare a timeline for shutting down Old Busted permanently.</p><p>If we don’t reach that point, and our feedback cycle doesn’t appear to be lengthening in time, it’s time to consider the sunk cost fallacy: in such a case, it’s likely that Old Busted has so many different side effects, relied on so broadly, that we failed in our initial step of evaluating whether it can be replaced. In that case, we should reevaluate in our new context, and decide if, rather than migrating to New Hotness, we should put in the work to turn Old Busted into Old Hotness.</p><p>Notably, a successful migration is lacking in dramatic moments. My ideal migration is one where I’ve done enough work ahead of time that it proceeds smoothly, with a series of incremental tweaks, until we finally arrive at an inevitable conclusion. Migrations don’t succeed when they have visible acts of heroism; they succeed when they invisibly transfer the earned trust of one system to a different one.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ffd2c73fd1a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why I Love Relational Databases]]></title>
            <link>https://medium.com/@transgingerjess/why-i-love-relational-databases-1eec84de2fcd?source=rss-44663d5275a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/1eec84de2fcd</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Jess Trochet]]></dc:creator>
            <pubDate>Thu, 31 Jul 2025 03:39:28 GMT</pubDate>
            <atom:updated>2025-07-31T03:51:50.902Z</atom:updated>
            <content:encoded><![CDATA[<p>Software engineers believe that there is value in understanding how to make a decision. We unlock value when we understand a decision-making process clearly enough to describe it precisely, enabling a computer to replicate it.</p><p>I write software that makes decisions about whether a particular person should be allowed to do a particular thing. There is value in making that process predictable and reducing the amount of human toil that goes into making similar decisions over and over. There is value in having a consistent amount of rigor and safety in those decisions.</p><p>To make decisions, we have to understand what we’re making decisions about. A lot of the time, we’re actually responsible for creating the information that feeds into the decision. We’re not only responsible for answering the question correctly; we’re responsible for defining what the precise question even is.</p><p>Once we define the exact question, we store information in a structured way, enabling us to efficiently answer that question (and others like it) repeatedly. We define the shape of the information that will be fed into our question-answering machine, and store it in a database.</p><p>The beauty of relational databases is that we can phrase huge parts of our question using the database itself, and those parts of the question will get the advantage of being optimized according to whole categories of specialized learning that you and I don’t need to know much about. Our decision-making engine gets to take advantage of the decision-making engines created by the database creators.</p><p>And it’s a virtuous cycle: if we design our tables properly, we’re effectively telling the database how to make those decisions even better. If we know that a particular value is always unique, we can tell the database that, and it’ll not only prevent us from making the mistake of duplicating it, it’ll help optimize the way records are stored and retrieved.</p><p>I won’t pretend that SQL is easy to learn. The multitude of ORMs out there proves that. And an ORM is a good place for a newcomer to start. But I believe ORMs paper over the fundamental, essential complexities of what we need to do. They hide the cost of interacting with a database by making it incredibly low-effort to get whatever data we want, instead of the exact data we need. An ORM has no issues with making fifteen queries to get fifteen pieces of data, and in some cases you might not even notice until you start hurting for performance.</p><p>An ORM says that you shouldn’t need to learn about or think in a new language. I disagree. I think learning and using SQL is worthwhile; it is a language that is created with the explicit aim of allowing the database to retrieve exactly the data you want as efficiently as possible, under the constraints you’ve provided. Thinking in that language will make your software better.</p><p>And you don’t even need to write SQL in plain text to do it; query builders like SQLAlchemy’s core sublibrary polish off the rough edges that exist among different backends and help avoid fatal flaws like SQL injection. Migration libraries like alembic can help avoid the many pitfalls of manually managing changes to your tables. These are abstractions that <em>embrace</em> the necessary complexity of SQL, instead of trying to hide it.</p><p>I see my database as a trusted, if sometimes frustratingly fastidious, partner: if I structure my data correctly, and am willing to think a bit harder about my query, instead of about what my algorithm looks like in Python or Go or Rust, I can vastly simplify the code I actually need to write in those languages. I can trust the database to efficiently handle the details, allowing me to focus on the decisions only I can articulate.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1eec84de2fcd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Loud Audiences]]></title>
            <link>https://medium.com/@transgingerjess/loud-audiences-ba0e6d364693?source=rss-44663d5275a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba0e6d364693</guid>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[access-control]]></category>
            <category><![CDATA[access-control-systems]]></category>
            <category><![CDATA[identity-management]]></category>
            <dc:creator><![CDATA[Jess Trochet]]></dc:creator>
            <pubDate>Fri, 20 Jun 2025 00:17:56 GMT</pubDate>
            <atom:updated>2025-06-20T00:17:56.928Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve been working in identity and access management, or IAM, for years now. There are two primary questions that IAM professionals build systems to answer: who is it that’s making a request, and are they allowed to do what they’re trying to?</p><p>The first question drives the practice of authentication. It’s the job of authentication primitives to ensure that one unambiguous answer to that question exists in any given context, and that answers are meaningfully comparable across contexts.</p><p>The second question drives the practice of authorization, and is more relevant to what I’m writing about today. Authorization primitives observe the entire state of the world, including the output of an authentication primitive, and boil it down to “yes, allow this thing” and “no, don’t.”</p><p>In the context of a large organization, “the entire state of the world” gets really big really fast. So in most large organizations, there are one or two blessed sources of authorization truth. They’re called names like “Capability Manager” and “Access Gateway”, or sometimes more whimsical names like “Gatekeeper” and “Zanzibar”.</p><p>These systems take an opinionated view that’s generally applicable elsewhere. They have leaf nodes, representing available access patterns, and call them “groups” or “capabilities” or “roles”. People “file tickets” or “place requests” when they need to do something that they’re not “assigned to” or a “member of” yet.</p><p>Regardless, we end up with a situation where we have some set of tracked relationships between people and the things they want to do. Having accomplished this, the rest of the organization can consume those relationships and use them to make decisions about who’s allowed to do what.</p><p>At least, that’s the default assumption. If Alice is a member of Gobblers, then certainly that just means that Alice is allowed to gobble, right? And that should hold true anywhere, right?</p><p>The problem is that building this graph of relationships isn’t our IAM team’s only responsibility. We’re also responsible for making our authorization primitives more powerful over time, and we’re accountable for making sure that they’re the right shape to fit the needs of our organization. In other words, we must be able to change the primitives over time, and we must be able to effectively communicate about those changes with the rest of the organization.</p><p>So returning to our hypothetical, let’s say that Alice is a Gobbler. When the Gobblers role was created, there was probably a good sense of what its purpose was — what it meant to be a Gobbler. And at the moment of creation, the actual practical purpose of Gobblers matched that sense exactly. So if Alice became a Gobbler at that moment, it likely meant that someone had made a decision that Alice in particular needed to do those practical Gobbler things in line with that shared sense of what Gobblerness was.</p><p>But things change over time. Maybe most Gobblers also need to squawk, and squawking happens in a different service than gobbling does. And creating a new role is such a pain. So instead of making Squawkers, we’ll just have the new app look up all the Gobblers and let them Squawk. Problem solved!</p><p>But back on the IAM team, we have a problem. We no longer know what the true purpose of the Gobblers role is — is it to allow gobbling, or is it to provide all the access that all the original Gobblers might need? We no longer have a sense about what access it implies in practice — gobbling, certainly, and we might even be aware of squawking, but what about pecking? What about crowing?</p><p>As a result, there’s no longer a safe way for us to fulfill our responsibility to change our authorization primitives over time. If we don’t know who’s using what memberships for which purposes, we can’t effectively say “this access is dangerous; this one is not.” We can’t break Gobblers up to reduce its sensitivity — doing so might result in lost access in other systems we don’t know about.</p><p>And as much as this issue is true for Gobblers, it’s true for thousands of other roles (or groups, or capabilities) that are out there. This is what I call the “silent audience” issue: if we don’t know who is using what access, we have no ability to improve the environment.</p><p>So we make audiences explicit; we make them loud. We don’t just say that Alice is a Gobbler, we define Gobblers in the context of who needs to know about them: it becomes old-macdonald.Gobblers, and we prevent anyone who’s not Old Macdonald from using information about it by default.</p><p>In fact, we don’t even need to know exactly what Gobblers means anymore. We actively don’t care if it means Alice’s particular team of hens or if it means all those who gobble. Our commitment is to Old Macdonald, and all we commit is that Old Macdonald will be able to see that certain people have a certain relationship to old-macdonald.Gobblers, and that those people will be determined according to the policy that has been set.</p><p>This lifts a tremendous burden from an operating IAM team. We define a commitment, and we make the same commitment to every one of our audiences. We don’t need to track what the difference is between Gobblers and Squawkers and Peckers and all the different roles. We ensure that whenever we’re making a change, we’re able to preserve the commitment we made to each individual audience—which boils down to preserving exactly one commitment at a time.</p><p>Avoid the silent audience, and you’ll find many fewer squawks of distress when you make the changes you need to keep your birds flapping.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba0e6d364693" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Less Mildly Fucked System]]></title>
            <link>https://medium.com/@transgingerjess/a-less-mildly-fucked-system-87c6e08c434f?source=rss-44663d5275a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/87c6e08c434f</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[consistency]]></category>
            <dc:creator><![CDATA[Jess Trochet]]></dc:creator>
            <pubDate>Sat, 12 Aug 2023 18:30:26 GMT</pubDate>
            <atom:updated>2023-08-12T18:42:25.569Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://x86.wtf/time-clocks-and-the-ordering-of-events-in-a-mildly-fucked-system-21cf0f564571">Yesterday</a>, I wrote about how clocks are all around us, and how we can use these clocks to make sense of our universe, and the ordering of how events unfold around us. Judicious use of clocks lets us build systems that have predictable behavior. If we have a system that should only perform an action after another action happens in a peer system, then the best way to guarantee that ordering is to wait to perform our action until the other system sends us a message saying “I have performed the action you’re waiting on.”</p><p>As in the previous post, this is moderately unsatisfying. And although it’s relatively easy to reason about in a system with only two peers, it gets increasingly complex with even moderate scale.</p><p>Luckily, many of the primitives we take for granted these days — TCP connections, SQL databases, even HTTP requests — have this class of guarantee built into them, so we often don’t have to reason at the very lowest level. This is why connectioned, stateful protocols are so attractive and easy to use — even when they’re strongly client-server-oriented, they’re doing bidirectional work behind the scenes to ensure that the states on either end remain in lockstep.</p><p>If I write bytes to a blocking TCP socket, and the syscall returns to the next line of my application logic, then I can be confident that the server has received or will receive those bytes, and associate them with all the other bytes I sent. My state has proceeded from “write pending” to “connection established”; the peer’s state has proceeded from “connection established” to “read pending”.</p><p>If I place an HTTP request, and I receive a response code, then generally I can be confident that the server has accomplished the work it commits to do when it receives such a request. My state has proceeded from “request pending” to “response received”; the server’s state has proceeded from “request processing” to “request completed”.</p><p>All of these primitives build on top of each other in very careful ways. Lamport even came up with a specification language that could be used to describe how large-scale sound, ordered primitives can be built out of small-scale sound, ordered primitives. It’s called TLA+, and while most of us don’t actually use it in our day-to-day lives, it’s proved popular with anyone who needs to formally verify the behavior of a system.</p><p>TLA+ can be considered as an ahead-of-time type-checker for time. Sometimes an explicit runtime clock is necessary, but more frequently, it’s enough to specify that we’ll only perform a particular class of action in response to another particular class of action. This kind of abstract clock, where we describe the places we guarantee a <em>partial</em> ordering of events, lets the TLA+ compiler figure out all the different total orders which might result, and which might contradict other invariants we specify as requirements.</p><p>TLA+ and the lesser, but often sufficient, mental models we use in its place, are necessary because while we have tons of great primitives that let us skip thinking about ordering, we can easily use them in a way that violates their core assumptions, or compose them in a way that results in unordered behavior.</p><p>One example is the class of asynchronous-response HTTP APIs. In this type of API, a server responding to a request will initiate a process (often a long-running one) and immediately return to the client, requiring the client to periodically check up on the results of the process.</p><p>If keeping a connection open was costless, this pattern might not exist at all, but because networks aren’t perfect, with variable timeouts and connectivity failures that might affect a TCP connection’s stability, it’s sometimes safer to design for a case where the server’s expensive end response to a request is durable (stored in a database and queryable) rather than ephemeral (written to a TCP socket as it’s constructed and then discarded from memory).</p><p>If the client directly depends on the result of that process, then there’s a clear pattern to follow: having been provided an identifier for the pending process, and a place where it can check the status of that pending process, it will proceed to do so, likely with an interval configured according to the process’s likely duration. When a result (possibly an error!) finally becomes available, the client will retrieve it some short amount of time after that, and the client’s clock will implicitly become synchronized to “after” the server completes the process, whether successfully or not, as it would have been if the response had been provided inline.</p><p>However, if the client itself does <em>not</em> directly depend on the result of the process, it’s easy to make mistaken assumptions. It might initiate a process and not wait for it to complete, or not keep track of a way to identify the process. In that case, the client may never actually resynchronize itself with the server’s clock — it won’t be able to know that the server has reached the point where the process has been resolved.</p><p><em>This is not necessarily a bug.</em> If there’s no other feedback loop, and the client process is not particular concerned with either the server’s overall state or the success or failure of the process, placing a best-effort request and letting it ride might be perfectly acceptable. This is a pattern commonly used in webhooks — the initiator often has no responsibility beyond ensuring that the request was sent.</p><p>Often, the client and server clocks might even accidentally resynchronize after the fact. If a client sends a request to a server asking it to send personalized links to a batch of users, and then never polls to check if the process succeeded, then its sense of the server’s clock might still proceed if users begin clicking on the links sent as a result of that process — they could not have done so if the process had not happened yet, and so the fact that they <em>are</em> doing so makes our client’s clock comparable (and strictly later than) whatever the server’s clock was when those emails were sent. Whether the client uses that clock information or not is irrelevant.</p><p>A common case where ignoring the results of asynchronous processes but assuming synchronization can cause issues is one where the client is responsible for driving some sort of state in the server. Failing to track the status of in-flight processes can result in a state where the client assesses what changes might be necessary before all pending changes have landed.</p><p>Suppose I have a task that periodically runs every hour, checks if a transaction corresponding to my paycheck has come in (we’ll assume this part of the process is not subject to failure), and if so, submits an asynchronous request to my bank to transfer $5 to my savings account (I’ll get that LEGO Star Destroyer some day; I swear).</p><p>The background process can sometimes take several minutes to run, so to avoid running up my AWS Lambda tab, I decide to ignore the result of the asynchronous request. To avoid making the transfer multiple times, the logic also checks that the ledger does not already show the transfer that should be produced as a result of this asynchronous process.</p><p>Now. Under certain circumstances, this <em>may work fine</em>. The assumptions I’m making with this design that must be true are as follows:</p><ul><li>The bank’s background process in response to my transfer takes no longer than an hour to complete</li><li><strong>If the process takes longer than an hour</strong>, then it’s possible for another instance of my script to run and fail to observe the side effect produced by an earlier run; this would result in a duplicate transfer request being filed</li><li>The method by which I schedule my script must never run it more than once within a one hour period</li><li><strong>If my script runs again 45 minutes after the last run</strong>, then it’s possible for the bank’s background process to meet its one hour requirement, but for us to still create a duplicate transfer request due to the prior run’s side effect not being observable in my account</li><li>The transaction created in my account (the side effect of the bank’s background process) must take a form my script recognizes</li><li><strong>If the bank changes the way it records a transaction I request</strong>, or if I fail to consider some conditions that might affect the way my script perceives it, I will not see it as the resolution of my intended process, and a duplicate transaction will be created (possibly repeatedly).</li><li>The bank’s background process must not fail, whether due to an error on my part or an error on their part</li><li><strong>If the process fails, and no transaction is created</strong>, my script will repeatedly attempt the same process. In this case, the actual behavior is unpredictable. My account might be restricted or closed due to high-risk behavior. A bank technician might discover a large batch of failures under certain conditions, fix a bug on their end, and re-execute all transactions that were affected, resulting in a large number of duplicates.</li></ul><p>Note that all of these failure modes are related to a failure to resynchronize our clock with the bank server’s. Possibly we didn’t wait long enough to receive evidence that the server’s clock has progressed. Possibly we didn’t recognize the form the server’s clock “ticked” in. Or possibly the clock didn’t tick at all, and our script has no way of knowing that it should’ve.</p><p>If I have these failure modes in mind, and consider them sufficiently unlikely to warrant the possible risks they pose, then maybe that’s okay. But up until now, we’ve only been considering this script as an isolated system, and it may have an impact on others. For example, if I have a separate script that assumes my $5 transfer will succeed, and transfers $5 out of my savings account every month unconditionally, then a failure to make the transfer would result in my savings account being overdrawn. The sort of not-quite-defined and certainly-not-intended behavior described here can balloon outwards in extremely unpredictable ways.</p><p>What if I wanted to reduce the possibility of this kind of issue happening? I could build the earlier, naive solution we mentioned where I always poll until the process completes and accept the higher AWS bill. I’d still need to make sure that another instance of my script can’t accidentally run concurrently, since it wouldn’t have any idea the original instance is waiting for a process to complete.</p><p>Or I could save some state.</p><p>Databases are powerful tools for resolving issues of distributed ordering. In this case, we can use them to observe and make explicit the clock synchronization we need to happen when waiting on a process that’s happening in another system. We can use them to bind that system’s clock to our own clock and make decisions based on that binding.</p><p>Let’s start with a couple tables for our problem case:</p><pre>CREATE TABLE paychecks (<br>  paycheck_id INT AUTO_INCREMENT PRIMARY KEY,<br>  bank_paycheck_id TEXT UNIQUE NOT NULL,<br>)<br><br>CREATE TABLE transfer_requests (<br>  rq_id INT AUTO_INCREMENT PRIMARY KEY,<br>  paycheck_id INT REFERENCES paychecks.paycheck_id,<br>  status ENUM (<br>    &#39;reserved&#39;, &#39;submitted&#39;, &#39;failed&#39;, &#39;complete&#39;<br>  ) NOT NULL,<br>  bank_request_id INTEGER,<br>  last_updated DATETIME,<br>);</pre><p>We have one table to track the paycheck transactions that we might have to create a corresponding transfer for. Having a separate table for this entity lets us conceptually lock over a particular paycheck as well as all the possible transfer requests that might be created for it. Here’s some pseudocode to describe how we can do that:</p><pre># Get the bank&#39;s ID for the paycheck we&#39;re making a<br># transfer related to <br>paycheck_id = BankApi.get_latest_paycheck_id()<br><br># First, we make sure that a row for this particular paycheck<br># does in fact exist. We don&#39;t need to be the ones to have made<br># it, so if the uniqueness constraint errors, that&#39;s fine;<br># we&#39;ll load it in a minute<br>try:<br>  Sql.exec(<br>    &#39;&#39;&#39;<br>    INSERT INTO paychecks (bank_paycheck_id)<br>    VALUES :check_id;<br>    &#39;&#39;&#39;,<br>    check_id = paycheck_id<br>  )<br>except Sql.ViolatesUniquenessConstraint:<br>  # We don&#39;t need to be the ones to have created this<br>  pass<br><br># We&#39;re starting an explicit transaction; this tells the<br># database that everything happening in here is mutually<br># dependent, and locks should last until the end of it.<br>Sql.exec(&#39;BEGIN&#39;)<br><br>def exit_and_wait_for_next_run():<br>  # This inline helper function will commit the transaction<br>  # and close the scope, saving all our changes and releasing<br>  # all the locks we might hold.<br>  Sql.exec(&#39;COMMIT&#39;)<br>  exit()<br><br># By using SELECT FOR UPDATE, we acquire an exclusive lock<br># on both the paycheck&#39;s database row, any currently existing<br># transfer requests related to that paycheck, and the indices<br># that were used for finding them, meaning that until we finish<br># our transaction, nobody can insert new transfer requests<br># for this particular paycheck.<br>pending_rqs = Sql.exec(<br>  &#39;&#39;&#39;<br>  SELECT rq_id, status, bank_request_id, last_updated<br>  FROM paychecks<br>  JOIN transfer_requests<br>  ON paychecks.paycheck_id = transfer_requests.paycheck_id<br>  WHERE bank_paycheck_id = :check_id<br>  FOR UPDATE;<br>  &#39;&#39;&#39;,<br>  check_id = paycheck_id<br>)<br><br># Now we can do all the checks we need to do to ensure we&#39;re<br># not trampling on a currently-running process.<br><br>for row in [r for r in pending_rqs if r.status == &#39;reserved&#39;]:<br>  # If another process lost its lock on a request while in<br>  # the pending status, it means that it failed to submit<br>  # the job to the bank for whatever reason. We should mark<br>  # them as failed preemptively.<br>  row.status = &#39;failed&#39;<br>  row.last_updated = now()<br>  row.save()<br><br># These requests were actually submitted to the bank.<br>submitted = [r for r in pending_rqs if r.status == &#39;submitted&#39;]<br><br>if len(submitted) &gt; 1:<br>  # We only expect one request to be in a submitted state at a<br>  # given time, but can&#39;t write that into a database<br>  # constraint. We alert if we see something we don&#39;t expect.<br>  alert(&#39;More submissions for paycheck found than expected&#39;)<br><br>for row in submitted:<br>  # These requests (again, there should only be one) actually<br>  # got sent to the bank for processing. We should check what<br>  # sort of state they&#39;re in at the moment and update them.<br>  status = check_bank_status(row.bank_request_id)<br>  if row.status == &#39;pending&#39;:<br>    # The request is still in progress; skip over it and<br>    # leave the record alone, but start alerting if it<br>    # seems like it&#39;s been way too long. It might need<br>    # some sort of manual intervention.<br>    if row.last_updated &lt; now() - duration(hours=2):<br>      alert(&#39;Request has been pending over two hours&#39;)<br>    continue<br>  else:<br>    # The request finished! Let&#39;s save the state.<br>    row.status = status<br>    row.last_updated = now()<br>    row.save()<br><br># We&#39;ve now handled all the requests that are already in<br># progress in some way. Now we need to decide what we<br># need to do next.<br><br>if any([r.status = &#39;complete&#39; for r in pending_rqs]):<br>  # We finished! We don&#39;t have to do anything else! This<br>  # is a stable state once we reach it, so we don&#39;t need<br>  # to change anything.<br>  exit_and_wait_for_next_run()<br><br>if any([r.status = &#39;submitted&#39; for r in pending_rqs]):<br>  # We have some requests that are waiting to be updated. We<br>  # should wait for them to reach completion before trying<br>  # to start up anything else.<br>  exit_and_wait_for_next_run()<br><br>if len([r.status = &#39;failed&#39; for r in pending_rqs]) &gt;= 3:<br>  # We haven&#39;t successfully completed, and we&#39;re seeing a<br>  # lot of failures when we try. Something&#39;s wrong. We should<br>  # give up for now, but make sure that we alert someone to<br>  # take a look under the hood to find out what&#39;s going on.<br>  alert(&#39;Excessive failure rate when trying to transfer $!&#39;)<br>  exit_and_wait_for_next_run()<br><br># Finally, we&#39;re at the place where we know there&#39;s something<br># we need to do, and we can do it. We start by creating a row<br># in the requests table to represent that:<br>new_request_record = Sql.exec(&#39;&#39;&#39;<br>  INSERT INTO transfer_requests(<br>    paycheck_id, status, last_updated<br>  ) VALUES (<br>    :check_id, &#39;reserved&#39;, now()<br>  ) RETURNING (<br>    rq_id, paycheck_id, status, bank_request_id, last_updated <br>  );<br>  &#39;&#39;&#39;,<br>  check_id = paycheck_id<br>)<br><br># Now we need to make the transfer request with the bank:<br>try:<br>  # Make the API call<br>  bank_rq_id = BankApi.enqueue_transfer(<br>    from=MY_CHECKING,<br>    to=MY_SAVINGS,<br>    amount_cents=500<br>  )<br>except BankApi.FailedSubmission as e:<br>  # If the API call failed, we don&#39;t actually need to modify<br>  # any state. The cleanup logic higher up will ensure that the<br>  # request record we created in the &#39;reserved&#39; state will be<br>  # moved to a &#39;failed&#39; state and counted towards the failure<br>  # count that will cause us to give up and start alerting. We<br>  # should also alert about the failure of this particular<br>  # submission, though:<br>  alert(&#39;Could not submit transfer because reasons: &#39; + e)<br>else:<br>  # If the call succeeded, update the record with the details<br>  # of the pending request to the bank, and move it into the<br>  # proper state for checking by the next run:<br>  new_request_record.status = &#39;submitted&#39;<br>  new_request_record.bank_request_id = bank_rq_id<br>  new_request_record.last_updated = now()<br>  new_request_record.save()<br>finally:<br>  # Regardless, we&#39;re all done now! Save everything to the<br>  # database, release all our locks, and say goodbye!<br>  exit_and_wait_for_next_run()</pre><p>Now. There are still failure cases to consider. Like, what do we do if we keep failing to submit the bank transfer? How do we debug if we manage to submit the transfer but it keeps getting marked as failed? But the difference is that these issues are understood — handling for them is built into the program, and the boundaries of what the program can handle are known. And, importantly, the program functions in a way that we’ve determined to be appropriate, even when:</p><ul><li>it gets run more frequently than we expect</li><li>background processes take longer than we expect</li><li>the exact form of the “side effect” changes</li><li>background processes fail unexpectedly</li></ul><p>Synchronize your fucking clocks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87c6e08c434f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Time, Clocks, and the Ordering of Events in a Mildly Fucked System]]></title>
            <link>https://medium.com/@transgingerjess/time-clocks-and-the-ordering-of-events-in-a-mildly-fucked-system-21cf0f564571?source=rss-44663d5275a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/21cf0f564571</guid>
            <dc:creator><![CDATA[Jess Trochet]]></dc:creator>
            <pubDate>Sat, 12 Aug 2023 03:52:15 GMT</pubDate>
            <atom:updated>2023-08-12T03:54:19.885Z</atom:updated>
            <content:encoded><![CDATA[<p>Leslie Lamport wrote a paper in 1978 that shaped the course of the Internet. Computer systems in general, really.</p><p>Lamport proposed that when you’re thinking about two things that happen, thinking about “before” and “after” in terms of wall clock time isn’t particularly meaningful. What you really want is causality.</p><p>Causality is a bitch to prove, though, as anyone who’s ever debugged anything can attest. Even in the most clear-cut cases, there are always confounding factors. Being able to say “A happened because B” doesn’t happen in any but the rarest of circumstances.</p><p>So Lamport settled on what he called the “Clock Condition”. The idea was to state the bare minimum that has to be true about a clock in order for it to be useful. In its original form, it has symbols I can’t type here, but the gist of it is that if an event a happens before another event b (and it’s assumed that it’s impossible for any two events to happen at precisely the same time), then the clock must be able to assign a time to event a that is strictly less than the time it assigns to b.</p><p>This isn’t exactly shocking stuff. If I arrive at the train station when the clock is chiming ten and you arrive when the clock is chiming eleven, we know who got there first.</p><p>But Lamport’s next step with the concept was where it got interesting.</p><p>Let’s say that I’m still headed to the train station, and I still arrive when the clock there rings ten. But you head to City Hall, all the way across town, and you arrive at when the clock <em>there</em> strikes eleven.</p><p>Who arrived first?</p><p>Common sense would say I did, but Lamport said that the result is pretty much unknowable. Because our arrivals were timed by different clocks, and assigned temporal coordinates in their respective systems, they’re not comparable to each other. Lamport would say our arrivals are <em>concurrent</em>; that insufficient evidence exists to prove the ordering of our arrivals at our respective destinations.</p><p>This is the part where we’re going to go down a rabbit hole to prove something extremely obvious, so if that’s not what you want, congrats! You already learned something highly unsatisfying today! Shoo!</p><p>Anyway.</p><p>Lamport’s next move was to ask how to resolve this dilemma. And the answer was brilliant.</p><p>Sure, the clock at the train station and the clock at City Hall observe the Clock Condition. But it turns out a lot of other things do too.</p><p>For example. Suppose that, having arrived at the train station and hearing it chime 10, I take a Lyft all the way across town, arriving at City Hall at 10:59, and tell the first person I see, “I arrived at the train station as its clock struck ten. Please look at the City Hall clock and observe what it says.”</p><p>To which they would probably look at me like I’m an utter weirdo (I am), but they’re very nice to weirdos in this hypothetical town of ours, so they oblige me, note that the clock does in fact say 10:59, and agree to stick around for a little bit until you arrive.</p><p>When you get there at 11:00 (by City Hall Time, anyway), you come over to us, and I ask my new friend to tell you what happened.</p><p>“First, Jess arrived here. Second, she told me that she arrived at the train station as its clock struck 10. Third, she asked me to look at the City Hall clock. Fourth, I did, and saw that the city hall clock showed 10:59. Fifth, you arrived just as the City Hall clock struck eleven. Sixth, Jess asked me to tell you what happened in a particular odd way. Seventh, I gave you this description of events.”</p><p>Oh hey, this third party is recounting an ordered sequence of events, assigning each to an ordinal number. Weird.</p><p>Lamport’s realization was that if we have multiple clocks, all adhering to the Clock Condition, then we can bind them together through observations of other clocks’ values. And clocks, by this meaning, are a lot easier to come by than just the two big ones in our city.</p><p>In this system, we have events happening according to (at least) five different clocks, but the least interesting of them are the ones that are… actual clocks.</p><p>The train station clock is a clock.</p><ul><li>It indicated 10:00.</li></ul><p>I’m a clock.</p><ul><li>I observed the train station clock chime 10:00 as I arrived at the station.</li><li>I called a Lyft to City Hall.</li><li>I arrived at City Hall.</li><li>I found a friendly stranger.</li><li>I told them that I had arrived at the train station as its clock chimed 10:00.</li><li>I asked them to look at the City Hall clock.</li><li>I asked our new friend to tell you what happened.</li></ul><p>The City Hall clock is a clock.</p><ul><li>It indicated 10:59.</li><li>It indicated 11:00.</li></ul><p>Our new friend is a clock.</p><ul><li>They saw me arrive at City Hall.</li><li>They heard me tell them about arriving at the train station as its clock chimed 10.</li><li>They heard me ask them to look at the City Hall clock.</li><li>They looked at the City Hall clock and saw it said 10:59.</li><li>They saw you arrive as the City Hall clock struck eleven.</li><li>They heard me ask them to tell you what happened.</li><li>They recounted the entire sequence of events.</li></ul><p>You’re a clock.</p><ul><li>You arrived at City Hall as its clock struck 11.</li><li>You came over to us.</li><li>You heard our new friend’s sequence of events.</li></ul><p>Each of these clocks has a partial picture of what really happened.</p><p>Our friend doesn’t actually know I got to the train station at 10, but they know I told them I did before they looked at the City Hall clock. They know that the City Hall clock said 10:59 before you arrived.</p><p>You know even less. You know you got here at 11:00 before you came over to us. You know you came over to us before you were told this story.</p><p>But if we trust each other, we can stitch together the story. Maybe we all believe each other to be faithful clocks; clocks that obey the Clock Condition and who only claim events happen if they actually did happen, and recount the ordering correctly. In that case, it’s clear what happened.</p><ul><li>I arrived at the train station, and the clock struck 10:00.</li><li>I told our friend about arriving at the train station, and they heard it.</li><li>They looked at the City Hall clock, and it said 10:59.</li><li>You arrived at City Hall, the clock struck 11, and our friend and I saw you.</li></ul><p>I arrived at the train station before you arrived at City Hall.</p><p>10:00 by the train station clock is earlier than 11:00 by the City Hall clock.</p><p>It is one story. We believe each other, and the system of our clocks working together is more powerful than just one clock on its own.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21cf0f564571" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Safe, Sound, and Correct]]></title>
            <link>https://medium.com/@transgingerjess/safe-sound-and-correct-165f1d00f954?source=rss-44663d5275a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/165f1d00f954</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[rust]]></category>
            <dc:creator><![CDATA[Jess Trochet]]></dc:creator>
            <pubDate>Thu, 18 May 2023 03:36:55 GMT</pubDate>
            <atom:updated>2023-05-18T13:12:38.446Z</atom:updated>
            <content:encoded><![CDATA[<p>Over the last few years, there’s been an increased interest, spurred in no small part by 2012’s Heartbleed bug, in memory-safe programming languages. One way of phrasing memory safety is that safe languages are those that can provide strong proof that references will only ever point to data that was intended to go with them, and that only references that are intended to point to a piece of data can.</p><p>Thinking about it another way, a memory-safe language is one where I can initialize a buffer full of secret information, and as long as I do nothing else with it — perhaps just keep a reference to it somewhere — no other part of my program will ever have access to the region of memory where it’s stored.</p><p>Most memory-safe languages, like Rust, will let programmer deliberately loosen the restrictions a little and do black magic, like dereferencing a “raw pointer” — this kind of thing is crucial to systems-level work, where you interact with the hardware you’re running on by twiddling bits at specific locations in memory.</p><p>This kind of loosening is generally unnecessary for most software, though, and if you find yourself reaching for an unsafe block in Rust, it might be worth asking if you really know why you’re doing it. Which invariant of the compiler is the control you’re trying to breach intended to protect? Are you well-equipped to provide that protection in the compiler’s place?</p><p>Aside from the protections that are inherent to the syntax, though, languages like Go and Rust also keep one other ace up their sleeve: the idea of the panic. A panic is triggered by the language under circumstances so dire that the program is essentially unrecoverable; it’s possible that the memory state has been irrevocably tainted, and safe operation is no longer something the language can guarantee.</p><p>The presence of the panic as a last resort for protecting the safety of the program means that memory-safe languages can operate safely past the border of what can actually be proven to be safe. You can build a function that takes an array of any length, safe in the knowledge that if you look past its end at runtime, the program will panic and exit.</p><p>Now, a panicking program is safe. But to go a step further, it might not be what we’d describe as <em>sound</em>. And this is where things get a little tricky and qualitative. It’s not possible in the general case to prove that a Rust program won’t panic — if it was, then there wouldn’t be a need in the language to even have the feature (and it is a feature). So, most programs are potentially unsound in this way: they might crash. But <em>how</em> unsound they are matters.</p><p>Take a piece of logic that takes input from a web request and converts it into a form that can be used by the rest of the program. If there are particular types of data it might receive that would cause it to panic, then it’s arguably extremely unsound. It’s unable to meet its core responsibility. Additional protections need to be in place such that it never approaches the point of panic in those everyday cases.</p><p>On the other hand, if we have the same logic that logs the information it receives to a Unix pipe, and that pipe disconnects, then it might panic when it next tries to write. If that’s an unusual occurrence, then even though the panic is possible, it might not be a meaningful soundness issue. Sometimes things crash, and it’s better they do before something goes even more horribly wrong than after.</p><p>Importantly, the fact that a program doesn’t crash doesn’t mean it’s sound. All sorts of weird interactions are perfectly valid from a memory-safety perspective, but utterly wrong when you glance at them. For example, Ruby provides a method .to_f on string objects that converts them to floats. It’s memory-safe! It does, in fact, always return a float! But if you pass in garbage data, you get a garbage answer. &quot;lsjfd&quot;.to_f becomes 0.0. And if you miss that fact, then you can keep passing that garbage around.</p><p>Rust tries to protect you from unsoundness by giving you tools to express different kinds of potential soundness issues, and by forcing you to use them, at a minimum, when you interact with its standard library. You can do &quot;lsjfd&quot;.parse::&lt;f64&gt;() very easily in hopes of getting a float. But you won’t be silently returned zero—you’ll be given a Result that might contain a float, but it also might contain an error. And you won’t be allowed to access the float until you show that you know what you would do with an error (which might just be to panic, but that’s usually the wrong answer; it just trades one form of unsoundness for another).</p><p>But when you get into your own logic, and nobody is forcing you to use this kind of construct, it’s easy to let some unsoundness slip in. Match a partial string to indicate status, rather than deserializing it into a finite number of possible enum values; why not? There are as many tradeoffs in writing a program as there are lines of code.</p><p>Even if a program is memory-safe, even if it’s totally sound, it might still not be correct. The kind of ambiguities that we, as software engineers, are paid to resolve, are ones that are difficult to articulate true solutions for. We might have a general idea of things <em>not</em> to do. We might have particular goals that we know we want to prioritize. If we work in security, we might have a particular set of threat models we choose to consider or discard. But what we don’t have is a definite answer.</p><p>And when complex systems come together, then seemingly-correct individual behaviors can turn wrong. I’ll always remember the first true security issue I triaged. The client was a gentleman who was trying to print a document to a PDF. But no matter how he tried, it would always spit out an encrypted PDF, requesting a password.</p><p>Eventually, I asked him if he had deliberately printed a PDF with a password before. It turned out he had, and it turned out that the password he had chosen to protect that previous document unlocked all of the subsequent ones.</p><p>The PDF printer had been implemented as a print driver. The different parameters for the PDF printer had been layered on top of that as printer preferences. The underlying printer framework chose to preserve a given set of printer preferences to make the user experience easier. The password given to protect the PDF was just one of those printer preferences.</p><p>You can prove memory safety. You can strive for soundness, and isolate the likely sources of unsoundness in your program. But correctness is a precious thing that cannot be guaranteed, and which, even when present, can easily be taken away.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=165f1d00f954" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[We Don’t Need No Stinkin’ ORs]]></title>
            <link>https://medium.com/@transgingerjess/we-dont-need-no-stinkin-ors-37625fc7d9b5?source=rss-44663d5275a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/37625fc7d9b5</guid>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[authorization]]></category>
            <category><![CDATA[boolean]]></category>
            <dc:creator><![CDATA[Jess Trochet]]></dc:creator>
            <pubDate>Mon, 24 Apr 2023 03:07:23 GMT</pubDate>
            <atom:updated>2023-04-24T17:41:06.647Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s invent a new ACL language for protecting web resources. There definitely aren’t enough of those already. We’ll begin by handling the most simple use case: allow access to a particular endpoint for a particular user:</p><pre>allow { resource: &quot;/path&quot; } =&gt; (principal) {<br>  attrs_eq {<br>    type: &quot;User&quot;,<br>    id:   &quot;123&quot;,<br>  }<br>}</pre><p>This is pretty easy so far! The user with ID 123 can access the resource at /path. Let’s get more complicated:</p><pre>allow { resource: &quot;/path&quot; } =&gt; (principal) {<br>  all_match {<br>    type: eq { &quot;User&quot; },<br>    group_names: contain { &quot;path_user&quot; }<br>  }<br>}</pre><p>So, a bit more complex, but still relatively easy to follow, and pretty easy to write. Instead of having an exact equality check on the provided details, we’re saying that each of the attributes is its own matcher. The type has to exactly equal User, and the group_names array has to contain the value path_user. Let’s continue.</p><pre>allow { resource: &quot;/path&quot; } =&gt; (principal) {<br>  all_match {<br>    type: eq{ &quot;User&quot; },<br>    group_names: contain { &quot;path_user&quot; } || contain { &quot;admin&quot; }<br>  }<br>}</pre><p>Here, we’re adding the || operator to serve as an “or” construct. Depending on the context, something like this might be called “any”. For this new ACL, what this means is that any user who is a member of <em>either</em> the path_user group <em>or</em> the admin group can access this resource. Moving on.</p><pre>allow { resource: &quot;/path&quot; } =&gt; (principal) {<br>  all_match {<br>    type: eq { &quot;User&quot; } || eq { &quot;Robot&quot; }<br>    group_names: contain { &quot;path_user&quot; } || contain { &quot;admin&quot; }<br>  }<br>}</pre><p>Now, we’re starting to run into some complexity. We’ve added the concept of a robot principal that doesn’t strictly map back to a human being. One possible variance when we’re adding that is that robot users might not actually be members of groups in the same way that humans are. In that case, this ACL breaks down, and we have to do some higher level refactoring:</p><pre>allow { resource: &quot;/path&quot; } =&gt; (principal) {<br>  any {<br>    all_match{<br>      type: eq{ &quot;User&quot; },<br>      group_names: contain { &quot;path_user&quot; } || contain { &quot;admin&quot; }<br>    },<br>    attrs_eq { type: &quot;Robot&quot; },<br>  }<br>}</pre><p>So now we have two entries under the ACL principal; one for a robot user type, and one for human users that are members of either of the path_user or admin groups. Suppose we want to enhance our security further by requiring admin users to use a second factor when signing in. Let’s refactor again:</p><pre>allow { resource: &quot;/path&quot; } =&gt; (principal) {<br>  any {<br>    all_match {<br>      type: eq { &quot;User&quot; },<br>      group_names: contain { &quot;path_user&quot; },<br>    },<br>    all_match {<br>      type: eq { &quot;User&quot; },<br>      group_names: contain { &quot;admin&quot; },<br>      session: attrs_eq { mfa_token: &quot;FIDO_U2F&quot; },<br>    },<br>    attrs_eq { type: &quot;Robot&quot; },<br>  }<br>}</pre><p>We’re always making our system more sophisticated, so we’re adding the concept of robot user <em>provenance</em> — that is, what individual human user a robot is actually doing work for. We’ll tighten security by making sure that only robot users working on behalf of human users who are allowed to use this route can request it.</p><pre>allow { resource: &quot;/path&quot; } =&gt; (principal) {<br>  any {<br>    all_match {<br>      type: eq { &quot;User&quot; },<br>      group_names: contain { &quot;path_user&quot; },<br>    },<br>    all_match {<br>      type: eq { &quot;User&quot; },<br>      group_names: contain { &quot;admin&quot; },<br>      session: attrs_eq { mfa_token: &quot;FIDO_U2F&quot; },<br>    },<br>    all_match {<br>      type: eq { &quot;Robot&quot; },<br>      on_behalf_of: any {<br>        all_match {<br>          type: eq { &quot;User&quot; },<br>          group_names: contain { &quot;path_user&quot; },<br>        },<br>        all_match {<br>          type: eq { &quot;User&quot; },<br>          group_names: contain { &quot;admin&quot; },<br>          session: attrs_eq { mfa_token: &quot;FIDO_U2F&quot; },<br>        },<br>      },<br>    },<br>  }<br>}</pre><p>We’re starting to see some duplication. And if we wanted to change the human policy, we’d need to remember to update the policy affecting robots as well, which makes it a bit error-prone. But here’s a twist: Robots are getting group memberships after all! Some robots don’t run on behalf of humans after all, it turns out, so we need robots that have access on their own merits:</p><pre>allow { resource: &quot;/path&quot; } =&gt; (principal) {<br>  any {<br>    all_match {<br>      type: eq { &quot;User&quot; },<br>      group_names: contain { &quot;path_user&quot; },<br>    },<br>    all_match {<br>      type: eq { &quot;User&quot; },<br>      group_names: contain { &quot;admin&quot; },<br>      session: attrs_eq { mfa_token: &quot;FIDO_U2F&quot; },<br>    },<br>    all_match {<br>      type: eq { &quot;Robot&quot; },<br>      on_behalf_of: any {<br>        all_match {<br>          type: eq { &quot;User&quot; },<br>          group_names: contain{ &quot;path_user&quot; },<br>        },<br>        all_match {<br>          type: eq { &quot;User&quot; },<br>          group_names: contain { &quot;admin&quot; },<br>          session: attrs_eq { mfa_token: &quot;FIDO_U2F&quot; },<br>        },<br>      },<br>    },<br>    all_match {<br>      type: eq { &quot;Robot&quot; },<br>      group_names: contain { &quot;robot_path_user&quot; },<br>    }<br>  }<br>}</pre><p>One more thing! Now we’re adding another endpoint that’s just for admins and robots working on behalf of admins! At last, we’ll have to break our ACL into two items, one for each route:</p><pre>allow { resource: &quot;/path&quot; } =&gt; (principal) {<br>  any {<br>    all_match {<br>      type: eq { &quot;User&quot; },<br>      group_names: contain{ &quot;path_user&quot; },<br>    },<br>    all_match {<br>      type: eq { &quot;User&quot; },<br>      group_names: contain { &quot;admin&quot; },<br>      session: attrs_eq { mfa_token: &quot;FIDO_U2F&quot; },<br>    },<br>    all_match {<br>      type: eq { &quot;Robot&quot; },<br>      on_behalf_of: any {<br>        all_match {<br>          type: eq { &quot;User&quot; },<br>          group_names: contain{ &quot;path_user&quot; },<br>        },<br>        all_match {<br>          type: eq { &quot;User&quot; },<br>          group_names: contain { &quot;admin&quot; },<br>          session: attrs_eq { mfa_token: &quot;FIDO_U2F&quot; },<br>        },<br>      },<br>    },<br>    all_match {<br>      type: eq { &quot;Robot&quot; },<br>      group_names: contain { &quot;robot_path_user&quot; },<br>    }<br>  }<br>}<br><br>allow { resource: &quot;/admin&quot; } =&gt; (principal) {<br>  any {<br>    all_match {<br>      type: eq { &quot;User&quot; },<br>      group_names: contain { &quot;admin&quot; },<br>      session: attrs_eq { mfa_token: &quot;FIDO_U2F&quot; },<br>    },<br>    all_match {<br>      type: eq { &quot;Robot&quot; },<br>      on_behalf_of: all_match {<br>        type: eq { &quot;User&quot; },<br>        group_names: contain { &quot;admin&quot; },<br>        session: attrs_eq { mfa_token: &quot;FIDO_U2F&quot; },<br>      },<br>    },<br>  }<br>}</pre><p>Now, suppose we’re designing our ACL constructs from the ground up with all of these use cases in mind. Let’s think about what we would need. Looking at the monster immediately above, we’ll definitely want some way to reuse logic. We see that “user is an admin and is using a FIDO-U2F token” logic showing up four times. We’ll also want a way to more-easily break apart things we thought were related but turned out not to be. What might that look like?</p><pre>uses_u2f =&gt; (session) { mfa_token: &quot;FIDO_U2F&quot; }<br><br>is_admin =&gt; (principal) { is_member { &quot;admin&quot; } }<br><br>is_mfa_admin =&gt; (principal) {<br>  is_human,<br>  is_admin,<br>  session: uses_u2f,<br>}<br><br>is_member{ $group } =&gt; (principal) {<br>  group_names: contain { $group }<br>}<br><br>is_human =&gt; (principal) { type: &quot;User&quot; }<br><br>is_robot =&gt; (principal) { type: &quot;Robot&quot; }<br><br>allow { resource: &quot;/path&quot; } =&gt; (principal) {<br>  is_human,<br>  is_member { &quot;path_user&quot; },<br>}<br><br>allow { resource: &quot;/path&quot; } =&gt; (principal) { is_mfa_admin }<br>allow { resource: &quot;/admin&quot; } =&gt; (principal) { is_mfa_admin }<br><br>allow { $resource } =&gt; (principal {<br>  is_robot,<br>  on_behalf_of: allow { $resource }<br>}<br><br>allow { resource: &quot;/path&quot; } =&gt; (principal) {<br>  is_robot,<br>  is_member { &quot;robot_path_user&quot; }<br>}</pre><p>Now. Looking at that ACL, it isn’t substantially shorter. But because each entry is relatively short, and makes use of human-named predicates, it’s easy to reason about the policy without necessarily diving into the underlying pieces. Finally, the recursive nature allows us to easily state the problem case of “allow robots access to any endpoints that the users they’re acting on behalf of have access to”.</p><p>One final thing to note is that this variant language makes no use of any sort of visible “or” primitive. Instead, each entry is constructed of strict logical ANDs of all its statements. ORs only exist at the very top level, where <em>any</em> instance of a particular parameterized predicate being met means that a statement evaluates as true. This is similar to how Prolog works, in that any number of implementations can exist, and only one must evaluate true.</p><p>In this case, we have three instances of the allow { resource: &quot;/path&quot; } predicate explicitly defined. Each of them can receive a principal and evaluate whether that particular principal may access the resource based on it. Any one can say “yes, this is allowed”.</p><p>So, maybe “we don’t need OR” is overstated. Because in this case, the OR is hiding in plain sight. Using an ACL language that forces us to hoist our ORs to the very top level (and which provides some basic affordances) can allow us to clarify our intentions, and build ACLs that are fit for both human and computer consumption.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37625fc7d9b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[iOS 16 Medication Tracking]]></title>
            <link>https://medium.com/@transgingerjess/ios-16-medication-tracking-1e14f53a6732?source=rss-44663d5275a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e14f53a6732</guid>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[ios-16]]></category>
            <category><![CDATA[medicine]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[prescription-drugs]]></category>
            <dc:creator><![CDATA[Jess Trochet]]></dc:creator>
            <pubDate>Thu, 15 Sep 2022 01:22:55 GMT</pubDate>
            <atom:updated>2022-09-15T01:22:55.850Z</atom:updated>
            <content:encoded><![CDATA[<p>As someone who takes a number of medications on several different schedules, I’ve been <a href="https://www.medisafeapp.com">using an app on my phone</a> to track and remind me of them for several years now. And, as someone who has periodically been annoyed by that app’s foibles, I was really excited when I heard that iOS 16 was going to have medication tracking built into the OS.</p><p>Of course, whether that excitement was deserved depends solely on the implementation that Apple came up with. And, unfortunately, that implementation is decidedly “meh”.</p><p>The ability to scan pill bottles is nice to have. But, it likely saves less than a minute when typing in a medication’s name, and only one time for that particular treatment. You still have to manually select dosage, schedule, and fiddle with its appearance (something that my existing tracker does for me for sufficiently-common pills).</p><p>Really, any review of iOS 16’s medication tracking has to speak to the experience, not of <em>setting up</em> medications, but of actually <em>using</em> them. And in the short time I’ve been using it, I’ve been pretty unimpressed.</p><p>My normal schedule has me taking one pill in the morning, two pills in the evening, and one injection every week. Those pills are scheduled as 8AM and 8PM for me, but taking them right on the hour isn’t necessarily critical — what’s most important is that I remember to take them at all.</p><p>iOS 16 will show a single reminder at the designated time, and you can interact with that reminder to either take your meds or snooze it — but you can also just swipe it away like any notification. If it’s gone from your lock screen, as far as I can tell, it’s gone for good.</p><p>And, because your medications exist solely inside the Health app, that’s where you have to go digging for them if you didn’t mark them as taken directly from the notification. Notably, the Health app doesn’t get a notification badge or similar when you have a medication outstanding — there’s no indicator that there’s something you need to do.</p><p>In comparison, the app I use provides configurable repeated nudging — it’ll buzz me on the hour, and then every ten minutes for a while afterwards, in case I need the nudge. It also has its own place on my home screen, and will show an angry red badge at me if I have outstanding meds I haven’t taken.</p><p>I think the thing I’m most sad about this particular part of iOS 16 is that it’s something where Apple really could have leaned into its system ownership to do things that other app developers aren’t given the API surfaces to. Like a permanent, always-forefront notification prompting me to take my pills that never goes away or falls behind until I mark my pills as taken. Or a friendly banner that shows up a half-hour before my scheduled pill time that starts asserting itself increasingly aggressively as more time elapses. And certainly, if nothing else, a dedicated spot on my home screen that gives me the red badge I need to remind me that I’m behind.</p><p>All in all, I really wanted to like Apple’s medication tracker. But it’s not there yet. Maybe for someone who’s better about immediately jumping up and taking their pills than I am, it’d be great. But for me, having a tool that’s supposed to help me keep track of my critical medical needs, but which gets itself buried behind all my other notifications, and which is difficult to find once it’s done that, is a non-starter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e14f53a6732" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>