One session, end to end — ZCode
architecture node:
User input:
Representation at this boundary
Source modules
Loop map
One session — a prompt enters on any surface → becomes a cancellable command on the runtime queue → the turn loop assembles the request (compaction, MCP, reminders, memory recall) → one model step runs through the provider layer → tool calls pass the permission service → everything persists to the SQLite session store → the cycle repeats.
The goal outlives the turn — a goal is a row in the session store, injected into every turn as authoritative state; when the session goes idle the runtime enqueues a continuation — but first a separate verifier, with no tools and a JSON-only answer, decides whether the goal is actually complete. The working model can read the goal (
GoalRead) and nothing more.Three ways to stop — a goal ends only when the verifier passes, when its token budget is exhausted (
budget_limited), or when the user pauses or clears it. A verifier failure without a next action also stops continuation, so a malfunctioning referee cannot spin the loop forever.