Home / Docs / Specification

26. Long-running programs

Release v0.4.0

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

  1. Edition. A package of edition 0.4 names it in ita.una (edition 0.4, spec/30); una.toml naming it is U7002, with una migrate as its repair (ADR 0122 Question 8.1). Edition 0.4 is cumulative over edition 0.3, as 0.3 is over 0.2: it has every construct, keyword and rule of edition 0.3. It is a preview under the terms of edition 0.3 (spec/13 §7) until the rules that target it have landed.
  2. Reserved words. In edition 0.4, diverges and within are reserved: used as an identifier, each is U0103, `<word>` is reserved for edition 0.4 (long-running programs). diverges is a word of a header (§5), and within one right after for 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

  1. The drive section. In edition 0.4, the drive section of ita.una (ADR 0122 rule 11) names a module of the package whose loop the host runs (ADR 0116 rule 1):

    una
    drive
      module game
      ticks 16
      budget 8
    • module is a module of the package. ticks is 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 module or ticks, a value out of range, and a drive section together with run entry. A module that is not a module of the package is U7002, as a run entry that names none is.
    • run grants keep their meaning. A dependency's drive section is not read.
  2. The module. The module of drive declares pub init() -> S, pub step(edit state: S, input: Tick) -> Unit and, optionally, pub on_stop(state: S) -> Unit, for one type S, with Tick of std.drive. std.drive declares pub kind Tick with the fields at: Int of Millisecond, the scheduled time of the tick from the first one, and missed: Int, the number of due ticks skipped just before it. std.time declares the measures Second, Millisecond and Minute and the constants second, millisecond and minute of Int of Millisecond, whose values are 1000, 1 and 60000 (ADR 0116 Amendment of 2026-10-19), and the failure kinds of within, Timed[E] and Deadline (spec/27 §5).

    • Effects. The three functions MAY have uses, checked against the grants as main's are (U3012, spec/05 §7 rule 2).
    • Failures. step and on_stop MUST NOT declare fails: the host has no caller to give a failure to, so each handles inside it what it meets (U3029 at the clause). init MAY fail, and its failure ends the run as one of main does (U6001, at the name of init); its message names init and the driven module where one of main names main, 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 requires clause: the host calls init once, step for every tick and on_stop at the stop, and no call of the host establishes a precondition, so a requires would be a fact the verifier assumes and nothing proves. A requires on any of them is U7008 at the section's module, with the clause as the related span, in una 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 (of Option, 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 as kind Calm = Tick where it.missed == 0 or an alias of one, with the type as the related span: the host gives step each tick with no fact about it, and hands the state from one function to the next by its type S alone, 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 of init is refused as well, although the body of init would prove it, so that the three shapes stay exact; an ensures on init states such a fact instead. Labels are not refinements: input keeps the label of rule 5. (Edition 0.4 preview, as spec/31 §7 rule 2 for serve.)
    • 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 init MUST flow into the declared type of the state parameter of step and of on_stop, and the declared type of the state parameter of step into that of on_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 in step or on_stop than in the result of init is legal. The shapes below compare S with 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 S MUST be the same at every position of the type, by the normal form of spec/25 §2 rule 2 (ADR 0104): the result type of init, the type of the state parameter of step and that of on_stop, at their top and in each type argument (of Option, 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, in una check, as the same flow is in ordinary code (spec/25 §2 rule 4): init() -> Int of Second with step(edit state: Int of Millisecond, input: Tick) is U2028 (issue #1647). Core IR erases units, so una run and una build also 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 with convert(). With rule 2's refinements and these units, the shapes are exact, labels aside.
    • Refinements at run time. Since a refinement in S is U7008 in una check, una run and una build never 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 the uses and fails of a function type exactly, and refuse a difference as the usage error of the shapes below (issue #1644).
    • Shapes. A module without init or step of these shapes, or with an on_stop of another shape, is a usage error of una run and una build, exit code 2, as an entry without main is (spec/13 §5).
  3. The driver. una run and the executable that una build writes run the driver instead of main:

    • It calls init once. Its result is the state.
    • Tick k is due k × ticks milliseconds after init returns, on the run's clock: the monotonic one, or the virtual one of §8 under --virtual-time. On the monotonic clock, the moment init returns and each tick's moment are readings in nanoseconds, so tick k is due exactly k × ticks milliseconds after it, whatever phase within a millisecond init ended at (ADR 0116 amendment, P13). The at of 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 with missed set 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 state step leaves 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.
  4. 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 waiting Http operations of the step that runs, and the loop stops at its next iteration start. The trace then gets an event whose outcome is {"kind":"stop"}, which names no operation, on_stop runs, 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 of for ever within (§7) do not apply to it.

  5. The timing label of a tick (IF7). at and missed depend on how long earlier steps took. So the input parameter of step MUST 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 label input needs. τ is the join of:

    1. the deep label (spec/07 §7 rule 3) of each parameter's declared type of step;
    2. for each operation in the effects of step and of every function step can reach, its result type's deep label, its accepts label and its failure kind's deep label;
    3. for each handler a reachable with installs, 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 a List, a value of a Map, an Option, a Result or 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 of step: 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;
    4. ⊤, when step 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. 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 as fold's initial, 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);
    5. conc(step) of spec/27 §11 rule 4: the labels of the work that can run beside a call of step, over every call of step in the package, public when no part of a construct reaches it;
    6. 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's at and missed.
    7. the deep label of every value that step and the code it reaches compute, as §7 rule 5 item 7 states (ADR 0116, amendment of 2026-11-06; issue #1685).

    A step whose effects only print public values and whose state is public has a public τ, and its input needs 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 function step reaches, captures bindings of that body. Item 1 counts step'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, the map, zip_map, update and fold of the dense values and the update of 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: fold returns its initial, a U that 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 secret length 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) and L_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.

3. stop and skip

  1. Grammar. In edition 0.4, a statement MAY be stop, stop when followed by a line expression, or skip, each alone on its line (ADR 0116 rule 5):

    ebnf
    stop_stmt = "stop" [ "when" line_expr ] NEWLINE ;
    skip_stmt = "skip" NEWLINE ;
    • stop and skip are words, not keywords: they start these statements only at the start of a statement line, alone or before when, and they stay identifiers elsewhere. Before edition 0.4 they are identifiers, so these statements do not exist there: a bare stop or skip line is a name, an expression like any other (U1001 unless a binding of that name is in scope), and a when after 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 edition 0.4, make it.)
    • skip takes no when (U0101): an if around skip says the same.
    • A block that ends in stop or skip has unit as its value.
    • A statement after an unconditional stop or skip in 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 after stop when c, and after the block that holds the exit, stay legal.
  2. Meaning (ADR 0116 rule 6).

    • stop ends the innermost enclosing for loop. stop when c does so when c, a Bool, holds (U2001 otherwise), and does nothing otherwise.
    • skip ends the current iteration and goes on to the next.
    • The bindings the loop updates keep the values they have at the statement: after stop they are the loop's final values, and after skip the next iteration starts with them.
    una
    let edit total = 0
    for order in orders
      if order.cancelled
        skip
      stop when total > limit
      total = total + order.amount
  3. Where (U2034). stop and skip belong 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 for and a branch of together (spec/19) are not loops for them, and a loop inside the task is.
  4. Core (ADR 0116 rule 20). stop and skip lower to exit_k(b, ...), with the tag k, stop or next, and the current values of the loop's state b, ... (spec/09). The end of the body is the tag next with the body's value. A stop ends the loop, whose value is that state. stop when c is if c around stop. Both engines run them alike (spec/16 §5).

  5. Verification (ADR 0116 V2). Each stop and skip is 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 each stop and skip as at the end of the body. On the path past stop when c, c is 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 counts skip and stop as paths that complete an iteration.

  6. Information flow (ADR 0116 IF2, IF3).

    • Whether later iterations run must not depend on data the body did not start with. stop and stop when c are legal only where the program counter, joined with the label of c, 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 for fail (spec/07 §3 rule 3).
    • skip inside a branch on c makes 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 of c.

4. for until c decreases m

  1. Grammar. In edition 0.4, a for statement MAY be for until c decreases m with a block (ADR 0116 rules 5 and 7):

    ebnf
    until_stmt = "for" "until" line_expr "decreases" add_expr NEWLINE INDENT block DEDENT ;
    • until and decreases are words: until right after for starts this form when in does not follow it, so for until in xs is a loop over xs whose variable is until.
    • Without decreases it is U0101, `for until` needs a `decreases` measure.
  2. Meaning. At the start of each iteration, c is evaluated with the current values of the bindings, and when it holds the loop ends. c is a Bool (U2001). stop and skip work in the body as in every for (§3).

  3. The measure. m is 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.

  4. Verification (ADR 0116 V1, V3). The loop carries the obligations decreases_bound and decreases_step of 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 c is in the refinement language, not c is a hypothesis in the body.
    • decreases_bound: where the loop continues, m >= 0.
    • decreases_step: at the end of the body and at each skip, m is less than at the start of the iteration. A path that ends at stop carries neither obligation.
    • Together they prove that the loop ends.
    • After a for until whose body has no stop of it, and whose c is in the refinement language, c holds. After every loop, the bindings it updates are fresh at their declared types.
  5. 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 a for over a list runs under the list's top label (spec/17 §6 rule 3). m is erased.

  6. Core (ADR 0116 rule 20). The loop is a Core loop whose source is until(c), with c an 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

  1. Grammar (ADR 0116 rule 5). In edition 0.4:

    ebnf
    clause    = ... | "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 ;
    • diverges is a clause word, and stays reserved elsewhere (§1 rule 2). ever right after for starts this form when in does not follow it, so for ever in xs is a loop over xs whose variable is ever. on stays an identifier.
    • on stop after a loop other than for ever is U2034. una fmt puts diverges after fails.
  2. diverges (ADR 0116 rule 8). A function whose header says diverges may run forever. It is never inferred, so it shows in every header that has it, and una contract reports it as the key diverges, a Bool, after fails.

    • Where. for ever, and a call of a function that says diverges, are legal only in the body of a function that says it (U3027), and not in a lambda, a together task, an on stop block or the body of a for ever (U3027). The functions of a driven module may not say it.
    • Not a value. A function that says diverges is not a value: naming it other than as a callee is U3028.
  3. 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 by stop, 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 no for ever and calls no function that says diverges (U3027), its other loops are bounded or proven to end (§4), and recursion is bounded by --max-depth.

  4. 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 no for ever and calls no function that says diverges (U3027), and stop or skip in it is U2034. Execution then goes on after the loop.

    una
    log_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")
  5. Verification (ADR 0116 V3, V4). After a for ever, the bindings it updates are fresh at their declared types, and on stop is verified with them fresh. A function that says diverges keeps partial correctness: its ensures holds whenever it returns.

  6. Core (ADR 0116 rule 20). The loop is a Core loop whose source is ever, with its on stop block, which binds the state afresh and returns it as the loop's value.

  7. Host stops. A for ever without stop ends 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-iterations or of a test's stop after line ends (§6 rule 1, §8 rule 1).

6. Host stops

  1. Requests (ADR 0116 rule 14). These are host stop requests of a run of una run or 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's stop after N line (§8 rule 1), are not host stop requests. They give each loop instance a budget of n iterations: each entry into a for ever, and the driver's loop (§2), counts its own iteration starts from 0, and that instance ends at the start of its iteration n + 1, as at a stop point after a request (rule 4 item 2): it appends the stop event, and then its on stop runs. 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: a for ever under a secret branch would move where a later public loop stops, and the output would reveal the secret.

  2. Flags (spec/13 §5, spec/16 §3). --deadline takes whole seconds from 1 to 31,536,000; --stop-grace takes whole seconds from 1 to 86,400, and is 10 when not given; --stop-after-iterations takes 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.

  3. Signal handlers (ADR 0116 rule 18). A run installs handlers of SIGINT and SIGTERM only when it runs a driver or its main says diverges, the only ways a run reaches a for 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 before main, 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 run checks 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).

  4. After a request (ADR 0116 rules 12 to 14):

    1. Interruption. An Http operation in the body of a for ever, in that body's own task, callees included, fails with HttpError.Interrupted when 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 every for ever body, on stop blocks included, and in the tasks a together block 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 with Interrupted when they return, within the request's own deadline (spec/24 §4).
    2. Stop. Every for ever that reaches an iteration start ends there, as by stop, 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 its on stop runs.
      • Quiet code (S-39, ADR 0116 amendment of 2026-11-06). The events that the runtime appends by itself, a loop's stop, a within's timeout and a task's cancelled (spec/27 §5, §6, §7), are sinks that accept public, as Console.print is (spec/07 §4). Code is quiet when it stands under a program counter above public, joined with the effect floor of an operation body and the timing floor of a within as 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 labeled l_f, through a kind's field too, stands under pc ⊔ l_f, joined with the decisions its arguments carry (spec/07 §3 rule 4, §7), so it is quiet when l_f is above public, at a public program 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 its start (spec/27 §7 rule 3). Quiet code appends none of those events and takes no seq for them, and it counts none of its tasks statements, first of blocks and starts: their parts of a path are qs, qf and q, with no number, and they move no number of public code (S-40, S-44, spec/27 §6 rule 5, §7 rule 5). Nor does it number its handler installations: each instance it installs is with:<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 no seq (#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 above public, as when a function with no effects of its own installs a handler, performs an operation served by it, and is called under a secret branch. 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 a seq for it (S-42, #1515, spec/11 §5), unless the only thing that makes that code quiet is the timing floor of a within or a first of, at a public program 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 above public (spec/07 §4), whose arguments the trace already redacts, but its occurrence under a secret branch, and the seq of 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 its expect performed lines 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 a secret branch 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 or starts ran before them under a secret branch. A start under a raised program counter is quiet code too, in a public tasks statement as well (S-40, #1512): its task runs under that program counter (spec/27 §7 rule 3), so its cancelled event is left out, and it never moves the index k of a later public start. 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 the seq they take, nor the task path of any event, public or quiet, nor the n of the id with:<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 secret branch runs depends on the secret. With an event per loop that a host stop ends, per within whose deadline cuts its loop, per task that a failing block cancels, or per operation performed there, a program that runs such code guarded by s > i for each i would give s events, 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 a via body (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 a secret branch or on secret arguments, 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 a public program counter records the operation that enters it, such as the hold of 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 e as e, so a declaration that holds quiet is re-checked by una-core-check like 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 for and start, each with that 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, the aborted event of a task (below) or an operation's in an example's trace, carries qs, qf or q in its task path where the program without the mark would carry s<c>, f<c> or k, and a task started in quiet code is placed by its start'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 public for 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 via function is not checked for labels (spec/07 §5 rule 3), so nothing bounds the program counter inside it: it counts as above public for 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 a public program counter, is not quiet because an argument is secret. 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.write under an internal branch creates a file that a later public Files.read finds, and a hidden Limit.acquire takes a token that a later public acquire misses. 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), a gives label (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: a Files.write of an internal path at a public program counter, the write's own outcome, and a server's decision on an internal body 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 aborted event 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). A within that stands under a public program counter and whose τ(e) is above public keeps its events: its timing is the reported channel of spec/27 §5 rule 7. So does the timeout event of a for ever within iteration whose deadline cuts a wait at a limiter (spec/27 §10), and the interrupted outcome of a loser of first of that was waiting at one: the acquire'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-time it is deterministic, with no noise. It is accepted as the reported timing channel of the report's out_of_model entry "waits at limits and at start": 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, whether starts under a secret branch ran decides whether a later public start of the statement waits. In the interpreter, a task that waits, or parks inside quiet code at a quiet tasks statement that waits for its tasks or at a quiet start that 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 and cancelled channels of S-40 are closed.
    3. Draining. Code outside every for ever runs on.
  5. HttpError.Interrupted. In edition 0.4, HttpError (spec/24 §1) has a ninth variant, Interrupted, after Protocol, and a tenth, RateLimited (spec/27 §9). Earlier editions keep eight, since a new variant changes which when arms are exhaustive.

  6. Grace and the hard stop (ADR 0116 rule 16). The hard stop comes at the end of the grace period, --stop-grace seconds 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 stop blocks included; in a together block, it cancels each task at its next check point, and each started task's cancelled event 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".
  7. 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.

  8. Both engines. una run and executables follow this section alike. Under the iteration budget of --stop-after-iterations (rule 1), every loop instance stops at the start of its iteration n + 1 unless 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.

    una
    serve() -> 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 SIGTERM

    The failure of a request is internal (spec/24 §5), so the count it changes is too.

7. for ever within d

  1. Grammar (ADR 0116 rule 5). In edition 0.4, a for ever loop MAY take a deadline:

    ebnf
    ever_stmt = "for" "ever" [ "within" add_expr ] NEWLINE INDENT block DEDENT [ on_stop ] ;

    within right after for ever starts the deadline. Anywhere else it stays reserved (§1 rule 2).

  2. The deadline (ADR 0116 rule 11). d is an Int of Millisecond, with Millisecond of std.time (§2 rule 2): a unitless Int or 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, a refinement obligation at d (spec/12 §3): within 0 * millisecond is U5001.

  3. Past the deadline. Each iteration has the deadline d after its start, armed on the run's clock in nanoseconds, as a within's is (spec/27 §5 rule 5): exactly d after 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: for Http, 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 of Http (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: an Http wait in the body ends at the deadline or at the request, whichever comes first, with TimedOut or Interrupted.

  4. Trace. Each iteration that meets its deadline gets one event {"seq": n, "outcome": {"kind": "timeout"}}, which names no operation (spec/11 §5). It carries the task field 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 a together or together for block 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).

    una
    import 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
  5. 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:

    1. the program counter at the loop, and the label of d;
    2. the deep label (spec/07 §7 rule 3) of every binding the body reads from outside it, its lambdas' captures included;
    3. for each operation the body can perform, directly or through the functions it calls: its result type's deep label, its accepts label 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;
    4. ⊤, 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;
    5. τ_conc at 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. A within and a first of take τ_conc at their own sites by the same section;
    6. 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_res is the join, over every tasks statement whose block or start expressions can reach an operation of Http through 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 every first of whose branches can reach an operation of Http, of its t (spec/27 §6 rule 8), at least internal, from that operation's label. It is public in 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), and L_res does not count it. L_res joins the timing label of every site: every within, first of and for ever within, every tick (§2 rule 5), L_lim (spec/27 §9 rule 5), and the statement an installation of limiter scopes 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_res is ⊤ when the package's code can reach, in that graph, a function of a standard module whose body holds a tasks statement or a first 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 that std.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 of HttpServer, the label L_srv of the serve threads joins L_res, and so every site that L_res joins (spec/31 §1 rule 5 item 7).
    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 = 3000000 in 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 τ (for Http, internal, spec/24 §5), the package is rejected with U4001 at the loop, naming the largest source of τ. A body that reads a secret binding and calls Http is rejected; one on public and internal data is accepted. A plain for ever needs 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 τ_conc of 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 τ_conc of spec/27 §11 for each construct, and counts every such tasks statement, 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).

  6. Report (ADR 0116 rule 21). The report's information section (spec/13 §6) lists each for ever within in timing, with its function and its timing label.

  7. Core (ADR 0116 rule 20). The loop's source is ever(d), with d an atom bound before the loop, and the span of d, where its obligation is reported.

  8. 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

  1. stop after N (ADR 0116 rule 19). In edition 0.4, a test (spec/08 §2, written test from edition 0.3, ADR 0105) MAY end with the line stop after N:

    ebnf
    stop_after = "stop" "after" integer_literal NEWLINE ;      (* the last line of a test *)
    • N is an integer literal from 1 to 2^63 − 1. Another value is U0101, and so is a line after it. stop and after are words, not keywords. Before edition 0.4 the line does not parse (U0101).
    • The stop schedule. N is 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 a for ever, counts its own iteration starts from 0 and ends at the start of its iteration N + 1, appending the event {"seq": n, "outcome": {"kind": "stop"}}, with the task field of its task, and then its on stop runs (§5 rule 4). It is not a host stop request: it interrupts no operation, and a loop entered later starts with its own budget of N. With stop after 2, each loop stops at the start of its third iteration.
    • Divergence. Only under this line may the do line call a function that says diverges (U3027 otherwise, §5 rule 2). The expect lines never may (U3027).
    una
    import 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 2

    Each read takes 150 virtual milliseconds, so the test is instant in real time. The stop arrives at the start of the third iteration, on stop runs, and poll returns the count of its reads.

  2. 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 by d at once (spec/14 §4). d is an Int of Millisecond of 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 within iteration (§7) is on this clock: d after 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 an elapse that 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 given lines (spec/08 §2 rule 1), so a test never reads the wall clock.
  3. --virtual-time. una run and executables take --virtual-time (spec/13 §5, spec/16 §3), which gives the run the clock of rule 2:

    • Clock.now reads it, in milliseconds from the start of the run, instead of the wall clock.
    • The driver's tick k is due k × ticks milliseconds after init returns, 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: at is k × ticks, and missed is 0.
    • Under it, both engines MUST give the same output, exit status, failure and trace, the readings of Clock.now included (spec/16 §5).
    • The flag is a property of the host, not a construct, so it is accepted for a package of any edition.
  4. 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.

  1. Forms. exit_k(b, ...) (§3 rule 4), the Core loop whose source is until(c) (§4 rule 6), and the one whose source is ever, with its on stop block, the identity when the source has none (§5 rule 6). The measure of decreases is 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 a for ever within as not re-checked.
  2. Runs. An exit ends the code around it up to its loop, which catches it: skip gives the next iteration its state, as the end of the body does, and stop gives the loop its value. A for until runs its condition before each iteration. A for ever reads 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 stop runs 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).
  3. 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 stop under the enclosing program counter (§5 rule 3), and on stop does 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 stop or skip above the public program counter, which §3 rule 6 allows where the body started there or, for skip, under a branch; and a for until condition that may fail.
  4. 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 a for ever at 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 (a for ever is 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 in formal/Theorems.lean, whose check admits no sorry and no axiom beyond Lean's own.
  5. 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 loop over that list: init once, step per tick, then on_stop. T6 for the driver is T6 for that program, with the ticks labeled as IF7 labels step's input: two runs whose ticks came at different times are related when the observer does not see those times.
  6. 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 n and of a test's stop after n line 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 iteration n + 1, whatever the run did elsewhere. That is the schedule that stops every loop at its iteration n, counted from 0, fixed and the same for every entry, so T6 covers it (stopping and ticks_runs in formal/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, timeout or cancelled event: a host stop ends a for ever at its stop point with the loop's value and adds nothing to the trace, while the runtime appends a stop event 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 the seq of later events. Since #1553 the re-check reads quiet e as e; 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). A for ever at the public program counter is re-checked, and its stop event is outside what T6 states.
    • Loop sites. The re-check names each for ever by 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.