Skip to content

Commit de9066a

Browse files
committed
refactor(core): consolidate session event reset
1 parent 31cda5e commit de9066a

5 files changed

Lines changed: 6 additions & 21 deletions

File tree

packages/core/src/database/migration.gen.ts

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/src/database/migration/20260703200000_reset_v2_event_fragments.ts renamed to packages/core/src/database/migration/20260703200000_reset_v2_session_events.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Effect } from "effect"
22
import type { DatabaseMigration } from "../migration"
33

44
export default {
5-
id: "20260703200000_reset_v2_event_fragments",
5+
id: "20260703200000_reset_v2_session_events",
66
up(tx) {
77
return Effect.gen(function* () {
88
yield* tx.run(`DELETE FROM \`session_input\`;`)

packages/core/src/database/migration/20260703210000_reset_v2_execution_errors.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

packages/core/test/database-migration.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import eventSourcedSessionInputMigration from "@opencode-ai/core/database/migrat
1515
import contextEpochAgentMigration from "@opencode-ai/core/database/migration/20260605042240_add_context_epoch_agent"
1616
import simplifyIntegrationCredentialsMigration from "@opencode-ai/core/database/migration/20260611192811_lush_chimera"
1717
import simplifySessionInputMigration from "@opencode-ai/core/database/migration/20260622202450_simplify_session_input"
18-
import resetExecutionErrorsMigration from "@opencode-ai/core/database/migration/20260703210000_reset_v2_execution_errors"
18+
import resetSessionEventsMigration from "@opencode-ai/core/database/migration/20260703200000_reset_v2_session_events"
1919
import { AppNodeBuilder } from "@opencode-ai/core/effect/app-node-builder"
2020
import { LayerNode } from "@opencode-ai/core/effect/layer-node"
2121
import { EventV2 } from "@opencode-ai/core/event"
@@ -39,7 +39,7 @@ const run = <A, E>(effect: Effect.Effect<A, E, SqlClientService>) =>
3939
const makeDb = EffectDrizzleSqlite.makeWithDefaults()
4040

4141
describe("DatabaseMigration", () => {
42-
test("resets incompatible V2 execution and error history", async () => {
42+
test("resets incompatible V2 Session event history", async () => {
4343
await run(
4444
Effect.gen(function* () {
4545
const db = yield* makeDb
@@ -52,7 +52,7 @@ describe("DatabaseMigration", () => {
5252
yield* db.run(sql`INSERT INTO event (id) VALUES ('event')`)
5353
yield* db.run(sql`INSERT INTO event_sequence (aggregate_id, seq) VALUES ('session', 1)`)
5454

55-
yield* DatabaseMigration.applyOnly(db, [resetExecutionErrorsMigration])
55+
yield* DatabaseMigration.applyOnly(db, [resetSessionEventsMigration])
5656

5757
expect(yield* db.get(sql`SELECT id FROM session_input`)).toBeUndefined()
5858
expect(yield* db.get(sql`SELECT id FROM session_message`)).toBeUndefined()

specs/v2/schema-changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,5 +972,5 @@ Compatibility:
972972

973973
Compatibility:
974974

975-
- All changed durable definitions remain version 1. `20260703200000_reset_v2_event_fragments` wipes experimental V2 events, sequences, projected messages, and admitted inputs.
975+
- All changed durable definitions remain version 1. `20260703200000_reset_v2_session_events` performs the single reset for this Session event contract update, wiping experimental V2 events, sequences, projected messages, and admitted inputs.
976976
- Promise, Effect, and legacy JavaScript SDK surfaces are regenerated from the simplified schemas.

0 commit comments

Comments
 (0)