Dashboard › opencode › Distillation
d4c7a821-59f9-4268-9884-7963ca1c723c["lore_tm_v1_PvC4Kcd_cvi8F1eWJLlC9fnplf-xeVMTVAUJyeZtzU8"]
Date: Sep 15, 2026
packages/core/src/session/input.ts:85-116, the input-admission projection accepts admittedSeq, id, sessionID, prompt, delivery, and timeCreated. It first checks SessionMessageTable for the same input.id; an existing message causes Effect.die(new LifecycleConflict({ id: input.id })). It then inserts into SessionInputTable with id, session_id, admitted_seq, prompt: encodePrompt(input.prompt), delivery, and epoch-millisecond time_created, using .onConflictDoNothing().returning({ id }).get(). Failure to insert also dies with LifecycleConflict.packages/core/src/session/input.ts:118-168, projectPrompted() receives id, sessionID, prompt, delivery, timeCreated, and promotedSeq. It first conditionally updates the matching SessionInputTable row only when promoted_seq is null, setting promoted_seq: input.promotedSeq.packages/core/src/session/input.ts:142-153, when projectPrompted() updates an existing row, it decodes it with fromRow(updated) and dies with LifecycleConflict if matchesProjection(stored, input) fails. If no row was updated, it calls find(db, input.id); an existing row is accepted idempotently only when both the projection matches and stored.promotedSeq === input.promotedSeq, otherwise it dies with LifecycleConflict.packages/core/src/session/input.ts:155-167, if projectPrompted() finds no existing input row, it inserts one with admitted_seq and promoted_seq both set to input.promotedSeq, plus encoded prompt, delivery, session_id, id, and epoch-millisecond time_created; the insert runs through Effect.orDie.packages/core/src/session/input.ts:170-174, hasPending() begins with parameters db: DatabaseService, sessionID: SessionSchema.ID, and delivery: Delivery; its implementation continues beyond the displayed excerpt.