Frostline Core Architecture

Design rev 2, 24 November 2026. The target for the Go rewrite, with what is already merged marked as such.

Frostline becomes three Go binaries with one job each, one dispatcher, a pure domain that owns every decision, and plugins that live on the caller's side of a process boundary. Python leaves the command path in phase 1 and the box in phase 2.

  • Three binaries. frostline runs as you. frostline-core runs as the service account and is the only dispatcher. frostline-root does 13 named privileged jobs through sudo and nothing else.
  • One dispatcher. CLI, MCP, Code Mode and HTTPS all become clients of service.Dispatch. No second path, no per-call Python, no per-call sudo.
  • Decisions are pure. The domain has no clock, no files, no network. It takes typed observations and returns typed decisions from transition tables. Everything that touches the world is an adapter behind a port.
  • A tap never happens twice. Intent is journaled before injection. A lost reply becomes OutcomeUnknown, never a retry.
  • Plugins stay outside. Stack knowledge (React Native, Flutter later) lives in frostline-<name> executables that run as you and talk only through the public API. Core knows no stack.

The map: who runs what, as whom

Three trust zones. Arrows are the only ways across. Your laptop runs the same front binary and reaches the box over HTTPS instead of the local socket.

flowchart LR
  subgraph you["Your account (laptop or box)"]
    front["frostline (Go front)
generated parser
MCP stdio, Code Mode broker
your files read and written as you"] ext["frostline-rn and other plugins
run as you, no new privileges"] serve["frostline serve
per member, HTTPS and tokens"] goru["goru-worker
sandbox for agent JS"] end subgraph svc["Service account (frostline)"] core["frostline-core serve
peer auth, Dispatch,
scheduler, state, journal"] dev["per-device supervisor
resident-worker + control socket"] sim["mldr, darlingserver,
DisplayHost, the iOS app"] end subgraph root["Root"] rootbin["frostline-root
13 named subcommands"] end laptop["Laptop front"] -->|"HTTPS /v2/call"| serve front -->|"unix socket, framed calls"| core serve -->|"unix socket, as that member"| core ext -->|"public CLI and API only"| front front -->|"runs agent code in"| goru core -->|"control socket"| dev dev -->|"supervises"| sim core -->|"sudo, exact subcommands"| rootbin front -->|"sudo forward-run only"| rootbin classDef caller fill:__ICESOFT__,stroke:__ICE__,color:__INK__ classDef service fill:__NEWSOFT__,stroke:__NEW__,color:__INK__ classDef privileged fill:__WARNSOFT__,stroke:__WARN__,color:__INK__ classDef outside fill:__SURF2__,stroke:__INK2__,color:__INK__ class front,ext,serve,goru caller class core,dev,sim service class rootbin privileged class laptop outside
One dispatcher in the middle. Devices are untrusted even though they run as the service account, so the core admits a service-account caller only from its own mount namespace and never from an app's cgroup.
BinaryRuns asOwnsNever does
frostlineyouParsing, your files, MCP, Code Mode, per-member HTTPS serve, plugin dispatch, port forwarding entryDevice work, state, decisions
frostline-coreservice accountAuth, the one dispatcher, scheduling, device state, the intent journal, device supervisorsHTTPS, tokens, writing your files, running plugins
frostline-rootroot via sudoMounts, images, network lock, namespace guard, kill and trace helpersAnything not on its list of 13
goru-workeryouRunning agent code in a sandboxLinking into a privileged binary

Layers inside the Go module

Dependencies point inward. A layering test parses every import and fails the build when an arrow goes the wrong way.

flowchart LR
  cmd["cmd/*
the only place that wires"] --> api cmd --> adapters cmd --> cli cli["cli/
parser, contexts, your I/O"] --> schema api["api/
wire, local, https, mcp"] --> service api --> schema service["service/
Dispatch, authz, scheduler,
machines, journal"] --> ports service --> domain adapters["adapters/
ctrl, frames, ax, hid, stage,
guest, sqlite, systemd, legacy"] --> ports ports["ports/
Device, Clock, StateStore,
Frames, AX, HID, RootHelper"] --> domain schema["schema/
generated from verbs/*.json"] --> domain domain["domain/
types, unions, transition tables
stdlib only, no IO, no clock"] classDef pure fill:__NEWSOFT__,stroke:__NEW__,color:__INK__ classDef edge fill:__ICESOFT__,stroke:__ICE__,color:__INK__ classDef wiring fill:__WARNSOFT__,stroke:__WARN__,color:__INK__ class domain,ports pure class adapters,api,cli,schema,service edge class cmd wiring
The domain sits at the end of every arrow and imports nothing of ours. Adapters never import the service or the API.
PackageHoldsMay importBanned inside it
domain/IDs, sessions, tap and settle, lifecycle, budgets, outcomes, errorsstdlibtime.Now, os, net, exec, panic, printing, globals
ports/Small interfaces plus scripted fakesdomainAny implementation
service/Dispatch, authorization, queues, the call, service and device machines, journaldomain, portsConcrete adapters, package globals
adapters/Everything that touches the world. All guest-written data enters through adapters/guest and leaves as validated, typed observations.domain, portsservice, api
api/Framed wire codec, peer auth, HTTPS relay, MCPservice, schemaadapters
schema/Generated types, codecs, help, MCP schemas, fl.d.tsdomainHand edits
cmd/main for each binaryeverythingLogic

Core types

Four ideas carry the whole core. The snippets are the shape the domain lane is building to, written against the strict gate.

Named IDs. A device ID can never be passed where a run ID belongs.

type DeviceID string
type RunID string
type LeaseID string
type PlanID uint64
type Generation uint32

type SessionKey struct {
	Device     DeviceID
	Generation Generation
}

Closed unions. The linter fails the build if a switch misses a case.

type Outcome interface{ isOutcome() }

type Settled struct{ Evidence Evidence }
type MovingAtDeadline struct{ Last Observation }
type OutcomeUnknown struct{ Plan PlanID }
type DeviceFailure struct{ Phase Phase }

func (Settled) isOutcome()          {}
func (MovingAtDeadline) isOutcome() {}
func (OutcomeUnknown) isOutcome()   {}
func (DeviceFailure) isOutcome()    {}

Transition tables. Every state machine is data plus one pure step function.

type SettleState interface{ isSettleState() }
type SettleEvent interface{ isSettleEvent() }

type Decision interface{ isDecision() }
type SampleAt struct{ At Instant }
type Finish struct{ Outcome Outcome }

func Advance(s SettleState, e SettleEvent) (SettleState, Decision)

Ports. The service sees the device through a narrow interface. Tests use a scripted fake.

type Device interface {
	Observe(ctx context.Context, k SessionKey) (Observation, error)
	Inject(ctx context.Context, k SessionKey, p Plan) (Receipt, error)
}

type Clock interface {
	Now() Instant
	WaitUntil(ctx context.Context, at Instant) error
}

func (s *Service) Dispatch(ctx context.Context, c Call) Reply

Errors are one closed union too: Usage, Denied, StaleSession, Busy, Deadline, EvidenceUnavailable, DeviceFailure, OutcomeUnknown. Each carries a stable code and whether the device was touched. They map to today's exit codes and JSON fields at the edge, and code matches them with errors.As, never by text.

State machines

Three explicit machines replace the implicit state spread across today's 17,000-line core. Each one is a table in domain/ with a test for every row.

stateDiagram-v2
  direction LR
  [*] --> Received
  Received --> Refused: peer auth fails
  Received --> Authenticated: auth ok
  Authenticated --> Refused: bad frame
  Authenticated --> Authorized: allowed
  Authenticated --> Refused: denied
  Authorized --> Queued: enqueued
  Authorized --> Refused: queue full
  Queued --> Cancelled: caller hangs up
  Queued --> Refused: device reset
  Queued --> Running: its turn
  Running --> Replied: done
  Running --> Cancelled: cancel before touch
  Running --> OutcomeUnknown: lost after touch
  Running --> DeadlineExceeded: deadline
  Running --> DeviceFailure: device died
  Replied --> [*]
The call machine. The line that matters is "lost after touch". Once a tap may have reached the device, the only honest answer is unknown.
ServiceMoves toWhen
StartingReconcilingJournal replayed. Pending intents with no receipt become unknown.
ReconcilingReady or DegradedEvery device classified, or 10 s with some unreachable
ReadyDegraded and backA device goes unreachable, then recovers or ends
AnyDrainingSIGTERM. Long calls answered at once, 5 s cap.
DrainingStoppedNothing in flight. Callers queue on the socket meanwhile.
DeviceMoves toWhen
UnknownReachable or UnreachableFirst probe
UnreachableReachableRe-probe with backoff, 1 to 30 s
ReachableWedgedA call runs 5 s past its deadline
AnyResettingdown --force or relaunch, on its own lane, never queued behind the stuck call
ResettingReachable at N+1, or EndedGeneration bumped, so late effects from the old session are fenced off

One tap, end to end

The overhead budget for everything before the device is 15 ms at p95, checked in CI on every PR. Today the same path costs 268 ms with two Python starts.

sequenceDiagram
  participant F as frostline (you)
  participant C as frostline-core
  participant J as Journal
  participant D as Device supervisor
  F->>C: tap frame over core.sock
  C->>C: peer creds, pidfd, groups, lease check
  C->>J: write intent (plan 17)
  C->>D: inject plan 17
  D-->>C: receipt for plan 17
  C->>J: record receipt
  loop settle, driven by domain.Advance
    C->>D: observe frame, accessibility, activity
    D-->>C: typed observation
  end
  C-->>F: reply Settled with evidence
  Note over C,J: if the reply is lost after injection, the next caller sees OutcomeUnknown with plan 17, and nothing is resent
Intent first, receipt second, decision from pure code. The device only ever sees a plan once.

Plugins

A plugin is an executable named frostline-<name>. Typing frostline rn push runs frostline-rn push as you, with no new privileges. Plugins hold all stack knowledge so the core stays generic.

What a plugin gets

FROSTLINE_BIN, FROSTLINE_DEVICE, FROSTLINE_SESSION, FROSTLINE_JSON. It calls Frostline only through the public CLI and API. Never tokens, never service paths.

Where plugins run

On your side of the process boundary. On team boxes, over HTTPS and through MCP, only plugins shipped in the kit and on the allowlist can run. Anything found on PATH is refused there.

What core offers them

Generic verbs: add, push changed files, up with app arguments, forward a port, look, tap, flows. The incremental push in #1391 is one of these. It moves bytes and knows nothing about JavaScript.

Your project file

Lives in your repo and is read by the client only: the app, flows, named forwards, native path globs, visual masks. Nothing from it crosses to the box except content and names.

flowchart LR
  edit["You change JS"] --> rn["frostline-rn push"]
  rn -->|"hash native inputs"| fp{"Native
unchanged?"} fp -->|"no"| build["Build natively, then add"] fp -->|"yes"| bundle["Export minified bundle
and assets locally"] bundle -->|"splice into cached shell,
check asset paths"| push["frostline push
(generic, core)"] push -->|"file hashes first,
then only missing bytes"| box["Box: assemble, install,
relaunch"] build --> box dev["frostline-rn up"] -->|"Metro on your machine,
forwarded port 8081"| box classDef plugin fill:__ICESOFT__,stroke:__ICE__,color:__INK__ classDef core fill:__NEWSOFT__,stroke:__NEW__,color:__INK__ classDef slow fill:__WARNSOFT__,stroke:__WARN__,color:__INK__ class rn,bundle,dev,fp plugin class push,box core class build slow class edit plugin
React Native as a plugin. Blue is the plugin, green is generic core. A JS change measured 1.2 to 1.3 s to push instead of 6.2 to 7.4 s on lab 4. Native changes still mean a build.
You changedOne way to ship itWhere it runs
JS, while developingfrostline rn up with fast refreshMetro on your machine, the box only runs the simulator
JS, release or CI bundlefrostline rn pushPlugin on your machine, generic delta push to the box
Native codeBuild, then frostline addYour machine, or a build service later

Rules the build enforces

Merged as #1395. A red gate is never waived.

RuleHow it is checked
Every switch over a union covers every caseexhaustive, gochecksumtype
No nil dereferencesnilaway
Layers point inwarddepguard plus a layering test over every import
The domain is pureforbidigo bans clock, files, network, processes, panic and printing in domain/
No hidden shared stategochecknoglobals in service, adapters and render. No init() side effects.
Errors are typederrorlint, wrapcheck at adapter edges, errcheck
No races, no order dependencego test -race -shuffle=on
Parsers survive hostile inputFuzz targets on every PR, longer at release. The wire codec took 65 million inputs clean.
Go behaves exactly like todayA command moves only when it matches the recorded corpus: JSON replies, error codes, exit codes, files written. Its Python is deleted in the same PR.

Plan and what has landed

Root targets as of 24 November: phase 1 around 5 December, a box with no Python around 19 December. The labs, the check queue and review rounds set the pace, not typing.

PieceStateLink
Delete before porting (3,650 lines)merged#1392 #1394 #1396
Strict Go gatemerged#1395
Command catalog split and generated parser, 13,960 usage cases identicalmerged#1393 #1398
Wire protocol and codecmerged#1399
Recorded corpus, 55 cases, zero diffs on replaymerged#1397 #1401
Core service and auth, 7 ms p95 overhead measuredin review soonW1-core
Domain types, machines, journalbuildingW1-domain
Go CLI front and cutoverbuildingW1-front
Commands one by one: tap, look, type, swipe, key, wait, up, down, then the restwave 2Starts when the core service merges
Runtime, setup and install off Pythonphase 2