Dashboard › opencode › Session 1NVveNTpsyJu
1NVveNTpsyJuwkUq6Read-only adversarial correctness review frozen v16. Base ab9408c81cc9916177641ae8e9f08624fc27b5b9. Patch /tmp/opencode/session-recovery-final-v16.patch SHA-256 b0e9fdde553e70f6f606c33c555f9e37bb52d6827dd1aad8d5a932b76cd2ee30. SEA /home/byk/Code/opencode/packages/opencode/dist/server/opencode-server SHA-256 a0eea521a58325461d7e533e5f3be05fccf2714a90a444eb67ac21b153f53c2f. Verify immutable inputs/base/clean apply/34 paths; inspect all. No mutation/tests/builds/services. v15 blocker closure: SessionExecutionClaim.update rejects every ordinary runner mutation/dispatch/event/transaction fence once phase cancelling/cancelled; SessionExecutionClaim.renew is isolated to execution adapter supervised heartbeat/cleanup; settleCancellation requires exact live claim and current phase cancelling. Runner detects durable cancelling after interrupt, switches fragment/tool reconciliation to cancellation-only commit, final Step.Interrupted alone changes to cancelled. Direct fiber interruption remains unknown and uses ordinary recovery settlement. Race test forces runner continue mutation after cancelling and requires retained claim/failing cleanup. Explicit resume durable intent and generated clients/index retained. Reassess everything. Accepted final-check-call/process-local/skew residuals. Evidence final exact source: typecheck pass; 228 non-migration recovery tests pass; migration upgrade tests 2 pass; migration script --check passes but fixed 30s wrapper times out; full Core 1183 pass plus two aggregate contention timeouts which pass alone (location 8.48s, webfetch 7.24s); prior all-green full run before last cancellation guard 1185/0; six package typechecks/manifest passed before final guard; exact v16 artifact smoke health/index/recovery/idempotence pass. Return PASS/CONCERN/MUST-FIX file:line and end exactly MERGE or DO-NOT-MERGE. Empty invalid; no recall.
b0e9fdde553e70f6f606c33c555f9e37bb52d6827dd1aad8d5a932b76cd2ee30 /tmp/opencode/session-recovery-final-v16.patch a0eea521a58325461d7e533e5f3be05fccf2714a90a444eb67ac21b153f53c2f /home/byk/Code/opencode/packages/opencode/dist/server/opencode-server dc661f30cb2055ad6248fdc59b14998d834497be ab9408c81cc9916177641ae8e9f08624fc27b5b9 M .lore.md M AGENTS.md M packages/client/src/generated/types.ts M packages/core/schema.json M packages/core/src/database/migration.gen.ts M packages/core/src/database/migration/20260914170650_session-recovery.ts D packages/core/src/database/migration/20260914214636_session-execution.ts D packages/core/src/database/migration/20260914222526_session-execution-phase.ts M packages/core/src/database/schema.gen.ts M packages/core/src/session.ts M packages/core/src/session/compaction.ts M packages/core/src/session/context-epoch.ts M packages/core/src/session/execution/local.ts M packages/core/src/session/input.ts M ...
ancestor_exit=0 packages/client/src/generated/types.ts | 72 + packages/core/schema.json | 615 ++++ packages/core/src/database/migration.gen.ts | 1 .../migration/20260914170650_session-recovery.ts | 62 packages/core/src/database/schema.gen.ts | 53 packages/core/src/session.ts | 10 packages/core/src/session/compaction.ts | 47 packages/core/src/session/context-epoch.ts | 88 - packages/core/src/session/execution/local.ts | 184 + packages/core/src/session/input.ts | 422 +++ packages/core/src/session/message-updater.ts | 69 packages/core/src/session/projector.ts | 89 + packages/core/src/session/recovery.ts | 504 ++++ packages/core/src/session/run-coordinator.ts | 35 packages/core/src/session/runner/index.ts | 4 packages/core/src/session/runner/llm.ts | 402 ++- ...
reverse_apply_exit=0 diff_check_exit=0
Found 100 matches (more matches available) /tmp/opencode/session-recovery-final-v16.patch: Line 1: diff --git a/packages/client/src/generated/types.ts b/packages/client/src/generated/types.ts Line 2: index 3b3188c874..5130fa9496 100644 Line 3: --- a/packages/client/src/generated/types.ts Line 4: +++ b/packages/client/src/generated/types.ts Line 109: diff --git a/packages/core/schema.json b/packages/core/schema.json Line 110: index d0eeeebd5c..81e5eca808 100644 Line 111: --- a/packages/core/schema.json Line 112: +++ b/packages/core/schema.json Line 1025: diff --git a/packages/core/src/database/migration.gen.ts b/packages/core/src/database/migration.gen.ts Line 1026: index e6ea4eaa14..77948f1529 100644 Line 1027: --- a/packages/core/src/database/migration.gen.ts Line 1028: +++ b/packages/core/src/database/migration.gen.ts Line 1036: diff --git a/packages/core/src/database/migration/20260914170650_session-recovery.ts ...
11095 /tmp/opencode/session-recovery-final-v16.patch 34 32
paths=34 base_preimages_and_postimages_match=True
<skill_content name="effect">
# Skill: effect
# Effect
This codebase uses Effect for typed, composable TypeScript services, schemas, and workflows.
## Source Of Truth
Use the current Effect v4 / effect-smol source, not memory or older Effect v2/v3 examples.
1. If `.opencode/references/effect-smol` is missing, clone `https://github.com/Effect-TS/effect-smol` there. Do this in the project, not in the skill folder.
2. Search `.opencode/references/effect-smol` for exact APIs, examples, tests, and naming patterns before answering or implementing Effect-specific code.
3. Also inspect existing repo code for local house style before introducing new patterns.
4. Prefer answers and implementations backed by specific source files or nearby repo examples.
## Guidelines
- Prefer current Effect v4 APIs and project-local patterns over old blog posts, examples, or package-memory guesses.
- Use `Effect.gen(function* () { ... })` for multi-step workflows.
- Use `Effect.fn("Name")` or ...
<path>/home/byk/Code/opencode/packages/core/src/session/execution/claim.ts</path>
<type>file</type>
<content>
1: export * as SessionExecutionClaim from "./claim"
2:
3: import { and, eq, gt, notInArray } from "drizzle-orm"
4: import { Clock, Effect } from "effect"
5: import type { Database } from "../../database/database"
6: import type { SessionSchema } from "../schema"
7: import { SESSION_EXECUTION_LEASE_MS, SessionExecutionTable } from "../sql"
8:
9: type DatabaseService = Database.Interface["db"]
10:
11: export type Claim = {
12: readonly sessionID: SessionSchema.ID
13: readonly executionID: string
14: readonly ownerID: string
15: }
16:
17: export type Values = Partial<
18: Pick<typeof SessionExecutionTable.$inferInsert, "assistant_message_id" | "assistant_seq" | "phase">
19: >
20:
21: export class Lost extends Error {
22: constructor(readonly claim: Claim) {
23: super(`Session execution claim lost: ${claim.executionID}`)
24: }
25: }
26:
27: const where = ...
<path>/home/byk/Code/opencode/packages/core/src/session/execution/local.ts</path>
<type>file</type>
<content>
1: import { and, asc, desc, eq, isNull } from "drizzle-orm"
2: import { Cause, Clock, Duration, Effect, Exit, Layer, Schedule } from "effect"
3: import { Database } from "../../database/database"
4: import { LocationServiceMap } from "../../location-service-map"
5: import { makeGlobalNode } from "../../effect/app-node"
6: import { SessionRunCoordinator } from "../run-coordinator"
7: import { SessionRunner } from "../runner"
8: import { SessionMessage } from "../message"
9: import { SessionSchema } from "../schema"
10: import { SessionStore } from "../store"
11: import { SessionExecution } from "../execution"
12: import { SessionExecutionClaim } from "./claim"
13: import {
14: SESSION_EXECUTION_LEASE_MS,
15: SessionExecutionTable,
16: SessionMessageTable,
17: SessionRecoveryTable,
18: } from "../sql"
19:
20: /** Current-process routing for implicit-local Locations. ...
<path>/home/byk/Code/opencode/packages/core/src/session/recovery.ts</path>
<type>file</type>
<content>
1: export * as SessionRecovery from "./recovery"
2:
3: import { and, asc, desc, eq, exists, gt, isNull, lte, or, sql } from "drizzle-orm"
4: import { Clock, DateTime, Effect, Layer, Option, Schedule, Schema } from "effect"
5: import { Database } from "../database/database"
6: import { makeGlobalNode } from "../effect/app-node"
7: import { EventV2 } from "../event"
8: import { SessionEvent } from "./event"
9: import { SessionExecution } from "./execution"
10: import { SessionProjector } from "./projector"
11: import { SessionExecutionClaim } from "./execution/claim"
12: import { SessionInput } from "./input"
13: import { continuation } from "./recovery-id"
14: import { SessionSchema } from "./schema"
15: import {
16: MAX_WAKE_ATTEMPTS,
17: SESSION_EXECUTION_LEASE_MS,
18: SessionExecutionTable,
19: SessionInputTable,
20: SessionRecoveryTable,
21: SessionMessageTable,
22: ...
<path>/home/byk/Code/opencode/packages/core/src/session/input.ts</path>
<type>file</type>
<content>
1: export * as SessionInput from "./input"
2:
3: import { and, asc, desc, eq, isNull, lte } from "drizzle-orm"
4: import { DateTime, Effect, Option, Schema } from "effect"
5: import { Admitted, Delivery } from "@opencode-ai/schema/session-input"
6: import type { Database } from "../database/database"
7: import { EventV2 } from "../event"
8: import { SessionEvent } from "./event"
9: import { SessionMessage } from "./message"
10: import { Prompt } from "./prompt"
11: import { continuation, message } from "./recovery-id"
12: import { SessionSchema } from "./schema"
13: import { SessionInputTable, SessionMessageTable, SessionRecoveryTable, SessionTable } from "./sql"
14:
15: type DatabaseService = Database.Interface["db"]
16:
17: export { Admitted, Delivery }
18:
19: const decodePrompt = Schema.decodeUnknownSync(Prompt)
20: const encodePrompt = Schema.encodeSync(Prompt)
21: const ...
<path>/home/byk/Code/opencode/packages/core/src/session/runner/llm.ts</path>
<type>file</type>
<content>
1: import {
2: LLM,
3: LLMClient,
4: LLMError,
5: LLMEvent,
6: Message,
7: SystemPart,
8: isContextOverflowFailure,
9: type ProviderErrorEvent,
10: } from "@opencode-ai/llm"
11: import { Cause, DateTime, Effect, Exit, Fiber, Layer, Option, Semaphore, Stream } from "effect"
12: import { and, eq } from "drizzle-orm"
13: import { AgentV2 } from "../../agent"
14: import { Config } from "../../config"
15: import { Database } from "../../database/database"
16: import { EventV2 } from "../../event"
17: import { Location } from "../../location"
18: import { ModelV2 } from "../../model"
19: import { PermissionV2 } from "../../permission"
20: import { ProviderV2 } from "../../provider"
21: import { QuestionV2 } from "../../question"
22: import { SystemContext } from "../../system-context/index"
23: import { SystemContextRegistry } from "../../system-context/registry"
24: ...
<path>/home/byk/Code/opencode/packages/core/src/session/runner/publish-llm-event.ts</path>
<type>file</type>
<content>
1: import { ToolOutput, type LLMEvent, type ProviderMetadata, type ToolResultValue, type Usage } from "@opencode-ai/llm"
2: import { DateTime, Effect } from "effect"
3: import { EventV2 } from "../../event"
4: import { ModelV2 } from "../../model"
5: import { SessionEvent } from "../event"
6: import { SessionMessage } from "../message"
7: import { SessionSchema } from "../schema"
8:
9: type Input = {
10: readonly sessionID: SessionSchema.ID
11: readonly agent: string
12: readonly model: ModelV2.Ref
13: readonly snapshot?: string
14: readonly startCommit: (assistantMessageID: SessionMessage.ID, seq: number) => Effect.Effect<void>
15: readonly eventCommit: () => Effect.Effect<void>
16: }
17:
18: const safe = (value: number | undefined) => Math.max(0, Number.isFinite(value) ? (value ?? ...
<path>/home/byk/Code/opencode/packages/core/src/session/compaction.ts</path>
<type>file</type>
<content>
1: export * as SessionCompaction from "./compaction"
2:
3: import { LLM, LLMError, LLMEvent, Message, type LLMRequest, type Model } from "@opencode-ai/llm"
4: import { DateTime, Effect, Stream } from "effect"
5: import type { Config } from "../config"
6: import type { EventV2 } from "../event"
7: import { SessionEvent } from "./event"
8: import { SessionMessage } from "./message"
9: import { SessionSchema } from "./schema"
10: import { Token } from "../util/token"
11:
12: const DEFAULT_BUFFER = 20_000
13: const DEFAULT_KEEP_TOKENS = 8_000
14: const TOOL_OUTPUT_MAX_CHARS = 2_000
15: const SUMMARY_OUTPUT_TOKENS = 4_096
16: const SUMMARY_TEMPLATE = `Output exactly the Markdown structure shown inside <template> and keep the section order unchanged. Do not include the <template> tags in your response. ...
<path>/home/byk/Code/opencode/packages/core/src/session/context-epoch.ts</path>
<type>file</type>
<content>
1: export * as SessionContextEpoch from "./context-epoch"
2:
3: import { eq } from "drizzle-orm"
4: import { DateTime, Effect, Schema } from "effect"
5: import type { Database } from "../database/database"
6: import { EventV2 } from "../event"
7: import { SystemContext } from "../system-context/index"
8: import { ContextSnapshotDecodeError } from "./error"
9: import { SessionEvent } from "./event"
10: import { SessionHistory } from "./history"
11: import { SessionInput } from "./input"
12: import { SessionMessage } from "./message"
13: import { SessionSchema } from "./schema"
14: import { SessionContextEpochTable } from "./sql"
15: import { SessionExecutionClaim } from "./execution/claim"
16:
17: type DatabaseService = Database.Interface["db"]
18:
19: interface Prepared {
20: readonly baseline: string
21: readonly baselineSeq: number
22: }
23:
24: export function ...
<path>/home/byk/Code/opencode/packages/core/src/session/message-updater.ts</path>
<type>file</type>
<content>
1: import { castDraft, produce, type WritableDraft } from "immer"
2: import { Effect } from "effect"
3: import { SessionEvent } from "./event"
4: import { SessionMessage } from "./message"
5: import { message } from "./recovery-id"
6:
7: export type MemoryState = {
8: messages: SessionMessage.Message[]
9: }
10:
11: export interface Adapter {
12: readonly getCurrentAssistant: () => Effect.Effect<SessionMessage.Assistant | undefined>
13: readonly getAssistant: (messageID: SessionMessage.ID) => Effect.Effect<SessionMessage.Assistant | undefined>
14: readonly getCurrentShell: (callID: string) => Effect.Effect<SessionMessage.Shell | undefined>
15: readonly updateAssistant: (assistant: SessionMessage.Assistant) => Effect.Effect<void>
16: readonly updateShell: (shell: SessionMessage.Shell) => Effect.Effect<void>
17: readonly appendMessage: (message: ...
<path>/home/byk/Code/opencode/packages/core/src/session/message-updater.ts</path>
<type>file</type>
<content>
401: status: "error",
402: error: event.data.error,
403: input: typeof match.state.input === "string" ? {} : match.state.input,
404: structured: match.state.status === "running" ? match.state.structured : {},
405: content: match.state.status === "running" ? match.state.content : [],
406: result: event.data.result,
407: }),
408: )
409: }
410: })
411: },
412: "session.next.reasoning.started": (event) => {
413: return updateOwnedAssistant(event.data.assistantMessageID, (draft) => {
414: draft.content.push(
415: castDraft(
416: SessionMessage.AssistantReasoning.make({
417: type: "reasoning",
418: id: event.data.reasoningID,
419: text: ...
<path>/home/byk/Code/opencode/packages/core/src/session/projector.ts</path>
<type>file</type>
<content>
1: export * as SessionProjector from "./projector"
2:
3: import { and, desc, eq, gt, or, sql } from "drizzle-orm"
4: import { DateTime, Effect, Layer, Schema } from "effect"
5: import { Database } from "../database/database"
6: import { EventV2 } from "../event"
7: import { makeGlobalNode } from "../effect/app-node"
8: import { SessionEvent } from "./event"
9: import { SessionV1 } from "../v1/session"
10: import { WorkspaceTable } from "../control-plane/workspace.sql"
11: import { SessionMessage } from "./message"
12: import { SessionMessageUpdater } from "./message-updater"
13: import { SessionInput } from "./input"
14: import { Prompt } from "./prompt"
15: import { continuation } from "./recovery-id"
16: import { WorkspaceV2 } from "../workspace"
17: import {
18: MessageTable,
19: PartTable,
20: SessionInputTable,
21: SessionMessageTable,
22: SessionRecoveryTable,
23: ...
No files found
/home/byk/Code/opencode/packages/core/src/event.ts
Found 25 matches
/home/byk/Code/opencode/packages/core/src/event.ts:
Line 122: /** Local operational projection committed atomically with a new durable event. Not replayed or serialized. */
Line 127: readonly publish: <D extends Definition>(
Line 137: readonly project: <D extends Definition>(definition: D, projector: Subscriber<D>) => Effect.Effect<void>
Line 140: options?: { readonly publish?: boolean; readonly ownerID?: string; readonly strictOwner?: boolean },
Line 144: options?: { readonly publish?: boolean; readonly ownerID?: string; readonly strictOwner?: boolean },
Line 179: const projectors = new Map<string, Subscriber[]>()
Line 180: // TODO: Bind durable projectors to exact type+version before supporting incompatible historical payloads.
Line 236: const list = projectors.get(event.type) ?? ...
<path>/home/byk/Code/opencode/packages/core/src/event.ts</path>
<type>file</type>
<content>
110: export class SubscriberOverflowError extends Schema.TaggedErrorClass<SubscriberOverflowError>()(
111: "EventV2.SubscriberOverflow",
112: { capacity: Schema.Int },
113: ) {}
114:
115: export const define = Event.define
116: export const versionedType = Event.versionedType
117:
118: export interface PublishOptions {
119: readonly id?: ID
120: readonly metadata?: Record<string, unknown>
121: readonly location?: Location.Ref
122: /** Local operational projection committed atomically with a new durable event. Not replayed or serialized. */
123: readonly commit?: (seq: number) => Effect.Effect<void>
124: }
125:
126: export interface Interface {
127: readonly publish: <D extends Definition>(
128: definition: D,
129: data: Data<D>,
130: options?: PublishOptions,
131: ) => Effect.Effect<Payload<D>>
132: readonly subscribe: <D extends Definition>(definition: D) => ...
<path>/home/byk/Code/opencode/packages/core/src/session/sql.ts</path>
<type>file</type>
<content>
1: import { sql } from "drizzle-orm"
2: import { check, sqliteTable, text, integer, index, primaryKey, real, uniqueIndex } from "drizzle-orm/sqlite-core"
3: import * as DatabasePath from "../database/path"
4: import { ProjectTable } from "../project/sql"
5: import type { SessionMessage } from "./message"
6: import type { Prompt } from "./prompt"
7: import type { SessionInput } from "./input"
8: import type { Snapshot } from "../snapshot"
9: import { PermissionV1 } from "../v1/permission"
10: import { ProjectV2 } from "../project"
11: import type { SessionSchema } from "./schema"
12: import type { MessageID, PartID, SessionV1 } from "../v1/session"
13: import { WorkspaceV2 } from "../workspace"
14: import { Timestamps } from "../database/schema.sql"
15: import type { SystemContext } from "../system-context/index"
16: import { AgentV2 } from "../agent"
17: import type { Revert } from ...
<path>/home/byk/Code/opencode/packages/core/src/database/migration/20260914170650_session-recovery.ts</path>
<type>file</type>
<content>
1: import { Effect } from "effect"
2: import type { DatabaseMigration } from "../migration"
3:
4: export default {
5: id: "20260914170650_session-recovery",
6: up(tx) {
7: return Effect.gen(function* () {
8: yield* tx.run(`ALTER TABLE \`session_input\` ADD \`wake_pending\` integer DEFAULT false NOT NULL;`)
9: yield* tx.run(
10: `ALTER TABLE \`session\` ADD \`wake_attempts\` integer DEFAULT 0 NOT NULL CONSTRAINT \`session_wake_attempts_check\` CHECK(\`wake_attempts\` >= 0 AND \`wake_attempts\` <= 9007199254740991);`,
11: )
12: yield* tx.run(`
13: CREATE TABLE \`session_execution\` (
14: \`id\` text NOT NULL,
15: \`session_id\` text NOT NULL,
16: \`owner_id\` text NOT NULL,
17: \`assistant_message_id\` text,
18: \`phase\` text NOT NULL,
19: ...
Found 21 matches
/home/byk/Code/opencode/packages/core/src/database/schema.gen.ts:
Line 158: CREATE TABLE \`session_execution\` (
Line 168: CONSTRAINT \`session_execution_pk\` PRIMARY KEY(\`id\`),
Line 169: CONSTRAINT \`fk_session_execution_session_id_session_id_fk\` FOREIGN KEY (\`session_id\`) REFERENCES \`session\`(\`id\`) ON DELETE CASCADE,
Line 170: CONSTRAINT "session_execution_phase_check" CHECK("phase" IN ('ready', 'safe', 'unknown', 'continue', 'cancelling', 'cancelled'))
Line 181: \`wake_pending\` integer DEFAULT false NOT NULL,
Line 199: CREATE TABLE \`session_recovery\` (
Line 205: \`wake_pending\` integer DEFAULT true NOT NULL,
Line 206: \`wake_attempts\` integer DEFAULT 0 NOT NULL,
Line 209: CONSTRAINT \`session_recovery_pk\` PRIMARY KEY(\`execution_id\`),
Line 210: CONSTRAINT \`fk_session_recovery_session_id_session_id_fk\` FOREIGN KEY ...
<path>/home/byk/Code/opencode/packages/core/src/database/schema.gen.ts</path> <type>file</type> <content> 145: CONSTRAINT \`fk_part_message_id_message_id_fk\` FOREIGN KEY (\`message_id\`) REFERENCES \`message\`(\`id\`) ON DELETE CASCADE 146: ); 147: `) 148: yield* tx.run(` 149: CREATE TABLE \`session_context_epoch\` ( 150: \`session_id\` text PRIMARY KEY, 151: \`baseline\` text NOT NULL, 152: \`snapshot\` text NOT NULL, 153: \`baseline_seq\` integer NOT NULL, 154: CONSTRAINT \`fk_session_context_epoch_session_id_session_id_fk\` FOREIGN KEY (\`session_id\`) REFERENCES \`session\`(\`id\`) ON DELETE CASCADE 155: ); 156: `) 157: yield* tx.run(` 158: CREATE TABLE \`session_execution\` ( 159: \`id\` text NOT NULL, 160: \`session_id\` text NOT NULL, 161: \`owner_id\` text NOT NULL, 162: \`assistant_message_id\` text, 163: ...
<path>/home/byk/Code/opencode/packages/core/src/database/migration.gen.ts</path>
<type>file</type>
<content>
1: import type { DatabaseMigration } from "./migration"
2:
3: export const migrations = (
4: await Promise.all([
5: import("./migration/20260127222353_familiar_lady_ursula"),
6: import("./migration/20260211171708_add_project_commands"),
7: import("./migration/20260213144116_wakeful_the_professor"),
8: import("./migration/20260225215848_workspace"),
9: import("./migration/20260227213759_add_session_workspace_id"),
10: import("./migration/20260228203230_blue_harpoon"),
11: import("./migration/20260303231226_add_workspace_fields"),
12: import("./migration/20260309230000_move_org_to_state"),
13: import("./migration/20260312043431_session_message_cursor"),
14: import("./migration/20260323234822_events"),
15: import("./migration/20260410174513_workspace-name"),
16: import("./migration/20260413175956_chief_energizer"),
17: ...
<path>/home/byk/Code/opencode/packages/core/src/session.ts</path>
<type>file</type>
<content>
1: export * as SessionV2 from "./session"
2: export * from "./session/schema"
3:
4: import { DateTime, Effect, Layer, Schema, Context, Stream } from "effect"
5: import { ListAnchor } from "@opencode-ai/schema/session"
6: import { and, asc, desc, eq, gt, like, lt, or, type SQL } from "drizzle-orm"
7: import { ProjectV2 } from "./project"
8: import { WorkspaceV2 } from "./workspace"
9: import { ModelV2 } from "./model"
10: import { Location } from "./location"
11: import { SessionMessage } from "./session/message"
12: import { Prompt } from "./session/prompt"
13: import { PromptInput } from "@opencode-ai/schema/prompt-input"
14: import { EventV2 } from "./event"
15: import { Database } from "./database/database"
16: import { SessionProjector } from "./session/projector"
17: import { SessionMessageTable, SessionTable } from "./session/sql"
18: import { SessionSchema } from ...
<path>/home/byk/Code/opencode/packages/core/src/session.ts</path>
<type>file</type>
<content>
351: ).pipe(Stream.filter((event): event is SessionEvent.DurableEvent => isDurableSessionEvent(event))),
352: history: Effect.fn("V2Session.history")(function* (input) {
353: yield* result.get(input.sessionID)
354: return yield* EventV2.readAggregate(db, {
355: ...input,
356: aggregateID: input.sessionID,
357: manifest: SessionDurable,
358: })
359: }),
360: prompt: Effect.fn("V2Session.prompt")((input) =>
361: Effect.uninterruptible(
362: Effect.gen(function* () {
363: yield* result.get(input.sessionID)
364: const prompt = resolvePrompt(input.prompt)
365: const messageID = input.id ?? SessionMessage.ID.create()
366: const delivery = input.delivery ?? "steer"
367: const expected = { sessionID: input.sessionID, messageID, prompt, delivery ...
<path>/home/byk/Code/opencode/packages/core/src/session/run-coordinator.ts</path>
<type>file</type>
<content>
1: export * as SessionRunCoordinator from "./run-coordinator"
2:
3: import { Deferred, Effect, Exit, Fiber, FiberSet, Scope } from "effect"
4:
5: /** Serializes execution for each key while allowing different keys to run concurrently. */
6: export interface Coordinator<Key, E> {
7: /** Snapshots keys with an execution owned by this coordinator. */
8: readonly active: Effect.Effect<ReadonlySet<Key>>
9: /** Starts execution while idle or joins the active execution. */
10: readonly run: (key: Key) => Effect.Effect<void, E>
11: /** Registers one coalesced follow-up after newly recorded work. */
12: readonly wake: (key: Key) => Effect.Effect<void>
13: /** Stops active execution, runs cleanup, then starts work that arrived while stopping. */
14: readonly interrupt: (key: Key, cleanup?: Effect.Effect<void>) => Effect.Effect<void>
15: }
16:
17: type Entry<E> = {
18: ...
<path>/home/byk/Code/opencode/packages/core/src/session/runner/index.ts</path>
<type>file</type>
<content>
1: export * as SessionRunner from "./index"
2:
3: import type { LLMError } from "@opencode-ai/llm"
4: import { Context, Effect } from "effect"
5: import { SessionSchema } from "../schema"
6: import type { SessionMessage } from "../message"
7: import type { ContextSnapshotDecodeError, MessageDecodeError } from "../error"
8: import { SessionRunnerModel } from "./model"
9: import type { SystemContext } from "../../system-context/index"
10: import type { ToolOutputStore } from "../../tool-output-store"
11:
12: export type RunError =
13: | LLMError
14: | SessionRunnerModel.Error
15: | MessageDecodeError
16: | ContextSnapshotDecodeError
17: | SystemContext.InitializationBlocked
18: | ToolOutputStore.Error
19:
20: /** Runs one local continuation from already-recorded Session history. */
21: export interface Interface {
22: /** Drains eligible durable work. ...
<path>/home/byk/Code/opencode/packages/core/src/session/recovery-id.ts</path>
<type>file</type>
<content>
1: import { SessionMessage } from "./message"
2:
3: export const message = (executionID: string, assistantMessageID?: SessionMessage.ID) =>
4: assistantMessageID ?? SessionMessage.ID.make(`msg_recovery_${executionID}`)
5:
6: export const continuation = (executionID: string) => SessionMessage.ID.make(`msg_recovery_continue_${executionID}`)
(End of file - total 6 lines)
</content>
<path>/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/server.ts</path>
<type>file</type>
<content>
1: import { Config as EffectConfig, Context, Effect, Layer } from "effect"
2: import { HttpApiBuilder, OpenApi } from "effect/unstable/httpapi"
3: import { HttpClient, HttpMiddleware, HttpRouter, HttpServer, HttpServerResponse } from "effect/unstable/http"
4: import * as Socket from "effect/unstable/socket/Socket"
5: import { FSUtil } from "@opencode-ai/core/fs-util"
6: import * as Observability from "@opencode-ai/core/observability"
7: import { Account } from "@/account/account"
8: import { Agent } from "@/agent/agent"
9: import { Auth } from "@/auth"
10: import { BackgroundJob } from "@/background/job"
11: import { Command } from "@/command"
12: import { Config } from "@/config/config"
13: import { Workspace } from "@/control-plane/workspace"
14: import { Env } from "@/env"
15: import { EventV2Bridge } from "@/event-v2-bridge"
16: import { Format } from ...
<path>/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/server.ts</path> <type>file</type> <content> 213: const app = LayerNode.group([ 214: Npm.node, 215: FSUtil.node, 216: Database.node, 217: Auth.node, 218: Account.node, 219: Config.node, 220: Env.node, 221: Git.node, 222: Ripgrep.node, 223: Storage.node, 224: Snapshot.node, 225: Plugin.node, 226: ModelsDev.node, 227: Provider.node, 228: ProviderAuth.node, 229: Agent.node, 230: Skill.node, 231: Discovery.node, 232: Question.node, 233: Permission.node, 234: PermissionSaved.node, 235: Todo.node, 236: Session.node, 237: SessionProjector.node, 238: SessionStatus.node, 239: BackgroundJob.node, 240: RuntimeFlags.node, 241: EventV2Bridge.node, 242: SessionRunState.node, 243: SessionProcessor.node, 244: SessionCompaction.node, 245: SessionRevert.node, 246: SessionSummary.node, 247: SessionPrompt.node, 248: Instruction.node, 249: ...
<path>/home/byk/Code/opencode/packages/server/src/routes.ts</path>
<type>file</type>
<content>
1: import { Database } from "@opencode-ai/core/database/database"
2: import { LayerNode } from "@opencode-ai/core/effect/layer-node"
3: import { httpClient } from "@opencode-ai/core/effect/app-node-platform"
4: import { AppNodeBuilder } from "@opencode-ai/core/effect/app-node-builder"
5: import { EventV2 } from "@opencode-ai/core/event"
6: import { Credential } from "@opencode-ai/core/credential"
7: import { PermissionSaved } from "@opencode-ai/core/permission/saved"
8: import { PtyTicket } from "@opencode-ai/core/pty/ticket"
9: import { SessionV2 } from "@opencode-ai/core/session"
10: import { SessionExecution } from "@opencode-ai/core/session/execution"
11: import { LocationServiceMap } from "@opencode-ai/core/location-service-map"
12: import { SessionExecutionLocal } from "@opencode-ai/core/session/execution/local"
13: import { SessionRecovery } from ...
<path>/home/byk/Code/opencode/packages/schema/src/session-event.ts</path>
<type>file</type>
<content>
1: export * as SessionEvent from "./session-event"
2:
3: import { Schema } from "effect"
4: import { optional } from "./schema"
5: import { Event } from "./event"
6: import { ProviderMetadata, ToolContent } from "./llm"
7: import { Delivery } from "./session-delivery"
8: import { Model } from "./model"
9: import { DateTimeUtcFromMillis, NonNegativeInt, RelativePath } from "./schema"
10: import { FileAttachment, Prompt } from "./prompt"
11: import { SessionID } from "./session-id"
12: import { Location } from "./location"
13: import { SessionMessage } from "./session-message"
14: import { Revert } from "./revert"
15:
16: export { FileAttachment }
17:
18: export const Source = Schema.Struct({
19: start: NonNegativeInt,
20: end: NonNegativeInt,
21: text: Schema.String,
22: }).annotate({
23: identifier: "session.next.event.source",
24: })
25: export interface Source extends ...
Found 100 matches (more matches available)
/home/byk/Code/opencode/packages/core/test/session-runner.test.ts:
Line 619: it.effect("redrives only the synthetic recovery continuation", () =>
Line 688: it.effect("clears durable execution intent when ordinary input is promoted", () =>
Line 715: it.effect("redrives an ordinary prompt after its advisory wake is lost", () =>
Line 752: it.effect("never dispatches a provider after ownership changes", () =>
Line 778: it.effect("never publishes streamed output after ownership changes", () =>
Line 805: it.effect("never starts a local tool after ownership changes", () =>
Line 845: it.effect("never fails interrupted tools after ownership changes", () =>
Line 902: it.effect("advertises and executes a globally attached application tool", () =>
Line 958: it.effect("starts a real runner turn after default prompt recording", () =>
Line 977: it.effect("streams one request with registry definitions from ...
Found 12 matches
/home/byk/Code/opencode/packages/core/test/session-execution-local.test.ts:
Line 45: it.effect("clears the claim after a successful drain", () =>
Line 54: it.effect("snapshots the latest assistant sequence when acquiring a claim", () =>
Line 86: it.effect("preserves the claim when its scope closes", () =>
Line 102: it.effect("clears the claim after explicit interruption", () =>
Line 116: it.effect("never starts a second owner while the lease is live", () =>
Line 139: it.effect("never overwrites an expired lease", () =>
Line 166: it.effect("never re-enters its own uncertain live lease", () =>
Line 193: it.effect("renews heartbeat expiry from the current clock", () =>
Line 216: it.effect("never revives an expired claim on heartbeat", () =>
Line 234: it.effect("settles cancellation before starting a pending successor", () =>
Line 278: it.effect("never lets runner settlement overwrite cancellation", () =>
Line 313: ...
<path>/home/byk/Code/opencode/packages/core/test/session-execution-local.test.ts</path>
<type>file</type>
<content>
1: import { describe, expect } from "bun:test"
2: import { Deferred, Effect, Exit, Fiber, Scope } from "effect"
3: import { TestClock } from "effect/testing"
4: import { eq, sql } from "drizzle-orm"
5: import { Database } from "@opencode-ai/core/database/database"
6: import { Project } from "@opencode-ai/core/project"
7: import { ProjectTable } from "@opencode-ai/core/project/sql"
8: import { AbsolutePath } from "@opencode-ai/core/schema"
9: import { SessionExecutionLocal } from "@opencode-ai/core/session/execution/local"
10: import { SessionExecutionClaim } from "@opencode-ai/core/session/execution/claim"
11: import { SessionMessage } from "@opencode-ai/core/session/message"
12: import { SessionSchema } from "@opencode-ai/core/session/schema"
13: import { SessionExecutionTable, SessionTable } from "@opencode-ai/core/session/sql"
14: import { testEffect } from ...
<path>/home/byk/Code/opencode/packages/core/test/session-runner.test.ts</path>
<type>file</type>
<content>
3750: ])
3751: }),
3752: )
3753:
3754: it.effect("awaits started local tools before surfacing provider stream failure", () =>
3755: Effect.gen(function* () {
3756: yield* setup
3757: const session = yield* SessionV2.Service
3758: yield* session.prompt({ sessionID, prompt: Prompt.make({ text: "Settle before failing" }), resume: false })
3759: const failure = providerUnavailable()
3760: toolExecutionGate = yield* Deferred.make<void>()
3761: responseStream = Stream.concat(
3762: Stream.fromIterable([
3763: LLMEvent.stepStart({ index: 0 }),
3764: LLMEvent.toolCall({ id: "call-before-failure", name: "echo", input: { text: "settle" } }),
3765: ]),
3766: Stream.fail(failure),
3767: )
3768:
3769: const run = yield* session.resume(sessionID).pipe(Effect.forkChild)
3770: ...
packages/core/test/session-runner-tool-events.test.ts:92:test("local tool success serializes media base64 once and reconstructs from structured content", async () => {
packages/core/test/session-runner-tool-events.test.ts:115:test("provider-executed success retains its compatibility result", async () => {
packages/core/test/session-runner-tool-events.test.ts:123:test("binary failure emits no success event", async () => {
packages/core/test/session-runner-tool-events.test.ts:139:test("old success event data containing result still decodes", () => {
packages/core/test/session-runner-tool-events.test.ts:168:test("step finish records settlement without publishing step ended", async () => {
packages/core/test/database-migration.test.ts:43: test("defaults missing workspace names while preserving legacy workspace data", async () => {
packages/core/test/database-migration.test.ts:75: test("imports unnamed legacy Drizzle journal entries by their actual migration timestamps", async () => ...
Found 2 matches
/home/byk/.local/share/opencode/repos/github.com/Effect-TS/effect-smol/packages/effect/src/Effect.ts:
Line 4883: export const raceFirst: {
/home/byk/.local/share/opencode/repos/github.com/Effect-TS/effect-smol/packages/effect/src/internal/effect.ts:
Line 1569: export const raceFirst: {
<path>/home/byk/.local/share/opencode/repos/github.com/Effect-TS/effect-smol/packages/effect/src/internal/effect.ts</path>
<type>file</type>
<content>
1520: }
1521: })
1522: }
1523:
1524: return fiberInterruptAll(fibers)
1525: })
1526: )
1527:
1528: /** @internal */
1529: export const race: {
1530: <A2, E2, R2>(
1531: that: Effect.Effect<A2, E2, R2>,
1532: options?: {
1533: readonly onWinner?: (options: {
1534: readonly fiber: Fiber.Fiber<any, any>
1535: readonly index: number
1536: readonly parentFiber: Fiber.Fiber<any, any>
1537: }) => void
1538: }
1539: ): <A, E, R>(
1540: self: Effect.Effect<A, E, R>
1541: ) => Effect.Effect<A | A2, E | E2, R | R2>
1542: <A, E, R, A2, E2, R2>(
1543: self: Effect.Effect<A, E, R>,
1544: that: Effect.Effect<A2, E2, R2>,
1545: options?: {
1546: readonly onWinner?: (options: {
1547: readonly fiber: Fiber.Fiber<any, any>
1548: ...
Found 2 matches /home/byk/.local/share/opencode/repos/github.com/Effect-TS/effect-smol/packages/effect/src/internal/effect.ts: Line 1481: export const raceAllFirst = <Eff extends Effect.Effect<any, any, any>>( Line 1605: ): Effect.Effect<A | A2, E | E2, R | R2> => raceAllFirst([self, that], options)
<path>/home/byk/.local/share/opencode/repos/github.com/Effect-TS/effect-smol/packages/effect/src/internal/effect.ts</path>
<type>file</type>
<content>
1430: }) => void
1431: }
1432: ): Effect.Effect<
1433: Effect.Success<Eff>,
1434: Effect.Error<Eff>,
1435: Effect.Services<Eff>
1436: > =>
1437: withFiber((parent) =>
1438: callback((resume) => {
1439: const effects = Arr.fromIterable(all)
1440: const len = effects.length
1441: let doneCount = 0
1442: let done = false
1443: const fibers = new Set<Fiber.Fiber<any, any>>()
1444: const failures: Array<Cause.Reason<any>> = []
1445: const onExit = (exit: Exit.Exit<any, any>, fiber: Fiber.Fiber<any, any>, i: number) => {
1446: doneCount++
1447: if (exit._tag === "Failure") {
1448: failures.push(...exit.cause.reasons)
1449: if (doneCount >= len) {
1450: resume(failCause(causeFromReasons(failures)))
1451: }
1452: ...
Found 8 matches /home/byk/Code/opencode/packages/client/src/generated/types.ts: Line 778: readonly requestExecution?: boolean Line 784: readonly type: "session.next.prompt.execution_requested" Line 908: readonly type: "session.next.step.recovered" Line 914: readonly executionID: string Line 1272: readonly requestExecution?: boolean Line 1278: readonly type: "session.next.prompt.execution_requested" Line 1402: readonly type: "session.next.step.recovered" Line 1408: readonly executionID: string
<path>/home/byk/Code/opencode/packages/client/src/generated/types.ts</path>
<type>file</type>
<content>
730: readonly durable?: { readonly aggregateID: string; readonly seq: number; readonly version: number }
731: readonly location?: { readonly directory: string; readonly workspaceID?: string }
732: readonly data: {
733: readonly timestamp: number
734: readonly sessionID: string
735: readonly messageID: string
736: readonly prompt: {
737: readonly text: string
738: readonly files?: ReadonlyArray<{
739: readonly uri: string
740: readonly mime: string
741: readonly name?: string
742: readonly description?: string
743: readonly source?: { readonly start: number; readonly end: number; readonly text: string }
744: }>
745: readonly agents?: ReadonlyArray<{
746: readonly name: string
747: ...
Found 26 matches
/home/byk/Code/opencode/packages/sdk/openapi.json:
Line 15309: "$ref": "#/components/schemas/EventSessionNextPromptAdmitted"
Line 15339: "$ref": "#/components/schemas/EventSessionNextStepRecovered"
Line 17899: "requestExecution": {
Line 17919: "enum": ["session.next.prompt.execution_requested"]
Line 18289: "enum": ["session.next.step.recovered"]
Line 20577: "$ref": "#/components/schemas/SyncEventSessionNextPromptAdmitted"
Line 20607: "$ref": "#/components/schemas/SyncEventSessionNextStepRecovered"
Line 23811: "$ref": "#/components/schemas/SessionNextPromptAdmitted"
Line 23841: "$ref": "#/components/schemas/SessionNextStepRecovered"
Line 24200: "$ref": "#/components/schemas/SessionNextPromptAdmitted"
Line 24230: "$ref": "#/components/schemas/SessionNextStepRecovered"
Line ...
<path>/home/byk/Code/opencode/packages/sdk/openapi.json</path>
<type>file</type>
<content>
25630: "timestamp": {
25631: "type": "number"
25632: },
25633: "sessionID": {
25634: "type": "string",
25635: "pattern": "^ses"
25636: },
25637: "messageID": {
25638: "type": "string",
25639: "pattern": "^msg_"
25640: },
25641: "prompt": {
25642: "$ref": "#/components/schemas/Prompt"
25643: },
25644: "delivery": {
25645: "type": "string",
25646: "enum": ["steer", "queue"]
25647: }
25648: },
25649: "required": ["timestamp", "sessionID", "messageID", "prompt", "delivery"],
25650: "additionalProperties": false
25651: ...
Found 7 matches
/home/byk/Code/opencode/packages/sdk/openapi.json:
Line 15312: "$ref": "#/components/schemas/EventSessionNextPromptExecution_requested"
Line 20580: "$ref": "#/components/schemas/SyncEventSessionNextPromptExecution_requested"
Line 23814: "$ref": "#/components/schemas/SessionNextPromptExecution_requested"
Line 24203: "$ref": "#/components/schemas/SessionNextPromptExecution_requested"
Line 25724: "SyncEventSessionNextPromptExecution_requested": {
Line 28610: "SessionNextPromptExecution_requested": {
Line 34822: "EventSessionNextPromptExecution_requested": {
<path>/home/byk/Code/opencode/packages/schema/test/event-manifest.test.ts</path>
<type>file</type>
<content>
1: import { describe, expect, test } from "bun:test"
2: import { FileSystem, Integration, Permission, Project, Reference, Session, Workspace } from "../src"
3: import { EventManifest } from "../src/event-manifest"
4: import { IdeEvent } from "../src/ide-event"
5: import { SessionEvent } from "../src/session-event"
6: import { SessionTodo } from "../src/session-todo"
7: import { SessionV1 } from "../src/session-v1"
8: import { WorkspaceEvent } from "../src/workspace-event"
9:
10: describe("public event manifest", () => {
11: test("owns the complete public event surface", () => {
12: expect(EventManifest.ServerDefinitions.length).toBe(61)
13: expect(EventManifest.Definitions.length).toBe(91)
14: expect(SessionV1.Event.Definitions).toEqual([
15: SessionV1.Event.Created,
16: SessionV1.Event.Updated,
17: SessionV1.Event.Deleted,
18: ...
<path>/home/byk/Code/opencode/packages/core/test/database-migration.test.ts</path>
<type>file</type>
<content>
110: await Effect.runPromise(
111: Effect.all(
112: layers.map((layer) => Effect.scoped(Layer.build(layer))),
113: { concurrency: "unbounded" },
114: ),
115: )
116: })
117: if (process.platform === "linux") {
118: test("declared schema has no ungenerated migrations", async () => {
119: const result = await $`bun ${fileURLToPath(new URL("../script/migration.ts", import.meta.url))} --check`
120: .quiet()
121: .nothrow()
122: expect(result.exitCode, result.stderr.toString()).toBe(0)
123: expect(result.stdout.toString()).toContain("No schema changes, nothing to migrate")
124: }, 30_000)
125: }
126:
127: test("applies tracked migrations to an empty database", async () => {
128: await run(
129: Effect.gen(function* () {
130: const db = yield* makeDb
131: yield* ...
Found 12 matches /home/byk/Code/opencode/packages/sdk/js/src/v2/gen/types.gen.ts: Line 874: requestExecution?: boolean Line 879: type: "session.next.prompt.execution_requested" Line 983: type: "session.next.step.recovered" Line 3430: requestExecution?: boolean Line 3439: type: "session.next.prompt.execution_requested.1" Line 3606: type: "session.next.step.recovered.1" Line 4362: requestExecution?: boolean Line 4371: type: "session.next.prompt.execution_requested" Line 4565: type: "session.next.step.recovered" Line 6464: requestExecution?: boolean Line 6470: type: "session.next.prompt.execution_requested" Line 6583: type: "session.next.step.recovered"
No files found
Found 58 matches /home/byk/Code/opencode/packages/core/schema.json: Line 66: "name": "session_execution", Line 78: "name": "session_recovery", Line 941: "table": "session_execution" Line 951: "table": "session_execution" Line 961: "table": "session_execution" Line 971: "table": "session_execution" Line 981: "table": "session_execution" Line 991: "table": "session_execution" Line 1001: "table": "session_execution" Line 1011: "table": "session_execution" Line 1021: "table": "session_execution" Line 1089: "name": "wake_pending", Line 1181: "table": "session_recovery" Line 1191: "table": "session_recovery" Line 1201: "table": "session_recovery" Line 1211: "table": "session_recovery" Line 1221: "table": "session_recovery" Line 1229: "name": "wake_pending", Line 1231: "table": "session_recovery" Line 1239: "name": ...
<path>/home/byk/Code/opencode/packages/core/test/session-projector.test.ts</path>
<type>file</type>
<content>
1: import { describe, expect } from "bun:test"
2: import { DateTime, Deferred, Effect, Exit, Fiber, Schema } from "effect"
3: import { TestClock } from "effect/testing"
4: import { asc, eq, sql } from "drizzle-orm"
5: import { Database } from "@opencode-ai/core/database/database"
6: import { LayerNode } from "@opencode-ai/core/effect/layer-node"
7: import { AppNodeBuilder } from "@opencode-ai/core/effect/app-node-builder"
8: import { EventV2 } from "@opencode-ai/core/event"
9: import { EventTable } from "@opencode-ai/core/event/sql"
10: import { ModelV2 } from "@opencode-ai/core/model"
11: import { Project } from "@opencode-ai/core/project"
12: import { ProjectTable } from "@opencode-ai/core/project/sql"
13: import { ProviderV2 } from "@opencode-ai/core/provider"
14: import { AbsolutePath } from "@opencode-ai/core/schema"
15: import { SessionV2 } from ...
<path>/home/byk/Code/opencode/packages/core/test/session-projector.test.ts</path>
<type>file</type>
<content>
1960: expect(yield* db.select().from(SessionInputTable).where(eq(SessionInputTable.id, ordinaryID)).get()).toMatchObject({
1961: promoted_seq: expect.any(Number),
1962: })
1963: }),
1964: )
1965:
1966: it.effect("quarantines a malformed claim without blocking a valid claim", () =>
1967: Effect.gen(function* () {
1968: const { db } = yield* Database.Service
1969: const validSession = SessionV2.ID.make("ses_recovery_valid")
1970: yield* db
1971: .insert(ProjectTable)
1972: .values({ id: Project.ID.global, worktree: AbsolutePath.make("/project"), sandboxes: [] })
1973: .run()
1974: yield* db
1975: .insert(SessionTable)
1976: .values(
1977: [sessionID, validSession].map((id) => ({
1978: id,
1979: project_id: Project.ID.global,
1980: slug: ...
No files found
Found 34 matches /home/byk/Code/opencode/packages/core/src/session/recovery.ts: Line 74: .where(and(lte(SessionExecutionTable.expires_at, scanTime), isNull(SessionExecutionTable.recovery_error))) Line 85: .update(SessionExecutionTable) Line 91: eq(SessionExecutionTable.owner_id, claim.owner_id), Line 92: lte(SessionExecutionTable.expires_at, now), Line 105: .update(SessionExecutionTable) Line 111: eq(SessionExecutionTable.owner_id, ownerID), Line 112: gt(SessionExecutionTable.expires_at, quarantinedAt), Line 124: .update(SessionExecutionTable) Line 130: eq(SessionExecutionTable.owner_id, recoveryClaim.ownerID), Line 131: gt(SessionExecutionTable.expires_at, quarantinedAt), Line 239: .update(SessionExecutionTable) Line 245: eq(SessionExecutionTable.owner_id, ...
Found 11 matches
/home/byk/Code/opencode/packages/core/src/session/compaction.ts:
Line 198: yield* dependencies.events.publish(
Line 233: yield* dependencies.events.publish(
/home/byk/Code/opencode/packages/core/src/session/todo.ts:
Line 56: yield* events.publish(Event.Updated, input)
/home/byk/Code/opencode/packages/core/src/session/revert.ts:
Line 90: yield* events.publish(SessionEvent.RevertEvent.Staged, {
Line 107: yield* events.publish(SessionEvent.RevertEvent.Cleared, {
Line 116: yield* events.publish(SessionEvent.RevertEvent.Committed, {
/home/byk/Code/opencode/packages/core/src/session/context-epoch.ts:
Line 76: yield* events.publish(
/home/byk/Code/opencode/packages/core/src/session/runner/llm.ts:
Line 135: yield* events.publish(
Line 481: events.publish(
/home/byk/Code/opencode/packages/core/src/session/runner/publish-llm-event.ts:
Line 67: ? events.publish(definition, data, { commit })
...
Found 15 matches
/home/byk/Code/opencode/packages/core/src/snapshot.ts:
Line 19: operation: Schema.Literals(["capture", "files", "diff", "preview", "restore"]),
Line 47: * best-effort capture fails.
Line 49: readonly capture: () => Effect.Effect<ID | undefined>
Line 52: * List project-relative paths changed between two captured trees without
Line 58: * Generate structured per-file diffs between two captured trees. `context`
Line 77: * Replace the snapshot index with a captured tree and check out all its entries.
Line 103: return yield* new Error({ operation: "capture", message: "Location is outside the project" })
Line 108: if (!source) return yield* new Error({ operation: "capture", message: "Project is not a Git repository" })
Line 121: .pipe(Effect.mapError((cause) => failure("capture", cause)))
Line 129: const capture = Effect.fn("Snapshot.capture")(function* () {
Line 134: yield* ...
<path>/home/byk/Code/opencode/packages/core/src/snapshot.ts</path>
<type>file</type>
<content>
90: const fs = yield* FSUtil.Service
91: const git = yield* Git.Service
92: const global = yield* Global.Service
93: const location = yield* Location.Service
94: const source = yield* git.repo.discover(location.project.directory)
95: const worktree = source
96: ? AbsolutePath.make(yield* fs.realPath(source.worktree).pipe(Effect.orDie))
97: : location.project.directory
98: const gitDirectory = AbsolutePath.make(path.join(global.data, "snapshot", location.project.id, Hash.fast(worktree)))
99:
100: const scope = Effect.fnUntraced(function* () {
101: const relative = path.relative(worktree, location.directory)
102: if (relative.startsWith("..") || path.isAbsolute(relative))
103: return yield* new Error({ operation: "capture", message: "Location is outside the project" })
104: return RelativePath.make(relative.replaceAll("\\", ...
Found 25 matches
/tmp/opencode/session-recovery-final-v16.patch:
Line 1402: - { commit: () => advance(db, sessionID, result.snapshot).pipe(Effect.orDie) },
Line 1403: + { commit: () => advance(db, sessionID, result.snapshot, claim).pipe(Effect.orDie) },
Line 1432: - snapshot: generation.snapshot,
Line 1445: + snapshot: generation.snapshot,
Line 1464: - snapshot: generation.snapshot,
Line 1478: + snapshot: generation.snapshot,
Line 1492: snapshot: SystemContext.Snapshot,
Line 1497: - .set({ snapshot })
Line 1507: + .set({ snapshot })
Line 3168: const snapshots = yield* Snapshot.Service
Line 3343: const startSnapshot = yield* snapshots.capture()
Line 3348: snapshot: startSnapshot,
Line 3542: const endSnapshot = yield* snapshots.capture()
Line 3557: - snapshot: endSnapshot,
Line 3569: + snapshot: endSnapshot,
Line 3729: readonly ...
Found 1 matches /home/byk/Code/opencode/packages/core/src/session/projector.ts: Line 515: .delete(SessionMessageTable)
patch_size=416673 patch_mode=644 patch_mtime=2026-09-16 23:28:52.884926935 +0000 sea_size=157879104 sea_mode=755 sea_mtime=2026-09-16 23:23:31.579190781 +0000 base=ab9408c81cc9916177641ae8e9f08624fc27b5b9 base_tree=d3323b963b9ef2de41a7ff9884299c74b93886ba base_parents=2e9407768d1401a25b69febb36657638a779053a base_subject=feat(app): adapt vertical tab density
Found 10 matches /home/byk/Code/opencode/packages/server/src/routes.ts: Line 32: SessionV2.node, /home/byk/Code/opencode/packages/opencode/test/session/prompt.test.ts: Line 732: LayerNode.compile(SessionV2.node, [ /home/byk/Code/opencode/packages/opencode/test/session/compaction.test.ts: Line 614: Effect.provide(AppNodeBuilder.build(SessionV2.node, [[SessionExecution.node, SessionExecution.noopLayer]])), /home/byk/Code/opencode/packages/core/test/session-runner.test.ts: Line 277: SessionV2.node, /home/byk/Code/opencode/packages/core/test/session-projector.test.ts: Line 42: const sessionsLayer = AppNodeBuilder.build(SessionV2.node, [[SessionExecution.node, SessionExecution.noopLayer]]) /home/byk/Code/opencode/packages/core/test/session-runner-recorded.test.ts: Line 112: SessionV2.node, /home/byk/Code/opencode/packages/core/test/session-prompt.test.ts: Line 48: LayerNode.group([Database.node, EventV2.node, ...
<path>/home/byk/Code/opencode/packages/core/test/session-prompt.test.ts</path>
<type>file</type>
<content>
280:
281: const first = yield* session.prompt(input)
282: const second = yield* session.prompt(input)
283:
284: expect(second.id).not.toBe(first.id)
285: expect(yield* session.messages({ sessionID })).toEqual([])
286: expect(yield* admittedCount).toBe(2)
287: }),
288: )
289:
290: it.effect("returns the original recorded message when the ID is retried", () =>
291: Effect.gen(function* () {
292: yield* setup
293: const session = yield* SessionV2.Service
294: const input = {
295: sessionID,
296: id: messageID,
297: prompt: Prompt.make({ text: "Fix the failing tests" }),
298: resume: false,
299: }
300:
301: const first = yield* session.prompt(input)
302: const retried = yield* session.prompt(input)
303:
304: expect(retried).toEqual(first)
305: expect(yield* ...
<path>/home/byk/Code/opencode/packages/core/test/session-prompt.test.ts</path>
<type>file</type>
<content>
130: SessionExecution.Service.of({
131: active: Effect.succeed(new Set()),
132: resume: () => Effect.void,
133: interrupt: () => Effect.void,
134: wake: (id) => Effect.sync(() => wakeCalls.push(id)).pipe(Effect.asVoid),
135: }),
136: ),
137: )
138:
139: describe("SessionV2.prompt", () => {
140: it.effect("exposes the execution registry", () =>
141: Effect.gen(function* () {
142: activeSessions.add(sessionID)
143: expect(Array.from(yield* (yield* SessionV2.Service).active)).toEqual([sessionID])
144: }).pipe(Effect.ensuring(Effect.sync(() => activeSessions.clear()))),
145: )
146:
147: it.effect("delegates execution continuation through SessionExecution", () =>
148: Effect.gen(function* () {
149: yield* setup
150: const session = yield* SessionV2.Service
151: executionCalls.length = ...
<path>/home/byk/Code/opencode/packages/core/test/session-projector.test.ts</path>
<type>file</type>
<content>
1130: SessionExecution.Service.of({
1131: ...recoveryExecution,
1132: wake: (id) => Effect.sync(() => wakes.push(id)).pipe(Effect.asVoid),
1133: }),
1134: ),
1135: )
1136:
1137: expect(wakes).toEqual([])
1138: expect(yield* db.select().from(SessionRecoveryTable).get()).toMatchObject({
1139: recovery_error: "Invalid recovery continuation input",
1140: })
1141: }),
1142: )
1143:
1144: it.effect("redrives durable ordinary input execution intent after a lost advisory wake", () =>
1145: Effect.gen(function* () {
1146: const { db } = yield* Database.Service
1147: const events = yield* EventV2.Service
1148: yield* db
1149: .insert(ProjectTable)
1150: .values({ id: Project.ID.global, worktree: AbsolutePath.make("/project"), sandboxes: [] })
1151: ...
<path>/home/byk/Code/opencode/packages/schema/src/session-event.ts</path>
<type>file</type>
<content>
480: schema: { ...Base, messageID: SessionMessage.ID },
481: })
482: }
483:
484: export const DurableDefinitions = Event.inventory(
485: AgentSwitched,
486: ModelSwitched,
487: Moved,
488: Prompted,
489: PromptAdmitted,
490: PromptExecutionRequested,
491: ContextUpdated,
492: Synthetic,
493: Shell.Started,
494: Shell.Ended,
495: Step.Started,
496: Step.Ended,
497: Step.Failed,
498: Step.Interrupted,
499: Step.Recovered,
500: Text.Started,
501: Text.Ended,
502: Tool.Input.Started,
503: Tool.Input.Ended,
504: Tool.Called,
505: Tool.Progress,
506: Tool.Success,
507: Tool.Failed,
508: Reasoning.Started,
509: Reasoning.Ended,
510: Retried,
511: Compaction.Started,
512: Compaction.Ended,
513: RevertEvent.Staged,
514: RevertEvent.Cleared,
515: RevertEvent.Committed,
516: )
517:
518: export const Definitions = ...
<path>/tmp/opencode/session-recovery-final-v16.patch</path>
<type>file</type>
<content>
1510: + .get()
1511: + .pipe(Effect.orDie),
1512: + )
1513: if (!updated) return yield* Effect.die("Context Epoch not found")
1514: })
1515: diff --git a/packages/core/src/session/execution/local.ts b/packages/core/src/session/execution/local.ts
1516: index d874c40832..0bb4f02b2c 100644
1517: --- a/packages/core/src/session/execution/local.ts
1518: +++ b/packages/core/src/session/execution/local.ts
1519: @@ -1,46 +1,192 @@
1520: -import { Cause, Effect, Layer } from "effect"
1521: +import { and, asc, desc, eq, isNull } from "drizzle-orm"
1522: +import { Cause, Clock, Duration, Effect, Exit, Layer, Schedule } from "effect"
1523: +import { Database } from "../../database/database"
1524: import { LocationServiceMap } from "../../location-service-map"
1525: import { makeGlobalNode } from "../../effect/app-node"
1526: import { SessionRunCoordinator } from "../run-coordinator"
1527: ...
Found 4 matches
/home/byk/Code/opencode/packages/core/src/session/execution/claim.ts:
Line 67: export const renew = Effect.fn("SessionExecutionClaim.renew")(function* (db: DatabaseService, claim: Claim) {
/home/byk/Code/opencode/packages/core/src/session/execution/local.ts:
Line 88: SessionExecutionClaim.renew(db, claim).pipe(
Line 137: SessionExecutionClaim.renew(db, claim).pipe(
Line 158: SessionExecutionClaim.renew(db, claim).pipe(
<path>/home/byk/Code/opencode/packages/core/test/session-run-coordinator.test.ts</path>
<type>file</type>
<content>
230: ),
231: })
232:
233: const resumed = yield* coordinator.run("session").pipe(Effect.forkChild)
234: yield* Deferred.await(started)
235: yield* coordinator.wake("session")
236: yield* coordinator.interrupt("session")
237: yield* Deferred.await(interrupted)
238:
239: const exit = yield* Fiber.await(resumed)
240: expect(Exit.isFailure(exit) && Cause.hasInterruptsOnly(exit.cause)).toBeTrue()
241: expect(Array.from(yield* coordinator.active)).toEqual([])
242: expect(runs).toBe(1)
243: }),
244: ),
245: )
246:
247: it.effect("runs a wake registered during interruption cleanup", () =>
248: Effect.scoped(
249: Effect.gen(function* () {
250: const firstStarted = yield* Deferred.make<void>()
251: const cleanupStarted = yield* ...
<path>/tmp/opencode/session-recovery-final-v16.patch</path>
<type>file</type>
<content>
3040: + ),
3041: +)
3042: +
3043: +export const node = makeGlobalNode({
3044: + service: undefined,
3045: + name: "session-recovery",
3046: + layer,
3047: + deps: [Database.node, EventV2.node, SessionProjector.node, SessionExecution.node],
3048: +})
3049: diff --git a/packages/core/src/session/run-coordinator.ts b/packages/core/src/session/run-coordinator.ts
3050: index 2f89aff9e3..ab4b833374 100644
3051: --- a/packages/core/src/session/run-coordinator.ts
3052: +++ b/packages/core/src/session/run-coordinator.ts
3053: @@ -10,13 +10,14 @@ export interface Coordinator<Key, E> {
3054: readonly run: (key: Key) => Effect.Effect<void, E>
3055: /** Registers one coalesced follow-up after newly recorded work. */
3056: readonly wake: (key: Key) => Effect.Effect<void>
3057: - /** Stops active execution and waits for its cleanup. */
3058: - readonly interrupt: (key: Key) => ...
<path>/tmp/opencode/session-recovery-final-v16.patch</path>
<type>file</type>
<content>
7835: + expect(Exit.isFailure(exit) && Cause.hasDies(exit.cause)).toBeTrue()
7836: + yield* Deferred.await(secondStarted)
7837: + yield* coordinator.run("session")
7838: + expect(Array.from(yield* coordinator.active)).toEqual([])
7839: + expect(runs).toBe(2)
7840: + }),
7841: + ),
7842: + )
7843: +
7844: it.effect("starts a resume registered during interruption cleanup", () =>
7845: Effect.scoped(
7846: Effect.gen(function* () {
7847: diff --git a/packages/core/test/session-runner-recorded.test.ts b/packages/core/test/session-runner-recorded.test.ts
7848: index d45cc8c734..ec91d1b4a4 100644
7849: --- a/packages/core/test/session-runner-recorded.test.ts
7850: +++ b/packages/core/test/session-runner-recorded.test.ts
7851: @@ -19,7 +19,7 @@ import { Snapshot } from "@opencode-ai/core/snapshot"
7852: import { Prompt } from ...
packages/schema/test/event-manifest.test.ts:6:import { SessionTodo } from "../src/session-todo"
packages/schema/test/event-manifest.test.ts:36: expect(EventManifest.Latest.get("todo.updated")).toBe(SessionTodo.Event.Updated)
packages/schema/src/session-event.ts:245: // Stream fragments are live-only; Text.Ended is the replayable full-value boundary.
packages/schema/src/session-event.ts:283: // Stream fragments are live-only; Reasoning.Ended is the replayable full-value boundary.
packages/schema/src/session-event.ts:327: // Stream fragments are live-only; Input.Ended is the replayable raw-input boundary.
packages/core/test/session-run-coordinator.test.ts:69: it.effect("snapshots only active executions", () =>
packages/core/src/session.ts:260: // TODO: Restore recorded sessions onto replacement synchronized workspaces in a future API slice.
packages/core/test/session-projector.test.ts:245: executionID: ...
Found 1 matches
/home/byk/Code/opencode/packages/schema/src/session-message.ts:
Line 12: export const ID = Schema.String.check(Schema.isStartsWith("msg_")).pipe(
<path>/home/byk/Code/opencode/packages/schema/src/session-message.ts</path>
<type>file</type>
<content>
1: export * as SessionMessage from "./session-message"
2:
3: import { Schema } from "effect"
4: import { optional } from "./schema"
5: import { ProviderMetadata, ToolContent } from "./llm"
6: import { Model } from "./model"
7: import { FileAttachment, Prompt } from "./prompt"
8: import { DateTimeUtcFromMillis, RelativePath, statics } from "./schema"
9: import { SessionID } from "./session-id"
10: import { ascending } from "./identifier"
11:
12: export const ID = Schema.String.check(Schema.isStartsWith("msg_")).pipe(
13: Schema.brand("Session.Message.ID"),
14: statics((schema) => ({ create: () => schema.make("msg_" + ascending()) })),
15: )
16: export type ID = typeof ID.Type
17:
18: export interface UnknownError extends Schema.Schema.Type<typeof UnknownError> {}
19: export const UnknownError = Schema.Struct({
20: type: Schema.Literal("unknown"),
21: message: ...
ab9408c81cc9916177641ae8e9f08624fc27b5b9.b0e9fdde553e70f6f606c33c555f9e37bb52d6827dd1aad8d5a932b76cd2ee30.a0eea521a58325461d7e533e5f3be05fccf2714a90a444eb67ac21b153f53c2f.cancelling and cancelled; only the cancellation transition accepts cancelling, and only from cancelling. packages/core/src/session/execution/claim.ts:27-65packages/core/src/session/execution/claim.ts:67-82, packages/core/src/session/execution/local.ts:86-91,128-162packages/core/src/session/execution/claim.ts:84-109, packages/core/src/session/execution/local.ts:133-161Step.Interrupted commit changes the phase to cancelled. packages/core/src/session/runner/llm.ts:415-447, packages/core/src/session/runner/publish-llm-event.ts:242-287,468-483