Dashboard › opencode › Distillation
81f648f7-eb44-48a7-90b1-d112381c754e["lore_tm_v1_mirS4SvvCJezY_6EwvaFCj2bFo056WN2BCVWsGHdcW0","lore_tm_v1_RGLsY-ijht35qoRsfenvLm0fwrOIjdoc4gaNY4Knufo","lore_tm_v1_LIS3qNTAAXgsS3arykhojbXG3bHkmCut3b8oWWULA88","lore_tm_v1_tqj-7ZrhChJ7nvaMvr04w63ah7CjX5jKdCp31rnDzj8","lore_tm_v1_sGObwgtPb632PRGmpCo2lKwpdmbJJ1BFnsIpGeFhPyU"]
Date: Sep 15, 2026
packages/core/src/event.ts:205-367 defines commitDurableEvent(definition, event, input?, commit?); it reads the aggregate ID from event.data[durable.aggregate], dies with InvalidDurableEventError if the value is not a string or differs from input.aggregateID, and executes durable projection and persistence inside an Effect.uninterruptible immediate database transaction.commitDurableEvent() reads EventSequenceTable.seq and EventSequenceTable.owner_id for the aggregate and treats a missing row as latest sequence -1; event data is encoded with Schema.encodeUnknownSync(definition.data).commitDurableEvent() dies with InvalidDurableEventError message Replay owner mismatch for aggregate ${aggregateID}: expected ${row.ownerID}, got ${input.ownerID ?? "none"} when input.strictOwner is true and the stored non-null owner differs from input.ownerID.input.seq <= latest, commitDurableEvent() treats the event as idempotent only when stored id, versioned type, and deeply equal encoded data all match. If input.ownerID is present and the aggregate has no owner, it assigns that owner; otherwise divergence dies with Replay diverged at aggregate ${aggregateID} sequence ${input.seq}.commitDurableEvent() silently returns without committing if the aggregate already has a different owner and strict ownership was not requested. It requires the incoming sequence to equal latest + 1, otherwise dying with Sequence mismatch for aggregate ${aggregateID}: expected ${latest + 1}, got ${seq}.commitDurableEvent() rejects globally duplicated event IDs by looking up EventTable.id and dying with Event ${event.id} already exists at aggregate ${stored.aggregateID} sequence ${stored.seq}.durable: { aggregateID, seq, version: durable.version }; 2. run every projector registered for event.type; 3. invoke optional local commit(seq); 4. upsert EventSequenceTable with aggregate_id, seq, and ownership assignment where applicable; 5. insert the encoded event into EventTable using versionedType(definition.type, durable.version).commitDurableEvent() publishes undefined to every durable wake pubsub registered under the committed aggregate ID; if no event was committed, no durable wake is published.packages/core/src/event.ts:369-395 function publishEvent() prohibits a local commit hook on a non-durable definition, dying with InvalidDurableEventError message "Local commit hooks require a durable event". A committed durable event receives durable metadata and calls notify(event, true); an uncommitted or non-durable event calls notify(event, false).packages/core/src/event.ts:398-416 isolates durable listeners through observe(): non-interruption listener failures are caught and logged as "Event listener failed" with eventID, eventType, and cause. notify() invokes all listeners first, then publishes to the event-type pubsub when present, then publishes to the all-event pubsub.packages/core/src/event.ts:419-438 function publish() resolves event location in precedence order: 1. options.location; 2. a Location.Service projection containing directory and workspaceID; 3. no location. It uses options.id ?? ID.create(), conditionally includes metadata, and passes options.commit to publishEvent().packages/core/src/event.ts:441-477 function replay() resolves the durable definition with Durable.get(event.type), rejects unknown/non-durable types with Unknown durable event type ${event.type}, decodes data through Schema.decodeUnknownSync(definition.data), and calls commitDurableEvent() with the serialized seq, aggregateID, optional ownerID, and optional strictOwner.replay() republishes only when the event was committed and options.publish is true; the published payload includes the committed aggregateID, seq, and current durable definition version, and listeners are isolated via notify(..., true).packages/core/src/event.ts:480-504 function replayAll() returns undefined for an empty event array, requires all events to share the first eventβs aggregateID, and dies with "Replay events must belong to the same aggregate" if they do not. It requires contiguous sequences beginning at events[0].seq, dying with Replay sequence mismatch at index ${index}: expected ${seq}, got ${event.seq} on a mismatch.Event.layerWith() finalizer shuts down pubsub.all, every pubsub in every pubsub.durable collection, and every pubsub in pubsub.typed.packages/core/test/session-runner.test.ts found 19 matches related to replaySessionProjection or wake_pending: helper definition at line 396; replay calls at lines 524, 643, 1083, 1313, 1385, 1645, 2073, 2132, 2277, 3477, 3736, 3816, and 3849; recovery wake_pending assertions at lines 640 and 644; input wake_pending mutation at line 673; and expected wake_pending: false values at lines 683 and 717.packages/core/test/session-runner.test.ts:396-420 helper replaySessionProjection(id: SessionV2.ID) reads all EventTable rows for the aggregate in ascending EventTable.seq, calls events.remove(id), deletes matching rows from SessionInputTable and SessionMessageTable, then rebuilds projections by passing mapped { id, aggregateID, seq, type, data } records to events.replayAll().packages/core/test/session-runner.test.ts:422-434 defines FragmentKind = "text" | "reasoning" | "tool input" and fragmentKinds in that exact order. FragmentFixture contains delta: EventV2.Definition, completeEvents: LLMEvent[], partialEvents: LLMEvent[], expectedAssistant, and expectedContent; fragmentID(kind, suffix) uses prefix "call" for "tool input" and otherwise the kind itself."interrupts runner continuation when a question is dismissed" in packages/core/test/session-runner.test.ts:3340-3394 registers a question tool whose execution calls questions.ask(), prompts "Ask then stop", supplies one provider turn containing stepStart, tool call ID "call-question", stepFinish, and finish, waits for a pending question, rejects it, and verifies the runner exits with interruption-only failure and makes exactly 1 provider request."Ask then stop" and an assistant tool fragment with ID "call-question" whose state is { status: "error", error: { type: "unknown", message: "Tool execution interrupted" } }."awaits started local tools before surfacing provider stream failure" in packages/core/test/session-runner.test.ts:3396-3428 prompts "Settle before failing", creates toolExecutionGate, emits stepStart and an echo tool call with ID "call-before-failure" and input { text: "settle" }, then fails the provider stream with providerUnavailable().toolExecutionGate, verifies joining the runner surfaces the original provider failure only after tool settlement, and confirms context durably records the tool as { status: "completed", structured: { text: "settle" } }.packages/core/test/session-runner.test.ts:3430 with title "durably fails blocked local tools when a provider turn is interrupted" and prompt text "Interrupt blocked tool".