March Docs

Recon

Recon: a running program's view of itself, from March code.

The same numbers the observe socket serves (forge observe, forge top), read in-process through the observe_query builtin, which answers one request line with the socket's JSON envelope. Observe tier: every function takes a Cap(Actor.Introspect) (mint it with Actor.introspect(io) in main) and none returns a crash message, only how an actor died.

Backends. Compiled, the answers come from the runtime's actor table and counters. Interpreted, from the interpreter's actor table: mailboxes are usually empty (delivery is eager), there is one scheduler, and no memory gauges, so those fields read 0 or None.

Windows. proc_window and scheduler_usage take two samples window_ms apart and sleep THIS green thread in between (the runtime's own windowed verbs would sleep a scheduler's OS thread, so in-process callers get them refused).

R3 of specs/plans/2026-09-28-observe-recon-shell-plan.md.

Every reading is of the live program, so the examples are plain code; only format_top, which renders rows you hand it, carries runnable ones. Every reader answers its empty value (Nil, None, zeros) when the query fails.

Types

typeActorInfoActorInfo = {#

One live actor, as info and the other actor views report it.

typeSupervisionSupervision = {#

A supervisor's restart policy: policy (one_for_one, one_for_all or rest_for_one), limit restarts allowed within window_secs, and held, how many are inside the window now.

typeTopRowTopRow = {#

One row of top: who the actor is, what it was ranked on, how big it is, and how it is supervised. value is the ranked metric; link is "supervised" (a supervise block restarts it), "spawned" (nobody restarts it, but an actor spawned it) or "none" (spawned from main or a task). parent and parent_type name its supervisor, and supervision is Some only when the row is itself a supervisor.

typeSupNodeSupNode = SupNode(Int, String, List(String), List(SupNode))#

A supervision-tree node: pid, actor type, registered names, children.

typeNodeStatsNodeStats = {#

Whole-node figures from one snapshot. Memory gauges are None where the backend has none.

typeCrashReportCrashReport = {#

One crash, without its message: kind is crash, draining or panic.

typeEpochReportEpochReport = { current : Int, pins : List((Int, Int)) }#

Hot-reload epochs: the current one and (epoch, pins) for every pinned epoch.

typeFnVersionFnVersion = {#

The version of a reloadable function a node runs: impl_hash is the code's identity (what forge deploy hot diffs), baseline_hash the one the program was built with, patched whether they differ, epoch the hot-reload epoch that activated it, and activated_at_ms when (0 for the baseline).

Functions

fnactorsactors(_c : Cap(Actor.Introspect)) : List(ActorInfo)#

Every live actor (up to 10000), deepest mailbox first. Nil if the query fails.

let busy = List.filter(Recon.actors(c), fn a -> a.mbox > 100)
fncrashescrashes(_c : Cap(Actor.Introspect), n : Int) : List(CrashReport)#

The last n crashes (at most 256), newest first, without their messages.

List.each(Recon.crashes(c, 10), fn r -> println(r.type_name ++ " " ++ r.kind))
fnepochsepochs(_c : Cap(Actor.Introspect)) : EpochReport#

The current hot-reload epoch and the pins held at each epoch, as (epoch, pins) pairs. { current: 0, pins: Nil } if the query fails.

let e = Recon.epochs(c)
println("epoch " ++ int_to_string(e.current))
fnformat_topformat_top(rows : List(TopRow)) : String#

rows (from top) as a table, one line per actor and a header line, in the order given. The ranked column is headed VALUE; NAME is the first registered name, else the actor type, and long cells are clipped to their column. No trailing newline; an empty rows gives the header line alone.

Examples

march> let row = { pid: 12, type_name: "Worker", names: ["billing"], status: "running", value: 40, mbox: 40, stack_bytes: 8192, link: "supervised", parent: Some(3), parent_type: "AppSup", spawned_by: Some(3), children: 0, crashes: 1, child_crashes: 0, supervision: None }
march> List.length(String.split(Recon.format_top([row, row]), "\n"))
3
march> let row = { pid: 12, type_name: "Worker", names: ["billing"], status: "running", value: 40, mbox: 40, stack_bytes: 8192, link: "supervised", parent: Some(3), parent_type: "AppSup", spawned_by: Some(3), children: 0, crashes: 1, child_crashes: 0, supervision: None }
march> List.nth(String.split(Recon.format_top([row]), "\n"), 1)
"     12  billing          running       40     8192       40       1  supervised 3 (AppSup)            -"
march> List.length(String.split(Recon.format_top([]), "\n"))
1
fninfoinfo(_c : Cap(Actor.Introspect), pid : Int) : Option(ActorInfo)#

The live actor with pid index pid (what pid_to_int returns), or None when it is dead or was never spawned.

match Recon.info(c, 3) do
  Some(a) -> println(a.type_name ++ " " ++ int_to_string(a.mbox))
  None -> println("gone")
end
fnnode_statsnode_stats(_c : Cap(Actor.Introspect)) : NodeStats#

Actors, queued messages, memory and crash totals from one snapshot. All zeros and Nones if the query fails.

let s = Recon.node_stats(c)
println(int_to_string(s.actors) ++ " actors, " ++ int_to_string(s.queued) ++ " queued")
fnprint_topprint_top(c : Cap(Actor.Introspect), attr : String, n : Int) : Unit#

Print top(c, attr, n) as a table: the one-liner for the remote shell, Recon.print_top(intro, "stack", 10). See format_top for the layout.

fnproc_countproc_count(_c : Cap(Actor.Introspect), attr : String, n : Int) : List((Int, Int))#

The n live actors highest on attr, as (pid, value), highest first. attr is one of "mbox" (queued plus held), "crashes" (its own and its children's crashes in the last hour), "slices", "msgs_in" or "msgs_out" (cumulative since spawn; see proc_window for a rate). An unknown attr gives Nil.

match Recon.proc_count(c, "mbox", 1) do
  Cons((pid, depth), _) -> println(int_to_string(pid) ++ ": " ++ int_to_string(depth))
  Nil -> println("no actors")
end
fnproc_windowproc_window(c : Cap(Actor.Introspect), attr : String, n : Int, window_ms : Int) : List((Int, Int))#

Like proc_count for "slices", "msgs_in" or "msgs_out", but ranked by how much each rose over the next window_ms: two samples, with this green thread asleep between them. An actor born during the window counts from 0. Any other attr ranks by mailbox depth growth.

Recon.proc_window(c, "msgs_in", 5, 1000)   -- top 5 receivers over 1 s
fnscheduler_usagescheduler_usage(_c : Cap(Actor.Introspect), window_ms : Int) : List((Int, Float))#

Each scheduler's utilisation over the next window_ms, as (scheduler id, fraction busy in 0.0 to 1.0): two samples of its idle time, with this green thread asleep between them. Nil under the interpreter (no scheduler threads). The fraction is clamped to 0.0..1.0.

List.each(Recon.scheduler_usage(c, 1000), fn t ->
  match t do (id, busy) -> println(int_to_string(id) ++ ": " ++ float_to_string(busy)) end)
fnsourcesource(_d : Cap(Actor.Debug), name : String) : Result(String, String)#

The source text of the version of name this node runs now, as it stood when that version was built and uploaded: the declaration, with the comments up to the next one. Debug tier: it needs Cap(Actor.Debug) and a $MARCH_DEBUG_POLICY file that lists SOURCE, else Err("policy"). Err("no_source") when the text of this version was never uploaded (forge deploy hot uploads it; a node built elsewhere has only its own).

match Recon.source(debug, "Billing.total") do
  Ok(text) -> println(text)
  Err(e) -> println("no source: " ++ e)
end
fntoptop(_c : Cap(Actor.Introspect), attr0 : String, n : Int) : List(TopRow)#

The n live actors highest on attr, biggest first, each with its supervision. Equal values are ordered by pid, so the same node state gives the same list.

attr is "mbox" (or "mailbox"; waiting work: queued plus held), "stack" (committed machine-stack bytes, the memory the runtime can attribute to one actor), "crashes" (its own and its children's in the last hour), or "slices", "msgs_in", "msgs_out" (cumulative since spawn; see proc_window for a rate). An unknown attr gives Nil. Heap bytes owned by an actor are not tracked, so there is no "heap" ranking.

Recon.top(c, "mbox", 10)
fntreetree(_c : Cap(Actor.Introspect)) : List(SupNode)#

The supervision tree: one node per root (an actor with no supervisor that supervises or spawned something live), children nested. Actors in neither role are left out; actors lists everything.

fn show(n : Recon.SupNode, depth : Int) : Unit do
  match n do
    Recon.SupNode(pid, ty, _, kids) ->
      println(String.repeat("  ", depth) ++ ty ++ " " ++ int_to_string(pid))
      List.each(kids, fn k -> show(k, depth + 1))
  end
end
List.each(Recon.tree(c), fn r -> show(r, 0))
fnwhichwhich(_c : Cap(Actor.Introspect), name : String) : Result(FnVersion, String)#

Which version of the reloadable function name ("Mod.fn", or an actor's "Counter_dispatch") this node runs: its impl_hash, the baseline it was built with, and when the current version was activated. Err("not_found") when name is not a reload slot of this node (a typo, a function the build does not make reloadable, or an interpreted program).

match Recon.which(intro, "Billing.total") do
  Ok(v) -> println(v.impl_hash)
  Err(e) -> println(e)
end