SessionEnvironment already names per-session shell variables, so the
engine tier takes distinct vocabulary. Review fixes fold in: per-bind
release tokens, bindings scoped to the environment rather than the
caller, one pinned environment per busy period with the bound context
provided directly (no per-continuation layer build or store read),
shared compileWithHoistedGlobals used by both constructors,
SessionRunnerModel.fixed beside its resolved seam, exported Tool.Draft,
PluginSupervisor.noop naming, a typed make error channel, dropped dead
Handle.context surface, and a compile-time subset guard tying the
engine tier to the full location graph.
A SessionEnv built from values (fixed model, one custom tool, upserted
build agent) admits a prompt through normal durable admission and drains
through the real SessionExecution path: the bound engine graph executes
the tool and persists assistant history in the application's Database,
with no discovery, plugins, MCP, or provider SDKs.
SessionEnvBindings maps Session IDs to live engine contexts; execution
resolves a bound context before the Session's Location graph. SessionEnv
becomes a global node that captures the root MemoMap at construction
(the LayerMap trick) so hoisted global nodes dedupe against the running
Database, Bus, and SessionStore. Its handle creates or adopts durable
sessions and scopes the binding to the caller.
Builds one live engine graph in the caller's scope from the sessionEnvGroup
with discovery, plugins, and MCP replaced, then populates Tool/Agent/Catalog
through the same draft APIs plugins use. Hoisted global nodes compile to the
application root's Layer references so memoization reuses the running
Database, Bus, and SessionStore.
PluginSupervisor.ready, McpTool.noop, and McpInstructions.noop let a
values-constructed engine graph settle immediately and drop the MCP and
config-discovery subtrees from its dependency closure.
Define sessionEnvNodes/SessionEnv alongside the full location graph: the
subset of nodes a session drain consumes, with dependency closure pulling
supporting nodes during compile. locationServiceNodes is untouched because
its list order is semantic (compile provide-merges in order).
Centralize control dispatch and first-Step preparation in advanceToStep. Keep input delivery outside logical-Step retries and preserve queue ordering, Location handoff, context refresh, and durable settlement.
Extract physical-attempt streaming, tool execution, and durable settlement from the Session runner. Preserve logical-Step retry and recovery policy, use tagged drain outcomes, and fix multi-click selection during auto-copy.