Dashboard › opencode › Distillation
534dde51-9e63-4395-9f77-eb34d0cc353a["lore_tm_v1_IbH012-WMyftRTHqBUliCJBvzfAHGMbZYfdkFFSeT3o","lore_tm_v1_h-3ZFk4EcI1YNCgOPOtBPA0J4pM1LP-sJcl2kevBNsg","lore_tm_v1_Wlw2OLlUf31NJ6-rcaVI1uzYPxzOit2i4C3ofBXC5Nk","lore_tm_v1_lq2f9RsdH8IKs2WOl4n4wIrWKQuQlvkAHrcoCeSZ0Ow","lore_tm_v1_BzWHjGMMbT8FW32DiHRLXpNZdnz4gn6stGdQePtpMzo","lore_tm_v1_tte8OB70F-hrt1b0PdZK2Tsk_2nZSrsipt339ptOEnU","lore_tm_v1_g82z6F7INVbvigW8n_Y04LleAgY7k6-fexpij-aqg-Y","lore_tm_v1__wZ_x1GvAgBaUZslqA9AcQPKwfKFlw5R0Osqfx9a5x4"]
Date: Sep 17, 2026
packages/core/src/session/context-epoch.ts defines SessionContextEpoch.initialize() and SessionContextEpoch.prepare(). Both accept a DatabaseService, SystemContext.SystemContext effect, sessionID, and SessionExecutionClaim.Claim; prepare() additionally accepts EventV2.Interface.SessionContextEpoch.prepareOnce() concurrently loads the current system context, stored context epoch, and SessionHistory.latestCompaction(db, sessionID) with { concurrency: "unbounded" }.prepareOnce() calls SystemContext.initialize(value), inserts the generated baseline/snapshot through the execution claim, and returns { baseline: generation.baseline, baselineSeq }.Schema.decodeUnknownEffect(SystemContext.Snapshot); decode failures become ContextSnapshotDecodeError({ sessionID, details: String(error) }).compaction.seq > stored.baseline_seq. In that case replacementSeq=compaction.seq and SystemContext.replace(value, snapshot) is used; otherwise SystemContext.reconcile(value, snapshot) is used.SessionContextEpoch.prepareOnce() handles reconciliation results as follows: "Unchanged" and "ReplacementBlocked" retain the stored baseline and baseline_seq; "ReplacementReady" replaces the epoch using replacementSeq or EventV2.latestSequence(db, sessionID); an update result publishes SessionEvent.ContextUpdated and commits advance(db, sessionID, result.snapshot, claim).SessionContextEpoch.initializeOnce() returns without work if the session epoch already exists; otherwise it initializes the context and inserts { session_id, baseline, snapshot, baseline_seq }.insert(), replace(), and advance() are fenced through SessionExecutionClaim.transaction(db, claim, ...). replace() and advance() die with exact error "Context Epoch not found" if their update returns no row.SessionContextEpoch.reset() deletes the row from SessionContextEpochTable matching session_id.packages/core/src/session.ts, V2Session.messages() paginates by SessionMessageTable.seq: default cursor direction is "next", default requested order is "desc", "previous" reverses query order and then reverses returned rows, and an unknown cursor message ID returns [].V2Session.prompt() is uninterruptible. It resolves the prompt, defaults messageID to SessionMessage.ID.create() and delivery to "steer", admits it through SessionInput.admit() with requestExecution: input.resume !== false, maps SessionInput.LifecycleConflict defects to PromptConflictError, checks SessionInput.equivalent(admission.admitted, expected), and calls execution.wake() only when admission.shouldWake.resolvePrompt() preserves text, agents, and files; file MIME type comes from a data URI when available, otherwise "application/x-directory" for paths ending in /, otherwise FSUtil.mimeType(target).V2Session.shell(), V2Session.skill(), V2Session.compact(), and V2Session.wait() currently fail with OperationUnavailableError using operations "shell", "skill", "compact", and "wait" respectively.V2Session.switchAgent() publishes SessionEvent.AgentSwitched. V2Session.switchModel() publishes SessionEvent.ModelSwitched unless provider ID, model ID, and normalized variant already match; an absent variant is normalized to "default".V2Session.resume() verifies the session, calls SessionInput.requestPendingExecution(db, events, sessionID), then execution.resume(sessionID). V2Session.interrupt() runs execution.interrupt(sessionID) uninterruptibly.V2Session.revert exposes stage, clear, and commit: stage supplies Database.Service, EventV2.Service, and the session location; clear supplies EventV2.Service and the location; commit supplies EventV2.Service.SessionV2.node depends on Database.node, EventV2.node, ProjectV2.node, SessionExecution.node, SessionStore.node, LocationServiceMap.node, and SessionProjector.node.packages/opencode/src/server/routes/instance/httpapi/server.ts, routes is created with createRoutes(), while webHandler is wrapped in lazy(() => HttpRouter.toWebHandler(...)) with disableLogger: true, memoMap, and disposeMiddleware.packages/opencode/src/server/routes/instance/httpapi/server.ts binds SessionExecution.node to SessionExecutionLocal.node. Observability.layer must remain the final Layer.provideMerge() because later-provided layers build beneath earlier ones; otherwise eagerly forked fibers such as the ModelsDev background refresh capture Effect’s default stdout logger and corrupt the TUI (#34730).packages/server/src/routes.ts defines applicationServices with Database.node, EventV2.node, httpClient, ToolOutputStore.cleanupNode, SessionV2.node, SessionRecovery.node, PermissionSaved.node, PtyTicket.node, Credential.node, PtyEnvironment.node, and LocationServiceMap.node.packages/server/src/routes.ts builds application services with AppNodeBuilder.build(applicationServices, [[SessionExecution.node, SessionExecutionLocal.node]]), so the server currently uses local session execution.createRoutes(password?) configures username "opencode" and uses Option.some(password) when a password is supplied; otherwise it uses ServerAuth.Config.layer. createEmbeddedRoutes() configures username "opencode" with Option.none()./openapi.json and provides, in order, handlers, sessionLocationLayer, locationLayer, authorizationLayer, schemaErrorLayer, authentication, and the built service layer. Its webHandler() adds HttpServer.layerServices and sets disableLogger: true.packages/core/schema.json is SQLite schema version "7" with ID 3bc49670-06d1-4eba-9a45-8c8128bdcf6f and previous ID f14a9b18-8207-487e-a3d3-227e629ba9ad. Visible table entries include workspace, data_migration, account_state, account, control_account, credential, event_sequence, event, permission, project_directory, project, message, and part.