Skip to content

12. Sessions and tooling

Draws on: ADR 0006, ADR 0010, ADR 0014, ADR 0015, ADR 0018, ADR 0019, ADR 0020, ADR 0027, ADR 0028, #61, #69, #71, #72, ADR 0039, ADR 0042, ADR 0045, ADR 0053, ADR 0060.

A REPL session is an ordinary Host running an ordinary Script Group. The Cores have no session concept (ADR 0014). This chapter states how that Host, the Session Host, turns Entries and Session Commands into Host Inputs, and what it prints. Its behaviour is normative, because a Session Transcript is a Conformance Corpus case, which must replay the same on the Go REPL and the TS REPL. The rest of the tooling is one TS stack, and nothing it produces is normative (ADR 0028).

The normative Session observation contract defines Declaration Documentation, :describe, :inspect, :apropos, dispatched-Run tracing, Fuel Measurements and object-crossing replay. These commands are part of Session Transcript parity, not the tooling-freedom exception in ADR 0028.

  • One Group: the Session Host makes a Group named session holding the Session Script, also named session, and any Scripts :script adds (ADR 0170). It owns no Host Object, so me is Nothing, and a Script reaches it by name, as in send ping to session. Its initial well-known object bindings are empty by default; a Host may supply the bindings recorded by the object setup envelope.
  • Starting: the session starts at its first Entry, or its first Session Command other than :grant and :mock. The Session Host then loads the Session Script from empty source.
  • Grants: console, with both its Operations, and whatever :grant and :mock added before the session started. They are fixed from then on, since only loading binds Grants (chapter 10).
  • Limits: the default limit profile (chapter 6). :limits tightens it for later Entries.
  • Libraries: the stdlib Libraries are always registered, so use pad from text works at the prompt (chapter 7). User Libraries come in with :library.
  • Pumps have no Fuel Slice and no Fuel cap, so a Segment always runs to its end within one Pump.
  • Costs: console’s and user’s Operations and every mock Operation cost nothing. store’s get, keys and unwatch cost 2 Fuel, and its set, delete, increment, swap and watch 4, with no declared allocation.
  • The Clock is real by default, and virtual under :clock virtual.
  • The end of the Message Path: a message that reaches it is reported, not an error, since the Session Script’s path is flat.

store is a Standard Capability (chapter 7), and every REPL builds it in (ADR 0050).

  • In memory: each Session Store lives in the Session Host’s memory, and starts empty, so a Transcript replays the same way wherever it runs. :store load is the only way contents come in from outside.
  • Named by the binding: :grant <name> store [<store>] grants all eight Operations, including watch and unwatch, on the Store named <store>, or default. Two Grants of one name share one Store.
  • Quotas: a total size of 1,048,576, 1,000 keys and a largest value of 65,536, each counted by logical size.
  • Watch limits: for each Session Store, watches 100, watchSize 65,536, pending 1,000 and pendingSize 1,048,576 (chapter 7).
  • Revisions: a Session Store’s revision counts its commits with changed keys from 0, within the Session Host’s memory.
  • Never busy: Session Pumps have no Fuel Slice, so a Segment ends within its Pump, and store busy can’t arise.
  • Outside saves: :save and :restore leave every Session Store as it is, as any Host’s saves do (chapter 10).

After each Pump returns, the Session Host calls the router’s pumped, before it prints the Pump’s lines. After a Pump in which the router admitted a Notification, during the Pump or in that retry, it pumps again at the same Clock reading if Host Inputs are queued, and keeps doing so until a Pump admits none or leaves none queued. These Pumps belong to the Host call that caused the first, so their lines come with its lines, and under a real Clock they have no @ line of their own. A Notification’s Run is a background Run, so its output lines start with [<run>] . A Handler whose own write always changes a key it watches never lets the session settle, as a Handler that keeps sending to itself doesn’t.

The sessions/store-notifications Transcript records this example under a virtual Clock:

> :grant scores store
> :clock virtual 2026-09-30T10:00:00Z
> on scoresChanged change, queued
| say the "keys" of change
| end scoresChanged
> ask scores to watch "all", "", "scoresChanged"
> ask scores to set "alex", 3
[session/r3] ["alex"]
> ask scores to set "alex", 3
> :save
saved default
> :store clear
cleared default
[session/r5] ["alex"]
> :restore
restored default
[session/r5] []

The second set changes nothing, so it sends nothing. :store clear removes alex. The restore brings back the run id counter of the save, and the watch, which is resynced because the Store’s revision changed after :save. Its marker’s keys is [].

console is a Standard Capability (chapter 7).

  • say: a Command Call named say with one argument, and no and wait, is short for tell console to write with that argument, whatever Handlers the Script has (ADR 0019). It lowers to tell console write 1 (chapter 8). say with no argument, more than one, or and wait, is a load error. A Script without a console Grant can’t use it, as with any tell.
  • Writing: the Session Host prints the text form of the value, then ends the line. A line break inside the text starts a new line, so say "a" & newline prints a and then an empty line.
  • Reading: the Session Host answers read with the next line the user types.

user is an optional Standard Capability (chapter 7), and every REPL builds it in (ADR 0077).

  • Granting: :grant user user grants it under the name user, with all four Operations. It takes no binding, and isn’t granted unless asked for.
  • Asking: when the foreground Run waits on confirm, choose or enter, the Session Host asks the person, answers the call with what they give, and pumps. The Transcript records the answer as a ~ line. How a REPL shows the prompt, and how the person answers or cancels, is its own, and prints nothing.
  • Background prompts wait, as a background read does, until their Run is cancelled or a deadline abandons the call.
  • One at a time: while the Session Script has a prompt unanswered, the Session Host fails its next one with user busy, recorded as a ~ line with fail.
  • notify prints * , then the title and : when the title isn’t empty, then the message, as console’s write prints a text, with [<run>] before it for a Run in the background.

Example.

> :grant user user
> on size
| ask user to choose ["S", "M", "L"] and wait
| say "got " & it
| end size
> size and wait
@ 2026-09-30T10:00:00Z
~ session/r1.c1 "M"
@ 2026-09-30T10:00:03Z
got M

An Entry is decided on its first token (chapter 2). It is one declaration, one statement or one expression, so several make several Entries, and it is atomic: a syntax error or any load-time diagnostic rejects the whole Entry, prints each diagnostic, and changes nothing.

The Session Host keeps the session source: the Session Script’s declarations, in the order they were entered, with each redefinition in its place. :export writes it, and every Reload the Session Host makes loads it. So a session means exactly what its export means as a file (ADR 0014).

  • New names: a declaration whose names the Session Script doesn’t have yet extends the Script, with the Entry as its source (chapter 10), and is added to the end of the session source. Nothing stops.
  • Redefining replaces the old declaration in the session source, then reloads the Script from it with its Script Variables carried over (chapter 10):
    • on m replaces every clause of m, at the first one’s place. So a Handler built at the prompt has one clause, and a Library can hold more.
    • function f and constant c replace the old declaration in its place.
    • use takes the names it reuses out of the earlier use lines, dropping any line left empty, and is added at the end.
  • Watches: successful redefinition reloads the Session Script and removes its watches. An Entry can register them again. Extending, by declaring new names, keeps them.
  • Discarded Runs: the Reload discards every Run, and the Session Host prints each one (Output).
  • A Reload that fails leaves the session source and the Script as they were.
  • script variable x = e for an x the Script already has sets its initialiser in the session source, then runs put e into x as a statement Entry, with no Reload. With no initialiser, it runs put nothing into x.
  • Migrating variables: a Reload carries Script Variables as they are, so new Handlers may expect a different shape from the values they find. There is no migration hook (#371). The user enters a statement that converts the variable, right after the redefinition. Nothing runs in between, since the Reload discarded every Run and dropped the mailbox.

A statement or an expression runs as a Run of an implicit Handler:

  1. Implicit Script Variables: each name the Entry binds outside its Lambdas as a Container’s root or with a Capture that binds, that the Script doesn’t have, becomes a Script Variable, starting as Nothing. Each is added to the session source as script variable x, in the order the Entry first binds them. A name a pattern binds (in let, repeat for each, match, catch or wait for) stays a local of the Entry’s Run, since a pattern binding named like a Script Variable is a name clash.
  2. The Handler is named entry<n>, where n is the smallest number above the last one used, from 1, that the Script has no name for.
  3. Extending: the Session Host extends the Script with the source made of these lines, each ended by an LF: script variable x for each implicit Script Variable, on entry<n>, the Entry’s lines, and end entry<n>. An expression’s first line has return before it. The implicit Handler isn’t added to the session source.
  4. Running: the Session Host requests entry<n> from the Session Script, with no arguments and the :limits override, and pumps.
  • Positions of the Entry’s own diagnostics and errors are shown in the Entry’s own lines and columns, not the extension’s.
  • it belongs to the Entry’s Run, so each Entry starts with it as Nothing.
  • Rollback: a Limit Fault rolls back the Entry’s Segment, prompt state included, with no extra rule (ADR 0006).

A Session Host on the message layer asks the Core to decide its Entries, rather than parsing them itself: an Entry’s kind, completeness, leading documentation, declarations and implicit Script Variables, and the catalogue :describe, :apropos and :inspect read, come from language analysis.

After it pumps, while the Entry’s Run hasn’t ended, the Session Host:

  • answers console’s read, if the Run waits on it, with the line the user types, and pumps again.

  • asks the person, if the Run waits on a user prompt, and answers it with what they give, and pumps again (Prompts).

  • under a real Clock, if the Run waits only for a deadline (a wait, or a wait for or block wait for with no call pending), sleeps until the Pump’s next deadline, and pumps again.

  • otherwise returns the prompt, and the Run goes on in the background. Under a virtual Clock, a deadline wait returns the prompt at once.

  • Following Runs: public Run accounting identifies dispatch, ancestry, exact Fuel and terminal/discarded work. The Trace’s seg and call observations still identify console callers and foreground suspension. The Session Host never inserts Inspect() merely to follow execution (ADR 0045, narrowed by ADR 0065).

  • Echo: when an expression’s Run completes, its value is printed in the display form, which tells "5" from 5.

  • In the background, the Session Host pumps whenever the next deadline comes under a real Clock.

  • Queued Host Inputs: after the Pumps of an Entry, a Session Command, an answer or a deadline, if Host Inputs are queued, including ones its Host adapters queued during those Pumps (a property getter’s deliver, say), the Session Host pumps once more, as a separate Host call. That Pump is never followed by another for the same reason, and what it leaves queued waits for the next Entry, Session Command, answer or deadline. So a getter whose message reads the getter again can’t keep the session pumping. Store Notifications are pumped for before it, at the same Clock reading (above). Notifications admitted in the extra Pump are pumped for too, within its Host call, but it is never followed by another Pump for other inputs.

  • Answers: the Session Host pumps after answering a read, and after a built-in Capability’s suspending call is answered.

  • Ctrl-C is :cancel of the foreground Run. The Session Host makes Host calls only between Pumps, so a Run spinning in one Segment ends at its Fuel limit.

Ordinary execution prints the lines below; observation commands add their specified rows. A Host call’s lines come after all of its Pumps, in the order they produced them, so in a Session Transcript they follow its @ and % lines. <where> is <line>:<column> in the Entry, or <unit>:<line>:<column> elsewhere.

Line Printed for
a value, in the display form the result of an expression Entry
the text, line by line a console write by the foreground Run
* , then the title and : , then the text, line by line a user notify by the foreground Run (Prompts)
[<run>] and any line in this table the same, for a Run in the background, or one not started by an Entry
! error <map> at <where> an uncaught error, as its map without message and at
! limit fault <limit> at <where> a Limit Fault, with the fault record’s limit word
! cancelled a cancelled Run
! <code> at <line>:<column> each syntax error or load-time diagnostic of an Entry, in its own lines
! unhandled <message> <args> a message that reached the end of the Message Path, with its arguments as a list
! discarded <run> each Run a Reload or a restore discarded
! rewound <run> the Run a :fix rewound
call <call> <capability>.<operation> <args> each call of a mock Operation, with its arguments as a list
! <reason> a refused Session Command or Entry: a Host error’s code, or unknown command, bad arguments, session started, clock is real, not rewindable, no such run, no such call, no such save or no such name

A Session Command is a :-prefixed instruction to the session itself, not part of the language, which no Script can issue. The catalogue is session.toml:

Command Written Does Notes
:grant :grant <name> <capability> [<binding>] Grants the session a Capability the REPL Host has built in, or a mock one, under <name>, with a calendar Grant’s default zone, a locale Grant’s default tag or a store Grant’s Store name as <binding>; a store Grant has all eight Operations, watch and unwatch included before the session starts
:mock :mock <capability>.<operation> <mode> [read-only] Defines a mock Operation, with up to eight arguments and any result, costing nothing, and grants its Capability under its own name; <mode> is immediate, suspending or fire-and-forget, and a suspending one may be declared read-only metered so :charge can take its calls before the session starts
:stub :stub <capability>.<operation> <value> | :stub <capability>.<operation> fail <error> Queues the result of the next call of a mock immediate Operation, or an error map to fail it with
:answer :answer <call> <value> Answers a pending call of a mock suspending Operation
:charge :charge <call> <fuel> Requests <fuel>, a whole number, for a pending call of a read-only metered mock, then pumps; the Trace records the request and its outcome, and a Run that can’t pay faults at the call
:fail :fail <call> <error> Fails a pending call of a mock suspending Operation with an error map
:clock :clock [real | virtual [<instant>] | advance <duration>] Shows the Clock, switches it between real and virtual, or advances a virtual Clock by an exact duration and pumps
:limits :limits [<limit> <value> | reset] Shows the limits later Entries run with, tightens one of the limits a Delivery may override, or clears every override
:cancel :cancel [<run>] Cancels a Run, by default the latest Entry’s Run if it hasn’t ended
:fix :fix <run> <path> Fix and Continue: rewinds a Run that hasn’t passed a Suspension Point and reloads the session with the file’s declarations in place, keeping the mailbox, so the Run’s message runs again on the new code
:runs :runs Lists every Run that hasn’t ended
:mailbox :mailbox Lists every message waiting in the Session Script’s mailbox
:vars :vars Lists the Session Script’s Script Variables and their values
:save :save [<name>] Saves the session under <name>, or default, in the Host’s memory
:restore :restore [<name>] Restores the session saved under <name>, or default
:library :library add <name> <path> | :library replace <name> <path> Adds a user Library from a file, or replaces one, carrying Script Variables over
:script :script add <name> <path> Adds a Script from a file to the session’s Group, reached by message
:store :store [<store>] | :store load <path> [<store>] | :store save <path> [<store>] | :store clear [<store>] Shows a Session Store’s contents, by default the default Store, loads them from a file, saves them to one, or empties the Store; a load or a clear is a commit, routed to the Store’s watches
:export :export [<directory>] Shows the Session Script’s source, or writes it and each user Library to a directory as .talk files
:describe :describe <target> Shows a named declaration and its documentation without executing it
:inspect :inspect <expression> Evaluates once and describes the result, reading Host Object properties in a second ordinary Run
:apropos :apropos [query] Lists matching available names and Library exports with their origins, describe targets and documentation
:trace :trace [selector] Lists trace filters or adds a full Selector across the Group for future dispatched Runs
:untrace :untrace [selector] Removes one trace filter or clears all; already traced Runs retain their terminal output
:fuel :fuel [entry] Lists exact Fuel Measurements or measures an executable Entry and its spawned descendants
:help :help [<command>] Shows help not recorded
:quit :quit Ends the session not recorded
  • Values in a command, such as a Stub’s value or an error map, are written in the display form (chapter 11). An error map needs a text code.
  • Mocks: :mock defines an Operation whose result has the any Shape, and which declares eight arguments, each an Optional any, so a call may give from none to eight. It declares no error codes. A call to one prints a call line, which names it by its Capability, whichever Grant the call goes through, and lists the arguments the call gave. An immediate one takes the next :stub queued for it, as a Trace Case’s runner does (chapter 11), and with none fails as host error. A suspending one waits for :answer or :fail, and a fire-and-forget one just succeeds. A suspending one declared read-only is a Metered Operation: :charge queues a charge request for its pending call and pumps, as :answer does. The Core’s refusal of a request, such as invalid value for a mock that isn’t metered, prints as ! <code>. An accepted request spends Fuel at once, and a request its Run can’t pay ends it with a Limit Fault at the call; the Trace records each request and its outcome.
  • Stubs in the Trace: :stub writes its stub line into the Trace where it was entered, as a Trace Case’s runner does, so a Session Transcript’s case.trace replays as a Trace Case.
  • :grant names a Capability the REPL Host has built in, or one :mock defined. Which Capabilities are built in is the Host’s choice.
    • <binding> is the Grant’s binding, which the Core reads when it checks a call (chapter 7): a default IANA zone id for calendar, a default BCP 47 tag for locale, and a Store name for store. With none, they bind UTC, und and default, so a Transcript replays with the binding it was recorded with. A binding for any other Capability is refused with bad arguments.
    • A mock can’t take the name of a Standard Capability a REPL may build in: clock, calendar, locale, store or user, or the name of a registered Host capability.
  • :clock:
    • :clock prints real <instant>, the last Pump’s reading, or real alone before the first Pump, or virtual <instant>, the virtual Clock’s instant, which the next Pump reads.
    • :clock virtual starts a virtual Clock at the instant given, or else at the current reading. A Transcript always records the instant. One earlier than the last Pump’s reading is refused with clock backwards, since the Clock never goes backwards.
    • :clock advance d moves a virtual Clock on by the exact duration d, a Quantity in the display form such as 5 s, and pumps. The duration is taken to whole microseconds, rounded half-even, as any exact duration is (chapter 3), so 0.0000005 s moves it on by nothing. Under a real Clock it is refused with clock is real, and a negative duration, even one that rounds to nothing, or anything but an exact duration, with bad arguments.
    • :clock real goes back to the real Clock. A real reading earlier than the last Pump’s is taken as the last Pump’s, so the Clock never goes backwards.
  • :limits:
    • :limits prints each limit a Delivery may override, one per line as <name> <value>, by its ts name: fuelPerRun, allocPerRun, maxWaitMs and maxJoin.
    • :limits <name> <value> sets that override for every Entry requested afterwards. It can only tighten the default limit profile, and a looser value is refused as invalid value. Runs started by a send keep the Script’s limits.
    • :limits reset clears every override.
  • :fix is Fix and Continue (ADR 0072). A Transcript records it as > :fix <run>, followed by the file’s lines as | lines, instead of the path, as for :library.
    • Its declarations are the file’s, read as a Script’s source, so a syntax error prints ! <code> at <line>:<column> in the file’s own lines, and a file with none is refused as bad arguments. Each declaration’s lines run from the line after the last one’s last line, without the blank lines at their start, to its own last line, so the comments before a declaration go with it. A Run that is not one of the Session Script’s, or has ended, is refused as no such run. A refused :fix makes no Host Input.
    • The Rewind: it makes RewindRun of the Run and pumps (chapter 9). If that Pump doesn’t return rewound, the Rewind did nothing: it prints what the Pump printed, then ! not rewindable, and reloads nothing. Otherwise it prints ! rewound <run>.
    • The Reload: each declaration goes into the session source as a redefinition or a new name would put it, in the file’s order, and the Session Host reloads the Script from it with its Script Variables carried over and its mailbox kept (chapter 10), and prints each Run discarded. A script variable x = e for an x the Script has changes its initialiser, and runs no put. A Reload that fails prints each diagnostic as ! <code> at session:<line>:<column> and leaves the session source as it was, so the message runs again on the code it had.
    • Then it pumps, and the message runs again.
    • Between Pumps, a Run still in its first Segment is one parked by , queued, since the Session Host pumps after every Entry. At a debugger pause, :fix takes only the paused Run, and the Rewind lands at the paused instruction, through the TS Core’s tooling hooks. A paused Entry’s Run keeps its message’s Handler: the Reload loads the Entry’s implicit Handler after the session source. The Session Transcript stops before the Entry, command, line or deadline whose Pump was paused, and what the session does after it is outside the Transcript.
  • :runs prints one line per Run that hasn’t ended, from Inspect() (chapter 9): its id, its status (ready, suspended, parked or preempted) and its Handler, then, for a suspended one, the end reason it suspended at, until <instant> if it has a deadline, and the ids it waits for, each separated from the last by a space.
  • :mailbox prints one line per message waiting: its delivery id, or the call or Run that sent it, then its name and its arguments as a list.
  • :vars prints one line per Script Variable, in declaration order, as <name> = <value>.
  • :save and :restore keep a Store Notification checkpoint, rather than a bare Group save. A checkpoint is kept in the Host’s memory with the Session Host’s own state: the session source, the next entry<n>, the :limits override, the Clock and the queued Stubs. :save prints saved <name>. :restore restores the checkpoint through the router with RejectMismatch, detaches the Group it replaces from the router, adopts every pending call, and prints restored <name>, then ! discarded <run> for each Run the restore discarded. A Session Store that changed since :save sends one marker to each restored watch on it, and the Session Host pumps for those markers as the Pump :restore causes. The restore uses the user Libraries the session has then, so one replaced since the save makes it refuse as save mismatch. After each :library replace the Session Host takes its Libraries from the Group’s Libraries, so a Library recompiled because it imports the replaced one doesn’t make a restore straight after a save refuse.
  • :library: add compiles the file and adds the Library, and replace replaces it, carrying Script Variables over (chapter 7). A Transcript records it as > :library add <name> or > :library replace <name>, followed by the Library’s source as | lines, instead of the path.
  • :script: add loads the file as a Script named <name> in the session’s Group, under GrantsAsUsed with the Session Script’s Grants and owning no Host Object, and starts the session. Entries reach it only by message. A name already in the Group, session included, is refused as name reused, and a Script that doesn’t load prints its ! <code> at <unit>:<line>:<col> lines and isn’t added. :save and :restore include added Scripts; :fix, :vars and Declarations act on the Session Script only. A Transcript records it as > :script add <name>, followed by the Script’s source as | lines, instead of the path, as for :library.
    • Its source is its lines, each ended by an LF, so a file whose last line has no line break is read as if it had one. Every user Library’s version is 1, and replacing one keeps it.
    • Refused here: add for a name the session has already added is refused as name reused, and replace for one it hasn’t as library mismatch, without a Host Input. A Library that doesn’t compile prints each of its diagnostics as ! <code> at <library>:<line>:<column>.
  • :store: each form names a Session Store, by default default, so a Store called load, save or clear can only be shown through a Script. A Store no Grant names is still there to load, save, clear and show.
    • :store prints one line per key, in Unicode code-point order, as <key> = <value>, with the key as text in the display form.
    • :store load reads a file holding one JSON object, whose members are keys and their values in the Value Encoding, and replaces the Store’s contents with them. Each member’s name is its key as written, never a tag, and only its value is decoded, so {"$map":7} loads the key $map holding 7, as :store save would write it. A member whose value is null holds Nothing, so it loads no key (chapter 7). It prints loaded <n> keys, counting the keys the Store then holds. A file that isn’t such an object, a key that is empty, a value that doesn’t decode or holds a Host Object, or contents past a quota, is refused as bad arguments, and the Store is unchanged. A Transcript records it as > :store load [<store>], followed by the file’s lines as | lines, instead of the path, as for :library.
    • :store save writes the Store’s contents to the file as one JSON object, with its members in key order and no white space, and prints wrote <file>.
    • :store clear empties the Store and prints cleared <store>.
    • Routing: :store load and :store clear are commits, routed by their net changes. The Session Host pumps after one that admits a Notification, as the Pump the command causes.
    • Between Pumps: each form runs between Pumps, when no Segment has uncommitted Store writes, and no form is a Host Input.
  • :export prints the session source, its use lines included. Given a directory, it writes the session source as session.talk and each user Library as <name>.talk, and prints wrote <file> for each, with the file’s name in the directory.
  • :help and :quit aren’t recorded, and what they print is outside parity.

Session observation fixes the command-specific input grammar, rows and failure behavior for :describe, :inspect, :apropos, :trace, :untrace and :fuel. All six commands and their output are recorded. :inspect and :fuel use expression/Entry completeness rather than treating every : line as immediately complete. Leading --| documentation blocks follow the same prompt attachment rules in both REPLs.

The Session save also includes the observation state. It is replaced, not merged, when restored. Snapshot reads performed by passive describe of a Script Variable are explicit vars Host Inputs; source metadata lookup and cached Fuel queries add none.

A Session Transcript records a session in a form a user can read and share: its Entries and Session Commands in order, with everything the session saw from outside, and what it printed (ADR 0014, ADR 0018). A REPL writes one as the session goes. In the Corpus, it is a session.transcript file with a blessed case.trace beside it (chapter 11).

Transcript ::= ( TranscriptLine #xA )*
TranscriptLine ::= '> ' [^#xA]+ | '| ' [^#xA]* | '|' | '< ' [^#xA]* | '<'
| '@ ' Instant | '~ ' Id ' ' Answer | '%' ' ' CrossingJSON | '#' [^#xA]*
| "'" [^#xA]* | OutputLine
CrossingJSON ::= '{' [^#xA]* '}'
/* one compact JSON object; record fields and canonical
encoding are in session-observation.md */
Answer ::= Value | 'fail ' MapValue
OutputLine ::= [^>|<@~%#'#xA] [^#xA]*
/* an output line that is empty or starts with one of
these characters is written after a `'` */
  • > starts the first line of an Entry, or a Session Command.
  • | starts each further line of an Entry, or a line of the source that :library, :script or :fix records. A | alone is an empty one.
  • < starts a line the user typed for console’s read, and a < alone is an empty one.
  • @ gives a real Clock reading, and comes before every Pump under a real Clock. The first @ after an Entry, a Session Command, or a < or ~ line is the reading of the Pump that line causes. The Pumps that one causes in turn, an :inspect reader’s and the Pump for queued Host Inputs, take the readings that follow. The Pumps for Store Notifications reuse the reading before them and have no @ line. Any other @ is a Pump the Session Host made at a deadline, and replay makes it there. A virtual Clock needs no @ lines, since it moves only at :clock commands.
  • ~ gives the answer a built-in Capability returned for a call, as its value or as fail and an error map: its code, its message and its other fields, or {} for a failure that isn’t a Script error, which the Script sees as host error. It comes where the answer arrived: after the line that caused an immediate call, or where a suspending call’s answer came, which causes a Pump.
  • % introduces the compact JSON object crossing envelope, including declarations, initial bindings, property callbacks, external Host actions and resolver outcomes.
  • # starts a comment, which a REPL never writes.
  • Every other line is output. An output line that is empty, or that starts with >, |, <, @, ~, %, # or ', is written after a '.

Example.

> :clock virtual 2026-09-30T10:00:00Z
> put 2.50 GBP into price
> price * 3
7.50 GBP
> "5"
"5"
> on greet name
| say "hello " & name
| end greet
> greet "Ann"
hello Ann
> 1 / 0
! error {code: "division by zero"} at 1:3
  • Replaying first restores the recorded object setup, consumes % crossings at their specified positions, and gives each Entry and recorded Session Command, in order, to a fresh Session Host, with each @ reading as that Pump’s Clock reading, each < line as the answer to read, and each ~ line as the answer of its call, in place of the built-in Capability. It never writes a file: :export with a directory writes to a scratch one.
  • Both must match: the printed lines must equal the Transcript’s output lines, and the Group’s Trace must equal case.trace (chapter 11).
  • Deterministic Host extensions: a Host may register additional immediate Capabilities whose implementation uses only arguments and session-owned state. A Transcript replays these through the same implementation and declarations; they do not read external I/O and need no ~ answers. Each fresh session receives fresh extension state. Trace replay carries their Operation Declarations and uses the recorded call outcomes. This does not make them Standard Capabilities.
  • In the Corpus, a Transcript may include recorded object setup/crossings and grants only console, user and mock Capabilities, since which other Capabilities a REPL has built in, and what they cost, is each Host’s own. Every REPL builds user in, at no cost.
  • Bless writes case.trace and fills in the output lines, only when every available REPL agrees, as for a Trace Case.

The command is northtalk, the editor language ID is northtalk, and the language server launches as northtalk lsp (ADR 0039).

The LSP, the formatter, the debugger and the Lint engine are one TypeScript tooling stack, under Bun or Node for editors and in a browser worker for Folio, built on the TS Core’s own parser and checker (ADR 0028). The Go REPL is the only Go tooling, and has no Lints, formatter or debugger. A Script in a Go Host is debugged by replaying its Trace on the TS Core.

northtalk app.talk [args…] runs a Script file (ADR 0126). Every northtalk command does the same: the TS one under Bun or Node, the Go one and the native Zig one. A first argument that ends in .talk, or that names an existing file and isn’t a subcommand, is the file. With no arguments the command opens the REPL.

  • Loading: the file is one Script in one Group, with the stdlib Libraries. It is granted, under GrantsAsUsed, each Standard Capability the Runner offers, under its own name: console, clock, timer, calendar, locale, an in-memory store, sqlite where the runtime has it, http, and user when standard input is a terminal. The native Zig Runner offers no calendar or locale. A load error is printed and the command exits 1.
  • peer: the Runner offers peer, carrying Remote Sends to other Runners over mutual TLS (ADR 0163). The native Zig Runner speaks a minimal TLS 1.3 of its own (ADR 0164), so all three Runners reach each other over either transport. Runner peers gives the flags and the wire.
  • Starting: the Runner Delivers start with one argument, the list of the arguments after the file, as texts. A Script without a start Handler simply ends that Run as unhandled.
  • http: the binding allows any address to listen on and any origin to fetch from, localhost and private networks included, since the Runner runs a trusted local program. Its header and body bounds are chapter 7’s defaults. --port before the file, or the PORT environment variable, overrides every serve’s port.
  • Exit: the command exits when the Group has no live Runs, no pending timers, no Serve Registrations and no open HTTP Exchanges. It exits 0, or 1 if any Run ended with an uncaught error, which it writes to standard error.
  • Signals: the first SIGINT or SIGTERM stops accepting connections and Delivers stop, with no arguments, if the Script has a Handler for it. The Runner waits up to 5 seconds for open HTTP Exchanges, answers any still open with 503, Stops the Group, and exits 130 or 143. A second signal exits at once.

The flags come before the file, as --port does. Each Runner has a key: an ECDSA P-256 key read from the PEM file --peer-key FILE, which holds the key and a certificate for it, or one made at start. Its key fingerprint is the lowercase hexadecimal SHA-256 of the key’s DER SubjectPublicKeyInfo, and when any of these flags is given the Runner writes it to standard error as peer: key <fingerprint>.

  • --listen HOST:PORT, or tls://HOST:PORT, accepts Remote Sends from other Runners, over TLS 1.3 with both ends presenting a certificate for their key. It accepts any key. Port 0 picks a free port, and the Runner writes peer: listening on tls://<host>:<port>#<fingerprint> to standard error once it listens. A Runner that listens doesn’t exit for want of work until it stops listening.
  • --listen tcp://HOST:PORT accepts them over plain TCP instead, writing peer: listening on tcp://<host>:<port>. HOST must be 127.0.0.1, ::1 or localhost, since nothing checks a plain connection’s ends.
  • --listen ws://HOST:PORT accepts browser Hosts’ WebSocket links instead (chapter 9), on any path, writing peer: listening on ws://<host>:<port>. TLS is a proxy’s job, as for http. The Runner has no authenticate, so the Caller Identity of what arrives is {key: "<fingerprint>", via: "ws"}. Only the TS Runner offers this flag; Runners reach each other over tls:// and tcp://.
  • --peer NAME=tls://HOST:PORT#FINGERPRINT, which may be repeated, names the Host that holds the exposure NAME. The Runner dials it when it first needs to, and refuses the connection unless the listener’s key has that fingerprint. Dialling and listening Runners exchange the same frames over the connection, in both directions.
  • --peer NAME=tcp://HOST:PORT names one reached over plain TCP, on a loopback HOST as for --listen. On a plain connection each end’s first frame is {"hello": "<fingerprint>"}, its own key’s, which nothing checks; a Runner with no TLS key claims 64 random lowercase hexadecimal digits instead.
  • The binding: reach allows the names --peer gives, and refuses any other with bad address. expose allows any name.
  • Peers: an exposure’s id is <fingerprint>/<secret>: the holding Runner’s key fingerprint, then 32 lowercase hexadecimal digits of random secret. Each Group has one Peer per id, of kind peer with that id, and a Peer crosses in the Value Encoding as {"$object": ["peer", "<id>"]}. A Runner sends to a Peer of its own key’s exposures locally, and to another Host’s only when a --peer gives that fingerprint’s address; otherwise the send fails unreachable.
  • Frames: each is a 4-byte big-endian length, at most 16 MiB, then that many bytes of a UTF-8 JSON object, whose values are in the Value Encoding:
    • {"reach": n, "name": NAME} asks for a named exposure, answered {"reached": n, "peer": id} or {"reached": n, "error": "not exposed"}.
    • {"post": id, "message": SELECTOR, "args": [ … ]} is a post, with no answer.
    • {"call": n, "to": id, "message": SELECTOR, "args": [ … ]} is a call, answered {"replied": n, "value": V} or {"replied": n, "failed": {"reason": R}}, with error beside reason when the receiving Request gave one.
    • n is a whole number the asking end chooses, unique among its open questions on the connection.
  • Arrival: a post is a Delivery to the exposure’s Script, and a call a Request, whose result is the reply. One to a withdrawn or unknown exposure is dropped, or answered failed with not exposed, and one the mailbox refuses with mailbox full. The Caller Identity of what arrives over TLS is {key: "<fingerprint>"}, the dialler’s or listener’s, with name: NAME added when a --peer names that key. What arrives over plain TCP has none, so caller gives Nothing.
  • At most once: a Runner never sends a frame again. A call whose connection closes, or can’t be made, before its reply fails with unreachable, and so does one whose reply can’t be decoded against the receiving Group.
  • Normative: the first syntax error and every load-time diagnostic (chapter 2, codes), the display form, the source map (chapter 8), the lowering, and Session Transcripts.
  • Tooling freedom: the formatter’s output, the LSP’s features, Lints and the debugger. None of them adds a case kind to the Corpus, and changing one is never a language change.
  • One parser: the TS Core’s parser gives a lossless syntax tree, comments and blank lines included, and goes on after the first error. The tooling uses that tree, and the Core compiles from the same parse, so the first error the tooling reports is the Core’s.

The Beginner Surface and the Advanced Constructs are a tooling view over one language (ADR 0027).

  • Every Core accepts everything, whatever the Host or profile. A layer never changes what loads, what the Corpus covers or how a Script runs, and a beginner’s Script can import any Library.
  • The tags: an Advanced Construct is one grammar.toml tags advanced (chapter 2). A construct is tagged only if a Beginner Surface form does the same ordinary job and a beginner reading it couldn’t guess what it means, and its tag names that form. Moving a construct between layers changes only grammar.toml.
  • A Lint is advice about a Script that loads, and never rejects it. Each has a stable kebab-case id, and a level in each Lint Profile: off, hint or warning. There is no error level.
  • Lint Profiles: beginner and standard. The Host sets the default, such as a beginner Host, and a user may override it.
  • Explicit endings: prefer-explicit-end flags each bare block-ending end at that token, suggesting the matching end <name> or end <keyword>. It is a warning in beginner and off in standard, using the existing suppression convention. It never prevents loading or execution. Bare endings are a style choice, not Advanced Constructs; beginner examples use explicit endings.
  • List splicing: suggest-list-splice hints in beginner and is off in standard. For put xs after acc with clear list evidence, it explains that xs becomes one element and suggests put ...xs after acc to append its items instead. Nesting is valid, so there is no automatic rewrite. The tooling guide describes its conservative evidence and limits (#381).
  • Suppressing: -- lint: ignore <id> on the line before suppresses one Lint there. It is a comment, not syntax.
  • The catalogue is the tooling’s lints.toml, with a wording template per Lint. It is published, but adding, removing or re-levelling a Lint is never a language change.

Note. The first Lint catalogue, with levels as beginner / standard: a likely bug is a warning in both, a trap only beginners fall into is a warning and then a hint, and a style suggestion is a hint in both.

Id Flags Levels
advanced-construct an Advanced Construct warning / off
prefer-explicit-end a bare block-ending end, suggesting its matching explicit ending warning / off
suggest-ignoring-case a text comparison that probably wants ignoring case hint / off
unreachable-clause a Handler Clause that an earlier clause always wins over warning / warning
pin-trap a pattern name that shadows a Script Variable, and so binds rather than compares warning / hint
is-empty-on-missing-key is empty on a key the map may lack warning / hint
whole-value-when a whole-value when <"WARN"> probably meant as when contains warning / hint
try-write-before-fail a Script Variable written inside try before a statement that can fail, since a caught error rolls nothing back warning / warning
inline-block-lambda a block Lambda written inline as an argument, rather than named first hint / hint
long-join-body a Join body whose head scrolls out of view hint / hint
plain-send-in-join a plain send inside a Join, probably a forgotten and wait warning / warning
conditional-join-member a Join Member inside an if, which makes the length of it depend on the data warning / hint
serialised-self-join a Join that sends to me for a message whose clauses all opt out of concurrency warning / warning
key-shadows-property a map literal key that shadows a Built-in property warning / warning
unknown-message a Handler for a message the Host Manifest doesn’t declare hint / hint
message-argument-count a command no Handler in the Script answers, giving a different number of arguments than the Host Manifest declares for its message warning / warning
fallback-routes-known a Fallback Handler clause that compares the message’s name with a Selector the Script has named clauses for, which runs only when those clauses fail hint / hint
ambiguous-ignoring-case a trailing ignoring case after an and or or chain, which binds only to the nearest comparison warning / hint
shadows-builtin a Script name that shadows a Built-in Constant or function warning / hint
unconvertible-literal a literal text given to as civil date or as instant that can’t convert warning / warning
  • No options: one layout for every project.
  • Line breaks are never added or removed, since a line break ends a statement. The formatter changes only indentation, 2 spaces per block, spacing within a line, and runs of blank lines, keeping at most one outside fenced literal content.
  • Comments and tokens: it keeps every comment exactly, only re-indenting it, and never changes a token’s spelling. Zero-argument choices print as choose offer name, omitting optional empty parentheses.
  • Documentation attachment: preserve the marked-block attachment, including the last separating blank line; formatting must not attach a previously detached block.
  • Its invariants, held by the tooling’s tests: formatting is idempotent, and it never changes a unit’s canonical disassembly, apart from the source positions it shows.
  • Diagnostics: the normative errors and the Lints.
  • Completion: Operations from the Grants, catch patterns from declared error codes, names from imports, message names from the Host Manifest, and Units and chunk words where the grammar allows them.
  • Hover: the declaration’s Declaration Documentation, plus a Constant’s value in the display form, an Operation’s Declaration with its description and examples, and a Function Value’s Home Script.
  • Navigation: go to definition and find references across imports, and rename.
  • Recovery diagnostics: use the grammar/checker rules and Advanced tags for offers, Recovery Catches and choices. A choice need not have a statically visible offer; dynamic availability alone is not a load error or LSP diagnostic. Beginner wording suggests a local catch with an explicitly supplied policy callback.
  • Suspension marks: a mark on every Suspension Point and every Handler or Lambda that may suspend. They add to the wait the source must already have, including a Join’s wait for all head, and never replace it.
  • Formatting, through the formatter.
  • Everything else, such as semantic highlighting and code actions beyond quick fixes for Lints, is the implementation’s.
  • Two modes: live, against the TS Core in a Bun Host, and replay, from any Trace, including one taken on a Go Host.
  • Breakpoints map through the source map to an instruction, and pause the whole Group at that instruction’s boundary, through the TS Core’s tooling-only hook.
  • A pause isn’t a Host Input: it costs no Fuel and leaves the Trace unchanged, and Fuel Slices count Fuel, not time. While paused, the Group is shown in the same form as :runs, :mailbox and :vars, read through the tooling hook rather than Inspect(), which is a Host Input. Resuming continues the same Run.
  • Stepping in, over and out works by statement. Stepping over a Suspension Point goes on until this Run resumes past it, while other Runs execute, and a breakpoint in any of them pauses the Group. Stepping into a send … and wait, or a call to a Function Value in another Script, follows the message into the receiving Run. Each Run’s view shows its Segment number and the Fuel it has used.
  • Recovery dispatch: live and replay stepping follow the active policy/cleanup cursor, rather than the retained failed stack’s deepest PC. Step over/out use the active owner path and helpers. Tooling-only frame views may add role (retained or dispatch); a dispatch activation includes an owning-frame reference and displays its actual shared owner locals. Ordinary frame views and chapter 9’s Inspect schema are unchanged. Debugger callbacks stay outside saves, costs and Trace.
  • The Clock: live, the debugger’s Host supplies Clock readings and subtracts paused time, so deadlines don’t all fire on resume. In replay, the readings come from the Trace.
  • Faults: “break on error”, caught or not, and “break on Limit Fault” pause before any rollback, so the state that caused it can be seen.
  • No edits: the debugger never writes Script state, and changing code is a Reload. Fix and Continue is a RewindRun of the paused Run followed by a Reload that keeps the mailbox, so the same message runs on the edited code (ADR 0068). It is offered only while the paused Run hasn’t passed a Suspension Point, and the debugger lists the Segment’s effects that will happen again. A session makes it with :fix. The message runs again on the carried Script Variables, before any Entry the developer makes, so a change to their shape is migrated after it.
  • Going back: replay offers “run to Host Input n” and reverse steps, by replaying again from the start or from a save.
  • Replaying a live Host’s Trace, the debugger answers every Host crossing from the Trace’s own records (chapter 11), and lands each early Stop, CancelRun or RewindRun at the instruction its pc names.

Tooling learns what a Host offers from the Host Manifest it exports for each kind of Script: its Grants and their Operation Declarations, with any description and examples the Host wrote for them, the Libraries a Script may import, the messages it may receive with their argument Shapes and any documentation, and the Host Object kinds and well-known objects (chapter 9). In a Handler for a declared message, tooling treats the target as an object of one of the kinds the message is delivered to, or of the Owner Kind when it is delivered to a Script; a Fallback Handler’s the target stays unknown. With an Owner Kind, tooling treats me as an object of that kind: it completes and hovers its properties, and the Lints unknown-property and read-only-property flag a literal property the kind lacks and a set of a read-only one, for me and the target alike. The checker’s can't write needs the live me at load, so from the manifest these stay advice. The Core never reads it, so a stale manifest can only mislead tooling.

The TS CLI supplies a typed canvas Host capability, granted with :grant canvas canvas, and Folio gives one to every Script. Its operations, state and bounds are documented in the tooling stack guide. Live evaluation preserves drawing state; fresh execution resets it. The CLI replays the same operations headlessly. Graphics are Host behavior, outside language parity. Go REPL support is a separate compatibility requirement.

The REPL waits while a literal, hole or enclosing Entry is incomplete. Blank lines inside literals are content. Submit when the whole Entry is complete. Final EOF reports the innermost unfinished construct at its opener.

The formatter preserves literal values, including all trailing whitespace and additional blank lines. When changing a margin-stripped literal’s indentation, change its closing margin and corresponding content prefixes together. Preserve inline-start content. Highlight delimiters and literal content separately from ordinary code inside holes.

  • The tooling: the formatter’s output, the LSP’s features, the debugger, the Lint catalogue and its wording, and the Advanced tags (ADR 0027, ADR 0028).
  • The REPL’s own interface: its prompt, line editing, colours, :help and :quit, and how it is told where to write a Transcript.
  • Built-in Capabilities: which ones a REPL offers to :grant, and their answers, which a Transcript records.
  • The TS Core’s tooling hooks, for pausing and for landing an early Stop, CancelRun or RewindRun in replay (TS implementation guide).