8000 mikan/src/runtime at main · geminixiang/mikan · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History

runtime

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

src/runtime

This directory coordinates conversation and session runtime execution.

Runtime state carries the office as its identity: ConversationRuntimeState and the ConversationRuntime methods take an OfficeAddress, while sessionKey stays the raw platform session-key grammar. Storage paths and settings are reached through the Office value, never rebuilt from the raw id.

Contracts

  • conversation-runtime.ts: The MessagingEventHandler behind every platform bot. Owns conversation orchestration: command dispatch, thread workflow, run instrumentation (Sentry span/metrics), and stop/new actions. /new resets only its own session, after that session's active run settles; runs in other sessions of the office, such as background tasks, neither delay it nor wait for it. It asks SessionLifecycle for a leased runner instead of manipulating runner ownership itself. Incremental chat-history persistence is awaited before the agent prompt. Before acquiring runner state it normalizes context.platform.trustModel ?? "membership" into the required session-state options and forwards that fixed value to the runner. Trust is platform-static for an OfficeAddress, is deliberately excluded from the cache key, and changing it requires runner replacement rather than another cache entry. Portal services (vault manager, link/session-view/admin token stores) are optional — embedders that construct the runtime without them get disabled defaults, and the command handlers reply "not configured" instead of failing. Platform capability packs arrive as factories, so each runner instantiates its own pack (bind state is per-runner) and core stays platform-neutral.
  • session-lifecycle.ts: The runner resource authority behind the runtime. It owns (OfficeAddress, sessionKey) serialization, materialization single-flight, cached-runner leases, generation-based invalidation, run settlement, exact writer handover during disposal, idle/cap eviction, and shutdown. A cached runner is the sole writable durable session handle for its file: lifecycle reuse checks the expected file before scope resolution can open the same path, and active leases prevent invalidation or eviction until their work settles. Shutdown neither waits for nor aborts a background task run (an event with a task: or resume: ID); the Slack bot resumes it after the restart. Shutdown aborts in-flight materialization, propagates that signal through runner-owned network setup, and waits up to five seconds for rollback settlement before reporting a shutdown failure rather than blocking forever.
0