Home / Docs / Specification
26. Long-running programs
Status: Normative, edition 0.4 preview (ADR 0116).
A program that runs until it is told to stop, such as a game loop, a server or a worker, hands its loop to the host, or runs a for ever loop in a function whose header says diverges. The rules of ADR 0116 join this chapter as they land, each with its conformance cases; until a rule has landed, the construct it defines is a syntax error (U0101) or its word is reserved (U0103).
Editions. The rules of this chapter apply only to packages of edition 0.4 (spec/13 §7). Earlier editions do not change, with one exception: the rule for quiet code (§6 rule 4) is applied in every edition, since it protects the trace and needs no syntax. In an earlier edition it reaches only the constructs that edition has: a call, an operation or a with under a raised program counter is quiet in Core, a handler that quiet code installs is with:<h>#q, the operations it serves append no event (#1544), and an operation performed in quiet code appends no event to a run's trace (S-42, spec/11 §5).
1. Edition and words
- Edition. A package of edition
0.4names it inita.una(edition 0.4, spec/30);una.tomlnaming it is U7002, withuna migrateas its repair (ADR 0122 Question 8.1). Edition0.4is cumulative over edition0.3, as0.3is over0.2: it has every construct, keyword and rule of edition0.3. It is a preview under the terms of edition0.3(spec/13 §7) until the rules that target it have landed. - Reserved words. In edition
0.4,divergesandwithinare reserved: used as an identifier, each is U0103,`<word>` is reserved for edition 0.4 (long-running programs).divergesis a word of a header (§5), andwithinone right afterfor ever(§7) and right after an expression, the deadline of spec/27 §5 (ADR 0117 rule 5); elsewhere both stay reserved, so neither can be a name. In earlier editions they are identifiers.
2. The host-driven step
-
The
drivesection. In edition0.4, thedrivesection ofita.una(ADR 0122 rule 11) names a module of the package whose loop the host runs (ADR 0116 rule 1):unadrive module game ticks 16 budget 8moduleis a module of the package.ticksis the tick period in milliseconds, an integer from 1 to 86,400,000.budget, optional, is the time limit of one step in milliseconds, with the same range.- Each of these is U7008: a missing
moduleorticks, a value out of range, and adrivesection together withrun entry. Amodulethat is not a module of the package is U7002, as arun entrythat names none is. run grantskeep their meaning. A dependency'sdrivesection is not read.
-
The module. The module of
drivedeclarespub init() -> S,pub step(edit state: S, input: Tick) -> Unitand, optionally,pub on_stop(state: S) -> Unit, for one typeS, withTickofstd.drive.std.drivedeclarespub kind Tickwith the fieldsat: Int of Millisecond, the scheduled time of the tick from the first one, andmissed: Int, the number of due ticks skipped just before it.std.timedeclares the measuresSecond,MillisecondandMinuteand the constantssecond,millisecondandminuteofInt of Millisecond, whose values are 1000, 1 and 60000 (ADR 0116 Amendment of 2026-10-19), and the failure kinds ofwithin,Timed[E]andDeadline(spec/27 §5).- Effects. The three functions MAY have
uses, checked against the grants asmain's are (U3012, spec/05 §7 rule 2). - Failures.
stepandon_stopMUST NOT declarefails: the host has no caller to give a failure to, so each handles inside it what it meets (U3029 at the clause).initMAY fail, and its failure ends the run as one ofmaindoes (U6001, at the name ofinit); its message namesinitand the driven module where one ofmainnamesmain, as in`init` of the driven module `metronome` failed with `Stuck`, in both engines and in a native executable (issue #1809). - No preconditions. None of the three has a
requiresclause: the host callsinitonce,stepfor every tick andon_stopat the stop, and no call of the host establishes a precondition, so arequireswould be a fact the verifier assumes and nothing proves. Arequireson any of them is U7008 at the section'smodule, with the clause as the related span, inuna check; so is a refinement at any depth of the type of a parameter or of the result of any of them, at its top or in a type argument (ofOption,List,Map, a dense value, a collection or a generic kind) or in a parameter, the result or the failure kind of a function type, written there or carried by a refined kind such askind Calm = Tick where it.missed == 0or an alias of one, with the type as the related span: the host givesstepeach tick with no fact about it, and hands the state from one function to the next by its typeSalone, with no fact about it, so a refinement is the same precondition and the shapes are exact. The fields of a kind are not looked into, since each construction of the kind proves their refinements. A refined result ofinitis refused as well, although the body ofinitwould prove it, so that the three shapes stay exact; anensuresoninitstates such a fact instead. Labels are not refinements:inputkeeps the label of rule 5. (Edition 0.4 preview, as spec/31 §7 rule 2 forserve.) - Labels. The host hands the state from one function to the next with no label rule of its own, so each hand-off is a flow into a declared type (spec/07 §7 rule 2): the result type of
initMUST flow into the declared type of the state parameter ofstepand ofon_stop, and the declared type of the state parameter ofstepinto that ofon_stop, with the labels compared at every position of the type. Otherwise the package is rejected with U4001 at the type of the parameter, the source of the flow as a related location (issue #1642). A state labeled higher insteporon_stopthan in the result ofinitis legal. The shapes below compareSwith labels aside, at every position of the type, the parameters and result of a function type included (issue #1644). - Units. The host hands the state on unchanged, so the units of measure of
SMUST be the same at every position of the type, by the normal form of spec/25 §2 rule 2 (ADR 0104): the result type ofinit, the type of the state parameter ofstepand that ofon_stop, at their top and in each type argument (ofOption,List,Map, a dense value, a collection or a generic kind) and in each parameter, the result and the failure kind of a function type. A difference only in units, or between a measured and a unitless type, is U2028 at the type of the parameter, with the source of the hand-off as a related location, inuna check, as the same flow is in ordinary code (spec/25 §2 rule 4):init() -> Int of Secondwithstep(edit state: Int of Millisecond, input: Tick)is U2028 (issue #1647). Core IR erases units, souna runanduna buildalso compare the units of the three types the checker recorded, and refuse a difference as the usage error of the shapes below. A state whose units must change is converted in the body withconvert(). With rule 2's refinements and these units, the shapes are exact, labels aside. - Refinements at run time. Since a refinement in
Sis U7008 inuna check,una runanduna buildnever see one in a package that checks; as defense in depth they compare the refinements of the three types too, predicate by predicate and in order, at every position, and theusesandfailsof a function type exactly, and refuse a difference as the usage error of the shapes below (issue #1644). - Shapes. A module without
initorstepof these shapes, or with anon_stopof another shape, is a usage error ofuna runanduna build, exit code 2, as an entry withoutmainis (spec/13 §5).
- Effects. The three functions MAY have
-
The driver.
una runand the executable thatuna buildwrites run the driver instead ofmain:- It calls
initonce. Its result is the state. - Tick
kis duek × ticksmilliseconds afterinitreturns, on the run's clock: the monotonic one, or the virtual one of §8 under--virtual-time. On the monotonic clock, the momentinitreturns and each tick's moment are readings in nanoseconds, so tickkis due exactlyk × ticksmilliseconds after it, whatever phase within a millisecondinitended at (ADR 0116 amendment, P13). Theatof a tick stays in milliseconds. Before each step, the driver waits for the next tick that is due, or, when some are already due, delivers the latest one withmissedset to the number it skipped. A slow step therefore never makes the state fall further and further behind. - It calls
step(edit state, input: tick)with each tick, and the statestepleaves is the state of the next one. - When the loop stops, it calls
on_stop(state)when the module declares it, and the run ends with exit code 0. - Both engines run the same driver, and their outputs and traces compare under spec/16 §5.
- It calls
-
Stopping. The driver's loop is a
for ever(§5): a host stop request (§6) interrupts its wait for a tick, within 100 ms at worst, or the waitingHttpoperations of the step that runs, and the loop stops at its next iteration start. The trace then gets an event whoseoutcomeis{"kind":"stop"}, which names no operation,on_stopruns, and the run ends with exit code 0, unless the hard stop of §6 comes first. The budget is read and kept, and it bounds no step yet: the deadlines offor ever within(§7) do not apply to it. -
The timing label of a tick (IF7).
atandmisseddepend on how long earlier steps took. So theinputparameter ofstepMUST be labeled at leastτ, the timing label of the step, or the package is rejected with U4001 at the parameter. The message names the largest source ofτand the labelinputneeds.τis the join of:- the deep label (spec/07 §7 rule 3) of each parameter's declared type of
step; - for each operation in the effects of
stepand of every functionstepcan reach, its result type's deep label, itsacceptslabel and its failure kind's deep label; - for each handler a reachable
withinstalls, the deep labels of its parameters,⊤for a parameter whose type holds a function type: a function type itself, or one at any depth in a field of a kind, an element of aList, a value of aMap, anOption, aResultor any other type argument, whether or not its operations call it, since its type does not bound what that function runs; and what its operation bodies run, their lambdas and tasks included, counted as for the code ofstep: the operations they perform (item 2), the functions they call with what those reach, the handlers they install (this item), and item 4 for the function values they call and the prelude functions they apply (issue #1436); and, for an operation of a capability that is not a host capability with no installation known on the way, the same for every handler of that capability in the package; ⊤, whenstepor a function it can reach calls a function value, calls a function of the prelude with a function argument whose code is not known at the call, or names such a function as a value. The code of a function argument is known at the call only when the argument is a lambda written there for a parameter whose declared type is a function type (ADR 0116 IF5 item 4, issue #1023); a lambda given to a parameter of another type, such asfold'sinitial, a parameter, a local bound to a lambda, a field of a kind, a named function, a receiver and any other expression are not known. A call whose every argument that may hold a function is such a lambda adds no⊤here: the lambda's captures and what its body calls and performs count under items 1 to 3, as for code written outside it (the rule below);conc(step)of spec/27 §11 rule 4: the labels of the work that can run beside a call ofstep, over every call ofstepin the package,publicwhen no part of a construct reaches it;L_res, the residue label of §7 rule 5 (ADR 0116 amendment, P9): requests that canceled tasks leave on helpers slow the step, and so the next tick'satandmissed.- the deep label of every value that
stepand the code it reaches compute, as §7 rule 5 item 7 states (ADR 0116, amendment of 2026-11-06; issue #1685).
A
stepwhose effects only printpublicvalues and whose state ispublichas apublicτ, and itsinputneeds no label.A lambda written at the call (issue #1023). Its label is that of what it captures, and that label is a sound upper bound of what its running time can depend on, for three reasons:
- What it captures is already counted. A lambda written in
step, or in a functionstepreaches, captures bindings of that body. Item 1 countsstep's parameters, item 2 the operations' answers, and the program counter and every other value of such a body is computed from those and from constants, so its captures carry nothing the other items do not bound, exactly as the body's own locals do. The lambda's parameters are given by the prelude function from its other arguments, which come from the same body. - What it runs is already counted. Its body is checked where it is written, so the functions it calls and the operations it performs are calls and operations of the enclosing body, and items 2 to 4 count them; a call of a function value inside it is item 4's
⊤. - It runs only during the call. A lambda counts as known only when it is the argument of a parameter whose declared type is a function type. The prelude's functions with such a parameter,
map,filter,first_where,fold, themap,zip_map,updateandfoldof the dense values and theupdateof a map and of a hash map, apply that argument while the call runs and keep no copy of it, since no declared result of theirs is a function type and none returns a value of that parameter. A function argument at a parameter of another type may be returned:foldreturns itsinitial, aUthat may be a function, so a lambda written there can run after the call, and it keeps⊤, as the receiver and every other argument that may hold a function do. A standard function that keeps an argument of a function-typed parameter MUST NOT be given this rule.
A lambda bound to a local, stored in a field or passed to a function of the package is a function value wherever it is later called, which keeps
⊤, however it was written: the call does not see which lambda it gets.Handlers (issue #1436). Item 3 counts a handler as ADR 0116 IF5 item 3 states: by its parameters' types and by the effect set of its operation bodies, taken in the same way as the site's own code. Until this fix, a parameter that held a function inside a kind, a list or an option counted by its deep label, and the calls of function values, the opaque applications and the calls of functions in an operation body did not count, so a function the handler was installed with could run a loop of
secretlength inside a deadline unseen. Counting them is a fix of soundness, not a refinement, so it is stricter than the rule before it.⊤for a parameter that holds a function and that the operations never call is the strict choice: a call of it anywhere would make the label⊤through item 4 in any case, and the type alone does not bound what it runs. What an operation body runs counts for the whole handler, not for the operation alone: a site that reaches the handler through one operation counts what every operation of it runs. This is coarser than ADR 0116 IF5 and sound; in the preview it MAY become more precise. One rule decides whether a type holds a function, for item 3, for the arguments whose code is known under item 4 and for the function values that cross a boundary (ADR 0093 rule 8): a type parameter, a type not yet inferred and a kind with a field that holds a function hold one in a package with or without boundaries. So generic code that gives a value of a type parameter's type to a boundary, or to a prelude function that applies a function argument, can be rejected where it was accepted before; the change is in the safe direction.Preview over-approximations. Item 4 is coarser than ADR 0116 IF5, which looks at the captures of the function values a site calls. Item 4 counts a lambda written at the call of a prelude function, for a parameter of function type, by its captures, and keeps
⊤for every other function value, a named function and a lambda passed to a function of the package included.L_res(§7 rule 5, item 6) andL_lim(spec/27 §9 rule 5), computed over the call graph of ADR 0116 P1, where every lambda is the one nodeΛ, keep⊤for every call of a prelude function with a function argument. They are sound:⊤is the mostτcan be. In the preview they MAY become more precise, so that a package accepted today stays accepted, and they MUST NOT become stricter. - the deep label (spec/07 §7 rule 3) of each parameter's declared type of
3. stop and skip
-
Grammar. In edition
0.4, a statement MAY bestop,stop whenfollowed by a line expression, orskip, each alone on its line (ADR 0116 rule 5):ebnfstop_stmt = "stop" [ "when" line_expr ] NEWLINE ; skip_stmt = "skip" NEWLINE ;stopandskipare words, not keywords: they start these statements only at the start of a statement line, alone or beforewhen, and they stay identifiers elsewhere. Before edition0.4they are identifiers, so these statements do not exist there: a barestoporskipline is a name, an expression like any other (U1001 unless a binding of that name is in scope), and awhenafter the word does not parse (U0101). (Note of 2026-11-09, #1807: this sentence said U0101 for the bare line too; a bare line is a name, as the keyword tables of spec/01 §5, where neither word is reserved before edition0.4, make it.)skiptakes nowhen(U0101): anifaroundskipsays the same.- A block that ends in
stoporskiphasunitas its value. - A statement after an unconditional
stoporskipin the same block never runs, and is U2040 at the first such statement, whose repair removes them (ADR 0116, amendment of 2026-10-19). Statements afterstop when c, and after the block that holds the exit, stay legal.
-
Meaning (ADR 0116 rule 6).
stopends the innermost enclosingforloop.stop when cdoes so whenc, aBool, holds (U2001 otherwise), and does nothing otherwise.skipends the current iteration and goes on to the next.- The bindings the loop updates keep the values they have at the statement: after
stopthey are the loop's final values, and afterskipthe next iteration starts with them.
unalet edit total = 0 for order in orders if order.cancelled skip stop when total > limit total = total + order.amount -
Where (U2034).
stopandskipbelong to the body of their innermost loop. Each is U2034:- outside any loop body;
- when the innermost loop lies outside the nearest enclosing task: the body of a
together forand a branch oftogether(spec/19) are not loops for them, and a loop inside the task is.
-
Core (ADR 0116 rule 20).
stopandskiplower toexit_k(b, ...), with the tagk,stopornext, and the current values of the loop's stateb, ...(spec/09). The end of the body is the tagnextwith the body's value. Astopends the loop, whose value is that state.stop when cisif caroundstop. Both engines run them alike (spec/16 §5). -
Verification (ADR 0116 V2). Each
stopandskipis a join of the bindings the body updates. Each rebind of a binding with a refined declared type carries its obligation where it happens (spec/17 §5 rule 2), so the refinements hold at eachstopandskipas at the end of the body. On the path paststop when c,cis false. After the loop, the bindings it updates are fresh at their declared types, as after any loop (spec/17 §5 rule 3). The length frame of ADR 0071 countsskipandstopas paths that complete an iteration. -
Information flow (ADR 0116 IF2, IF3).
- Whether later iterations run must not depend on data the body did not start with.
stopandstop when care legal only where the program counter, joined with the label ofc, is the one the loop's body starts with. Otherwise the statement is U4002, with the condition that raised it as a related location, as forfail(spec/07 §3 rule 3). skipinside a branch oncmakes the rest of the body run only when the branch was not taken: the statements of the body after it are checked under the program counter joined with the label ofc.
- Whether later iterations run must not depend on data the body did not start with.
4. for until c decreases m
-
Grammar. In edition
0.4, aforstatement MAY befor until c decreases mwith a block (ADR 0116 rules 5 and 7):ebnfuntil_stmt = "for" "until" line_expr "decreases" add_expr NEWLINE INDENT block DEDENT ;untilanddecreasesare words:untilright afterforstarts this form whenindoes not follow it, sofor until in xsis a loop overxswhose variable isuntil.- Without
decreasesit is U0101,`for until` needs a `decreases` measure.
-
Meaning. At the start of each iteration,
cis evaluated with the current values of the bindings, and when it holds the loop ends.cis aBool(U2001).stopandskipwork in the body as in everyfor(§3). -
The measure.
mis an expression of an integer type (Int, a fixed-width type or a measured type), in the refinement language (U2014 otherwise), over the bindings in scope; another type is U2001. It is never evaluated: it exists for the verifier. -
Verification (ADR 0116 V1, V3). The loop carries the obligations
decreases_boundanddecreases_stepof spec/12 §3, under the loop's invariant: the bindings the body updates are fresh at their declared types, and the facts of the enclosing context are kept (spec/17 §5 rule 3).- When
cis in the refinement language,not cis a hypothesis in the body. decreases_bound: where the loop continues,m >= 0.decreases_step: at the end of the body and at eachskip,mis less than at the start of the iteration. A path that ends atstopcarries neither obligation.- Together they prove that the loop ends.
- After a
for untilwhose body has nostopof it, and whosecis in the refinement language,cholds. After every loop, the bindings it updates are fresh at their declared types.
- When
-
Information flow (ADR 0116 IF1). The body runs under the program counter joined with the label of
c, since how many iterations run depends on it, as aforover a list runs under the list's top label (spec/17 §6 rule 3).mis erased. -
Core (ADR 0116 rule 20). The loop is a Core
loopwhose source isuntil(c), withcan expression over the state that both engines evaluate before each iteration, its formula when it is in the refinement language, and the measure as a clause.
5. diverges, for ever and on stop
-
Grammar (ADR 0116 rule 5). In edition
0.4:ebnfclause = ... | "diverges" NEWLINE ; (* after "fails", before "derived from" *) ever_stmt = "for" "ever" NEWLINE INDENT block DEDENT [ on_stop ] ; on_stop = "on" "stop" NEWLINE INDENT block DEDENT ;divergesis a clause word, and stays reserved elsewhere (§1 rule 2).everright afterforstarts this form whenindoes not follow it, sofor ever in xsis a loop overxswhose variable isever.onstays an identifier.on stopafter a loop other thanfor everis U2034.una fmtputsdivergesafterfails.
-
diverges(ADR 0116 rule 8). A function whose header saysdivergesmay run forever. It is never inferred, so it shows in every header that has it, anduna contractreports it as the keydiverges, aBool, afterfails.- Where.
for ever, and a call of a function that saysdiverges, are legal only in the body of a function that says it (U3027), and not in a lambda, atogethertask, anon stopblock or the body of afor ever(U3027). The functions of a driven module may not say it. - Not a value. A function that says
divergesis not a value: naming it other than as a callee is U3028.
- Where.
-
for ever(ADR 0116 rules 9 and 10). The body runs again and again, under the program counter of the enclosing code (IF4). The loop ends only bystop, by a host stop at the start of an iteration, by a failure of its body or by the cancellation of its task. Each iteration ends: its body runs nofor everand calls no function that saysdiverges(U3027), its other loops are bounded or proven to end (§4), and recursion is bounded by--max-depth. -
on stop(ADR 0116 rule 10). It runs once the loop has ended, in any of these ways, and sees the bindings the body updates, with their values where the loop ended. After a failure of the body, those are their values from before the loop, and the failure propagates after the block. Its statements MUST NOT fail: each fallible one is handled where it is (U3029). It runs nofor everand calls no function that saysdiverges(U3027), andstoporskipin it is U2034. Execution then goes on after the loop.unalog_forever() -> Unit uses @console: Console[print] diverges = let edit n = 0 for ever @console.print("alive {n}") n = n + 1 stop when n == 1_000_000 on stop @console.print("done") -
Verification (ADR 0116 V3, V4). After a
for ever, the bindings it updates are fresh at their declared types, andon stopis verified with them fresh. A function that saysdivergeskeeps partial correctness: itsensuresholds whenever it returns. -
Core (ADR 0116 rule 20). The loop is a Core
loopwhose source isever, with itson stopblock, which binds the state afresh and returns it as the loop's value. -
Host stops. A
for everwithoutstopends by a failure of its body, at the first iteration start after a host stop request (§6), or at the iteration start where its own budget of--stop-after-iterationsor of a test'sstop afterline ends (§6 rule 1, §8 rule 1).
6. Host stops
-
Requests (ADR 0116 rule 14). These are host stop requests of a run of
una runor of an executable:- SIGINT or SIGTERM, delivered to the process;
- the end of
--deadline <seconds>, counted from the start of the run, and local to the run.
A request is sticky: once one has arrived, it stays for the rest of the run. The run's own request, the deadline's, counts once, however many tasks reach it together.
The iteration budget (ADR 0116 rule 19, #1472).
--stop-after-iterations <n>, and a test'sstop after Nline (§8 rule 1), are not host stop requests. They give each loop instance a budget ofniterations: each entry into afor ever, and the driver's loop (§2), counts its own iteration starts from 0, and that instance ends at the start of its iterationn + 1, as at a stop point after a request (rule 4 item 2): it appends thestopevent, and then itson stopruns. Nothing else changes: the end of one instance's budget interrupts no operation, does not reach any other loop, a loop entered later included, and starts no grace period (rule 6). How many iterations one loop ran, under any branch, therefore never changes where another loop stops. A count shared across loops would: afor everunder asecretbranch would move where a laterpublicloop stops, and the output would reveal the secret. -
Flags (spec/13 §5, spec/16 §3).
--deadlinetakes whole seconds from 1 to 31,536,000;--stop-gracetakes whole seconds from 1 to 86,400, and is 10 when not given;--stop-after-iterationstakes an integer from 1 to 2^63 − 1. Any other value, or one that is not a number, is a usage error, exit code 2. -
Signal handlers (ADR 0116 rule 18). A run installs handlers of SIGINT and SIGTERM only when it runs a driver or its
mainsaysdiverges, the only ways a run reaches afor ever(§5 rule 2). Any other run keeps their default actions, so a signal ends it as before. A handler only records the request and wakes the waiting operations. The wake pipe the handlers write to lies at descriptor 512 or above, or, under a soft limit of open files (ulimit -n) below 514, as high as the limit allows, and at the lowest free descriptors from 3 when those are taken, never on standard input, output or error. When the handlers are installed, at the run's start beforemain, a soft limit below 16, or fewer than four free descriptors under the limit, is a usage error, exit code 2, in both engines (#1757).una runchecks the package first: a check that runs the solver under a hard limit below 16 is U5003, since the solver's confinement sets its own limit of 16 (spec/12, ADR 0124 rule 7). -
After a request (ADR 0116 rules 12 to 14):
- Interruption. An
Httpoperation in the body of afor ever, in that body's own task, callees included, fails withHttpError.Interruptedwhen it is waiting at the request, or when it starts after it. A request that has started may or may not have reached its server: it was performed at most once. The trace records the failure as any failure of an operation. Operations outside everyfor everbody,on stopblocks included, and in the tasks atogetherblock starts, are not interrupted. A waiting operation sees the request within 100 ms at worst, and at once after a signal or the deadline: once connected, a request never blocks on its socket, so a peer that sends part of a response, or stops reading, cannot hold it. In this release, name resolution and the connection of a request are not interrupted: a request that waits there fails withInterruptedwhen they return, within the request's own deadline (spec/24 §4). - Stop. Every
for everthat reaches an iteration start ends there, as bystop, keeping its bindings, a loop entered after the request included. It appends{"seq": n, "outcome": {"kind": "stop"}}to the trace, unless it is quiet, and then itson stopruns.- Quiet code (S-39, ADR 0116 amendment of 2026-11-06). The events that the runtime appends by itself, a loop's
stop, awithin'stimeoutand a task'scancelled(spec/27 §5,§6,§7), are sinks that acceptpublic, asConsole.printis (spec/07 §4). Code is quiet when it stands under a program counter abovepublic, joined with the effect floor of an operation body and the timing floor of awithinas an effect's is (spec/07 §3 rule 4, spec/27 §5), or when it runs inside a call or an operation that stands under one. A call of a function value labeledl_f, through a kind's field too, stands underpc ⊔ l_f, joined with the decisions its arguments carry (spec/07 §3 rule 4,§7), so it is quiet whenl_fis abovepublic, at apublicprogram counter as well. Callees, the operations of handlers and the tasks they start count too, since a started task runs under the program counter of itsstart(spec/27 §7 rule 3). Quiet code appends none of those events and takes noseqfor them, and it counts none of itstasksstatements,first ofblocks andstarts: their parts of a path areqs,qfandq, with no number, and they move no number of public code (S-40, S-44, spec/27 §6 rule 5,§7rule 5). Nor does it number its handler installations: each instance it installs iswith:<h>#q, with no number (S-41, #1514, spec/27 §8 rule 1). An operation served by an instance that quiet code installed appends no event and takes noseq(#1544), in a run's trace and an example's: the instance is in scope only in quiet code, so whether the operation ran may depend on data abovepublic, as when a function with no effects of its own installs a handler, performs an operation served by it, and is called under asecretbranch. The call is quiet, since its callee installs a handler; the callee cannot know the program counter of its callers. Nor does an operation performed in quiet code, of a host capability or of a handler, append its event to the trace of a run, or take aseqfor it (S-42, #1515, spec/11 §5), unless the only thing that makes that code quiet is the timing floor of awithinor afirst of, at apublicprogram counter and effect floor: there the operation's occurrence is the reported timing channel of spec/27 §5 rule 7, and its event stays, as that rule says it does. Otherwise such an operation is mostly one of a capability that accepts a label abovepublic(spec/07 §4), whose arguments the trace already redacts, but its occurrence under asecretbranch, and theseqof every later event, spelled out the secret; the code of a handler that serves it runs in quiet code too. The trace of an example keeps those events, since an example's data come from its source (ADR 0078) and itsexpect performedlines read them (spec/08 §2 rule 7). A count of them would be a count of how often quiet code ran, which may depend on the secret, and code can be quiet without asecretbranch around it, under a decision on values of a type parameter or the effect floor of an operation body: its events then occur whatever the secret, and a count in their paths would spell out how many quiet blocks orstarts ran before them under asecretbranch. Astartunder a raised program counter is quiet code too, in apublictasksstatement as well (S-40, #1512): its task runs under that program counter (spec/27 §7 rule 3), so itscancelledevent is left out, and it never moves the indexkof a later publicstart. It still holds a slot of the statement's one bound (spec/27 §7 rule 4, ADR 0117 rule 7), which is an open channel below. So, in both engines, whether quiet code ran changes neither the number of these three events, nor that of the operations' events, nor theseqthey take, nor thetaskpath of any event, public or quiet, nor thenof the idwith:<h>#<n>of a later public installation; how many installations quiet code ran shows in no id, a later quiet one's included. The tasks and the instances that quiet code starts and installs are therefore not told apart by their paths and ids. That is all this rule covers: the other channels listed below stay open. - Why. Whether code under a
secretbranch runs depends on the secret. With an event per loop that a host stop ends, perwithinwhose deadline cuts its loop, per task that a failing block cancels, or per operation performed there, a program that runs such code guarded bys > ifor eachiwould givesevents, the whole secret in one run, with the same output and exit status. - The cost of the conservative rules (S-42). Code is also quiet where its events occur whatever the secret: under a decision on values of a type parameter, in the body of an operation of a capability that accepts a label above
public(the effect floor), and in aviabody (below). Those events are left out of a run's trace too, though their occurrence does not depend on the secret, since the same code also runs under asecretbranch or onsecretarguments, and no rule tells the two apart at run time; a count of them would also show how many ran under the branch. So a run that calls such code at apublicprogram counter records the operation that enters it, such as theholdof an operation body, with its arguments redacted, but none of the operations its quiet code performs. This hides more, never less: no observation is added, so T6 (spec/07 §1) is unaffected, both engines leave out the same events, so their traces still compare (spec/16 §5), and an example still sees every operation but those of instances that quiet code installed (#1544). - Formal re-check. Since #1553 the F1 importer reads
quiet ease, so a declaration that holdsquietis re-checked byuna-core-checklike any other (docs/plan/formal-track-status.md), and a form outside F1 inside it still makes it not re-checked. What the re-check certifies is T6 on F1's trace, which keeps the events of the operations in quiet code. The step to the runtime's trace, which leaves them out, is argued, not proven: in code the re-check accepts, each event left out is of a sink that accepts the raised label, so an observer below it does not see it, and an observer at or above it sees the decision, so both runs leave out the same events. - Core. Elaboration marks each such loop,
within,first of,tasks,together,together forandstart, eachwiththat installs a handler, each call whose callee can run one of them, install a handler or perform an operation, and each operation,quiet(spec/09 §2). A program keeps its meaning otherwise: its output, failures, exit status and every other event are those of the same program without the mark, except that a run's trace leaves out the operations' events of quiet code, and an event written in quiet code, theabortedevent of a task (below) or an operation's in an example's trace, carriesqs,qforqin itstaskpath where the program without the mark would carrys<c>,f<c>ork, and a task started in quiet code is placed by itsstart's site (spec/27 §1 rule 2). One exception holds for exit status: the event of an operation that is not recorded, by S-42 or #1544, is not rendered, so the abort for an integer of more than 4300 digits that recording its arguments or result would raise (spec/11 §7) does not happen for it; whether it happens depends on where the code runs and where the handler was installed, not on the value of any secret. - Type parameters. A label that mentions a type parameter, or a decision on values of a type parameter, counts as above
publicfor the rule above, since one generic body serves every instantiation. A public program that calls such a generic function therefore loses the events this rule suppresses, as a program that stands under a raised program counter does. - Bodies no label rule checks. The body of a policy's
viafunction is not checked for labels (spec/07 §5 rule 3), so nothing bounds the program counter inside it: it counts as abovepublicfor the rule above. Its loops, task constructs and calls of functions that can run them are quiet, and so is each operation it performs, whatever the labels of the arguments, so a run's trace leaves its events out. The same operation in a body that is checked for labels, at apublicprogram counter, is not quiet because an argument issecret. This is the safe direction. - Shared host state (S-45, #1552, ADR 0032 amendment of 2026-11-06). This rule leaves out the events of operations that quiet code performs, not what they did: a hidden
Files.writeunder aninternalbranch creates a file that a later publicFiles.readfinds, and a hiddenLimit.acquiretakes a token that a later publicacquiremisses. An event's outcome is rendered at its label (spec/11 §5): the label of the operation's decision, which the file-state label (ADR 0085),Limited(spec/27 §10 rule 4), agiveslabel (ADR 0094 rule 2) and the arguments that decide it raise, joined with its failure type's and its result's. So what quiet code did to shared host state shows in no outcome of a run's trace: such an outcome is{"kind":"redacted","level":...}, the same in every run. The route does not need quiet code: aFiles.writeof aninternalpath at apublicprogram counter, the write's own outcome, and a server's decision on aninternalbody are rendered at their labels the same way. The program could already not observe any of them (U4003 on a branch that prints); only the trace did. The trace of an example keeps its outcomes in clear. - Outside the rule. The
abortedevent of a started task that runs too deep is stack exhaustion, which also writes its line to stderr, and stays out of model (spec/07 §1). Awithinthat stands under apublicprogram counter and whoseτ(e)is abovepublickeeps its events: its timing is the reported channel of spec/27 §5 rule 7. So does thetimeoutevent of afor ever withiniteration whose deadline cuts a wait at a limiter (spec/27 §10), and theinterruptedoutcome of a loser offirst ofthat was waiting at one: theacquire's outcome is redacted (S-45), but whether the iteration has the event, or the loser was waiting, shows whether it waited for a token, and so what hidden code did to the limiter. That still varies with the secret, and under--virtual-timeit is deterministic, with no noise. It is accepted as the reported timing channel of the report'sout_of_modelentry "waits at limits and atstart": how long a call waits at a limit is timing, out of model (spec/27 §10 rule 5), and under virtual time only waits move the clock, so no other computation feeds the event. Closing it would mean leaving out the iteration's observation of its deadline by the timing label, not an outcome rule. One channel of the trace is not closed by this rule, and is an open security issue:- Slots and parks of quiet code (S-40 remainder, #1545). A quiet task holds a slot of its statement's one bound (ADR 0117 rule 7), so under
tasks at most n at once, or at the default bound, whetherstarts under asecretbranch ran decides whether a later publicstartof the statement waits. In the interpreter, a task that waits, or parks inside quiet code at a quiettasksstatement that waits for its tasks or at a quietstartthat waits for a slot, lets the queued tasks run first, so the order of the public events of other tasks changes with the secret, deterministically. Natively the order across tasks is real time (spec/27 §8 rule 1). Bounding quiet tasks apart would close the slot route but let a statement run twice its bound; it is a proposed amendment of ADR 0117 rule 7 (docs/plan/0117-quiet-bounds-amendment-draft.md), not in force. The numbering andcancelledchannels of S-40 are closed.
- Slots and parks of quiet code (S-40 remainder, #1545). A quiet task holds a slot of its statement's one bound (ADR 0117 rule 7), so under
- Quiet code (S-39, ADR 0116 amendment of 2026-11-06). The events that the runtime appends by itself, a loop's
- Draining. Code outside every
for everruns on.
- Interruption. An
-
HttpError.Interrupted. In edition0.4,HttpError(spec/24 §1) has a ninth variant,Interrupted, afterProtocol, and a tenth,RateLimited(spec/27 §9). Earlier editions keep eight, since a new variant changes whichwhenarms are exhaustive. -
Grace and the hard stop (ADR 0116 rule 16). The hard stop comes at the end of the grace period,
--stop-graceseconds after the first request, or at a second request, whichever comes first. It cancels the run at its next check point, a call or a loop iteration,on stopblocks included; in atogetherblock, it cancels each task at its next check point, and each started task'scancelledevent is appended (spec/19 §7 rule 3).- A run that ends before the hard stop ends normally: exit code 0 when
main, or the driver, returns. - A run that the hard stop cancels ends with U6007, "the host stopped the run before it finished", exit code 1, at the check point, with the trace of an abort (spec/11 §7). The message says why: "the host stopped the run before it finished, after the grace period of 10 seconds", or "..., at a second host stop request".
- A run that ends before the hard stop ends normally: exit code 0 when
-
Out of reach (ADR 0116 rule 17). A third request, or the end of a second grace period after the hard stop, restores the default actions of SIGINT and SIGTERM and ends the process with the signal SIGTERM, so a run stuck in an operation that is not interruptible still ends. A run that has ended by then, its output and trace written or being written, is never ended this way. SIGKILL, the end of the machine and the kernel's out-of-memory killer end a process without any check point, and no program can clean up after them.
-
Both engines.
una runand executables follow this section alike. Under the iteration budget of--stop-after-iterations(rule 1), every loop instance stops at the start of its iterationn + 1unless it ended before, whatever the run did elsewhere: a schedule fixed per loop instance and the same for every entry, so their outputs and traces compare under spec/16 §5. The budget is not a stop schedule of the run's own behaviour: no instance's stop point depends on how many iterations any other loop ran.unaserve() -> Unit uses @http: Http[get] diverges = let edit polls: internal Int = 0 for ever let reply = attempt @http.get("http://127.0.0.1:8080/", headers: [], key_name: None) when reply is Ok(response) -> polls = polls + 1 is Err -> unit -- Interrupted after a SIGTERMThe failure of a request is
internal(spec/24 §5), so the count it changes is too.
7. for ever within d
-
Grammar (ADR 0116 rule 5). In edition
0.4, afor everloop MAY take a deadline:ebnfever_stmt = "for" "ever" [ "within" add_expr ] NEWLINE INDENT block DEDENT [ on_stop ] ;withinright afterfor everstarts the deadline. Anywhere else it stays reserved (§1 rule 2). -
The deadline (ADR 0116 rule 11).
dis anInt of Millisecond, withMillisecondofstd.time(§2 rule 2): a unitlessIntor another unit is U2028, and a type that is not an integer is U2001. It is evaluated once, before the first iteration. It MUST be at least 1, arefinementobligation atd(spec/12 §3):within 0 * millisecondis U5001. -
Past the deadline. Each iteration has the deadline
dafter its start, armed on the run's clock in nanoseconds, as awithin's is (spec/27 §5 rule 5): exactlydafter the iteration starts, whatever phase within a millisecond earlier code left (ADR 0116 amendment, P13). Once an iteration has passed it, every interruptible operation it waits on, and every one it starts later in that iteration, fails at once with its time-out failure: forHttp,HttpError.TimedOut(spec/24 §1). The tasks the iteration starts (spec/19) share its deadline. Nothing else changes: the iteration runs on to its end with the values its code gives the bindings, effects already performed stay (spec/17 §7 rule 2), and the next iteration has a new deadline. In this edition the interruptible operations are those ofHttp(ADR 0116 rule 12); the operations of a handler are Una code, which a deadline does not cut. A host stop request (§6) cuts the same waits: anHttpwait in the body ends at the deadline or at the request, whichever comes first, withTimedOutorInterrupted. -
Trace. Each iteration that meets its deadline gets one event
{"seq": n, "outcome": {"kind": "timeout"}}, which names no operation (spec/11 §5). It carries thetaskfield of the task that runs the loop, and it is written where the iteration's own control flow first observes a failure the deadline caused, outside quiet code (§6 rule 4): a failure in quiet code, or in a task started there, neither appends the event nor counts as that first observation, so a later one in public code still appends it, and whether the event appears never depends on whether quiet code ran (S-42): right after the event of an operation of that task that the deadline made fail, or, when a task of atogetherortogether forblock the iteration runs met the deadline, at the block's join, after the block's events, whether the block ends normally or fails. A trace therefore never depends on which task met the deadline first: its events and their order are the same in every run that meets the deadline at the same operations, and in both engines (spec/16 §5).unaimport std.time (millisecond) poll(url: Text) -> Unit uses @http: Http[get] uses @console: Console[print] diverges = let edit n = 0 for ever within 100 * millisecond stop when n == 10 let reading = attempt @http.get(url, headers: [], key_name: None) @console.print("polled {n}") -- also after a `TimedOut` reading n = n + 1 -
Information flow (ADR 0116 IF5, IF6, IF8). Whether an operation completes, or fails because the deadline passed, depends on how long the iteration took. The timing label
τof the body bounds what that can depend on. It is the join of:- the program counter at the loop, and the label of
d; - the deep label (spec/07 §7 rule 3) of every binding the body reads from outside it, its lambdas' captures included;
- for each operation the body can perform, directly or through the functions it calls: its result type's deep label, its
acceptslabel and its failure kind's deep label; and, for every handler of that operation's capability in the package, the deep labels of the handler's parameters (⊤for one whose type holds a function type, §2 rule 5 item 3), what its operation bodies run, their lambdas and tasks included, counted as for the body under items 3 and 4 (issue #1436), and the same for the operations it needs; ⊤, when the body, or a function it can reach, calls a function value, calls a function of the prelude with a function argument whose code is not known at the call, or names such a function as a value; a lambda written at the call as that argument is known, and counts by its captures and its body under items 2 and 3, as §2 rule 5 item 4 states;τ_concat the loop, as spec/27 §11 computes it: each iteration's deadline starts at the iteration's start, whose place among the tasks beside it the constructs around the loop decide. Awithinand afirst oftakeτ_concat their own sites by the same section;L_res, the residue label (ADR 0116 amendment, P9). A request whose task is canceled before its own time-out leaves residue on two paths. One that runs on a helper of the I/O pool, as every request of a task does in a run where a grant carries limits or where no task parks on the reactor (spec/27 §2 rules 3 and 4), keeps its helper, and the cores its exchange spends, until its next I/O step; one parked on the reactor ends its exchange on its task when the cancellation wakes it. On either path, a lookup or a connection in flight keeps a thread of its bounded pool until it returns, also when a deadline cut it (spec/27 §2 rule 4, spec/24 §4 rule 2). That residue runs beside whatever code runs later, also code that makes no request.L_resis the join, over everytasksstatement whose block orstartexpressions can reach an operation ofHttpthrough the call graph of ADR 0116 P1 (functions, the operations of handlers through their capabilities, and every lambda through a call of a function value), of the timing label of the whole statement and itsτ_conc; and, over everyfirst ofwhose branches can reach an operation ofHttp, of itst(spec/27 §6 rule 8), at leastinternal, from that operation's label. It ispublicin a program with neither, so a program pays for it only when its started tasks or its races make requests. A deadline's own cut leaves no residue, since its request ends at that deadline (spec/27 §2 rule 4), andL_resdoes not count it.L_resjoins the timing label of every site: everywithin,first ofandfor ever within, every tick (§2 rule 5),L_lim(spec/27 §9 rule 5), and the statement an installation oflimiterscopes over (spec/27 §10). A message whose label it raises names the construct whose requests can be left running. The call graph has an edge from each body, a lambda's included, to every operation it performs. A path dependency's modules are checked with the package, so their constructs count precisely, as the root's do. Outside what is checked, until issue #1166 makes them precise,L_resis⊤when the package's code can reach, in that graph, a function of a standard module whose body holds atasksstatement or afirst of, since the standard modules are checked apart; or a function of a dependency whose code the checker does not see, a module not checked with the package or a function without a body, whatever it holds. The message names that function: "the tasks thatstd.m.f, outside this package, may leave running". No standard module holds such a construct today, which a test keeps. It is computed once per package, in time linear in the call graph, in what the checking recorded at each construct, and in the bodies of the outside functions the package reaches. (v0.4, ADR 0123.) In a package that performs an operation ofHttpServer, the labelL_srvof the serve threads joinsL_res, and so every site thatL_resjoins (spec/31 §1 rule 5 item 7).- the deep label (spec/07 §7 rule 3) of every value that the body computes, and that the code it reaches computes: every function it can reach and the operation bodies of every handler item 3 counts, their lambdas included (ADR 0116, amendment of 2026-11-06, IF5 item 7). The labels of type parameters are left out, since the values of a type parameter come from the callers, whose own values count. So a value labeled from literals, such as
let k: secret Int = 3000000in a function the body calls, a labeled result or a kind with a labeled field built there, counts as the same value read from outside does under item 2 (issue #1685). The item is stricter than items 2 and 3 alone: a function reached that computes on a parameter labeled above the argument it gets counts at the parameter's label. It is computed once per function while bodies are checked, in time linear in their size.
The operations the deadline can cut run as if under
τ, and their failures carry it: when an interruptible operation that the body can perform declares a failure label belowτ(forHttp,internal, spec/24 §5), the package is rejected with U4001 at the loop, naming the largest source ofτ. A body that reads asecretbinding and callsHttpis rejected; one onpublicandinternaldata is accepted. A plainfor everneeds no timing label (ADR 0116 IF7).Preview over-approximations. Items 3 and 4 are coarser than ADR 0116 IF5, as in §2 rule 5: they count every handler of a capability, not only the one installed. Item 5 is the precise
τ_concof spec/27 §11, whichκof each construct over-approximates as that section states. They are sound; in the preview they MAY become more precise, and they MUST NOT become stricter. Item 6 uses theτ_concof spec/27 §11 for each construct, and counts every suchtasksstatement, not only one whose block can fail; it is a fix of soundness, and it MAY be dropped once the reactor ends an interrupted request with its task. The same rule computes the timing label of a driven step (§2 rule 5). - the program counter at the loop, and the label of
-
Report (ADR 0116 rule 21). The report's
informationsection (spec/13 §6) lists eachfor ever withinintiming, with its function and its timing label. -
Core (ADR 0116 rule 20). The loop's source is
ever(d), withdan atom bound before the loop, and the span ofd, where its obligation is reported. -
Costs. One clock reading per iteration to arm the deadline, and one per interruptible operation to bound its wait, each O(1).
8. Tests and virtual time
-
stop after N(ADR 0116 rule 19). In edition0.4, a test (spec/08 §2, writtentestfrom edition0.3, ADR 0105) MAY end with the linestop after N:ebnfstop_after = "stop" "after" integer_literal NEWLINE ; (* the last line of a test *)Nis an integer literal from 1 to 2^63 − 1. Another value is U0101, and so is a line after it.stopandafterare words, not keywords. Before edition0.4the line does not parse (U0101).- The stop schedule.
Nis the iteration budget of §6 rule 1, as--stop-after-iterations <n>is for a run: each loop instance of the test's run, each entry into afor ever, counts its own iteration starts from 0 and ends at the start of its iterationN + 1, appending the event{"seq": n, "outcome": {"kind": "stop"}}, with thetaskfield of its task, and then itson stopruns (§5 rule 4). It is not a host stop request: it interrupts no operation, and a loop entered later starts with its own budget ofN. Withstop after 2, each loop stops at the start of its third iteration. - Divergence. Only under this line may the
doline call a function that saysdiverges(U3027 otherwise, §5 rule 2). Theexpectlines never may (U3027).
unaimport std.testing (elapse) import std.time (Millisecond, millisecond) pub handler slow_store(delay: Int of Millisecond) for Store op get(key) = elapse(delay) "v" test "the loop reads the store twice, then stops" given @store = slow_store(delay: 150 * millisecond) given @log = memory_log() do poll("k") -- a `diverges` function whose `for ever` reads and logs expect result == 2 expect performed @log.write stop after 2Each read takes 150 virtual milliseconds, so the test is instant in real time. The stop arrives at the start of the third iteration,
on stopruns, andpollreturns the count of its reads. -
Virtual time. Time in a test is virtual. The run's clock counts milliseconds from 0, at the start of the run:
- It moves only forward, and it never waits on the wall clock.
std.testing.elapse(d)moves it forward bydat once (spec/14 §4).dis anInt of Millisecondof at least 0, an obligation of each call (requires d >= 0, U5001 when refuted), and the move saturates at 2^64 − 1 milliseconds.- It also moves when the run waits on time and nothing else can run: it then jumps to the earliest moment waited for, so a test never hangs on a wait that only time could end. In this preview, the one such wait is the driver's wait for its next tick (§2 rule 3). The waits of ADR 0117 jump it the same way once they land.
- Deadlines. The deadline of a
for ever withiniteration (§7) is on this clock:dafter the clock's reading at the iteration's start, and it has passed once the clock has reached it. Under virtual time, waiting on the network takes no virtual time, so an operation fails with its time-out failure only when the virtual clock has already reached the deadline, as after anelapsethat passed it; an operation that starts before that waits on the network as it would without a deadline. - Nothing else moves it: computation, host operations and their waits on the network take no virtual time.
- A host operation of a test is served by a handler of its
givenlines (spec/08 §2 rule 1), so a test never reads the wall clock.
-
--virtual-time.una runand executables take--virtual-time(spec/13 §5, spec/16 §3), which gives the run the clock of rule 2:Clock.nowreads it, in milliseconds from the start of the run, instead of the wall clock.- The driver's tick
kis duek × ticksmilliseconds afterinitreturns, and the wait for it moves the clock there at once. A step takes no virtual time, so each tick is delivered when it is due:atisk × ticks, andmissedis 0. - Under it, both engines MUST give the same output, exit status, failure and trace, the readings of
Clock.nowincluded (spec/16 §5). - The flag is a property of the host, not a construct, so it is accepted for a package of any edition.
-
One clock per run. A run has exactly one clock, made when it starts and shared by all of its tasks. A virtual one moves only at the run's waits on time, never back. Reading it, moving it and jumping it to a moment are O(1) each.
9. The formal model
The formal track's model of Core (formal/UnaFormal/F1, docs/plan/formal-track.md) covers the Core forms of this chapter, and grows with them (ADR 0116 implementation plan, step 8). It is a statement about the model and the re-check of una.core/1 documents, not a rule on programs: no verdict of una check depends on it.
- Forms.
exit_k(b, ...)(§3 rule 4), the Coreloopwhose source isuntil(c)(§4 rule 6), and the one whose source isever, with itson stopblock, the identity when the source has none (§5 rule 6). The measure ofdecreasesis the verifier's, so it is not part of the model's syntax. A deadline (within, §7) is timing, which the model leaves out: the re-check reports afor ever withinas not re-checked. - Runs. An exit ends the code around it up to its loop, which catches it:
skipgives the next iteration its state, as the end of the body does, andstopgives the loop its value. Afor untilruns its condition before each iteration. Afor everreads the host's stop schedule at the start of each iteration (§6 rule 4): the schedule, fixed by the host before the run, gives each loop of the program the iterations at whose start a host stop ends it, the same for every entry of that loop.on stopruns on the final state, or, after a failure of the body, on the state from before the loop, and the failure then propagates (§5 rule 4). - Typing.
- T-Exit types an exit at the public program counter, its state flowing into the loop's state types.
- T-Until types the condition and the body under the label that decides how many iterations run, at least the condition's, with every component of the state at least it (§4 rule 5).
- T-Ever types the body and
on stopunder the enclosing program counter (§5 rule 3), andon stopdoes not fail. - The model's rules are stricter than the checker's in two places, each of which the re-check reports as not re-checked, never as accepted: a
stoporskipabove the public program counter, which §3 rule 6 allows where the body started there or, forskip, under a branch; and afor untilcondition that may fail.
- Theorems. Type safety (T1) and noninterference (T6) cover the forms. T6 holds for every fixed stop schedule: two runs on one host, which share its schedule, and that differ in data an observer does not see, show the observer the same events of the model's trace and related outcomes when both end (ADR 0116, "Where this sits in the model"). The model's trace holds the events of operations, not the events the runtime appends by itself (item 6). A decreasing measure ends a
for until(ADR 0116 V1), and a host stop ends afor everat its stop point once the iterations before it end (rules 13 and 14). The erasure of annotations, the host independence of code without host operations (afor everis never such code, since it reads the schedule), authority confinement (ADR 0093) and trace safety (ADR 0092) cover them as well. Each theorem is listed informal/Theorems.lean, whose check admits nosorryand no axiom beyond Lean's own. - The driver (§2). Under a fixed stop schedule, the driver delivers a finite list of ticks before its stop, so its loop runs as a Core
loopover that list:initonce,stepper tick, thenon_stop. T6 for the driver is T6 for that program, with the ticks labeled as IF7 labelsstep'sinput: two runs whose ticks came at different times are related when the observer does not see those times. - Outside the model.
- Timing, deadlines and the cost of a step.
- Schedules whose stop points differ between entries of one loop, such as a sticky host stop request (§6 rule 1), which ends at its first iteration a loop entered after it (§6 rule 4 item 2). T6 says nothing of two runs whose schedules differ at a loop the observer sees.
- The iteration budget is inside it. The budget of
--stop-after-iterations nand of a test'sstop after nline is per loop instance (§6 rule 1, §8 rule 1, ADR 0116 amendment of 2026-11-03, S-36): each entry of a loop counts its iterations from 0 and stops at the start of its iterationn + 1, whatever the run did elsewhere. That is the schedule that stops every loop at its iterationn, counted from 0, fixed and the same for every entry, so T6 covers it (stoppingandticks_runsinformal/UnaFormal/F1/LongRunExample.lean). Before S-36 the budget was a count shared across loops, which T6 did not cover. - The events the runtime appends by itself. The model's trace has no
stop,timeoutorcancelledevent: a host stop ends afor everat its stop point with the loop's value and adds nothing to the trace, while the runtime appends astopevent there (§6 rule 4 item 2). Whether a loop under a raised program counter appends one is the channel that quiet code closes (S-39, ADR 0116 amendment of 2026-11-06). T6 therefore says nothing of these events, or of how they move theseqof later events. Since #1553 the re-check readsquiet ease; the step from F1's trace, which keeps the operations' events of quiet code, to the runtime's, which leaves them out, is argued, not proven (docs/plan/formal-track-status.md). Afor everat the public program counter is re-checked, and itsstopevent is outside what T6 states. - Loop sites. The re-check names each
for everby the line and column where it starts, without its file or module, and by 0 when the export gives it no span; the copies of one generic function share their source's names. Loops with one name share one entry of the schedule. The theorems hold for every schedule, so this only narrows the schedules the re-check represents for an imported program; the iteration budget, the same at every loop, is among them.