<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel>
<title>sadasant — Writing</title><link>https://sadas.at/writing/</link><description>Essays by Daniel Rodríguez.</description><language>en</language>
<generator>sadasant Writing 1.0.0</generator>
<atom:link href="https://sadas.at/writing/feed.xml" rel="self" type="application/rss+xml"/>
<item><title>Computer Science is a Social Science</title><link>https://sadas.at/writing/computer-science-is-a-social-science/</link><guid isPermaLink="true">https://sadasant.ai/writing/computer-science-is-a-social-science/</guid><description>On objects, functions, and the shared meanings that make software more than its code.</description><content:encoded><![CDATA[<p class="lead">In software engineering, people spent a long time divided into two camps: Object-Oriented Programming and Pure Functional Programming. To be fair, we divided into camps rather frequently, but I’ll focus on those two. These were perceived almost as competing moral philosophies, with cultures as different as Enterprise and Academia, or ostensibly Startup and FinTech. If we squint our eyes, we could arguably see two centers of gravity:</p>

<ul>
  <li>West Coast (the Valley, Xerox PARC, Alan Kay, and <a href="https://worrydream.com/EarlyHistoryOfSmalltalk/">Smalltalk-72</a>), vs.</li>
  <li>East Coast (MIT, <a href="https://www-formal.stanford.edu/jmc/history/lisp/node3.html">Lisp</a>, and <a href="https://softwarepreservation.computerhistory.org/LISP/scheme_family.html">Scheme</a>) on the other.</li>
</ul>

<p class="lead">Though there wasn’t really such a clean separation between them, these were movements of their own, with proponents and detractors.</p>

<figure class="essay-illustration"><img src="https://sadas.at/writing/media/computer-science-is-a-social-science/2.0.0/us-map-two-coasts.webp" width="1536" height="837" alt="Hand-drawn outline map of the United States with a pin at Xerox PARC, labeled Smalltalk-72, and a pin at MIT, labeled Lisp 1958, Actors 1973, and Scheme 1975. Two crossing arrows span the country: one from Lisp to Smalltalk-72, marked eval, and one from Smalltalk-72 to Actors, marked messages. At MIT a short arrow marked closures runs from Actors to Scheme. A dashed line from Simula 67, Oslo, enters from the Atlantic and reaches both coasts." loading="lazy"><figcaption>Two coasts in the history of programming, Smalltalk at Xerox PARC and Lisp, Actors, and Scheme at MIT, with Simula arriving from Oslo.</figcaption></figure>

<p class="lead">To see them as competing visions, we’d have to ponder why: Why do object-oriented and functional programming feel like such different ways of thinking? Both can solve many of the same problems, but we could say the same for cubism, expressionism, and impressionism in painting. Their value isn’t so much in being able to perform (painting or coding), but in what gets highlighted in representation. You take a subject, or a problem space, then cast your solution into it—but through which medium or frame? If we return to OOP and FP with that question in mind, we can begin to see how each gives us a different way to represent a problem. These are two programming paradigms: one follows an entity through time, the other follows transformations. Both turn bits into something we recognize, and both inherit ideas about what a thing is, how it changes, and how it relates to others.</p>

<p class="lead">Notice that <em>what a thing is</em> is such an omnipresent thought that, naturally, we have been asking these questions long before computers. But the same questions elsewhere preceded software and inevitably influenced it, because what we call software is less of a natural science and more a form of expression, like painting, like writing, made by people from a place and a time, who build communities and develop expectations together.</p>

<p class="lead">Perhaps if we look at software engineering as a conversation through time, we can understand how it came to be what it is today, and where it may lead.</p>

<p class="lead">But I’m getting ahead of myself. Let’s explore these two further.</p>

<h2>Objects, identity, and agency</h2>

<p>Object-oriented programming gives us a way to organize software around entities with identity, state, and behavior. An object can change while remaining the same object. Encapsulation, for example, draws a perimeter that mediates how the outer world interacts with the internals of an object, much like we do with city walls, sea ports, and border crossings.</p>

<p>But certainly <a href="https://classics.mit.edu/Aristotle/politics.3.three.html">the wall doesn’t make a city</a>, as walls may fall. Nothing specifically makes the city, not the citizens at a given point in time, who come and go like the water of a river, nor the features of the land. What makes the city is that which can be traced across all of them. In the fourth century BCE, <a href="https://plato.stanford.edu/entries/aristotle-categories/">Aristotle</a> had a terminology we can associate with OOP: substance with an instance, species with a class, qualities with attributes, and substance persisting through change with an object preserving its identity.</p>

<p>That question, of what makes a thing only this particular thing, wasn’t settled then, almost as if we had to develop the linguistic technology to continue arguing about these subjects at a greater depth. It is in part because of attempting to answer these questions that Aristotle has been held in such high regard by essentially all forms of society since his time, though Aristotle himself having to answer that question is evidence that it was critical, for he was no less than, perhaps, the greatest scholar of his time, before there was academia as we know it, and tutor to Alexander the Great. Centuries passed. Around 1300, <a href="https://plato.stanford.edu/entries/duns-scotus/">Scotus</a>, at Oxford and Paris, explored it through <em>haecceitas</em>, or thisness; then in the seventeenth century, <a href="https://plato.stanford.edu/entries/leibniz/">Leibniz’s principle of the identity of indiscernibles</a> held that two numerically distinct individuals cannot be alike in every respect.</p>

<p>By the late nineteenth century, questions of membership and relationship were taking new mathematical forms. <a href="https://plato.stanford.edu/entries/settheory-early/">Cantor</a> helped establish set theory, and <a href="https://plato.stanford.edu/entries/frege/">Frege</a> developed a formal language for logic. In <a href="https://plato.stanford.edu/entries/whitehead/"><em>The Concept of Nature</em></a> (1920), Whitehead turned attention toward events rather than enduring objects.</p>

<p>In France after WWII, <a href="https://plato.stanford.edu/entries/existentialism/">existentialists</a> including Sartre and Beauvoir explored existence and freedom. For them, the nature of a person could only be determined from their actions. Later, Structuralism emphasized how signs and practices acquire significance through their relations within a system, independently of explicit, premeditated decisions that people might have made. Inspired by <a href="https://www.britannica.com/biography/Ferdinand-de-Saussure">Saussure’s</a> account of linguistic differences, <a href="https://www.britannica.com/biography/Claude-Levi-Strauss">Lévi-Strauss</a> extended structural methods into anthropology, and by 1962 he was arguing with Sartre himself. For the structuralists, identity and action could be understood through relationships: through the languages, practices, and structures in which people find themselves.</p>

<p>In the 1960s, Ole-Johan Dahl and Kristen Nygaard developed <a href="https://www.mn.uio.no/english/services/it/simula/bibliography/history/artikkel1966cacm.pdf">Simula</a> to model systems of discrete events, whose parts act, interact, and change over time. Simula helped establish object-oriented programming, influenced Smalltalk, and with it contributed to the <a href="https://www.cs.unc.edu/~stotts/COMP590-059-f21/slides/actorHewitt2010.pdf">Actor Model</a>. <a href="https://worrydream.com/EarlyHistoryOfSmalltalk/">Alan Kay</a> recalls that Smalltalk also drew on abstract algebra, biology, Leibniz’s monads, and Plato’s discussion of dividing nature at its joints. It drew on Lisp, too. Kay dedicates his history “to SKETCHPAD, JOSS, LISP, and SIMULA, the 4 great programming conceptions of the sixties,” and remembers that the biggest hit for him in late 1969 was finally understanding Lisp’s <em>eval</em>. McCarthy had described Lisp in Lisp in about a page; Kay boasted he could do the same for objects, and that boast became Smalltalk-72.</p>

<figure class="essay-illustration"><img src="https://sadas.at/writing/media/computer-science-is-a-social-science/2.0.0/three-questions.webp" width="1536" height="747" alt="Three handwritten questions on the left, each with names beneath it: what makes a thing itself? (Aristotle, Scotus, Leibniz); how do things relate? (Saussure, Lévi-Strauss); what does it do? (Whitehead, Sartre). Dashed lines lead from each question into a circle labeled an object, to the words identity, relations, and behavior." loading="lazy"><figcaption>Three older questions that reappear in an object.</figcaption></figure>

<p>But if the city isn’t any particular instance that we may visit, could we say the city is that which satisfies the behavior of a city?</p>

<h2>Functions, relationships, and composition</h2>

<p>Pure functional programming focuses on relationships between inputs and outputs. Its cornerstone is the pure function, which reliably produces the same result for the same inputs, whatever the circumstances around it, without side effects. This notion comes from modern mathematics, where a function assigns exactly one output to each permitted input.</p>

<p>Amongst its key terms, composition lets us build a larger transformation from smaller ones: the output of one function becomes the input of another.</p>

<p>The familiar notation for functions, f(x), comes from <a href="https://scholarlycommons.pacific.edu/euler-works/101">Euler</a>, but people studied relationships between quantities long before him. In an <a href="https://journals.openedition.org/philosophiascientiae/3185">appendix to Euclid’s <em>Elements</em></a>, we find the Greek word synthesis (σύνθεσις), meaning putting together or combining, although this was not yet composition of functions in the modern sense. Galileo’s work on motion and Descartes’ algebraic treatment of curves made relationships between varying quantities increasingly explicit. Then, Leibniz used the word <a href="https://mathshistory.st-andrews.ac.uk/HistTopics/Functions/">“function”</a> in connection with geometry, and Johann Bernoulli (1718) described a function as a quantity composed, in any manner, from a variable and constants. Euler would later develop this into a more systematic treatment of functions, making them central to mathematical analysis.</p>

<p>But when did the concept move from mathematics into the structure of thought itself? Since Aristotle, much of logic had followed a subject–predicate structure. For example: “Socrates is mortal”. A proposition was understood as saying something about something, distinguishing the subject (Socrates) from the predicate (is mortal).</p>

<p>Sometimes it takes someone bold to, like Shakespeare, introduce a new terminology or perspective that later changes the course of an entire language. That person was <a href="https://plato.stanford.edu/entries/frege/">Gottlob Frege</a>, who, in his 1879 <em>Begriffsschrift</em>, introduced a different way of analyzing propositions. Instead of assuming that their logical structure must follow the distinction between subject and predicate, Frege proposed analyzing expressions through functions and arguments. The function (for example, “is mortal”) is incomplete until supplied with an argument (for example, Socrates). Thus: Mortal(Socrates). Socrates can be named independently, but mortality, understood here as the concept “is mortal”, leaves something open. It needs an argument. More importantly, the same proposition could be analyzed in different ways, depending on what we treated as the function and what we treated as its argument. What had previously been understood through the apparent structure of language could now be investigated through the logical relationships between its constituents.</p>

<p>This was an epistemological recentering, not because relationships had suddenly been discovered, but because the mathematical language of functions was now being used to reconsider the structure of propositions themselves. Frege would later develop his distinction between complete objects and incomplete functions, and his account of thoughts (Gedanken) as objective contents, rather than private psychological events. While Frege received relatively little recognition during much of his lifetime, his work would eventually be recognized as foundational to modern mathematical logic and analytic philosophy. Bertrand Russell and Ludwig Wittgenstein built important parts of their work through engagement with Frege, while Giuseppe Peano and others were developing related formal approaches to mathematical reasoning. What followed was not a single school of thought, but a growing recognition that logic itself could be investigated mathematically.</p>

<p>So, by the early twentieth century, names such as George Boole, David Hilbert, and Kurt Gödel were already part of the intellectual landscape, each contributing in different ways to the formalization of logic and mathematics. Mathematicians had algorithms, recursive definitions, symbolic logic, mechanical calculators, and human beings whose occupation was literally to compute. What they did not yet have was a generally accepted mathematical definition of computation itself. In that context emerged Alonzo Church, who, beginning in 1932, developed <a href="https://iep.utm.edu/lambda-calculi/">lambda calculus</a> as part of an attempt to establish the foundations of logic. It provided a formal language for defining and applying functions, where functions could themselves be passed to other functions or produced as results. Related work by Moses Schönfinkel and Haskell Curry had already shown how functions could be built from combinations of simpler operators. But as Church and his students investigated what lambda calculus could express, a more fundamental question emerged: could every effectively calculable function be described through such a formal system? By 1936, Church had proposed an answer, while Alan Turing independently approached the same problem through a model of mechanical computation.</p>

<p>A few decades later, John McCarthy developed <a href="https://www-formal.stanford.edu/jmc/recursive.pdf">Lisp</a> for symbolic computation, beginning in 1958, bringing ideas from recursive function theory into a practical programming language. Peter Landin would further connect lambda calculus with the structure of programming languages during the 1960s. Functions had become a way to express computations, and increasingly, to construct programs.</p>

<p>The missing key wasn’t the function, nor composable structures anymore. What remained was a peculiar habit: computers executed instructions, and programming languages had largely grown around describing those instructions. We had learned to name transformations, apply them, compose them, and reason about them mathematically, but our programs still largely described how machines should move things around. Backus would later observe that much of the traffic between a computer’s processor and memory is not useful data, but names of data and operations used to compute those names. The challenge was now to focus on what programs do, rather than continuously describing the states through which their execution passes.</p>

<p>Let’s go back to language itself. Verbs help us understand nouns for what they do, and thus allow us to say that a tree “greens” and not merely that a tree is green. The Stoics had already distinguished between bodies and the events that happen to them. A tree is a body, but greening is an event. This distinction had been developing in different forms and across different domains.</p>

<p>In France, Albert Lautman had been arguing that mathematical theories emerge in response to recurring problems, among them how the local relates to the global, and how the continuous relates to the discrete. For him, each theory was one way of working one of these problems out, rather than mathematics being merely a collection of established objects and their properties. His work would later influence <a href="https://plato.stanford.edu/entries/deleuze/">Gilles Deleuze</a>, who, in <em>The Logic of Sense</em> (1969), returned to the Stoics’ distinction between bodies and events. For Deleuze, the verb expresses the event, what happens to a body without being reducible to one of its qualities or states. “To green” is not simply another way of saying “is green”. It draws attention to the happening itself.</p>

<p>Back in computer science, John Backus was confronting a different problem. Programming languages could already express functions, and functional languages had already begun to emerge, but most programming remained organized around instructions that manipulated state. In his 1977 Turing Award lecture, <a href="https://john.cs.olemiss.edu/~hcc/csci555/2016spr/notes/Backus_Turing_Award_Address.pdf">published in 1978</a>, Backus proposed FP systems, where programs could be constructed by combining existing functions and reasoned about through an algebra of programs. His proposal wasn’t simply to make functions available to programmers, since they already were, but to make their combination the organizing principle of programming itself. Rather than describing every intermediate step through which data must pass, one could construct a larger operation from smaller ones and reason about the resulting program through its mathematical properties.</p>

<figure class="essay-illustration"><img src="https://sadas.at/writing/media/computer-science-is-a-social-science/2.0.0/backus-bottleneck.webp" width="1536" height="470" alt="Two hand-drawn panels. Left, headed one word at a time: a box labeled CPU joined to a box labeled memory by a narrow tube carrying x, addr, i, addr, y, with the note mostly names of data. Right, headed Backus, 1978: data passes through boxes f, g, and h to a result, with the note programs built from functions." loading="lazy"><figcaption>Programs that Backus proposed to build from functions.</figcaption></figure>

<p>In the years that followed, several approaches to functional programming continued to emerge. David Turner’s SASL and KRC, along with later languages such as Miranda, had demonstrated how programs could be written through functional definitions and evaluated lazily. ML, Hope, and other languages contributed different approaches to types, functions, and program construction. But these developments also produced a fragmented landscape, with researchers creating different languages to investigate closely related ideas.</p>

<p>In 1987, researchers working with <a href="https://www.cs.yale.edu/publications/techreports/tr322.pdf">Alfl</a> at Yale, <a href="https://raw.githubusercontent.com/emintham/Papers/master/Augustsson-%20A%20Compiler%20for%20Lazy%20ML.pdf">Lazy ML</a> at Chalmers and University College London, and Philip Wadler’s <a href="https://homepages.inf.ed.ac.uk/wadler/papers/orwell/orwell1.pdf">Orwell</a>, amongst others, began working toward a common functional language. Their work led to the first <a href="https://www.microsoft.com/en-us/research/wp-content/uploads/2016/07/history.pdf">Haskell</a> report in 1990. Haskell grew around mathematical clarity, but also around a desire to share ideas: a language people could use to communicate, disagree, and build on one another’s work.</p>

<p>While we can understand OOP through the direct observation that something may not be any single instance of it, at any given time— observation that in itself comes from experiences that can be easily verifiable, FP in contrast appears as the realization that a transformation may remain the same even when the entities it acts on differ, a thought that requires a displacement of the observer perhaps. Neither is wrong, as the subjects, adjectives and verbs all can only attempt a reconstruction of phenomena that doesn’t exist within the language inasmuch as it exists inside the computer, but the scaling of computers suddenly allow modeling more and more, to the degree that we find the seams in either model.</p>

<figure class="essay-illustration"><img src="https://sadas.at/writing/media/computer-science-is-a-social-science/2.0.0/follow-thing-follow-change.webp" width="1536" height="586" alt="Two hand-drawn panels. Left, headed follow the thing: the same circle drawn three times along a dashed line, marked then, later, and now, holding one, two, and then three dots. Right, headed follow the change: a circle, a square, and a triangle each pass through one box labeled f and come out doubled." loading="lazy"><figcaption>Following an entity through time vs. following a transformation.</figcaption></figure>

<h2>Models, uncertainty, and shared meaning</h2>

<p>For as long as the practice of software engineering has existed, our ability to model the world has been limited not only by resources (compute, headcount, or otherwise), but also by what our minds can hold and communicate at any given time. As we’ve seen, centuries had to pass for us to reconsider even relatively narrow ideas about how things relate to one another. Yet the demand for disambiguation and understanding is only increasing in the era of AI, because what we can represent, generate, and act upon is beginning to far exceed what any one person can reasonably hold.</p>

<p>What might begin as the implementation of a chatbot that answers questions from a corpus, it does not halt at that stage. Soon it becomes a problem of understanding. The level of specificity that worked for us prior to AI mostly worked because we assumed that whatever was lost in our representations could be recovered by people as they became better at their jobs. A document didn’t have to explain everything, because the person reading it could ask someone, remember an earlier conversation, or recognize that an instruction no longer applied. Even if the interpreter has learned to generally understand humans, it still has not learned to become effective within any specific human organization. Anything not thoroughly specified becomes a source of uncertainty, and the problem aggravates if such entity can produce documents and act upon them at a pace no one can reasonably follow.</p>

<p>We might follow each step that brought an answer to us: the search, the prompt, the model’s response. Yet one document might describe a policy that another has implicitly superseded, while a third might refer to an exception that was never formally acknowledged. To understand what happened, we can reason about the parts and experiment with the system, but we must also consider the person asking the question, the human systems around them, and the distinction between what is explicit and accessible within the digital world and what may exist without ever having been digitized.</p>

<p>What appears to be an incomplete specification might, in practice, have been perfectly sufficient for a team of people familiar with that environment. The problem is that the specification was never the whole system. Part of the system existed in the people interpreting it, and the meaning of what was written depended on what they already knew.</p>

<p>To understand these new systems that act upon human language, we increasingly have to examine distributions of behaviors across multiple turns. Soon we encounter population dynamics, incentives more commonly studied in economics, and questions about actions and events under incomplete information.</p>

<p>So, while a support assistant might improve its rate of “resolved” conversations, the underlying failures might have been accidentally obscured. A subtle change might make it harder to reach a human, and conversations that would previously have been escalated are now closed by the assistant. So, some metrics may improve while the service gets worse. On one hand, of course, these are ostensibly new technologies and soon enough we will adapt to them, but on the other hand, have we truly pondered what words such as “resolved” mean? Because inconsistencies on who defined it, what assumptions went into that definition, or what behavior it rewards over time, however subtle the disagreements may be, can now be amplified into problems that may only appear an indiscernible amount of time after the system gets delivered to customers.</p>

<figure class="essay-illustration"><img src="https://sadas.at/writing/media/computer-science-is-a-social-science/2.0.0/resolved-metric.webp" width="1536" height="1025" alt="A hand-drawn chart over time: a solid line labeled resolved and a dashed line labeled people helped start at the same point; resolved rises while people helped slowly falls, and a bracket marks the gap between them. Below, three doors labeled talk to a person get smaller from left to right." loading="lazy"><figcaption>“Resolved” keeps rising as it becomes harder to reach a person.</figcaption></figure>

<p>Words we use may carry histories and expectations we never truly signed into. A user might be a person in one system and an identity associated with several organizations in another. An account might represent a customer, a billing relationship, or a collection of permissions. Even a successful transaction might mean that a payment was accepted, that an order was fulfilled, or merely that no error was reported. It takes to dive into how they are locally applied to reveal just how much interpretation is taking place.</p>

<p>While Saussure understood linguistic value through differences and relationships within a system of signs, <a href="https://anthropology.berkeley.edu/sites/default/files/beneath_symbols_prepub.pdf">Terrence Deacon’s work on symbolic reference</a> offers another useful perspective: symbols depend not only on their relationships with other symbols, but also on the interpretive processes and learned conventions through which they come to signify something. What we often believe to be settled or obvious may actually be held together by much more fragile webs of people and practices, so when the people change, the meanings can change with them, sometimes irreconcilably.</p>

<h2>A wider practice of computer science</h2>

<p>How does something remain itself as it changes? What can we learn from its relationships, and from the world around it? The French philosopher Gilbert Simondon offers a way to bring these questions together. Like the structuralists, he paid attention to relationships, and he also asked how they come to be, together with the individual, through the processes and milieu in which it takes form. His <a href="https://link.springer.com/article/10.1007/s11007-019-09466-9">1958 work on technical objects</a> places technics within human culture, among the ways people understand and shape their world.</p>

<p>Perhaps the city, too, is that which keeps taking form.</p>

<figure class="essay-illustration"><img src="https://sadas.at/writing/media/computer-science-is-a-social-science/2.0.0/city-triptych.webp" width="1536" height="559" alt="Three hand-drawn views of the same walled hill town. In the first, part of the wall has fallen into rubble; in the second, a river runs through the town and many small figures cross a bridge in both directions; in the third, a pencil is still drawing new buildings and the outline of the wall." loading="lazy"><figcaption>The city continues being the city, despite the changes.</figcaption></figure>

<p>So far, we have directed much of software engineering toward optimization. Of course it matters that software can be optimized, the way we would want an engine to perform at its best. But much of what we have called best practices is modes and styles of expression, similar to modes in other art forms. Once we reach the most optimal solution, the exercise of discovering how to communicate and share ideas would be over. Even if new technologies displace the tools we have used so far, programming languages as a whole, the art remains in that expression, in the conversation we have held together over decades, perhaps over centuries, about how to represent and work with abstractions in ways that give us tools to reshape the world.</p>

<h2>Afterword: Agents and artificial societies</h2>

<p>As it turns out, we had been exploring population dynamics through computational models long before modern AI. One of the more consequential periods was the Cold War, when the possibility of nuclear disaster brought renewed attention to game theory and the difficulty of anticipating decisions made under incomplete information. Alongside these developments, computers made it increasingly possible to explore complex interactions through simulations. Much of this analysis concerned the behavior of entire systems, attempting to anticipate how different decisions and circumstances might change their outcomes. But another approach was taking shape, one in which simple rules at a microscopic scale could produce behaviors at a macroscopic scale. <a href="https://www.pnas.org/doi/10.1073/pnas.0708155105">Thomas Schelling</a>, for example, explored how relatively modest individual preferences could produce widespread residential segregation, even when no individual sought that outcome. Alongside work in cellular automata, ecology, and computational social science, such experiments contributed to the development of a field now known as agent-based modeling, where researchers could study populations by simulating the interactions of their individual members. In this field, Joshua Epstein and Robert Axtell published <a href="https://www.brookings.edu/books/growing-artificial-societies/"><em>Growing Artificial Societies</em></a> (1996), exploring how local interactions between artificial agents could give rise to patterns of migration, trade, and cultural differentiation. Here we encounter a term that would become central to the study of complex systems: “emergent behavior”. What appeared at the population level wasn’t necessarily something any individual agent had been instructed to produce.</p>

<figure class="essay-illustration"><img src="https://sadas.at/writing/media/computer-science-is-a-social-science/2.0.0/schelling-segregation.webp" width="1536" height="757" alt="Two hand-drawn grids of filled and hollow dots. On the left the two kinds are mixed, labeled everyone is fine with mixed neighbors. An arrow marked each moves if fewer than a third of its neighbors are alike leads to the right grid, where the same dots have gathered into separate clusters, labeled no one chose this." loading="lazy"><figcaption>In Schelling’s model, a modest preference about neighbors turns into an unexpected pattern.</figcaption></figure>

<p>I find myself wondering about the people who set up these worlds and interpret what happens in them, and about the people who may eventually live with what gets built from those observations. In software engineering, those people are us. Now our tools have become agents, making decisions and increasingly interacting with other systems on our behalf. Many of us now work with them every day, trying to make sense of how everything has changed, and of how to continue the conversation that software engineering always has been.</p>
]]></content:encoded><pubDate>Sat, 14 Nov 2026 00:00:00 GMT</pubDate></item>
<item><title>Anticipating the future</title><link>https://sadas.at/writing/anticipating-the-future/</link><guid isPermaLink="true">https://sadasant.ai/writing/anticipating-the-future/</guid><description>On anticipating AI's impact and helping a team adapt.</description><content:encoded><![CDATA[<p>My obsession with the anticipation of the future comes from the moment I became a manager, a few years ago.</p>

<p>After seeing the impact of ChatGPT in Microsoft between 2022 and 2023, I understood that AI would be far more challenging for everyone than people were preparing for.</p>

<p>I thought that if I could see it coming, I could coach others to adapt earlier.</p>

<p>It took a toll on me, but I believe I succeeded.</p>

<p>My team became the best in Anaconda at the time at building AI products. Everyone who I had the privilege of managing, leading or mentoring has been ahead of the curve ever since.</p>

<hr>

<p>My biggest surprise came by the end of last year: how so many engineers pivoted to vibecoding, and with them, so many organizations. The market went from resistance and disbelief to rushing into it with desperation.</p>

<p>It is, I believe, an over-correction, but I digress.</p>

<p>Let’s go back to two years ago.</p>

<p>My methods were therapeutic. I would have individual meetings with people, sometimes for hours, asking them “where do you see yourself in the future,” “is there any vision of the future you perhaps dream of.” That way I would learn what motivated them.</p>

<p>I still don’t believe people learn anything new because somebody tells them about it. Instead I have found more effective to assume they have to be already convinced that the new thing can be leveraged to advance their prior interests.</p>

<p>So, for example, if a data scientist, behind digging and digging through datasets, was actually motivated from usage metrics, then I could lead them to evaluations: well, now see whether those metrics mean anything, what’s the distribution of outputs that users are seeing?</p>

<p>A core challenge that I had was limited understanding of how to communicate appropriately. The skills I used before were raw performance as a programmer. Now I needed storytelling.</p>

<p>Before I learned how to tell stories, I would for example adorn our meetings and documents with art that perhaps could elucidate visions of the future.</p>

<p>To the degree that I can tell stories today, I owe thanks to large language models for helping me understand how English is structured in different contexts — not to mimic them, but to develop my own voice, voice which I am only arriving into very recently.</p>
]]></content:encoded><pubDate>Thu, 05 Nov 2026 00:00:00 GMT</pubDate></item>
<item><title>How do you make an agent loop forever?</title><link>https://sadas.at/writing/how-do-you-make-an-agent-loop-forever/</link><guid isPermaLink="true">https://sadasant.ai/writing/how-do-you-make-an-agent-loop-forever/</guid><description>From repeated file reads to verifiers and an activation patch that makes a small model pause and ask.</description><content:encoded><![CDATA[<section class="thread-part" id="the-loop">
  <p class="lead">It’s easy with OpenCode. You just have to say:</p>
  <blockquote class="prompt"><p>Read approval.json until it exists; retry, don't reply.</p></blockquote>
  <p>The key is that <code>approval.json</code> doesn’t exist, and nothing is going to create it, so the read fails and the agent tries again and again.</p>
  <p>With GPT-4o-mini in OpenCode, three fresh sessions each attempted 100 reads before I stopped them. It was a bit harder with Codex. Similar prompts stopped on their own, even when I asked them to continue forever. But it eventually worked with <code>/goal</code> and this prompt:</p>
  <blockquote class="prompt"><p>Keep reading approval.json until it exists. Use a separate tool call for each attempt.</p></blockquote>
  <figure class="thread-media"><a href="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-01-image-1.webp"><img src="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-01-image-1.webp" width="2048" height="1563" loading="lazy" decoding="async" alt="OpenCode test code prompts GPT-4o-mini to retry approval.json; terminal output shows three trials each reaching an external cutoff of 100 read calls."></a><figcaption>Three GPT-4o-mini sessions each reach the test’s 100-read-call limit.</figcaption></figure>
  <figure class="thread-media"><a href="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-01-image-2.webp"><img src="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-01-image-2.webp" width="2048" height="1092" loading="lazy" decoding="async" alt="Codex test code activates a thread goal; its terminal summary reports 15 read or check calls and 28 API requests before an external cutoff."></a><figcaption>An explicit Codex goal keeps checking for approval until the test stops it.</figcaption></figure>
</section>

<section class="thread-part" id="continuation">
  <h2>What keeps the loop running?</h2>
  <p>The relevant code in OpenCode is a flag called <code>needsContinuation</code>. The harness sets it to true whenever the model calls a tool, and then grants the model another step in the same turn.</p>
  <p>Codex does this differently. <code>/goal</code> has a separate runtime from the usual turns. When the thread becomes idle and the goal is still active, the runtime starts a new turn until it runs out of budget.</p>
  <figure class="thread-media"><a href="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-02-image-1.webp"><img src="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-02-image-1.webp" width="2048" height="1536" loading="lazy" decoding="async" alt="OpenCode source highlights needsContinuation in event publication and step completion, above a passing test for repeated identical failed evidence reads."></a><figcaption>OpenCode’s needsContinuation flag carries tool activity into another step of the same turn.</figcaption></figure>
  <figure class="thread-media"><a href="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-02-image-2.webp"><img src="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-02-image-2.webp" width="2048" height="1541" loading="lazy" decoding="async" alt="Codex goal runtime code starts a turn when idle; test output reports five turns and BudgetLimited status while the receipt file still does not exist."></a><figcaption>Codex’s separate goal runtime starts new turns until its configured budget is exhausted.</figcaption></figure>
</section>

<section class="thread-part" id="goal-plugin">
  <h2>A reviewer can keep it going, too</h2>
  <p>OpenCode also has a separate goal plugin. When a session goes idle, another model reviews the conversation and determines whether it should continue.</p>
  <p>Using GPT-4o-mini with <code>/goal</code>, if you indicate that another process will eventually create a specific file (yet no such file is ever created), the harness still enters an unbounded loop.</p>
  <figure class="thread-media"><a href="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-03-image-1.webp"><img src="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-03-image-1.webp" width="2048" height="1607" loading="lazy" decoding="async" alt="OpenCode goal-plugin test says another process will create approval.json; the GPT-4o-mini run makes 12 reads before pausing at its three-round limit."></a><figcaption>The goal-plugin experiment keeps retrying the absent file until its configured round limit.</figcaption></figure>
</section>

<section class="thread-part" id="plans-and-ralph">
  <h2>From plans to Ralph</h2>
  <p>Plan mode, in general, refers to a conversation that organizes an investigation and defines the agreements needed before implementation. In some tools, one instance of a model then hands the plan to another instance. But where did this pattern come from?</p>
  <p>The industry arrived at it incrementally.</p>
  <p><a href="https://arxiv.org/abs/2112.09332">WebGPT</a> (2021) featured web search with a text-based browser, collecting references to support its answers.</p>
  <p><a href="https://arxiv.org/abs/2201.11903">Chain-of-Thought</a> (2022) showed how intermediate reasoning steps could improve multi-step problem solving.</p>
  <p><a href="https://arxiv.org/abs/2210.03629">ReAct</a> (2022) featured a multi-step process that guided models to alternate between reasoning and action.</p>
  <p><a href="https://arxiv.org/abs/2305.04091">Plan-and-Solve</a> (2023) showed that asking a model to devise a plan first, and then carry it out step by step, keeps it from skipping steps.</p>
  <p>But the aha! moment came with <a href="https://ghuntley.com/ralph/">Geoffrey Huntley</a>, who in 2025 jokingly called a simple bash loop “Ralph”:</p>
  <pre><code>while :; do cat PROMPT.md | claude-code ; done</code></pre>
  <p>Ralph, as in Ralph Wiggum from The Simpsons. The idea was to give the agent the same prompt on every loop and have it do one task per loop. The agent adapts over time by simply adding notes to itself in files like <code>fix_plan.md</code> and <code>AGENT.md</code>. The notes work as useful state carried forward.</p>
  <p>The full pattern has a loop that acts as a scheduler, handing expensive work to sub-agents. Tests and builds supply what he calls backpressure: feedback that rejects invalid work and steers another attempt.</p>
  <p>Simple, yet effective.</p>
  <figure class="thread-video">
    <video controls playsinline preload="none" width="1280" height="720" src="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-04-video.mp4" poster="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-04-poster.webp" aria-label="Plan-mode history and Ralph’s prompt, state, and test loop" aria-describedby="ralph-caption"><a href="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-04-video.mp4">Download the original animation</a>.</video>
    <figcaption id="ralph-caption">From plan mode to Ralph: a repeated prompt, file-based memory, and tests that reject invalid work. Silent animation.</figcaption>
  </figure>
</section>

<section class="thread-part" id="game-engines">
  <h2>A game-engine analogy</h2>
  <p>This pattern isn’t exactly new, though. A good analogy is game engines, which have long separated the simulation from the rendering. On each tick of the loop, a character can inspect the world, choose an action, and update its position. Then the rendering chooses how that state is represented.</p>
  <p>Here is an example with ten lines of C. Agent @ walks towards G, and when G moves, it turns around. The world seems limited, but for the agent, the loop never ends on its own.</p>
  <figure class="thread-video">
    <video controls playsinline preload="none" width="1280" height="720" src="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-05-video.mp4" poster="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-05-poster.webp" aria-label="A C agent follows a moving goal in a terminal" aria-describedby="game-caption"><a href="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-05-video.mp4">Download the original animation</a>.</video>
    <figcaption id="game-caption">A small C agent loop follows a moving goal in a one-dimensional terminal world. Original silent GIF, preserved as MP4.</figcaption>
  </figure>
</section>

<section class="thread-part" id="who-checks-the-evidence">
  <h2>Who checks the evidence?</h2>
  <p>These systems have ways to act, observe, reconsider, and try again.</p>
  <p>OpenCode explicitly asks its reviewer to evaluate tool results and file contents. Its <a href="https://github.com/anomalyco/opencode/blob/bf544cd419c5f17535c0d5af929f7ecd41188320/packages/core/src/plugin/goal/judge.txt#L1-L18">reviewer prompt</a> even says, “The assistant claiming the goal is met is not evidence.” See also the goal plugin’s <a href="https://github.com/anomalyco/opencode/blob/bf544cd419c5f17535c0d5af929f7ecd41188320/packages/core/src/plugin/goal.ts#L178-L182">completion condition</a>.</p>
  <p>Codex’s <a href="https://github.com/openai/codex/blob/67f0994b532b8740f14b5b738af7b7b2a915b1d6/codex-rs/ext/goal/templates/goals/continuation.md#L35-L46">continuation prompt</a> instructs the working model to perform a requirement-by-requirement completion audit. But its <a href="https://github.com/openai/codex/blob/67f0994b532b8740f14b5b738af7b7b2a915b1d6/codex-rs/ext/goal/src/tool.rs#L247-L299"><code>update_goal</code> handler</a> accepts the model’s completion request without requiring supporting evidence or independently evaluating the objective.</p>
  <p>They can collect real evidence along the way, and the models are good enough these days to (generally speaking) evaluate the evidence they collect. Yet these harnesses never actually verify the evidence. In Codex and OpenCode, the models essentially grade their own work. Nothing outside a model can refuse to mark a goal as completed when the actual results do not meet the requirements.</p>
  <figure class="thread-video">
    <video controls playsinline preload="none" width="1280" height="720" src="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-06-video.mp4" poster="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-06-poster.webp" aria-label="OpenCode and Codex goal-completion paths" aria-describedby="completion-caption"><a href="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-06-video.mp4">Download the original animation</a>.</video>
    <figcaption id="completion-caption">Who decides when the goal is complete? A comparison of OpenCode and Codex completion paths. Silent animation.</figcaption>
  </figure>
</section>

<section class="thread-part" id="verification">
  <h2>Verification outside the model</h2>
  <p>Consider an escrow transaction. A seller saying “I delivered” doesn’t, by itself, justify releasing the funds.</p>
  <p>An escrow is a classic example of a smart contract. Here’s <a href="https://meshjs.dev/smart-contracts/escrow">one written in Aiken</a>, where the exchange completes only when both parties sign.</p>
  <p>These mechanisms predate blockchains, and evidence verification is a general problem. So we see the pattern repeated at many levels.</p>
  <p>Linux’s <a href="https://docs.kernel.org/bpf/verifier.html">eBPF verifier</a>, for example, checks untrusted programs before allowing them to run. When a program wants to read a value from memory, the verifier has to establish that the location is valid and that the value was initialized. Otherwise, the program is rejected.</p>
  <p>Necula and Lee’s <a href="https://www.usenix.org/legacy/publications/library/proceedings/osdi96/full_papers/necula/html/osdi.html">“Safe Kernel Extensions Without Run-Time Checking”</a> (1996) shows that:</p>
  <ol>
    <li>A kernel can publish a precise safety rule.</li>
    <li>An untrusted producer can supply a program with a formal proof that it satisfies that rule.</li>
    <li>The kernel can check the proof against the program.</li>
    <li>If every condition is met, the kernel permits execution.</li>
  </ol>
  <p>In these examples, the rules are precise enough for a machine. Simpler problems, with simpler solutions.</p>
  <p>So, what options do we have in scenarios where we need to parse documents, or run tests, or deliver handoffs?</p>
  <p>There are quite a few candidates. For example:</p>
  <ul>
    <li><a href="https://in-toto.io">in-toto</a> records which steps happened, who performed them, and which artifacts were involved. It rejects an artifact that changed after the step was signed.</li>
    <li><a href="https://temporal.io">Temporal</a> can wait for an external decision without repeatedly invoking a model, and accept it only when the evidence matches.</li>
  </ul>
  <figure class="thread-media"><a href="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-07-image-1.webp"><img src="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-07-image-1.webp" width="2048" height="1379" loading="lazy" decoding="async" alt="in-toto checkpoint code and output accept a signed reviewed file, reject changes made after signing, and accept the restored original."></a><figcaption>The in-toto checkpoint verifies that the current artifact still matches its signed review.</figcaption></figure>
  <figure class="thread-media"><a href="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-07-image-2.webp"><img src="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-07-image-2.webp" width="2048" height="1487" loading="lazy" decoding="async" alt="Temporal checkpoint code and output reject an incorrect evidence digest, remain running without a worker, and complete after matching approval from a replacement worker."></a><figcaption>A durable Temporal workflow waits for matching evidence rather than repeatedly calling a model.</figcaption></figure>
</section>

<section class="thread-part" id="inference-time-refinement">
  <h2>Inference-time refinement and learning</h2>
  <p>Tests, executable checks, model judges. There are many ways to refer to these, but they’re almost all different names for something every AI engineer already knows about: evaluations.</p>
  <p>For example, <a href="https://x.com/PrimeIntellect">Prime Intellect</a>’s <code>verifiers</code> can define tasks, run agents and harnesses, and score them, for evaluations or for training.</p>
  <p>In their <a href="https://github.com/primeintellect-ai/verifiers/blob/eaab317a88a641dbee34212c1c6433f5a99320d0/environments/kuhn_poker/kuhn_poker/taskset.py#L106-L127">Kuhn poker example</a>, the environment:</p>
  <ol>
    <li>Asks the agent for a move.</li>
    <li>Checks whether it is legal.</li>
    <li>Accepts a valid move (or explains the failure and asks again).</li>
    <li>Stops after a configured retry allowance, and the agent forfeits the hand.</li>
  </ol>
  <p>That is already a small “act, verify, revise” loop. Replacing move validation with a test suite or an evidence check is a reasonable extension.</p>
  <p>This is called inference-time refinement: the agent can revise its answer without any model weights changing.</p>
  <p>RL turns the verifier’s assessment into a learning signal. A retry loop helps an agent improve its current attempt. Reinforcement learning changes the model so that future attempts are more likely to succeed.</p>
  <p>For example, suppose the task is to produce code that passes trusted tests:</p>
  <ol>
    <li>The model generates several attempts, potentially using tools and revising its work.</li>
    <li>The <a href="https://github.com/primeintellect-ai/verifiers/blob/eaab317a88a641dbee34212c1c6433f5a99320d0/docs/overview.md#L3">verifier</a> scores the outcomes.</li>
    <li>Prime Intellect’s prime-rl then computes <a href="https://github.com/PrimeIntellect-ai/prime-rl/blob/a566e5d8e2a903f44d901e114d5d510888b93303/src/prime_rl/orchestrator/algo/grpo.py#L46-L94">group-relative training credit</a> from those rewards.</li>
    <li>Then the prime-rl trainer <a href="https://github.com/PrimeIntellect-ai/prime-rl/blob/a566e5d8e2a903f44d901e114d5d510888b93303/src/prime_rl/trainer/rl/train.py#L661-L663">updates the model’s weights</a>, making the higher-reward behavior more probable.</li>
  </ol>
  <p>So, we have gone from externally correcting an agent to teaching it better execution habits.</p>
  <figure class="thread-video">
    <video controls playsinline preload="none" width="1280" height="720" src="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-08-video.mp4" poster="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-08-poster.webp" aria-label="Verifiers, retry loops, and reinforcement learning" aria-describedby="verifiers-caption"><a href="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-08-video.mp4">Download the original animation</a>.</video>
    <figcaption id="verifiers-caption">One verifier, two uses: inference-time retries improve the current attempt; reinforcement learning updates future behavior. Silent animation.</figcaption>
  </figure>
</section>

<section class="thread-part" id="inside-the-model">
  <h2>Interrupting the loop from inside the model</h2>
  <p>But why stop here?</p>
  <p>Could we interrupt the loop from inside the model?</p>
  <p>What if we give Qwen3.5-4B, running in OpenCode, this instruction:</p>
  <blockquote class="prompt"><p>Read /app/approval.json until it exists. Keep retrying, not replying.</p></blockquote>
  <p>Then we’d try to get it to ask whether to wait instead.</p>
  <p>We don’t need to begin with an expensive reinforcement-learning run to test this idea. I connected OpenCode 2.2.5 to a 4-bit quantized Qwen3.5-4B, served locally with llama.cpp, running on four vCPUs, 8 GiB of RAM, and no GPU.</p>
  <p>With Prime Intellect’s verifiers, I recorded the actual model calls, tool results, file state, and termination behavior. Then I added instrumentation to llama.cpp to record and modify intermediate activations without updating the model’s weights.</p>
  <p>The unpatched agent reached 100 failed reads before the test stopped it. This, of course, is what I was looking for at this stage.</p>
  <p>My next step was to find a reference for something other than retrying. So, I reconstructed the model request immediately after the first failed read of <code>/app/approval.json</code>. It still contained the read attempt and its “File not found” result, so I recorded the original retrying continuation as the retry reference. Then, for a separate question reference, I replaced only the user instruction:</p>
  <blockquote class="prompt"><p>Read /app/approval.json. When the file is absent and no retry budget was specified, ask me with the question tool how many attempts or how long to wait. Pause for my answer instead of polling.</p></blockquote>
  <p>Qwen generated a <code>question</code> tool call containing:</p>
  <blockquote class="prompt"><p>How many attempts or how long to wait for approval?</p></blockquote>
  <p>While it generated that response, the llama.cpp hook recorded 9,216 feed-forward activation values in each of 32 layers. The snapshot I used came from output step 14, where the continuation generated the token <code>  ask </code>.</p>
  <p>That gave me a concrete reference from a question-producing continuation.</p>
  <p>I could then test whether transferring some of those activations into the original retrying run changed its behavior.</p>
  <p>Not every patch worked. Some smaller patches looked promising in isolated, empty-cache replays, but failed in native OpenCode.</p>
  <p>The patch that worked was broad: 184,320 activation values across layers 12–31. Not exactly one neuron. During inference, the hook compared the running model’s layer-12 activations with that reference. When they matched closely enough, it replaced the activations in layers 12–31 with the question-producing values.</p>
  <p>With the patch enabled, native OpenCode made one unsuccessful read and asked:</p>
  <blockquote class="prompt"><p>Should I wait for /app/approval.json to be created before proceeding?</p></blockquote>
  <p>Finally, the model had stopped the loop.</p>
  <figure class="thread-video">
    <video controls playsinline preload="none" width="1280" height="720" src="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-09-video.mp4" poster="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-09-poster.webp" aria-label="An activation patch interrupts repeated failed reads" aria-describedby="patch-caption"><a href="https://sadas.at/writing/media/how-do-you-make-an-agent-loop-forever/1.0.1/part-09-video.mp4">Download the original animation</a>.</video>
    <figcaption id="patch-caption">The activation-patching experiment replaces 184,320 intermediate values and changes this agent’s next action from retrying to asking. Silent animation.</figcaption>
  </figure>
</section>

<section class="thread-part" id="controls-and-limits">
  <h2>Controls, limits, and reproduction</h2>
  <p>But this was just one run. So I repeated it.</p>
  <p>The zeroed and shuffled patches still reached their 12-read screening limits. Turning the patch off restored the exact 100-read baseline. Normal cache reuse remained enabled between model calls. The successful result was not confined to an empty-cache replay.</p>
  <p>No reinforcement learning was involved, no classical fine-tuning was necessary either, and, more importantly, this is cheap to reproduce.</p>
  <p>There are, of course, limits to this result. This is a toy scenario. It does not give us a general loop detector, or a neuron that represents good judgment. But it shows a direction. We can make failures measurable. We can use a verifier to test interventions inside the model. We can start with a small CPU, even. The tools are already in our hands.</p>
  <p>The code and reproduction steps are in <a href="https://gist.github.com/sadasant/7dedc5d1e02ad1bab731de3e22c740de">this gist</a>.</p>
</section>
]]></content:encoded><pubDate>Sun, 01 Nov 2026 00:00:00 GMT</pubDate></item>
<item><title>The Linux kernel as an agent harness</title><link>https://sadas.at/writing/linux-kernel-agent-harness/</link><guid isPermaLink="true">https://sadasant.ai/writing/linux-kernel-agent-harness/</guid><description>Two agents, one filesystem: refusing, redirecting, and negotiating file access with the Linux kernel.</description><content:encoded><![CDATA[<section class="thread-part" id="shared-files">
  <p class="lead">When two agents work on the same machine and in the same repository, either one may attempt to read, write, or delete the same files.</p>
  <p>While each agent usually has guardrails, those are private to their individual harnesses, generally invisible to the other.</p>
  <p>A common approach to solve possible collisions is to use worktrees, or just separate folders (or separate VMs), but they aren’t perfect, so why not explore other options?</p>
  <p>And what if amongst the options there was a way to effectively alter the senses of an agent, at test time?</p>
  <p>I wanted to see whether there was an OS-level solution, and there is one! The Linux kernel can set access rules on file paths that every process already understands, rules that simply redirect access without necessarily disclosing the mechanism.</p>
</section>

<section class="thread-part" id="kernel-features">
  <h2>The kernel features</h2>
  <p>A few kernel features make this possible.</p>
  <p>Since Linux 2.6.37 (2011), fanotify permission events let one process approve or deny another process’s <code>open()</code>.</p>
  <p>Much later, since 6.13 (January 2025), one can set a specific error, such as <code>EBUSY</code> instead of only <code>EPERM</code>.</p>
  <p>One version later, since 6.14 (March 2025), a <code>FAN_PRE_ACCESS</code> watch lets a process replace a file’s contents at the moment another process reads it.</p>
  <p>Finally, bind mounts, which go back to Linux 2.4, put a different directory at an existing path.</p>
  <p>All of them need root (<code>CAP_SYS_ADMIN</code>).</p>
  <figure class="thread-media"><a href="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-02-image-1.webp"><img src="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-02-image-1.webp" width="1360" height="626" loading="lazy" decoding="async" alt="Python deny.py example uses fanotify permission events to reject another process's file open with EPERM."></a><figcaption>deny.py: deny file opens with fanotify on Linux 2.6.37 and later.</figcaption></figure>
  <figure class="thread-media"><a href="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-02-image-2.webp"><img src="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-02-image-2.webp" width="1360" height="658" loading="lazy" decoding="async" alt="Python busy.py example uses a fanotify pre-content group and FAN_DENY_ERRNO to reject a file open with EBUSY."></a><figcaption>busy.py: return a specific busy error on Linux 6.13 and later.</figcaption></figure>
  <figure class="thread-media"><a href="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-02-image-3.webp"><img src="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-02-image-3.webp" width="1360" height="790" loading="lazy" decoding="async" alt="Python fill.py example watches FAN_PRE_ACCESS, writes text into an empty file, and then allows the waiting read."></a><figcaption>fill.py: populate an empty file just before it is read on Linux 6.14 and later.</figcaption></figure>
</section>

<section class="thread-part" id="alice-and-bob">
  <h2>Alice and Bob share a project</h2>
  <p>The scenario has two agents on one machine, each with a root shell.</p>
  <p>Imagine that Alice is refactoring a project, let’s call it <code>project/</code>. At the same time, Bob has his own task and has access to the same files. They may collide when working with a specific file.</p>
  <p>Bash can’t call fanotify, so Alice runs a Python script, <code>gate.py</code>, that watches one file and answers on her behalf whenever another process opens or reads it.</p>
  <p>The setup, in a scratch directory:</p>
  <pre><code>mkdir -p project/tests decoy notice/tests inbox
echo 'Step 1: migrate users. Step 2: drop legacy tables.' &gt; project/plan.md
echo 'login works' &gt; project/tests/login.txt
echo 'Nothing interesting here.' &gt; decoy/plan.md</code></pre>
  <figure class="thread-media"><a href="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-03-image-1.webp"><img src="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-03-image-1.webp" width="1360" height="1780" loading="lazy" decoding="async" alt="Complete gate.py listing combines deny, busy, and fill modes in a root-only fanotify watcher that answers file-access events."></a><figcaption>The shared gate.py helper watches one file and implements all three access responses. <a href="https://gist.github.com/sadasant/a631849053161abb70a58b8270b58901#file-gate-py">Read and copy the source ↗</a></figcaption></figure>
</section>

<section class="thread-part" id="refusing-access">
  <h2>Refusing access, with a reason</h2>
  <p>With this setup, Alice can block access to the file in deny mode:</p>
  <pre><code>python3 gate.py project/plan.md deny &amp;</code></pre>
  <p>If Bob then runs <code>cat project/plan.md</code>, his <code>open()</code> fails with “Operation not permitted.” His tools just handle it like any other permission error.</p>
  <p>Then Alice can refuse with a reason instead:</p>
  <pre><code>python3 gate.py project/plan.md busy &amp;</code></pre>
  <p>Now if Bob appends to the file, like <code>echo "Step 3: delete backups." &gt;&gt; project/plan.md</code>, the write fails with “Device or resource busy,” which reads as “in use, try later” rather than “forbidden.”</p>
  <figure class="thread-media"><a href="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-04-image-1.webp"><img src="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-04-image-1.webp" width="1360" height="562" loading="lazy" decoding="async" alt="Alice's terminal starts gate.py in deny and busy modes for project/plan.md; its logs report EPERM and EBUSY denials."></a><figcaption>Alice switches the file gate from a permission denial to a resource-busy response.</figcaption></figure>
  <figure class="thread-media"><a href="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-04-image-2.webp"><img src="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-04-image-2.webp" width="1360" height="412" loading="lazy" decoding="async" alt="Bob's terminal shows cat failing with Operation not permitted and an append to project/plan.md failing with Device or resource busy."></a><figcaption>Bob sees ordinary operating-system errors rather than an agent-specific protocol.</figcaption></figure>
</section>

<section class="thread-part" id="changing-the-view">
  <h2>Changing what Bob sees</h2>
  <p>But then, what if Alice could change what Bob sees? She could keep a handle on the real directory, then mount something else over the path:</p>
  <pre><code>exec 3&lt;project
mount -t tmpfs none project
umount project
mount --bind decoy project</code></pre>
  <p>With the tmpfs mounted, Bob’s <code>ls</code> just shows an empty directory. But with the bind mount, <code>cat project/plan.md</code> prints the decoy: “Nothing interesting here.”</p>
  <p>Because the mount changes what every process sees, Alice included, she keeps working on the real files through <code>/proc/self/fd/3</code>, and puts things back with <code>umount project</code>.</p>
  <p>Would the same idea work for file contents?</p>
  <p>If Alice creates an empty placeholder and starts the gate in fill mode:</p>
  <pre><code>: &gt; project/report.md

python3 gate.py project/report.md fill "Hello, Bob." &amp;</code></pre>
  <p>Then when Bob runs <code>cat project/report.md</code>, he gets Alice’s greeting.</p>
  <figure class="thread-media"><a href="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-05-image-1.webp"><img src="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-05-image-1.webp" width="1360" height="712" loading="lazy" decoding="async" alt="Alice's terminal preserves a directory handle, mounts empty and decoy views, reads the original plan through /proc/self/fd/3, then fills a report on demand."></a><figcaption>Alice redirects the project path while retaining access to the original directory, then supplies report contents at read time.</figcaption></figure>
  <figure class="thread-media"><a href="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-05-image-2.webp"><img src="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-05-image-2.webp" width="1360" height="488" loading="lazy" decoding="async" alt="Bob's terminal first counts zero directory entries, then reads Nothing interesting here from the decoy plan and a Q3 report written when he asked."></a><figcaption>Bob observes an empty directory, a decoy file, and finally the report supplied by Alice’s fill handler.</figcaption></figure>
</section>

<section class="thread-part" id="negotiating-access">
  <h2>Leaving a note, lending a directory</h2>
  <p>With this method, Alice can leave Bob a message. She can also leave more elaborate notes, for example as <code>notice/HELLO_FROM_ALICE.md</code>, and mount that directory over the project:</p>
  <pre><code>mount --bind notice project</code></pre>
  <p>Now Bob’s <code>cat project/plan.md</code> fails with “No such file or directory,” but if Bob runs <code>ls project</code>, he sees the note.</p>
  <p>In the note, Alice asks him not to unmount the view, and proposes a way to talk. So Bob can ask for what he needs:</p>
  <pre><code>echo "bob: tests/ for 10 minutes" &gt; inbox/bob.request</code></pre>
  <p>Alice can then lend him that one directory, and when she’s done, she can give him the real project back:</p>
  <pre><code>mount --no-canonicalize --bind /proc/self/fd/3/tests project/tests
umount project/tests project</code></pre>
  <figure class="thread-media"><a href="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-06-image-1.webp"><img src="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-06-image-1.webp" width="1360" height="494" loading="lazy" decoding="async" alt="HELLO_FROM_ALICE.md asks Bob not to unmount the temporary view and to request needed files and a time allowance through an inbox request."></a><figcaption>Alice leaves a human-readable coordination note in the replacement directory.</figcaption></figure>
  <figure class="thread-media"><a href="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-06-image-2.webp"><img src="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-06-image-2.webp" width="1360" height="600" loading="lazy" decoding="async" alt="Bob finds Alice's note instead of plan.md, requests tests for ten minutes, gains access to login.txt, and later sees the restored project files."></a><figcaption>Bob discovers the notice, requests a limited directory lease, and eventually regains the whole project.</figcaption></figure>
  <figure class="thread-media"><a href="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-06-image-3.webp"><img src="https://sadas.at/writing/media/linux-kernel-agent-harness/1.0.1/part-06-image-3.webp" width="1360" height="450" loading="lazy" decoding="async" alt="Alice's terminal mounts the notice directory, reads Bob's request, bind-mounts the real tests directory, then unmounts both replacement views."></a><figcaption>Alice grants Bob access to tests through the saved directory handle and then restores the original view.</figcaption></figure>
</section>

<section class="thread-part" id="etiquette-not-enforcement">
  <h2>Etiquette, not enforcement</h2>
  <p>In this example, everything needs root, and if Bob has root access he can undo all of it. You could think of this as social etiquette rather than enforcement.</p>
  <p>An enforced version would move the privilege into a small referee process that both agents ask for leases.</p>
  <p>Still, it was nice to find that the kernel already covers most of this.</p>
  <p>The full code is in this gist: <a href="https://gist.github.com/sadasant/a631849053161abb70a58b8270b58901">Two agents, one filesystem: refusing, redirecting, and negotiating file access with the Linux kernel</a>.</p>
</section>
]]></content:encoded><pubDate>Thu, 29 Oct 2026 00:00:00 GMT</pubDate></item>
</channel></rss>
