<?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 Peter Saghelyi on Medium]]></title>
        <description><![CDATA[Stories by Peter Saghelyi on Medium]]></description>
        <link>https://medium.com/@psaghelyi?source=rss-d5415ac858b1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dZKvIihQf5qTQsNQF7OUXw.jpeg</url>
            <title>Stories by Peter Saghelyi on Medium</title>
            <link>https://medium.com/@psaghelyi?source=rss-d5415ac858b1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 01:22:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@psaghelyi/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[Stop Turning Your Agents into Boxes and Arrows]]></title>
            <link>https://medium.com/@psaghelyi/stop-turning-your-agents-into-boxes-and-arrows-ba9b2f79b984?source=rss-d5415ac858b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba9b2f79b984</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[logic]]></category>
            <category><![CDATA[agentic-workflow]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Peter Saghelyi]]></dc:creator>
            <pubDate>Tue, 11 Aug 2026 21:09:05 GMT</pubDate>
            <atom:updated>2026-08-14T07:50:53.914Z</atom:updated>
            <content:encoded><![CDATA[<h3>Big steps, small steps: a declarative way to orchestrate long-running agents</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bj7YB6P8x0lvAZszIxnYVQ.jpeg" /></figure><p>An agentic workflow looks simple until it becomes real. At the beginning it is only a flowchart. Plan the work. Collect the evidence. Test the controls. Report the findings. Four boxes, three arrows. Anyone can hold it in their head.</p><p>Then reality enters. If the client does not respond to the evidence request, follow up — but at most three times, then escalate to the audit lead. If the evidence arrives but covers the wrong period, request it again, with clearer criteria this time. If validation fails twice, a human has to make a judgment call: proceed with a qualified opinion, extend the fieldwork, or accept the risk. If a control test fails, notify the control owner and track the remediation. If the remediation cannot finish inside the project timeline, someone with actual authority has to approve an exception — in writing, with compensating controls documented. And if two of these things happen at once, the process must not lose track of either.</p><p>Suddenly the workflow is no longer a flowchart. It is a long-running, branching, looping process with humans in the middle and weeks of waiting between the steps. And the standard engineering response is to draw it. Every branch becomes an arrow. Every exception becomes another arrow. Every failure of a failure becomes an arrow between arrows. We call the result a workflow graph, and we tell ourselves it is rigorous because it is explicit.</p><p>I want to argue that for agentic systems this instinct is structurally wrong, and that the alternative has been sitting in programming-language textbooks for forty years: keep a short list of milestones you can defend, and inside each milestone, replace the graph with a table of rules. Precondition, actions, postcondition. Rows, not arrows.</p><p>I am using an audit as the running example because it is the least forgiving case — a regulated process where “the agent figured something out” is not an acceptable answer to “what did the system do?” But the shape is the same for an insurance claim, a loan origination, an incident response, or any process that runs for weeks and involves people who do not answer email.</p><h3>Every exception becomes an arrow</h3><p>Why does the graph fail? Three things go wrong, and they go wrong together.</p><p>It is brittle. Every newly discovered edge case is a topology change. The client sent evidence for the wrong subsidiary — a case nobody drew. Now someone has to open the diagram, splice in a node, reroute the edges around it, and redeploy the process definition. The graph treats learning as redesign.</p><p>It is opaque. A graph with a handful of nodes is a picture; a graph with two hundred is a database that happens to be rendered as a picture. Nobody reviews it. People approve it, which is not the same thing. And a workflow with N independent conditions hides up to 2^N paths — the diagram shows you the edges, never the combinations.</p><p>It is over-specified. The graph prescribes how, when the organization only cares about what. The audit methodology requires that evidence be validated before a control is tested. It does not require that validation happen in the third box from the left, after the second follow-up email and before the SLA timer fires.</p><p>Every arrow is a prediction. A workflow graph is a bet that you have foreseen every way the world can disappoint you — placed at design time, settled in production. And the failure modes compound, which is what actually kills it: a failed request after a failed follow-up, a partial delivery where three documents arrive and two are wrong, two controls failing at once with remediation deadlines that interact. In a graph, each combination needs its own explicitly wired edge, because in a graph an unhandled state is not a gap — it is a dead end.</p><p>So teams respond in one of two bad ways. They keep drawing, and the graph becomes unmaintainable. Or they give up, hand the whole process to an LLM with a long prompt, and hope. The first is rigor without adaptability. The second is adaptability without rigor. In a regulated process, an LLM improvising the methodology per session is not a feature — it is a finding.</p><p>There is a third option.</p><h3>Two altitudes</h3><p>The way out is to notice that a long-running process contains two different kinds of order, and they deserve two different tools.</p><p>At the top, there is a fixed sequence, and it is short. An audit really does go Planning → Fieldwork → Reporting → Close. A claim really does go Intake → Investigation → Decision → Settlement. These are the big steps: a linear spine of milestones, each with a human approval at the boundary. This layer changes maybe once a year, when the methodology changes. It should be deterministic, boring, and legible to a regulator.</p><p>Inside each milestone, there is no fixed sequence at all. Which evidence request gets answered first, which control test fails, which client goes quiet — none of that is knowable at design time. These are the small steps, and this is where the graph was lying to you: it drew a route through territory that has no roads.</p><p>So: big steps as a short workflow, small steps as a decision table. Call it big-step / small-step orchestration. The big steps are for the parts of the process you must be able to defend. The small steps are for the parts you cannot predict.</p><p>The names are not mine, and the borrowing is more than decorative.</p><h3>The names are stolen from formal semantics</h3><p>When programming-language theorists define what a program means, they choose an altitude — and they have named the two altitudes precisely.</p><p>Big-step semantics — Gilles Kahn called it natural semantics — relates a configuration directly to its final result: starting from this program and this state, evaluation produces this value. One judgment, written ⟨program, state⟩ ⇓ result. Everything that happens in between is deliberately invisible. The judgment is a contract, and the interior is nobody’s business.</p><p>Small-step semantics — Gordon Plotkin’s structural operational semantics — refuses the shortcut. It defines a transition relation instead: from this configuration, one rule application leads to that configuration. ⟨program, state⟩ → ⟨program′, state′⟩. A run is the chain of configurations it passes through, and every link in the chain is justified by exactly one rule that matched the shape of the current configuration.</p><p>Both describe the same execution; they answer different questions. Big-step answers what does this produce? Small-step answers what exactly can happen along the way? — and that second question is why the field needed small-step at all. A big-step judgment either concludes or it doesn’t, and when it doesn’t, the formalism cannot tell you whether the program is still working or wedged. Small-step can. It has a name for the difference: a stuck state is a configuration that is not finished, yet no rule can advance it. The celebrated progress and preservation theorems of type soundness are exactly the guarantee that well-typed programs never get stuck — every configuration is either final or some rule applies.</p><p>Pause on what a small-step semantics actually consists of: a short list of reduction rules, and nothing else. Nobody draws the calculus. The calculus — every execution the language admits — is derived from the rules, step by step, by applying whichever rule matches the configuration at hand. The rules are the definition; the behavior is a consequence.</p><p>The decision table adds nothing to this concept, and that is a boast, not an apology. Each row is a reduction rule. The only change is typographic: where logicians typeset a rule as premises stacked above a horizontal bar, a row lays the same rule out in three named columns — because audit managers, compliance reviewers, and embedding indexes all read tables more fluently than they read inference notation. The table is the rule set made explicit: easier for a human to review, easier for a machine to index and retrieve. The mathematics is unchanged; the typesetting got friendlier, and with it the audience got wider.</p><p>It also names the workflow graph’s original sin. The graph tries to draw the derived object — to enumerate the executions instead of stating the rules that generate them. The executions are combinatorial; the rules are not. That is the entire explosion, in one sentence.</p><p>Now map it onto the process. The milestone layer is a big-step judgment: input context ⇓ output context, internals invisible, the phase judged only by its contract. The decision table is a small-step transition relation: each row is a rule, the agent’s run is one rule application after another, and the chain of states is the thing you audit. And the reason you need the small-step view inside each milestone is the same reason semanticists did: in a weeks-long process, it hasn’t finished yet and it is stuck are precisely the two conditions you must never confuse.</p><p>One more theft, and the toolbox is complete. Formal semantics has three classical traditions: operational (the two altitudes above), axiomatic, and denotational. The axiomatic tradition — Hoare logic — is what gives the small-step rules their shape. Which brings us to the rows.</p><p>(The denotational tradition goes unused. Give it time.)</p><h3>Small steps: rows, not routes</h3><p>The outer layer needs little explanation, because it is deliberately unclever. Each milestone defines an input context (what must be available to begin) and an output context (what must exist before handover). The orchestrator validates that one phase’s output satisfies the next phase’s input, a human approves the transition, and the handover is an explicit context package — not a shared memory the next phase inherits by accident. That is the whole layer. Its job is to be the thing you can print out for an audit committee: these were the stages, these were the gates, this person approved each one, on this date.</p><p>Everything interesting happens one level down — in the table.</p><p>Each row of the table has three columns, and they come from Tony Hoare’s 1969 proposal for proving programs correct with triples written {P} C {Q}: if precondition P holds before executing command C, then postcondition Q holds after. The insight was that you do not need to trace every path a program can take — you only need the contract each piece honors. We borrow the structure, in natural language:</p><ul><li>Precondition — a description of a state the world can be in.</li><li>Actions — what to do about it. Not a rigid procedure; a bounded set of operations, possibly with loops and circuit breakers.</li><li>Postcondition — the “good enough” state where this row’s work is done.</li></ul><p>Each row is a self-contained rule: if the world looks like this, do these things, until the world looks like that. Here is the happy path of the fieldwork phase, three rows:</p><pre>- precondition: &gt;<br>    A control test plan exists, but no evidence has been<br>    collected for it yet.<br>  actions: &gt;<br>    Request evidence from the client. Follow up if there is<br>    no response within the SLA.<br>    Circuit breaker: three follow-ups, then stop.<br>  postcondition: &gt;<br>    An evidence package is available and linked to the<br>    control test plan.<br><br>- precondition: &gt;<br>    Evidence is available but has not been validated.<br>  actions: &gt;<br>    Run validation. Flag gaps and inconsistencies. If gaps<br>    are found, request the missing items.<br>    Circuit breaker: two re-request cycles, then stop.<br>  postcondition: &gt;<br>    Evidence is validated and assessment-ready, or the case<br>    is escalated to a human reviewer.<br><br>- precondition: &gt;<br>    Evidence is validated and the control test plan is ready.<br>  actions: &gt;<br>    Execute the control test per the plan. Record<br>    observations and results.<br>  postcondition: &gt;<br>    The control test is complete, with a pass/fail<br>    determination and a documented rationale.</pre><p>Notice what is missing: there are no arrows. No row names a next row. Row two does not know row one exists. That is not an omission — it is fidelity to the source. Reduction rules never reference one another; sequencing belongs to the derivation, not to the rules. Which row fires next is decided by what the world looks like after the last one fired, not by a pointer drawn at design time.</p><p>If you read the earlier article in this series about questionnaire logic, you have seen this move before. The important routing rule in a survey is not after question 3, go to question 8; it is ask question 8 only if the respondent has children — and once every question carries its own condition of relevance, the engine derives the flow instead of following a hand-drawn one. This is the same move, one level up. The important rule is not after collection, go to validation. It is validate whenever unvalidated evidence exists. State the conditions; let the flow emerge.</p><h3>Failure is just another row</h3><p>Here is where the table stops being a notational preference and starts paying rent.</p><p>The rows above are positive preconditions — descriptions of the world going well. But a precondition can just as easily describe the world going badly. These are negative preconditions, and their actions are remediations:</p><pre>- precondition: &gt;<br>    A PBC request was sent, and the client has not responded<br>    after all follow-ups. The circuit breaker is exhausted.<br>  actions: &gt;<br>    Escalate to the audit lead with a summary of attempts.<br>    Propose alternative evidence sources or a scope<br>    adjustment. Request a human decision.<br>  postcondition: &gt;<br>    A human has chosen a path: accept alternative evidence,<br>    adjust scope, or formally document an exception.<br><br>- precondition: &gt;<br>    Evidence was submitted, but validation found critical<br>    gaps — wrong period, missing signatures, incomplete<br>    population.<br>  actions: &gt;<br>    Prepare a gap report for the client. Re-request the<br>    specific missing items with explicit criteria.<br>    Circuit breaker: two cycles, then stop.<br>  postcondition: &gt;<br>    The gaps are resolved and evidence is resubmitted, or<br>    the case is escalated for a judgment call.<br><br>- precondition: &gt;<br>    A control test failed, the owner attempted remediation,<br>    and now reports it cannot be completed within the<br>    project timeline.<br>  actions: &gt;<br>    Assess the residual risk. Prepare an exception request<br>    with a compensating-controls analysis. Route it to the<br>    risk acceptance authority.<br>  postcondition: &gt;<br>    An exception is formally approved with compensating<br>    controls documented, or the timeline is extended.</pre><p>In a graph, every one of these would be an edge you had to draw in advance. In a table, every one of them is a row you can add afterwards. That inversion is the entire point.</p><p>And the compound failures that make graphs explode fall out for free:</p><ul><li>Retries with a different strategy. A failed action leaves the world in a new state, and that state matches a different row with a different approach. No retry edge was drawn.</li><li>Escalation chains. Repeated failure produces progressively more desperate states, which match progressively more severe rows: retry, then escalate to a senior, then summon a human with authority.</li><li>Partial success. Three documents arrived, two are wrong. The resulting state matches a row about the incomplete portion; the complete portion simply stops matching anything.</li><li>Cascading failures. A failure in one area changes states in adjacent areas, whose rows begin to match, triggering coordinated remediation nobody choreographed.</li></ul><p>In a graph, failure handling is topology. In a table, it is content.</p><h3>How the agent finds the next row</h3><p>If no row points to the next row, something has to decide which row fires. In structural operational semantics, that decision is syntactic: the applicable rule is the one whose premises match the shape of the current configuration. Our configurations are not terms of a calculus — they are states of an audit, described in prose. So the matching goes soft, and this is the part that was not possible before LLMs.</p><p>The orchestrating agent maintains a running description of the current state: accumulated context, action history, outputs collected so far. After every action, it re-evaluates — the connection between rows is indirect, mediated by the actual state of the world. Matching that state against the table happens in two steps.</p><p>Step one: semantic retrieval. The state description is used as a query against every precondition in the table, via embeddings. This returns the top K candidate rows — the preconditions that sound most like the current situation. Fast, cheap, imprecise.</p><p>Step two: LLM adjudication. The agent reads the K candidates against the full state description and decides three things: which precondition genuinely matches, using nuance that similarity scores miss (a precondition about evidence gaps and one about evidence rejection can score nearly identically while demanding different responses); whether none of them fit, which is a signal we will come back to; and whether the milestone’s overall postcondition has already been reached, in which case nothing should fire at all.</p><p>If this looks familiar, it should: it is retrieval-augmented generation applied to orchestration. The decision table is the corpus. The preconditions are the indexed documents. The current state is the query. The LLM is the reasoning layer that makes the final call. We spent two years using RAG to answer questions; the same machinery can decide what happens next.</p><p>When several rows genuinely match at once, the agent has three honest options — decompose the situation into independent sub-problems and run the rows in parallel; prioritize and handle them in order; or recognize a compound state that needs a merged plan. Reasoning about which is correct is exactly what the adjudication step is for.</p><p>One clarification, because it is the most common misreading: this is not “the LLM decides what to do.” The LLM decides which written rule applies. The rules themselves — what to do about a silent client, when a human must be summoned, how many retries are acceptable — were authored, reviewed, and versioned by people, and they sit in a flat file anyone can read. The agent’s discretion is real but narrow: it is a judge matching facts to law, not a legislator.</p><h3>You have seen this before</h3><p>Formal semantics is not the only field that arrived at this shape. Two applied disciplines converged on it independently, which is the strongest argument that the shape is right.</p><p>Business rules engines. Insurance underwriting, tax computation, and loan approval abandoned flowcharts for decision tables decades ago, for exactly our reasons: a flowchart with N conditions hides 2^N paths, while a table lays the conditions flat where a regulator can read them, an analyst can maintain them, and a missing combination is visible as a missing row. The OMG even standardized the notation (DMN). Our variation is that conditions are semantic — natural language judged by an LLM — rather than boolean. The structural benefits carry over unchanged.</p><p>Behavior trees. Game AI and robotics hit the identical wall with finite state machines: every transition had to be explicitly wired, and past a few dozen states the wiring became the system. Behavior trees replaced FSMs with modular condition-action leaves that compose without combinatorial explosion — the robot’s mission has sequential phases (navigate, pick, deliver), and within each phase, condition-action logic reacts to the world as found. Sequential spine outside, reactive rules inside: the big-step / small-step split, discovered independently by people whose agents have grippers.</p><h3>Lego, not marble</h3><p>A workflow graph is carved: touch one edge and you are re-sculpting. A decision table is assembled, and that difference compounds, because every row has the same interface — precondition in, postcondition out. Rows are bricks.</p><p>This means the table does not have to be one artifact with one author. It can be layered:</p><ul><li>A platform baseline — the vendor’s starter kit: universal tasks and the failure patterns everyone eventually hits. Evidence collection, validation, standard escalation.</li><li>An industry pack — themed expansion sets for a regulatory context: SOX testing cadence, GDPR data-handling checks.</li><li>A customer layer — the organization’s own procedures: all IT controls require CISO sign-off before close; escalate to the regional director after five business days.</li><li>Run-specific overrides — for one engagement: skip SOX rows; this is an internal review.</li></ul><p>At runtime, the layers merge into a single effective table, and the orchestrating agent neither knows nor cares which layer a row came from. Three composition behaviors fall out of the semantic matching for free:</p><p><strong>Union</strong> — rows from all layers simply coexist.<br><strong>Extension</strong> — a customer with a workflow the baseline never anticipated adds rows; nothing else changes.<br><strong>Override</strong> — a customer row with a more specific precondition naturally outcompetes a broader baseline row, because the more specific description is the closer semantic match.</p><p>The baseline row says a test plan exists but no evidence has been collected; the customer row says a test plan exists for a SOX-critical control but no evidence has been collected — and prescribes their SOX template, their CC list, their five follow-ups, their coordinator. When the control is SOX-critical, the customer row wins the match. When it is not, the baseline quietly handles it.</p><p>No forking — customers never clone-and-modify the baseline, so vendor improvements arrive without merge conflicts. And a refined table is exportable: an organization that has tuned its rows for a specific audit type can share them as a layer for someone else to compose on top of. Process knowledge becomes a library, not a diagram in one architect’s head.</p><h3>The table learns</h3><p>A graph fails silently: execution reaches a state nobody drew, and the process is simply wedged, in a way that produces a ticket. The table fails legibly, and its two failure modes are the two maintenance signals — semantics already named both.</p><p><strong>Gaps.</strong> Sometimes the adjudication step concludes that none of the top K candidates describe the current state. This is a stuck state, in Plotkin’s exact sense: the run is not finished, and no rule applies. But where a stuck program can only crash, a stuck process can confess. The agent escalates to a human and logs the full state description alongside the rejected candidates. A table author reads the log and writes the row that was missing: the precondition that would have matched, the actions, the expected postcondition. The unknown unknowns surface one at a time, each arriving with its own documentation. A gap is a row you have not written yet.</p><p><strong>Overlaps.</strong> Sometimes retrieval returns several preconditions with nearly identical scores and the LLM struggles to choose — or worse, chooses differently on different runs. Two applicable rules with different outcomes make a transition relation nondeterministic; in a calculus that can be a design choice, in an audit it is a bug. The fixes are editorial, not architectural: merge the rows if they were really one situation; sharpen the preconditions with discriminating detail the matcher can grip (<em>rejected for format issues</em> versus rejected for completeness issues); or split with a guard if two genuinely different situations happen to sound alike.</p><p>Run this loop for a while and the table converges toward its own informal progress theorem: every realistic state either satisfies the milestone’s postcondition or matches exactly one row. Type soundness for a business process — approached asymptotically, enforced editorially.</p><p>And notice who runs the loop. The fixes are edits to natural-language descriptions, so the people evolving the system’s behavior are audit managers and risk officers, not developers. The domain experts maintain the domain logic. The engineers maintain the engine.</p><h3>From arrows to rows</h3><p>For decades we have encoded long-running processes as graphs, because graphs feel rigorous: every path drawn, every transition explicit. But for processes executed by agents in a world that refuses to follow the diagram, the graph’s explicitness is exactly its weakness — it demands that we predict, at design time, every way reality can deviate, and it punishes every prediction we miss with a dead end.</p><p>Programming-language theory needed both altitudes to say what programs mean: one judgment that states the contract, one transition relation that owns everything that can happen along the way. A process run by agents needs the same pair — stated the same way: not by drawing every execution, but by writing the rules each execution is derived from. A short spine of milestones you can defend to a regulator, each judged big-step — context in, context out. Inside each, a flat table of small-step rules: if the world looks like this, do these things, until it looks like that. Failures as rows. Customization as layers. Maintenance as editing prose. And an LLM doing the one job it is actually suited for in a regulated process — not inventing the rules, but reading the world and finding the rule that applies.</p><p>From arrows to rows. From routes to rules. From flowcharts to contracts.</p><h3>Notes and further reading</h3><p>The big-step / small-step names come from operational semantics:</p><ul><li>G. D. Plotkin, A Structural Approach to Operational Semantics, Report DAIMI FN-19, Computer Science Department, Aarhus University, 1981; reprinted in the Journal of Logic and Algebraic Programming, 60–61, 2004. — The origin of small-step (structural operational) semantics. Plotkin’s own retrospective, <a href="https://www.sciencedirect.com/science/article/pii/S1567832604000268"><em>The Origins of Structural Operational Semantics</em></a>, tells the history.</li><li>G. Kahn, <a href="https://link.springer.com/chapter/10.1007/BFb0039592"><em>Natural Semantics</em></a>, STACS ’87, LNCS 247, Springer, 1987. — The origin of big-step (natural) semantics.</li><li>A. K. Wright and M. Felleisen, A Syntactic Approach to Type Soundness, Information and Computation, 115(1), 1994. — The progress-and-preservation method: well-typed programs never get stuck. B. C. Pierce, Types and Programming Languages, MIT Press, 2002, is the standard textbook treatment.</li><li><a href="https://softwarefoundations.cis.upenn.edu/plf-current/Smallstep.html"><em>Software Foundations</em>, Vol. 2, “Smallstep”</a> — a free, hands-on introduction to small-step semantics, stuck states, and why the small-step view exists at all.</li></ul><p>The row structure comes from axiomatic semantics:</p><ul><li>C. A. R. Hoare, An Axiomatic Basis for Computer Programming, Communications of the ACM, 12(10), 1969. — The original {P} C {Q} triples and the composition rule this model relaxes into state-mediated matching.</li></ul><p>Decision tables as a replacement for control-flow graphs have a long history in business rules:</p><ul><li>Object Management Group, <a href="https://www.omg.org/dmn/"><em>Decision Model and Notation (DMN)</em></a> — the standardized modern form of business decision tables.</li></ul><p>Behavior trees are the closest architectural cousin — reactive condition-action rules under a sequential mission spine:</p><ul><li>M. Colledanchise and P. Ögren, Behavior Trees in Robotics and AI: An Introduction, CRC Press, 2018 (also arXiv:1709.00084). — Including the history of why game AI abandoned finite state machines.</li><li>R. Brooks, A Robust Layered Control System for a Mobile Robot, IEEE Journal of Robotics and Automation, 2(1), 1986. — The subsumption architecture: layered condition-action control, forty years early.</li></ul><p>The two-step matching mechanism is retrieval-augmented generation repurposed for control:</p><ul><li>P. Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, NeurIPS 2020 (arXiv:2005.11401).</li></ul><p>On the workflow/agent split that the big-step layer respects:</p><ul><li>Anthropic, <a href="https://www.anthropic.com/engineering/building-effective-agents"><em>Building Effective Agents</em></a> — the canonical distinction between orchestration through predefined code paths and LLM-directed processes; this article’s answer is: both, at different altitudes.</li></ul><p>Earlier articles in this series:</p><ul><li><a href="https://medium.com/@psaghelyi/stop-begging-your-agent-to-behave-b3664280c464"><em>Stop Begging Your Agent to Behave</em></a> — enforcing temporal rules on agent traces with LTLf; the natural verification layer under this article’s postconditions.</li><li><a href="https://medium.com/@psaghelyi/stop-guessing-who-has-access-32790cb4e83e"><em>Stop Guessing Who Has Access</em></a> — proving access-control policies with an SMT solver.</li><li><a href="https://medium.com/@psaghelyi/stop-writing-survey-logic-as-spaghetti-fac7e3465949"><em>Stop Writing Survey Logic as Spaghetti</em></a> — replacing questionnaire routing with declarative conditions; the same jumps-to-conditions move this article applies to orchestration.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba9b2f79b984" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Begging Your Agent to Behave]]></title>
            <link>https://medium.com/@psaghelyi/stop-begging-your-agent-to-behave-b3664280c464?source=rss-d5415ac858b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3664280c464</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[llm-guardrails]]></category>
            <category><![CDATA[temporal-logic]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[agents]]></category>
            <dc:creator><![CDATA[Peter Saghelyi]]></dc:creator>
            <pubDate>Sat, 04 Jul 2026 20:44:49 GMT</pubDate>
            <atom:updated>2026-07-14T10:21:03.558Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Hooks, traces, and a little temporal logic: real guardrails for agentic workflows</em></p><p>An AI agent looks trustworthy until it becomes real.</p><p>At the beginning it is only a description. <em>Handle customer refund requests. Look up the order, check the receipt, issue the refund, write a note for the audit log.</em></p><p>Then reality enters. Never issue a refund before the receipt has been verified. If the receipt is missing, ask the customer for it — but at most three times, then hand the case to a human. Once a case has been escalated, don’t touch the payment system again. Every refund must be followed by an audit note. Every request must end in <em>some</em> decision — a refund, a rejection, or an escalation — never in silence.</p><p>Suddenly the agent is no longer a description. It is a small process with rules. And where do those rules live today? In the system prompt:</p><blockquote>“IMPORTANT: Always verify the receipt before issuing a refund.”<br>“NEVER call the payment API after a case has been escalated.”<em><br></em>“You MUST write an audit note after every refund. This is CRITICAL.”</blockquote><p>Every capital letter is a confession. We write IMPORTANT and NEVER and MUST because we know, deep down, that we are not configuring the system. We are pleading with it.</p><h3>A prompt is a wish, not a rule</h3><p>Large language models are probabilistic. That is not a flaw — it is the property that makes them useful. It is why they can read a messy customer email, why they can decide that “the thingy never arrived” is a delivery complaint. No rule engine does that.</p><p>But probabilistic also means: an instruction in the prompt is a strong suggestion, not a constraint. It competes for attention with everything else in the context window — the customer’s angry message, the tool descriptions, the retrieved documents, the previous forty turns of conversation. On a long run, instructions drift. The agent that dutifully verified receipts in step 2 may, by step 23, be deep in a remediation loop where “just issue the refund and move on” looks locally reasonable.</p><p>The industry’s current answers to this are revealing:</p><ul><li>Write the instruction again, louder, in more places.</li><li>Add a second LLM to watch the first one.</li><li>Read the transcripts afterwards and wince.</li></ul><p>The first is superstition. The second is turtles all the way down — who watches the watcher? The third is not a guardrail at all; it is an autopsy.</p><p>Notice what all three have in common: they try to fix a reliability problem <em>inside</em> the probabilistic layer. That is the wrong level of abstraction. When something must <em>always</em> or <em>never</em> happen, you don’t want a smarter wish. You want a mechanism that does not run on wishes.</p><h3>Hooks: the place where wishes become code</h3><p>Most serious agent frameworks now expose <strong>hooks</strong>: points in the agent’s loop where the framework calls <em>your</em> code — plain, deterministic, boring code — and lets it observe or intervene. Claude Code, for example, fires a PreToolUse hook before every tool call and a PostToolUse hook after it. The PreToolUse hook doesn&#39;t just watch: it can <strong>allow, deny, or modify</strong> the tool call before it happens.</p><p>That one architectural fact changes everything, because of what an agent run looks like from the hooks’ point of view. Strip away the prose, the reasoning, the personality — what remains is a sequence of events:</p><pre>step 1:  look_up_order        (order #4711 found)<br>step 2:  request_receipt      (email sent to customer)<br>step 3:  verify_receipt       (failed — image unreadable)<br>step 4:  request_receipt      (second attempt)<br>step 5:  verify_receipt       (success)<br>step 6:  issue_refund         ($84.90 refunded)<br>step 7:  write_audit_note     (note stored)</pre><p>A run is a <strong>finite trace</strong>: it starts, some events happen in some order, and it ends. Every agent run — the good ones and the disasters — has this shape.</p><p>And a trace is something you can do two things with.</p><p>You can <strong>record</strong> it. A hook that appends one line per tool call gives you a flight recorder: a complete, structured account of what the agent actually did, independent of what it <em>said</em> it did. For any agent that touches money, records, or customers, this alone is worth the afternoon it takes to build.</p><p>And you can <strong>constrain</strong> it. The PreToolUse hook sees the tool call <em>before it executes</em>. If your code can decide, deterministically, &quot;this event must not happen here,&quot; the framework will refuse the call — no matter how confident the model is.</p><p>Which raises the real question. Refuse <em>based on what?</em> A hook that blocks <br>rm -rf is easy: the rule is about one event in isolation. But look back at our refund rules. Almost none of them are about one event in isolation.</p><h3>Rules about time, not about moments</h3><p>An allowlist says: <em>this tool may be used, that tool may not.</em> A schema says: <em>this argument must be a positive number.</em> Both are rules about a single moment. Useful — and not remotely enough.</p><blockquote>Never issue a refund before the receipt has been verified.</blockquote><p>This rule is not about issue_refund by itself. issue_refund is fine — it&#39;s the whole point of the agent. The rule is about the <strong>order</strong> of events: refund <em>after</em> verification is the happy path; refund <em>before</em> verification is the incident report.</p><blockquote>Every refund request must eventually reach a decision.</blockquote><p>This rule is not about any event at all. It is about the <strong>eventual shape of the whole run</strong> — a promise that something will happen before the end.</p><blockquote>Ask for the receipt at most three times.</blockquote><p>A rule about <strong>how often</strong> across the run.</p><blockquote>After escalation, never touch the payment system again.</blockquote><p>A rule about <strong>what the future may contain</strong>, given the past.</p><p>Order, eventually, how often, never after — these are rules about <em>time</em>. To write them precisely, we need a small language extension: a handful of operators that talk about sequences instead of moments. This is where a little math enters. I promise it stays little.</p><p>Start with the ingredients we already have: simple true/false statements about a single step of the trace. Call them <strong>propositions</strong>:</p><pre>issue_refund        — this step is a call to the refund tool<br>receipt_verified    — the verify tool has succeeded by this step<br>escalated           — the case has been handed to a human</pre><p>(Where do these come from? From the hooks. The hook payload contains the tool name, its arguments, and — in PostToolUse — its result. Deriving &quot;which propositions are true at this step&quot; is a <strong>dictionary lookup</strong>, not an AI problem.)</p><p>Now the operators. There are only four you need, and each is a word you already use:</p><p><strong>G — “always.”</strong> G p means: <em>p holds at every step of the trace.</em></p><pre>G (not delete_customer_record)</pre><p><em>At no point in this run is the delete tool called.</em> An allowlist, it turns out, is just the simplest temporal rule.</p><p><strong>F — “eventually.”</strong> F p means: <em>p holds at some step, now or later.</em></p><pre>F (refund_issued or rejected or escalated)</pre><p><em>Sooner or later, this case reaches a decision.</em> No run may simply trail off.</p><p><strong>X — “next.”</strong> X p means: <em>p holds at the very next step.</em></p><pre>G (issue_refund -&gt; X write_audit_note)</pre><p><em>Whenever a refund happens, the immediately following step is the audit note.</em> Not “at some point” — <em>immediately</em>. Compliance people love this operator.</p><p><strong>U — “until.”</strong> p U q means: <em>p keeps holding until q happens — and q does happen.</em></p><pre>(not issue_refund) U receipt_verified</pre><p>Read it out loud: <em>no refund until the receipt is verified.</em> That is our first rule, exactly as the policy manual states it — except now it is a formula, and a formula can be checked by a machine, mechanically, on every step of every run.</p><p>That’s the whole toolbox. Four operators, combined with plain and/or/not. The result is called <strong>Linear Temporal Logic</strong> — “linear” because it describes events on a single timeline, which is precisely what an agent trace is.</p><h3>The small f</h3><p>Temporal logic was invented for systems that never stop: elevators, network protocols, operating systems. Classical LTL therefore assumes the trace is <em>infinite</em> — the elevator keeps running forever, and “eventually” may lawfully mean “in a thousand years.”</p><p>Agent runs are not like that. A run starts when the request arrives and ends when the case closes — or when the token budget dies. Every trace has a last step.</p><p>This matters more than it sounds. The variant we need is <strong>LTLf</strong> — Linear Temporal Logic over <em>finite</em> traces, put on solid foundations by De Giacomo and Vardi in 2013. Same four operators, one crucial change of meaning: the trace ends, and every promise comes due at the end.</p><p>Under finite semantics, F decision_reached doesn&#39;t mean &quot;someday, perhaps.&quot; It means: <strong>before this run terminates, a decision is reached — or the run is in violation.</strong> The end of the trace is judgment day. An &quot;eventually&quot; that hasn&#39;t happened by then is not pending; it is <em>broken</em>.</p><p>For guardrails, this is exactly the semantics you want. A vague hope becomes a deadline.</p><h3>You don’t have to write the formulas</h3><p>At this point a fair objection: <em>my compliance team will never write <br></em><em>(not issue_refund) U receipt_verified.</em></p><p>They don’t have to. It turns out that real-world process rules cluster into a couple dozen recurring shapes, and those shapes have names. The business-process community catalogued them years ago in a language called <strong>DECLARE</strong> — each pattern is a named template with a precise LTLf formula hiding inside:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ELP_5diaVKyxuLrx3hFvKg.png" /></figure><p>Nobody on the team writes operators. The policy author writes — or already wrote, years ago, in the operations manual — sentences like <em>“escalated cases must not be processed further.”</em> Mapping such sentences onto named templates is exactly the kind of constrained translation LLMs are good at, and there is prior art: IBM’s open-source NL2LTL does precisely this, prompting an LLM to translate natural language into DECLARE patterns.</p><p><strong>Note the role reversal, because it is delicious.</strong> The LLM is used <em>at design time</em> to translate policy into formal rules — a task where a human reviews the output once, before anything runs. At <em>runtime</em>, when there is real money in the pipeline and no human watching, the checking is done by deterministic code. The creative component and the trustworthy component swap places exactly where each belongs.</p><p>One safeguard makes the design-time translation honest: the <strong>round trip</strong>. Take each generated formula, have the LLM paraphrase it back into English, and show both sentences to the policy owner. <em>You wrote: “escalated cases must not be processed further.” The rule says: “once escalate_to_human occurs, issue_refund never occurs afterwards.” Same thing?</em> If yes, ship it. If no, the original sentence wins and a human looks closer. Formal-methods researchers use this same pattern to catch mistranslations — it catches the LLM’s occasional wrong turn without requiring anyone to read logic.</p><h3>The trick that makes it enforceable: every rule is a little machine</h3><p>Here is the fact that turns all this theory into a practical guardrail, and it deserves its own drum roll:</p><p><strong>Every LTLf formula can be compiled into a finite state machine.</strong></p><p>A state machine is the least intimidating object in computer science. It is a handful of states, one of which is “current,” and a rule for moving between them when an event arrives. A subway turnstile is a state machine: <em>locked</em> becomes <em>unlocked</em> when a coin arrives, <em>unlocked</em> becomes <em>locked</em> when a person pushes through. No memory beyond the current state. No cleverness. That is the point.</p><p>Compile (not issue_refund) U receipt_verified and you get, essentially, this:</p><pre>                verify succeeds<br>   [ WAITING ] ────────────────► [ SATISFIED ]<br>        │                 (stays here, rule fulfilled)<br>        │<br>        │ issue_refund<br>        │<br>        ▼<br>   [ VIOLATED ]<br>(trap state — no way back)</pre><p>Three states. The machine starts in WAITING. Every event in the trace nudges it. If verify_receipt succeeds, the machine settles into SATISFIED and this rule never complains again. If issue_refund arrives while still WAITING — the machine falls into VIOLATED, a trap with no exit, because no future event can un-refund the money before the verification. <em>The order was wrong, and order cannot be repaired retroactively.</em></p><p>Now put one such machine — researchers who monitor business processes this way call them <em>colored automata</em> — next to every rule in your rulebook, and wire them into the hooks:</p><p><strong>On </strong><strong>PostToolUse:</strong> translate the event into propositions, advance every machine one step, and append the verdicts to the flight-recorder log. Each rule, at each step, wears one of four colors:</p><ul><li><strong>permanently satisfied</strong> — fulfilled, whatever happens next (the verification came through);</li><li><strong>currently satisfied</strong> — fine so far, could still go wrong;</li><li><strong>currently violated</strong> — an obligation is open (an “eventually” still unmet — fine mid-run, fatal at the end);</li><li><strong>permanently violated</strong> — broken beyond repair, no possible future fixes it.</li></ul><p><strong>On </strong><strong>PreToolUse:</strong> before the tool actually runs, simulate. Feed the <em>proposed</em> event to copies of the machines and ask: does any rule land in <strong>permanently violated</strong>? If yes — deny, and name the rule:</p><pre>{<br>  &quot;hookSpecificOutput&quot;: {<br>    &quot;hookEventName&quot;: &quot;PreToolUse&quot;,<br>    &quot;permissionDecision&quot;: &quot;deny&quot;,<br>    &quot;permissionDecisionReason&quot;: &quot;Blocked by rule &#39;no refund before receipt verification&#39; (Precedence): verify_receipt has not succeeded in this run.&quot;<br>  }<br>}</pre><p><strong>Stop and appreciate what this is <em>not</em>.</strong> It is not a second LLM judging the first — there is no model in this loop at all. It is not a regex over the transcript. It is a turnstile: a deterministic machine that advances one state per event, in microseconds, and its refusals are not judgment calls but <em>theorems</em> — “no continuation of this trace satisfies the rule.” The model remains free everywhere the rules are silent: free to reason, to phrase, to choose tools, to be creative about <em>how</em>. The trace, however, will conform to the rulebook about <em>what and when</em> — not because we asked nicely in the prompt, but because the mechanism sits outside the thing it constrains.</p><p>The agent proposes. The automaton disposes.</p><h3>Three postures: recorder, tripwire, seatbelt</h3><p>You do not have to jump to blocking on day one. The same machinery supports three postures, in escalating order of confidence:</p><p><strong>Recorder.</strong> Hooks only log: each event, each rule’s color after it. You learn how your agent <em>actually</em> behaves across hundreds of runs — including the near-misses that current-transcript-reading would never surface. (“Rule ‘audit note follows refund’ spends 40% of runs in <em>currently violated</em> for more than five steps. Why?”)</p><p><strong>Tripwire.</strong> Violations don’t block; they alert. A rule going red mid-run pings a human, opens a ticket, or pauses the agent for review. Right for rules where the mapping from events to propositions is still being tuned.</p><p><strong>Seatbelt.</strong> PreToolUse denies any call that would make a rule permanently violated. Right for the rules where you&#39;d rather have a false refusal than a true incident: payments, deletions, external communications, anything legal reads about later.</p><p>Run new rules through the postures like a promotion pipeline: record for two weeks, tripwire until the false positives are boring, then enforce. Every promotion is backed by data from the previous stage — which the recorder has been collecting all along.</p><h3>Lint the rulebook before the flight</h3><p>One more gift falls out of the compilation trick, and it may be the most underrated one.</p><p>Rulebooks are written by many hands over a long time. The platform team contributes baseline rules; the industry pack adds regulatory ones; the customer adds their own overrides. Nobody reads the union. And a rulebook can be broken <em>as a whole</em> in ways no individual author can see:</p><ul><li><strong>Contradiction.</strong> One rule demands F audit_note; another, added two quarters later, forbids write access in this context. Together they are unsatisfiable — <em>no possible run</em> complies. Your agent is doomed before the first token, and the error message will look like the model misbehaving.</li><li><strong>Dead rule.</strong> A rule guards a tool that no longer exists, or fires on a state that upstream rules make unreachable. It costs attention forever and protects nothing.</li><li><strong>Shadowed rule.</strong> A customer’s override quietly subsumes a platform compliance rule — the platform rule can never trigger again, and nobody decided that on purpose.</li><li><strong>Trap.</strong> A reachable situation where every continuation violates <em>something</em> — the agent’s only options are different flavors of red. The run stalls, is force-killed, and the incident review blames the model for “getting stuck.”</li></ul><p>Because every rule is an automaton, the <em>whole rulebook</em> is one big automaton (run all the machines side by side), and these questions become mechanical: <em>Does any accepting trace exist at all? Is there a trace that exercises rule 17? Can a trace reach a state with no legal exits?</em> When the answer is bad, the checker doesn’t just say no — it hands you a concrete counterexample trace, a short story of a run that walks into the trap, which is worth a hundred abstract warnings.</p><p>This is design-time verification, and it runs before any agent does — in CI, on every edit to the rulebook. In our implementation the rulebook lives in versioned files, and a PostToolUse hook watches for edits to those files and re-runs the verification automatically. When an agent (or a human) edits the guardrails, the guardrails on the guardrails fire. It is hooks all the way down, and for once that is a compliment.</p><h3>What this does not solve</h3><p>Honesty section. The mechanism is strong precisely because its scope is narrow, so let’s draw the border.</p><p><strong>The mapping is the weak joint.</strong> The automaton sees propositions; reality sends tool calls. If receipt_verified is derived incorrectly — the verify tool &quot;succeeded&quot; on the wrong document — the monitor cheerfully approves a bad refund. Formal guarantees hold <em>modulo the translation from world to symbols</em>. Keep that translation embarrassingly simple (tool names, exit codes, explicit result fields), and audit it like the security boundary it is.</p><p><strong>It governs the trace, not the text.</strong> No temporal rule notices that the refusal email the agent wrote was rude, that the summary hallucinated a policy clause, or that the model was manipulated into <em>wanting</em> something silly. Content quality still needs its own tools: evals, sampling, human review. Temporal guardrails govern <em>what happened and when</em> — that is a lot, and it is not everything.</p><p><strong>Rules only cover what someone thought to write.</strong> The rulebook is a floor, not a ceiling. The verifier can prove the rules are consistent; it cannot know the rule you forgot. (Though the flight recorder helps here too: surprising traces are where missing rules announce themselves.)</p><p><strong>Someone must own the rulebook.</strong> Rules encode policy, and policy has owners, versions, and disputes. The formal layer makes disagreements <em>visible</em> — two contradictory rules now fail loudly in CI instead of silently in production — but a human still has to decide which one wins.</p><h3>Why this matters more, not less, as agents get better</h3><p>It is tempting to file all this under “training wheels for weak models” — surely GPT-next or Claude-next will just follow instructions?</p><p>The trend runs the other way. Agents are getting <em>more</em> autonomous: longer runs, more tools, more consequential actions, less human attention per decision. Agents now write other agents’ configurations; rulebooks are assembled from layers owned by different organizations; a single platform hosts thousands of agent variants doing structurally similar work under structurally different policies. Reading transcripts does not scale to that world. Prompt discipline does not compose across organizational boundaries.</p><p>A trace-based guardrail does. It doesn’t care which model is running, how it was prompted, or who wrote its instructions. It watches events at the only boundary that ultimately matters — where the agent touches the world — and it speaks a language precise enough to verify and plain enough to read back to a policy owner as an English sentence.</p><p>The division of labor is the same one I argued for in questionnaire design, and I suspect it is a general law of building with LLMs: <strong>the model supplies judgment; the structure supplies guarantees; a human remains responsible for meaning.</strong> The LLM decides <em>how</em> to pursue the case. The temporal rules decide <em>what may follow what</em>. The policy owner decides what the rules should say.</p><h3>Conclusion</h3><p>We have been treating agent safety as a prompting problem — pleading in capital letters and hoping the plea survives forty turns of context. But an agent run, seen from its hooks, is something much more tractable than a conversation: it is a finite trace of events. And finite traces of events are a solved genre. We know how to state rules over them (four operators you already use as English words), how to make the rules readable (named templates instead of formulas), how to enforce them (each rule compiled to a small deterministic machine, advanced on every hook event, empowered to refuse), and how to lint the whole rulebook before anything runs.</p><p>None of it constrains the model&#39;s intelligence. All of it constrains the model’s <em>footprint</em>.</p><p>That is the shift agentic engineering needs:</p><p><strong>From prompts to promises. From transcripts to traces. From hoping to checking.</strong></p><h3>Notes and further reading</h3><p>The ideas here stand on two decades of work in temporal logic, declarative process modeling, and runtime verification. Starting points:</p><ul><li><strong>De Giacomo &amp; Vardi</strong>, <em>Linear Temporal Logic and Linear Dynamic Logic on Finite Traces</em> (IJCAI 2013) — the paper that put LTLf on solid ground: same operators as classical LTL, finite-trace semantics. The “small f” section above is this paper in street clothes.</li><li><strong>Pesic, Schonenberg &amp; van der Aalst</strong>, <em>DECLARE: Full Support for Loosely-Structured Processes</em> (EDOC 2007) — the template catalog (Response, Precedence, Absence, …) that lets domain experts state temporal rules without writing formulas.</li><li><strong>Maggi, Montali, Westergaard &amp; van der Aalst</strong>, <em>Monitoring Business Constraints with Linear Temporal Logic: An Approach Based on Colored Automata</em> (BPM 2011) — the runtime-monitoring construction: compile each constraint to an automaton, advance it per event, color each rule’s status four ways. The guardrail engine above is this idea relocated into agent hooks.</li><li><strong>Fuggitti &amp; Chakraborti</strong>, <em>NL2LTL</em> (AAAI 2023; open source from IBM Research) — LLM-driven translation of natural-language requirements into DECLARE/LTL patterns. Evidence that the policy-to-rules step can be automated with review, not authored by logicians.</li><li><strong>Mendoza et al.</strong>, <em>Translating Natural Language to Temporal Logics with Large Language Models and Model Checkers</em> (FMCAD 2024) — the round-trip validation pattern for keeping LLM translations honest.</li><li><strong>LTLf2DFA / MONA</strong> — the open-source toolchain that compiles LTLf formulas to minimal deterministic automata; the practical engine behind “every rule is a little machine.”</li><li><strong>Claude Code hooks documentation</strong> — the concrete PreToolUse / PostToolUse mechanism used as the running example; other agent frameworks expose equivalent interception points.</li></ul><h3>Hey, wanna see it in action?</h3><p><a href="https://github.com/askalot-io/ltl-harness">https://github.com/askalot-io/ltl-harness</a></p><p><em>If you publish this elsewhere as well, set a canonical link to the original so search engines know the source.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*Vy-dVvlQlpVc6yQT8kg5QA.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3664280c464" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Guessing Who Has Access]]></title>
            <link>https://medium.com/@psaghelyi/stop-guessing-who-has-access-32790cb4e83e?source=rss-d5415ac858b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/32790cb4e83e</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[formal-verification]]></category>
            <category><![CDATA[access-control]]></category>
            <category><![CDATA[z3]]></category>
            <dc:creator><![CDATA[Peter Saghelyi]]></dc:creator>
            <pubDate>Sat, 04 Jul 2026 17:30:11 GMT</pubDate>
            <atom:updated>2026-07-04T20:53:48.577Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>Proving access-control policies with an SMT solver</em></h4><p>An access policy looks simple until it becomes real.</p><p>At the beginning it is only a list of grants. <em>Alice is a developer. The QA team can read the test plans. Bob may edit Project B.</em> Anyone can hold the whole thing in their head.</p><p>Then reality enters. Users join groups, and groups carry roles, so people receive permissions nobody granted them personally. Someone needs an exception: Bob should only <em>read</em> Project B, even though his team can edit everything. Someone needs the opposite of a grant: Alice must be locked out of Project A while an investigation runs, no matter what her other roles say. A contractor needs access to one project without joining any team. An auditor asks which two people can approve <em>and</em> review the same payment. Suddenly the policy is no longer a list. It is a small program: it has inputs (memberships and assignments), rules (inheritance, precedence, denial), and an output — <strong>who can actually do what</strong> — that nobody ever wrote down anywhere. And like many small programs that grow over time, it becomes hard to understand.</p><p>Security engineers have known this for a long time. Role-based access control was invented precisely to tame permission sprawl: instead of granting thousands of individual permissions, you define a handful of roles and assign those. It works. But the moment roles can arrive from more than one direction — from group membership <em>and</em> from individual assignment — the effective permissions of a user become a <em>derived</em> quantity. You can read every grant in the database and still answer the question “can Bob edit Project B today?” incorrectly, because the answer is not stored anywhere. It is computed by rules, and the rules interact.</p><p>Most organizations verify this interaction the same way: someone clicks through the admin UI, someone exports a spreadsheet, someone writes a script that checks the cases they thought of. That is testing. It shows you the cases you <em>tried</em>. It cannot tell you that <em>no</em> combination of memberships, roles, and exceptions violates your compliance rules.</p><p>There is a tool built for exactly this gap, and it is not a security product. It is an SMT solver.</p><h3>Effective access is computed, not stored</h3><p>The heart of the problem is a shift in what the important fact is.</p><blockquote><em>1. The stored fact is: </em>Bob was granted Reader on Project B.<br>2. <em>The important fact is: </em>Given everything else we granted, Reader is all Bob has on Project B.</blockquote><p>The first statement is a row in a table. The second is a <em>consequence</em> — it depends on Bob’s group memberships, on the roles those groups carry, on the precedence rule between individual and inherited roles, and on any denial that might apply. Change any of those and the consequence changes, without anyone touching Bob’s row.</p><p>This is the same trap that makes any rule system hard: the rules are individually simple, but the behavior is their interaction. And interactions don’t live in any single rule — so reading the rules one by one, which is what code review and access review both do, systematically misses them.</p><h3>Three levels: enforcement, auditing, reasoning</h3><p>It helps to separate three levels of assurance about an access policy:</p><pre><strong>Level 1 — Enforcement</strong><br>The system answers one question at runtime:<br>may THIS user do THIS action on THIS resource, right now?<br><br><strong>Level 2 — Auditing</strong><br>Scripts and dashboards enumerate the current state:<br>who has which role, where, today? Reports get exported, reviewed, signed.<br><br><strong>Level 3 — Reasoning</strong><br>The policy itself is a logical object. Properties are proven or refuted<br>across ALL configurations the rules allow — not just the current one.</pre><p>Almost every system has Level 1 — that’s the authorization middleware. Mature organizations have Level 2 — access reviews, recertification campaigns, CSV exports for the auditors. Level 3 sounds academic until you notice that Amazon runs it in production: their Zelkova engine translates IAM policies into logical formulas and answers questions like <em>“can this bucket ever be read by the public?”</em> — not by trying requests, but by proving properties about the policy itself.</p><p>The gap between Level 2 and Level 3 is where compliance actually lives. An access review can confirm that nobody currently holds two conflicting roles. It cannot confirm that your rules make such a state <em>impossible</em>. The clearest way to see the difference is to build a small policy and reason about it. Everything below comes from a small public repo of runnable examples; the code is Python using the Z3 solver, and the snippets are lightly trimmed for reading.</p><h3>The building blocks</h3><p>Our miniature world has four kinds of entities. <strong>Users</strong> are people: Alice, Bob, Carol, David, Eve. <strong>Groups</strong> collect users: Engineering and QA. <strong>Projects</strong> are the resources: Project A and Project B. <strong>Roles</strong> are named permission sets — and here is the first interesting decision: a role can be <em>permissive</em> (Reader, Contributor) or <em>restrictive</em> (DenyAll). A restrictive role is not the absence of a grant; it is a grant of denial, an explicit “no” that someone placed deliberately.</p><p>Roles arrive from two directions:</p><ul><li>A <strong>group role</strong> attaches to a group and applies to <em>every</em> project. Engineering carries Contributor; QA carries Reader. Join the group, inherit the role, everywhere.</li><li>An <strong>individual role</strong> attaches to one user on one project. Bob has Reader on Project B. Alice has DenyAll on Project A. Eve — who belongs to no group at all — has Contributor on Project A.</li></ul><p>The cast is chosen to cover the corners: Alice and Bob are ordinary Engineering members with one exception each, Carol is ordinary QA, David belongs to <em>both</em> groups, and Eve belongs to none.</p><h3>When rules collide</h3><p>Two collisions are built into this design, and every real RBAC system has some version of both.</p><p><strong>Collision one: inherited versus individual.</strong> Bob’s group says Contributor on every project. Bob’s individual assignment says Reader on Project B. What does Bob have on Project B? There are three defensible answers: the union (both roles), the most permissive, or the most specific. Our policy — like most systems that take exceptions seriously — chooses specificity:</p><blockquote>An individual assignment overrides inherited roles for that user and that project.</blockquote><p>Bob gets Reader on Project B, and <em>only</em> Reader. The whole point of the exception was to narrow his access; a union would silently defeat it.</p><p><strong>Collision two: permission versus denial.</strong> Alice’s group says Contributor everywhere. Alice’s individual assignment says DenyAll on Project A. Precedence alone answers this (the individual role wins), but denial deserves a stronger rule, one that also covers denials arriving <em>from groups</em>:</p><blockquote>If any restrictive role applies, access is denied — regardless of what else is granted.</blockquote><p>This is <strong>deny-wins</strong>, and it’s the rule auditors ask about first, because it is the mechanism behind “we locked this person out and can prove nothing un-locks them.”</p><p>Notice what just happened: we needed two policy sentences, each one line of English. The trouble is that English doesn’t compose. Does Bob’s override happen before or after deny checking? If a group carries DenyAll and the user has an individual Reader, does the override <em>remove the denial</em>? (In our policy: yes for that project — the individual assignment replaces inherited roles, including inherited denials. That’s a real design decision, and reasonable people could choose differently.) Prose hides these questions. Logic forces them into the open.</p><h3>From policy prose to predicates</h3><p>Here is the entire vocabulary of our policy, in Z3. Entities become enumerated <strong>sorts</strong>, relationships become boolean <strong>functions</strong> — predicates that are true or false for each combination of arguments:</p><pre>from z3 import *<br><br>User,    (Alice, Bob, Carol, David, Eve) = EnumSort(&#39;User&#39;, [&#39;Alice&#39;, &#39;Bob&#39;, &#39;Carol&#39;, &#39;David&#39;, &#39;Eve&#39;])<br>Group,   (Eng, QA)                       = EnumSort(&#39;Group&#39;, [&#39;Eng&#39;, &#39;QA&#39;])<br>Project, (ProjA, ProjB)                  = EnumSort(&#39;Project&#39;, [&#39;ProjA&#39;, &#39;ProjB&#39;])<br>Role,    (Reader, Contributor, DenyAll)  = EnumSort(&#39;Role&#39;, [&#39;Reader&#39;, &#39;Contributor&#39;, &#39;DenyAll&#39;])<br><br>InGroup        = Function(&#39;InGroup&#39;,        User,  Group,          BoolSort())<br>GroupRole      = Function(&#39;GroupRole&#39;,      Group, Role,           BoolSort())<br>IndividualRole = Function(&#39;IndividualRole&#39;, User,  Role,  Project, BoolSort())<br>pisRestrictive  = Function(&#39;isRestrictive&#39;,  Role,  BoolSort())</pre><p>The configuration — who is where, who holds what — becomes a list of facts:</p><pre>facts = [<br>    InGroup(Alice, Eng), InGroup(Bob, Eng), InGroup(Carol, QA),<br>    InGroup(David, Eng), InGroup(David, QA),    # Eve: no groups<br><br>    GroupRole(Eng, Contributor),                # applies to every project<br>    GroupRole(QA,  Reader),<br><br>    IndividualRole(Bob,   Reader,      ProjB),  # narrow Bob on ProjB<br>    IndividualRole(Alice, DenyAll,     ProjA),  # lock Alice out of ProjA<br>    IndividualRole(Eve,   Contributor, ProjA),  # contractor access, no group<br>]</pre><p>And the two policy sentences become quantified rules that <em>define</em> effective access. RoleSet is the set of roles a user effectively holds on a project after precedence; Denied and Granted are the final decisions:</p><pre>u, g, p = Consts(&#39;u g p&#39;, ... )   # one variable per sort<br>r, r2   = Consts(&#39;r r2&#39;, Role)<br><br>rules = [<br>    # DenyAll is the restrictive role<br>    ForAll(r, isRestrictive(r) == (r == DenyAll)),<br><br>    # Effective roles: individual assignments override <br>    # inherited ones per (user, project)<br>    ForAll([u, r, p],<br>        RoleSet(u, r, p) ==<br>            Or(IndividualRole(u, r, p),<br>               And(Not(Exists(r2, IndividualRole(u, r2, p))),  # no individual role here at all<br>                   Exists(g, And(InGroup(u, g), GroupRole(g, r)))))),<br><br>    # Deny-wins: any restrictive role in the set blocks the project<br>    ForAll([u, p],<br>        Denied(u, p) == Exists(r, And(RoleSet(u, r, p), isRestrictive(r)))),<br><br>    # Granted: a permissive role survives only if nothing denies<br>    ForAll([u, r, p],<br>        Granted(u, r, p) ==<br>            And(RoleSet(u, r, p), Not(isRestrictive(r)), Not(Denied(u, p)))),<br>]</pre><p>Read the middle rule slowly, because it is the entire override policy in one formula: a role is effective either because it was assigned individually, or because it is inherited from a group <em>and the user has no individual assignment of any kind on that project</em>. That second condition is the override.</p><p>This is the same mental shift as moving from imperative to declarative anywhere else. We did not write an evaluation algorithm — no loops over groups, no precedence-sorting, no early returns. We wrote down what “effective access” <em>means</em>, and left the computing to an engine.</p><h3>A different kind of engine</h3><p>An SMT solver takes a pile of constraints and does one of two things. Either it finds a concrete assignment of values that makes every constraint true — the answer <strong>sat</strong>, plus a <strong>model</strong>, which is a full worked example — or it proves that no such assignment exists: <strong>unsat</strong>. SMT stands for <em>satisfiability modulo theories</em>: the solver handles not just boolean logic but integers, enumerations, uninterpreted functions, and quantifiers, which is exactly the vocabulary a policy needs.</p><p>Those two answers give you two complementary moves, and the whole methodology is learning which one you want:</p><ul><li><strong>Violation hunting.</strong> Assert the policy, the configuration, and <em>“a violation exists.”</em> If the solver says <strong>sat</strong>, the model is your culprit — it names the user, the project, the roles. If it says <strong>unsat</strong>, no violation is possible. Not “none found”: none <em>exists</em>.</li><li><strong>Proof by refutation.</strong> Same thing seen from the other side. To prove a property holds, assert its negation and hope for <strong>unsat</strong>. The solver becomes an adversary that searches every corner of the configuration space for a counterexample, and unsat means the adversary gave up — provably.</li></ul><p>A satisfiability check on this kind of formula is NP-hard in general — the same complexity wall that makes exhaustively testing every path hopeless. The practical magic of modern solvers is that real policies, even large ones, sit comfortably within what they crunch in milliseconds. (This is the bet Zelkova made, and it pays off at cloud scale.)</p><h3>The bug that prose hides</h3><p>Time for a confession that doubles as the best argument for this whole approach. The first version of the override rule — in the design document <em>and</em> in the code — looked like this:</p><pre># looks like an override…<br>Or(IndividualRole(u, r, p),<br>   And(Not(IndividualRole(u, r, p)),<br>       Exists(g, And(InGroup(u, g), GroupRole(g, r)))))</pre><p>Guard the inherited branch with “no individual assignment,” and individual roles take precedence. Reasonable, reviewable, wrong.<br>Look at the shape: A ∨ (¬A ∧ B). By elementary boolean algebra that is exactly A ∨ B — the guard contributes <em>nothing</em>. The formula computes the plain <strong>union</strong> of individual and inherited roles. Bob, who was supposed to be narrowed to Reader on Project B, kept his inherited Contributor too. The exception that someone deliberately created was silently void, and every human who read the rule — author, reviewer, documentation writer — read the <em>intention</em>, not the logic.</p><p>The fix is the version shown earlier: the guard must check that the user has no individual role <em>of any kind</em> on that project (Not(Exists(r2, IndividualRole(u, r2, p)))), not merely that the specific role being derived wasn&#39;t individually assigned.</p><p>Here is the beautiful part: the tool that runs the policy can also debug it. Load both versions into one solver and ask whether any configuration distinguishes them:</p><pre>s = Solver()<br>s.add(rules_v1 + rules_v2 + facts)     # both encodings over the same facts<br>s.add(Exists([u, r, p], RoleSet_v1(u, r, p) != RoleSet_v2(u, r, p)))<br>print(s.check())                       # sat — they differ!<br>print(s.model())                       # witness: Bob, Contributor, ProjB</pre><p><strong>sat</strong> — and the model hands you Bob on Project B holding a Contributor role that the corrected policy says he must not have. An equivalence check between “what we wrote” and “what we meant,” with a counterexample attached. No test suite finds this bug by accident, because every test the author writes encodes the same misunderstanding the rule does.</p><h3>Say “and nothing else”</h3><p>One more concept before the payoff, because everyone hits it in their first hour with a solver. To Z3, the facts you assert are a <em>lower</em> bound, not a complete description. You said Alice is in Engineering; you never said Carol <em>isn’t</em>. The solver is free to imagine any world consistent with your constraints — including one where it helpfully adds Carol to Engineering, hands Eve three roles, and invents a group membership that makes your compliance check pass.</p><p>Real configurations are complete: the membership table <em>is</em> the membership. Logic calls this the <strong>closed-world assumption</strong>, and you must state it explicitly — the listed facts are true <em>and nothing else is</em>:</p><pre>ForAll([u, g], InGroup(u, g) == Or(<br>    And(u == Alice, g == Eng),<br>    And(u == Bob,   g == Eng),<br>    And(u == Carol, g == QA),<br>    And(u == David, g == Eng),<br>    And(u == David, g == QA)))</pre><p>Forget this and your audits don’t fail loudly — they pass vacuously, which is worse. We’ll see a concrete case in a moment.</p><h3>Compliance as satisfiability</h3><p>Now the payoff. Every compliance requirement about access follows one recipe: <em>assert the policy rules, assert the closed-world configuration, assert the negation of the requirement, and check.</em> <strong>Sat</strong> means the requirement can be violated, and the model is the incident report — names, projects, roles. <strong>Unsat</strong> means the requirement provably holds for this configuration. Let’s climb from easy to hard.</p><p><strong>Who has access to what?</strong> The baseline isn’t a compliance check, just honesty: ask the solver for a model of the rules plus facts and read off Granted.</p><ul><li><strong>Alice:</strong> denied on Project A, Contributor on B.</li><li><strong>Bob:</strong> Contributor on A, <em>only</em> Reader on B — the override works.</li><li><strong>Carol:</strong> Reader everywhere.</li><li><strong>David</strong>, member of both groups: Reader <em>and</em> Contributor everywhere — multi-group membership unions before precedence, another decision the formulas make explicit.</li><li><strong>Eve:</strong> Contributor on A, nothing on B. This table is the derived quantity that no database row contains — and here it is, computed from first principles.</li></ul><p><strong>Separation of Duty.</strong> The classic: <em>no user may hold both conflicting roles on the same project</em> — approve and review, develop and audit. This is a SOX and ISO 27001 staple, and it is one constraint:</p><pre>s.add(Exists([u, p], And(Granted(u, Reader, p), Granted(u, Contributor, p))))</pre><p>Sat? The model names the violator and the project. Unsat? Compliance, proven — over the whole configuration, including every role that arrives indirectly through some chain of group memberships nobody remembers creating. In our little world, David is exactly the kind of user who trips this wire: nobody granted him a conflicting pair, his two group memberships <em>composed</em> into one.</p><p><strong>Coverage: every project needs two admins.</strong> Compliance isn’t only about too much access; too little is also a finding. <em>Every project must have at least two users who can administer it</em> — otherwise one resignation strands a resource. Counting is where SMT earns the “modulo theories” part of its name:</p><pre>for P in projects:<br>    s.add(Sum([If(Granted(U, Contributor, P), 1, 0) for U in users]) &gt;= 2)</pre><p><strong>Unsat</strong> is the interesting answer here: it means some project <em>cannot</em> meet the requirement no matter how the unconstrained parts fall — and re-checking project by project tells you which one starves. In the repo’s version of this scenario, one project passes and the other has a single admin; the check reports exactly that.</p><p>This is also where the closed world stops being pedantry. Our first version of this check forgot the “and nothing else” constraints — and it could never fail. Asked whether every project <em>could</em> have two admins, the solver cheerfully invented the missing admins, answered sat, and the audit passed forever. A compliance check that cannot fail is indistinguishable from no check at all, and an open world is the quietest way to build one.</p><p><strong>Cardinality caps.</strong> The mirror image: <em>no more than N global administrators in the whole system.</em> Same counting machinery, opposite direction — and on an open configuration you can flip the question from checking into <em>choosing</em>: let the solver decide which admins to keep within the cap.</p><p><strong>Change impact: the orphan-access question.</strong> Someone proposes deleting the QA group. What breaks? Encode <em>two</em> worlds in one solver — Effective_Before with all memberships, Effective_After with QA&#39;s inheritance removed — and compare them pointwise. The model lists exactly who loses what (Carol loses everything; David loses only what Engineering doesn&#39;t independently give him) and, just as important for the auditors, who <em>retains</em> access through other paths after the deprovisioning. This is the dry run that access reviews pretend to be.</p><p><strong>Privilege escalation: one group away.</strong> Now reverse the direction of time. Instead of asking what access exists, ask what access is <em>reachable</em>: for each user and each group they haven’t joined, would joining grant anything new? Same trick — a hypothetical world per candidate membership, compared against the real one. The answer is a map of your escalation surface: <em>Carol is one Engineering membership away from Contributor on Project A.</em> Nobody violated anything yet. That is precisely why the report is valuable — it’s the audit of the paths, not the state. A guard at Level 2 sees who is inside the building; this is Level 3 checking which doors a visitor could reach from the lobby.</p><p><strong>Least privilege, synthesized.</strong> The final step up: stop auditing and start designing. Given a set of <em>requirements</em> — Alice needs Reader on A, Bob needs Contributor on B, Carol needs both — find the <strong>minimum</strong> set of grants that satisfies them. Make each potential grant a boolean decision variable, require that every need is covered, and hand the objective to Z3’s optimizer:</p><pre>o = Optimize()<br>o.add(rules_linking_grants_to_effective_access + needs)<br>o.minimize(Sum([If(grant, 1, 0) for grant in all_possible_grants]))</pre><p>The solver returns a provably minimal assignment — it mixes group grants and individual grants, and in our example it proves that four grants are necessary because no group contains two users who share a need. “Least privilege” appears in every security policy document ever written; this is the version of it that comes with a proof of the word <em>least</em>.</p><p>Notice the ladder we just climbed: read the current state, check a forbidden pattern, count, compare two worlds, search reachable worlds, optimize over all worlds. Same vocabulary, same engine, six increasingly powerful questions.</p><h3>Why this matters more with AI-managed access</h3><p>Access policies are increasingly written, modified, and granted by automation — infrastructure-as-code templates, provisioning pipelines, and now AI agents that respond to “give the new contractor what she needs” with a batch of grants. This is genuinely useful, and it has the same failure mode as AI-generated questionnaires or AI-generated anything: the output <em>looks</em> plausible at exactly the speed that makes review impossible. A language model can produce a role structure that reads beautifully and contains a vacuous override, an unintended escalation path, or a group whose deletion strands a project.</p><p>The answer is not to slow the generation down; it is to make the checking as mechanical as the generating. If policy changes arrive faster, the properties — SoD, coverage, caps, escalation bounds — must be checked on every change, by a prover, in CI, the way type checkers run on every commit. Generation proposes; the solver disposes. The human owns the <em>properties</em>, which change rarely, instead of reviewing the <em>grants</em>, which change daily.</p><h3>What changes for the engineer</h3><p>The shift is the same one that declarative thinking brings everywhere: you stop asking <em>“did my checks pass on the current data?”</em> and start asking <em>“does a configuration exist that violates my invariant?”</em> For every compliance rule you can now ask: Is it enforced by construction or merely observed? What is the counterexample if it fails? Which rule interactions does it depend on? Could two of my policy sentences be simplified into one — and are they even consistent with each other? The policy stops being folklore distributed across middleware, admin UIs, and tribal memory, and becomes one analyzable artifact.</p><p>There’s also a quieter benefit. Writing the rules in logic forced us to answer questions the prose never raised — does an individual role suppress an inherited denial? does multi-group membership union before or after precedence? — and the formulas <em>are</em> the answers. The specification and the implementation stop being two documents that drift apart; they are one object the solver executes and interrogates.</p><h3>What this does not solve</h3><p>An SMT solver is not a security program. It verifies the policy you modeled, not the system you run — if your authorization middleware diverges from the formulas, the proofs are about the wrong thing, and keeping model and enforcement aligned is real engineering work. It won’t tell you <em>which</em> roles should conflict for SoD, how many admins are enough, or whether Eve should have been given access at all; properties are human judgments, and garbage properties get proven just as rigorously. It doesn’t replace authentication, secrets hygiene, network security, or penetration tests — someone who steals Alice’s token doesn’t care what we proved about Alice. And at some scale and expressiveness, solver performance becomes its own craft. What it addresses is one specific, chronically under-tooled layer: whether the <em>logic</em> of your access control does what everyone believes it does. That layer fails silently, fails at composition points, and fails in exactly the ways spot-checking cannot catch — which makes it the right layer to hand to a prover.</p><h3>From access lists to access logic</h3><p>For decades, access control has been reviewed the way it is stored: as lists. Lists of members, lists of roles, lists of grants, exported quarterly and eyeballed. But the security-relevant object was never the lists — it is the <em>function</em> that maps lists to decisions, the emergent behavior of inheritance, precedence, and denial composing across thousands of assignments. If we keep reviewing the inputs while the risk lives in the function, we shouldn’t be surprised when audits pass and access is still wrong.</p><p>The alternative exists, is open source, and fits in an afternoon of experimentation: write the rules as predicates, state the configuration as a closed world, and turn every compliance requirement into a satisfiability question. Sat gives you the incident before it happens, with names attached. Unsat gives you something no spreadsheet ever contained: a proof.</p><p><strong>From grants to consequences. From spot checks to proofs. From access lists to access logic.</strong></p><h3>Notes and further reading</h3><ul><li><strong>The companion repo</strong> — all examples in this article are runnable: <a href="https://github.com/psaghelyi/smt_rbac">github.com/psaghelyi/smt_rbac</a>. Nine scenarios, from effective-access enumeration to least-privilege synthesis.</li><li><strong>Zelkova</strong> — AWS’s production use of SMT for policy reasoning: <a href="https://aws.amazon.com/blogs/security/protect-sensitive-data-in-the-cloud-with-automated-reasoning-zelkova/"><em>Protect sensitive data in the cloud with automated reasoning</em></a>; formally described in Backes et al., <em>Semantic-based Automated Reasoning for AWS Access Policies using SMT</em> (FMCAD 2018).</li><li><strong>Z3</strong> — de Moura &amp; Bjørner, <em>Z3: An Efficient SMT Solver</em> (TACAS 2008); open source at <a href="https://github.com/Z3Prover/z3">github.com/Z3Prover/z3</a>. A gentle overview of the field: <a href="https://en.wikipedia.org/wiki/Satisfiability_modulo_theories">Satisfiability modulo theories</a>.</li><li><strong>RBAC foundations</strong> — Ferraiolo &amp; Kuhn, <em>Role-Based Access Controls</em> (1992); Sandhu et al., <em>Role-Based Access Control Models</em> (1996) — the RBAC96 family that most real systems descend from. For the attribute-based generalization: NIST SP 800–162 (ABAC).</li><li><strong>Separation of Duty</strong> — Clark &amp; Wilson’s integrity model (1987) is the classical root; SoD constraints in RBAC are treated formally in the RBAC96/ANSI-RBAC literature.</li></ul><p><em>If you publish this elsewhere as well, set a canonical link to the original so search engines know the source.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6sVnZIyTnBk9Dh8Pv1Rcdw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32790cb4e83e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Writing Survey Logic as Spaghetti]]></title>
            <link>https://medium.com/@psaghelyi/stop-writing-survey-logic-as-spaghetti-fac7e3465949?source=rss-d5415ac858b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/fac7e3465949</guid>
            <category><![CDATA[surveys]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[market-research]]></category>
            <category><![CDATA[data-quality]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Peter Saghelyi]]></dc:creator>
            <pubDate>Sat, 20 Jun 2026 19:46:53 GMT</pubDate>
            <atom:updated>2026-10-02T14:37:24.750Z</atom:updated>
            <content:encoded><![CDATA[<h3>A declarative way to design complex questionnaires</h3><p>A questionnaire looks simple until it becomes real.</p><p>At the beginning it is only a list of questions. <em>What is your age? Are you employed? Do you have children? How satisfied are you with the service?</em></p><p>Then reality enters. If the respondent is under 18, don’t ask about employment history. If they’re unemployed, skip the salary section. If they have children, ask how many — and if more than one, ask about the oldest and youngest. If they gave a low satisfaction score, ask for the reason; if high, ask whether they’d recommend the service. Suddenly the questionnaire is no longer a list. It is a small program. And like many small programs that grow over time, it becomes hard to understand. Survey researchers have known for a long time that questionnaire design is not just about writing nice questions. The questionnaire scripts the conversation between researcher and respondent: its wording, ordering, answer categories, routing rules, and validation checks all shape the data that will later be analyzed. A badly designed questionnaire doesn’t merely produce an ugly form. It produces bad evidence. In traditional survey tools, the usual way to handle this complexity is <strong>skip logic</strong>:</p><blockquote><em>If Q3 is </em>Yes<em>, go to Q4.<br>If Q3 is </em>No<em>, go to Q8.<br>If income is below a threshold, skip to the assistance section.<br>If the respondent refuses, jump to the next block.</em></blockquote><p>This works well enough for small surveys. It is intuitive, and it mirrors what an interviewer does on paper: follow the instruction, turn the page, ask the next relevant question. But for large computer-assisted questionnaires, skip logic has an unfortunate tendency to become spaghetti — not because survey designers are careless, but because they’re trying to encode a complex, adaptive conversation using a control-flow mechanism that asks them to manually direct every path. The designer has to think not only about the meaning of each question but about the exact route through the questionnaire. Every branch becomes an arrow. Every exception becomes another arrow. Every later change can break an earlier assumption.</p><p>At some point the question is no longer <em>“What does this item mean?”<br></em>It becomes <em>“Where do I jump from here?”</em></p><p>That is the wrong level of abstraction.</p><h3>A questionnaire is a conversation</h3><p>A good questionnaire should feel like a conversation — not a free one, of course. Survey research depends on structure: the wording must be controlled, the response options comparable, the order deliberate. Sensitive questions may need to appear later, eligibility questions early. Some topics should be grouped; some questions shouldn’t be asked unless they apply. But the respondent should still experience the survey as a meaningful sequence. They shouldn’t see questions that don’t apply to them, be asked for impossible information, be allowed to contradict what they already said, or be trapped in a branch that leads nowhere.<br>This is where the “jump to question X” model starts to show its limits. A jump instruction describes <em>movement</em>. But most questionnaire logic isn’t about movement — it’s about <strong>relevance</strong>.</p><blockquote>The important rule is not: <em>After Q3, go to Q8.<br></em>The important rule is: <em>Ask Q8 only if the respondent has children.</em></blockquote><p>The first statement tells the engine <em>where to go</em>. The second tells the engine <em>when the question is meaningful</em>. That difference is the heart of the declarative approach.</p><h3>From jumps to conditions</h3><p>In an imperative questionnaire, the designer controls the route:</p><pre>Ask Q1<br>If Q1 = 1, go to Q2<br>If Q1 = 2, go to Q5<br>After Q5, go to Q9<br>If Q9 &gt; 10, go to Q12</pre><p>The questionnaire is defined as a path with branches. In a declarative questionnaire, each item declares the conditions under which it is relevant. (The examples below use a YAML-based declarative questionnaire language; the exact syntax is illustrative.)</p><pre>- id: q_has_children<br>  kind: Question<br>  title: &quot;Do you have children?&quot;<br>  input:<br>    control: Switch<br>    off: &quot;No&quot;<br>    on: &quot;Yes&quot;<br>- id: q_number_of_children<br>  kind: Question<br>  title: &quot;How many children do you have?&quot;<br>  precondition:<br>    - predicate: q_has_children.outcome == 1<br>  input:<br>    control: Editbox<br>    min: 1<br>    max: 20</pre><p>There is no “go to” instruction here. The second question simply says: <em>I exist only when the respondent has children.</em> The engine derives the flow from that. It is a small change in syntax but a large change in mindset. The designer no longer draws every route; they describe the logical meaning of every item, and the flow becomes a <em>consequence</em> of the rules.</p><h3>Lazy evaluation: the engine derives the flow</h3><p>The execution model can be surprisingly simple. When the engine needs the next item, it scans from the top of the questionnaire for the first item that:</p><ul><li>has not been answered yet,</li><li>is not an informational comment already passed, and</li><li>has a precondition that is currently true.</li></ul><p>That item is shown. After the respondent answers, the engine checks whether the answer is acceptable, then scans again from the top for the next suitable item. This is <strong>lazy evaluation</strong> applied to questionnaire flow. The engine doesn’t need to know in advance which full path the respondent will take — only which item is currently the first relevant unanswered one. That matters, because complex surveys are full of partial information: at the start, many future questions can’t be evaluated yet because the answers they depend on don’t exist. As the respondent answers, more of the questionnaire becomes meaningful. A declarative engine embraces this instead of forcing the designer to enumerate every journey.</p><h3>Three levels: static, reactive, algorithmic</h3><p>It’s worth being fair to existing tools. Most electronic survey systems support a great deal of logic. You can hide a question, show one only when another answer has a certain value, skip to a later page, pipe a previous answer into later question text. More advanced systems let you calculate values, define variables, or fire triggers. These features are useful — they’re the reason modern online surveys are possible at all.</p><p>But it helps to separate three levels of questionnaire behavior:</p><pre><strong>Level 1 - Static forms</strong><br>Every respondent sees the same fields.</pre><pre><strong>Level 2 — Reactive forms</strong><br>Questions can be shown, hidden, skipped, piped, or mutated based on previous answers.</pre><pre><strong>Level 3 — Algorithmic questionnaires</strong><br>The instrument has explicit state, computed variables, preconditions, postconditions,<br>block-level logic, repeated structures, and analyzable execution behavior.</pre><p>Most tools live firmly at Level 2. They let the questionnaire <em>react</em>. They don’t necessarily let it <em>behave algorithmically</em>. Skip logic is usually framed as forward routing tied to a single closed-ended answer; some tools even warn that a checkbox answer with multiple logic paths can only follow the first selected answer’s path, or that you should attach logic to just one question per page because the survey can’t skip to two places at once. The power is real, but the logic ends up scattered across display rules, calculations, hidden variables, triggers, and survey-flow elements rather than living in one analyzable model. The gap between Level 2 and Level 3 is where complex survey design actually needs to go. The clearest way to see it is with state.</p><h3>The missing thing is state</h3><p>Consider a simple rule:</p><blockquote><em>After the third negative answer, skip the rest of this question block.</em></blockquote><p>This is a natural research rule — it reduces respondent burden. If someone has already rejected three product concepts, disliked three service experiences, or failed three eligibility conditions, the remaining questions in the block may no longer be worth asking. But how do you express this with traditional skip logic? Do you attach the skip to the first negative question? That fails — one negative isn’t enough. To the third question? That fails too, because the third negative answer might land on the fifth, seventh, or tenth question. Do you attach a condition to every question in the block? Then where does the count live — a hidden question, a calculated field, a custom variable, a page-level branch, a survey-flow rule, a trigger, a snippet of JavaScript? And who is responsible for understanding it later: the designer, the programmer, the analyst, the reviewer, the translator, the person debugging the collected data?</p><p>This is where skip logic reaches its conceptual limit. The problem isn’t that the system <em>can’t</em> be forced to do it — a clever designer can usually build a workaround. The problem is that the workaround doesn’t live naturally in the questionnaire model.</p><p>The rule isn’t really a jump. It’s an accumulated state:</p><pre>negative_count = number of negative answers in this block</pre><p>…and the remaining questions share a common condition:</p><pre>ask this item only while negative_count &lt; 3</pre><p>That is algorithmic questionnaire behavior. In a declarative language the design can say it directly:</p><pre>questionnaire:<br>  title: &quot;Concept Test&quot;<br>codeInit: |<br>    negative_count = 0<br>  blocks:<br>    - id: concept_block<br>      kind: Group<br>      title: &quot;Product concepts&quot;<br>      precondition:<br>        - predicate: negative_count &lt; 3<br>      items:<br>        - id: q_concept_1<br>          kind: Question<br>          title: &quot;Would you consider buying Concept 1?&quot;<br>          input:<br>            control: Radio<br>            labels: { 0: &quot;No&quot;, 1: &quot;Maybe&quot;, 2: &quot;Yes&quot; }<br>          codeBlock: |<br>            if q_concept_1.outcome == 0:<br>                negative_count = negative_count + 1<br>        - id: q_concept_2<br>          kind: Question<br>          title: &quot;Would you consider buying Concept 2?&quot;<br>          input:<br>            control: Radio<br>            labels: { 0: &quot;No&quot;, 1: &quot;Maybe&quot;, 2: &quot;Yes&quot; }<br>          codeBlock: |<br>            if q_concept_2.outcome == 0:<br>                negative_count = negative_count + 1<br>        - id: q_concept_3<br>          kind: Question<br>          title: &quot;Would you consider buying Concept 3?&quot;<br>          input:<br>            control: Radio<br>            labels: { 0: &quot;No&quot;, 1: &quot;Maybe&quot;, 2: &quot;Yes&quot; }<br>          codeBlock: |<br>            if q_concept_3.outcome == 0:<br>                negative_count = negative_count + 1</pre><p>This is not merely shorter. It is a different abstraction. The questionnaire has state; the state is updated by answers; the state controls later relevance; the flow is computed from the state. The instruction “skip the rest of the block after the third negative answer” is no longer scattered across many jumps — it’s a rule of the block itself. That is easier to read, and easier to test, document, analyze, and eventually verify.</p><h3>Mutating text is not enough</h3><p>Some tools support dynamic question text — <em>“Why did you dislike [selected product]?”</em> or <em>“You said your household has [number] people; please answer about each of them.”</em> This is valuable: it makes the questionnaire more personal and less repetitive. But mutating text is not the same as algorithmic behavior. A questionnaire with dynamic text can still have entirely static routing.</p><p>The harder cases appear when the questionnaire must <em>compute</em> something, <em>remember</em> it, and use that state to decide what remains relevant:</p><ul><li>After the third negative answer, skip the rest of the block.</li><li>Ask follow-up questions only for the two highest-rated products.</li><li>Stop asking satisfaction details once there’s enough evidence of churn risk.</li><li>Ask a clarification question only if two previous answers contradict each other.</li><li>Prevent a total from being lower than the sum of its parts.</li></ul><p>These are not exotic cases. They are ordinary research requirements — and they’re awkward to express with page jumps and per-question skip rules, because they need a model that treats outcomes, state, conditions, and constraints as first-class concepts.</p><h3>The building blocks</h3><p>In this model a questionnaire is built from a few basic elements. There are <strong>comments</strong>, which display information but collect no answer. There are <strong>questions</strong>, which collect one answer. There are <strong>question groups</strong>, which collect several related answers under one item. There are <strong>matrix questions</strong>, which collect a table of answers — several rating dimensions across several products, household members, or time periods. And there are <strong>repeated sections</strong> (rosters), which apply the same block to each member of a list.</p><h4>Preconditions solve relevance</h4><p>A precondition protects the respondent from irrelevant questions.</p><pre>- id: q_household_size<br>  kind: Question<br>  title: &quot;How many people live in your household?&quot;<br>  input:<br>    control: Editbox<br>    min: 1<br>    max: 20<br>- id: q_children_count<br>  kind: Question<br>  title: &quot;How many of them are children?&quot;<br>  precondition:<br>    - predicate: q_household_size.outcome &gt; 1<br>  input:<br>    control: Editbox<br>    min: 0<br>    max: 19</pre><p>The follow-up appears only if it can make sense. A one-person household needs no composition question. Trivial in a small example — but in a real questionnaire this pattern is everywhere: employment questions depend on labor-force status, medical-history questions on diagnosis, education questions on age, product-usage questions on ownership. In an imperative model all these relationships become routes. In a declarative model they become <em>local truths</em> attached to the items themselves, so the question and its reason for appearing live together.</p><h4>Postconditions solve coherence</h4><p>They must be true after the respondent answers:</p><pre>postcondition:<br>  - predicate: q_driving_years.outcome &lt;= q_age.outcome - 16<br>    hint: &quot;Driving experience cannot exceed the number of years since turning 16.&quot;</pre><p>A postcondition means the answer isn’t merely checked against a fixed range — it’s checked against the respondent’s previous answers. A 50-year-old can report 30 years of driving experience; a 20-year-old cannot. The survey is no longer asking only <em>“Is this number between 0 and 100?”</em> It’s asking <em>“Does this answer make sense in the context of the conversation?”</em></p><h3>When logic gets real: three problems the platform must solve</h3><p>Once a questionnaire genuinely behaves like a small program, three deeper questions appear. They are not edge cases — they are ordinary requirements in serious instruments. The useful reframing is this: <strong>existing survey systems can react to answers; a declarative engine can reason about them.</strong></p><h4>Problem 1 — Validating an answer against earlier answers</h4><p>Most form validation starts with the field itself: Is this number between 0 and 100? Is the option allowed? Is the field empty? Useful, but not enough. In a questionnaire, the <em>meaning</em> of an answer often depends on previous answers.</p><pre>- id: q_age<br>  kind: Question<br>  title: &quot;How old are you?&quot;<br>  input: { control: Editbox, min: 0, max: 120 }<br>- id: q_driving_years<br>  kind: Question<br>  title: &quot;How many years have you been driving?&quot;<br>  precondition:<br>    - predicate: q_age.outcome &gt;= 16<br>  input: { control: Editbox, min: 0, max: 100 }<br>  postcondition:<br>    - predicate: q_driving_years.outcome &lt;= q_age.outcome - 16<br>      hint: &quot;Driving experience cannot exceed the years since turning 16.&quot;</pre><p>The input range (0–100) is still too wide. For a 60-year-old, 40 years of driving is possible; for a 20-year-old it’s impossible. The validation rule is not <em>local</em> to the question — it is <em>relational</em>. It says: this answer is valid only in relation to an earlier one.</p><p>The same idea runs through many domains. A child can’t be older than the parent. Household income can’t be lower than the sum of reported personal incomes. The number of employed people can’t exceed household size. A respondent can’t report <em>using</em> a product before reporting they <em>know</em> it exists. A total allocation can’t exceed 100%.</p><pre>- id: q_personal_income<br>  kind: Question<br>  title: &quot;What is your annual personal income?&quot;<br>  input: { control: Editbox, min: 0, max: 1000000 }<br>- id: q_spouse_income<br>  kind: Question<br>  title: &quot;What is your spouse&#39;s annual income?&quot;<br>  precondition:<br>    - predicate: q_married.outcome == 1<br>  input: { control: Editbox, min: 0, max: 1000000 }<br>- id: q_household_income<br>  kind: Question<br>  title: &quot;What is your total annual household income?&quot;<br>  input: { control: Editbox, min: 0, max: 2000000 }<br>  postcondition:<br>    - predicate: q_household_income.outcome &gt;= q_personal_income.outcome + q_spouse_income.outcome<br>      hint: &quot;Household income cannot be lower than the personal incomes already reported.&quot;</pre><p>Traditional systems handle these through input validation, calculated fields, data cleaning, or custom scripts. A declarative questionnaire treats them as part of the item definition: the question states not only <em>what can be entered</em> but <em>what must remain true after this answer is given</em>. That shifts part of data quality from post-collection correction to point-of-collection prevention. It doesn’t replace statistical cleaning, and it doesn’t know whether the respondent is honest or the wording biased — but it stops a large class of mechanical and logical errors from entering the dataset at all.</p><h4>Problem 2 — Computing the right order</h4><p>Suppose an item has the condition <em>ask </em><em>q_child_age only if </em><em>q_has_children == Yes.</em> Then q_has_children must be answered first. Obvious. But real questionnaires aren&#39;t always obvious: a later question may depend on a calculated score; the score may depend on three earlier answers; one of those may live inside a matrix question; another inside a repeated household-member section; a block may depend on a counter updated by several items.</p><p>The question is no longer <em>“What should come next?”</em> but <em>“What must already be known before this condition can be evaluated?”</em> That is a dependency problem. A declarative engine can analyze every precondition, postcondition, and computation and build a <strong>dependency graph</strong>: if B uses A’s answer, B depends on A; if C uses a variable computed from A and B, C depends on both. From that graph it derives a safe evaluation order — so the questionnaire doesn’t rely on the author’s intuition that the items happen to be in the right sequence; the platform can <em>prove</em> every condition is evaluated only after the values it references exist. In a declarative model, dependencies are first-class, so the system can detect the cycle and name the items that participate in it.</p><h4>Problem 3 — Static validation before fieldwork</h4><p>This is the most important one. How do you validate a questionnaire full of conditional logic? Manual testing helps — a tester tries many paths, a reviewer inspects the flow, a designer previews the instrument — but testing shows the paths you <em>tried</em>. It can’t guarantee that <em>all possible</em> respondent paths are sound. And adaptive questionnaires have an enormous number of routes: every conditional question multiplies the possible states, every computed variable adds a layer, every block-level rule changes what can happen later.</p><p>Static validation asks different questions:</p><p>Not <em>“Did this preview session work?”,</em><br>but <em>“Can any respondent reach an impossible state?”</em></p><p>Not <em>“Did I see every important branch?”,</em><br>but <em>“Is this question reachable by at least one valid respondent?”</em></p><p>A serious validator checks at least:</p><ul><li><strong>Can each item be reached?</strong> If not, it’s <em>dead code.</em> For example, a precondition like q_years_employed.outcome &gt;= 20 and q_years_employed.outcome &lt; 10 can never be true — yet the question still has text, options, translations, maybe interviewer notes, and everyone assumes it&#39;s part of the instrument. No respondent will ever see it.</li><li><strong>Can each postcondition be satisfied?</strong> If a question can appear but no valid answer exists, the questionnaire traps the respondent. Picture a budget survey where the parts already reported sum to at least 30,000, but the “total budget” field is capped at 25,000. No one can answer correctly — and that’s a design error, not a respondent error.</li><li><strong>Are there circular references?</strong> If A depends on B and B on A, the engine can’t know which to evaluate first.</li><li><strong>Are the accumulated rules consistent?</strong> A question can look reachable in isolation yet be impossible once earlier answers and constraints pile up.</li><li><strong>Can the questionnaire terminate cleanly?</strong> There should be no state where the respondent can’t continue, can’t correct an answer, and can’t finish.</li><li><strong>Is each rule attached to the right conceptual level?</strong> A rule about “three negative answers in this block” belongs to the block’s state, not to some arbitrary individual question.</li></ul><h3>Why this matters more with AI-generated questionnaires</h3><p>AI can now draft questionnaires quickly. That’s useful — it helps move from an objective to a first version, suggest dimensions, formulate items, propose scales, generate demographic sections. But generation is not design, and generation is definitely not validation. A language model can produce a questionnaire that <em>looks</em> plausible while containing unreachable questions, contradictory rules, missing constraints, inappropriate ordering, or inconsistent answer domains. This isn’t a knock on AI — humans make the same mistakes. The difference is scale. If AI helps generate hundreds of interconnected questions, the need for a precise, analyzable representation of questionnaire logic gets <em>stronger</em>, not weaker. The future of questionnaire design shouldn’t be “let AI generate a long form and hope for the best.” It should be a clearer division of labor: AI proposes the instrument; the designer reviews concepts and wording; the language captures the logic declaratively; the platform checks reachability, consistency, and execution behavior before deployment; the engine asks only the next relevant item.</p><p>AI helps with content. The declarative model protects structure. The researcher remains responsible for meaning.</p><h3>What changes for the designer</h3><p>The designer stops asking <em>“Where should the respondent go next?”</em> and starts asking <em>“When is this question meaningful?”</em> It sounds small; it changes the whole workflow. For every item you can now ask: Who should see this? What previous answers does it depend on? What values are allowed? What would make an answer inconsistent? What should the respondent see if the answer doesn’t make sense? Does this item belong to one respondent, one household member, one selected product, or a whole matrix of repeated dimensions? The result is a questionnaire that’s easier to inspect — not necessarily shorter or simpler, but more explicit. And explicit logic is the first step toward reliable logic.</p><h3>What this does not solve</h3><p>A declarative questionnaire language is not magic. It won’t write unbiased questions, choose the right sampling frame, eliminate nonresponse, or solve social-desirability bias. It won’t decide whether an open- or closed-ended question is methodologically better, and it won’t replace cognitive testing, pilot studies, expert review, translation review, or fieldwork experience. Those remain essential parts of survey methodology. What it addresses is a different layer: the <em>logical structure</em> of the questionnaire — whether the adaptive instrument behaves as intended. That layer deserves its own tools.</p><h3>From survey scripting to questionnaire engineering</h3><p>The survey world already knows that questionnaire design is a serious methodological discipline. The software world already knows that complex logic needs better abstractions than tangled control flow. Declarative questionnaire design brings the two together. It treats the questionnaire as both a research instrument and an executable object — respecting that wording, order, response options, and respondent burden matter, while recognizing that adaptive logic can fail. The three levels make the destination concrete. A <em>static form</em> asks the same fields of everyone. A <em>reactive form</em> can hide, show, skip, pipe, mutate, or calculate based on previous answers. An <em>algorithmic questionnaire</em> has explicit state, dependency-aware ordering, semantic validation, block-level rules, and static analysis. The difference between the second and third is not cosmetic — it changes what the platform can <em>understand</em>. In a reactive form the author says <em>“if this answer is selected, jump there.”</em> In an algorithmic questionnaire the author says:</p><blockquote><em>This item is relevant under these conditions. This answer is valid only if these relationships hold. This block continues while this state remains true. This computed value summarizes these previous outcomes. This questionnaire is valid only if no reachable respondent state contradicts these rules.</em></blockquote><p>That is a richer model — and closer to how researchers actually think. A researcher doesn’t start with arrows. They start with meaning: Who’s eligible? Which follow-up is relevant? What would make an answer inconsistent? When do we already know enough? When should we stop asking? What must be true for the resulting data to be defensible? A declarative language lets those ideas appear directly in the questionnaire — and once they’re explicit, the platform can reason about them.</p><h3>Conclusion</h3><p>For decades, complex questionnaires have been treated as forms with routing instructions. But a modern adaptive questionnaire is more than that. It is a structured, stateful, respondent-specific conversation with logic, dependencies, constraints, and failure modes. If we keep encoding that logic as a maze of jumps, we shouldn’t be surprised when the maze becomes hard to reason about. A declarative approach offers a cleaner alternative. Each item declares when it is relevant. Each answer declares what values are valid. Each consistency rule declares what must remain true. The engine derives the flow.</p><p>That is the shift questionnaire design needs:</p><p><strong>From paths to predicates. From jumps to meaning. From survey scripting to questionnaire engineering.</strong></p><h3>Notes and further reading</h3><p>The framing here draws on a long tradition in survey methodology and questionnaire theory. Useful starting points:</p><ul><li><strong>Spencer</strong>, <em>The Case Against the Skip Statement</em> — argues that handling skips one at a time obscures questionnaire complexity, and that questionnaires can be understood algorithmically. Closest in spirit to the argument above.</li><li><strong>Bethlehem &amp; Hundepool</strong>, <em>TADEQ</em> — documents how computer-assisted interviewing made very large, complex electronic questionnaires possible while making their content and structure harder for teams to keep under control.</li><li><strong>Feeney &amp; Feeney</strong> — on questionnaires as questions, responses, and skip instructions, and the need for shared vocabulary between questionnaire designers and programmers.</li><li><strong>Willenborg</strong> — formalized routing and edit structures, and proved that checking their combined consistency is NP-complete (the reason exhaustive path testing doesn’t scale).</li><li><strong>Krosnick &amp; Presser</strong>; <strong>Tourangeau, Rips &amp; Rasinski</strong>; <strong>Dillman, Smyth &amp; Christian</strong> — the broader methodological backdrop: the questionnaire as the heart of a survey, the respondent’s cognitive process, and modern survey-design practice.</li><li><strong>Sághelyi &amp; Bereczky</strong> — <a href="https://doi.org/10.17048/icai.2026.227"><em>Formal Verification of Questionnaire Logic Using SMT Solvers</em></a> (ICAI 2026) — the formal version of this argument: questionnaires modeled with Hoare-style pre- and postconditions and checked statically with an SMT solver.</li></ul><h3>Hey, wanna see it in action?</h3><p><a href="https://askalot.io/">Askalot - The Research Operating System with mathematically verified questionnaires</a></p><p><em>If you publish this elsewhere as well, set a canonical link to the original so search engines know the source.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0cLwZZ9oFlSvHeIdxiz7gQ.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fac7e3465949" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>