refactor(core): move database schema ownership (#29068)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
Dax
2026-05-30 21:08:38 -04:00
committed by GitHub
parent 6bcb9cb9bb
commit 7f571d36ea
390 changed files with 11127 additions and 9164 deletions

View File

@@ -5,8 +5,8 @@ import { Deferred, Effect, Layer } from "effect"
import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
import fs from "fs/promises"
import path from "path"
import { disposeAllInstances, provideInstance, TestInstance, tmpdirScoped } from "../fixture/fixture"
import { Bus } from "../../src/bus"
import { disposeAllInstances, provideInstance, testInstanceStoreLayer, TestInstance, tmpdirScoped } from "../fixture/fixture"
import { EventV2Bridge } from "../../src/event-v2-bridge"
import { FileWatcher } from "../../src/file/watcher"
import { Git } from "../../src/git"
import { Vcs } from "@/project/vcs"
@@ -19,11 +19,12 @@ import { testEffect } from "../lib/effect"
const weird = process.platform === "win32" ? "space file.txt" : "tab\tfile.txt"
const layer = Layer.mergeAll(
Vcs.layer.pipe(Layer.provideMerge(Git.defaultLayer), Layer.provideMerge(Bus.layer)),
Vcs.layer.pipe(Layer.provideMerge(Git.defaultLayer), Layer.provideMerge(EventV2Bridge.defaultLayer)),
CrossSpawnSpawner.defaultLayer,
AppFileSystem.defaultLayer,
)
const it = testEffect(layer)
const worktreeIt = testEffect(Layer.mergeAll(layer, testInstanceStoreLayer))
const git = Effect.fn("VcsTest.git")(function* (cwd: string, args: string[]) {
const result = yield* Git.Service.use((git) => git.run(args, { cwd }))
@@ -47,13 +48,15 @@ const init = Effect.fn("VcsTest.init")(function* () {
})
const nextBranchUpdate = Effect.fn("VcsTest.nextBranchUpdate")(function* () {
const bus = yield* Bus.Service
const events = yield* EventV2Bridge.Service
const updated = yield* Deferred.make<string | undefined>()
const off = yield* bus.subscribeCallback(Vcs.Event.BranchUpdated, (evt) => {
Effect.runSync(Deferred.succeed(updated, evt.properties.branch))
const off = yield* events.listen((event) => {
if (event.type === Vcs.Event.BranchUpdated.type)
Deferred.doneUnsafe(updated, Effect.succeed((event.data as typeof Vcs.Event.BranchUpdated.data.Type).branch))
return Effect.void
})
yield* Effect.addFinalizer(() => Effect.sync(off))
yield* Effect.addFinalizer(() => off)
return updated
})
@@ -62,9 +65,9 @@ const publishHeadChangeUntil = Effect.fn("VcsTest.publishHeadChangeUntil")(funct
pending: Deferred.Deferred<string | undefined>,
head: string,
) {
const bus = yield* Bus.Service
const events = yield* EventV2Bridge.Service
for (let i = 0; i < 50; i++) {
yield* bus.publish(FileWatcher.Event.Updated, { file: head, event: "change" })
yield* events.publish(FileWatcher.Event.Updated, { file: head, event: "change" })
if (yield* Deferred.isDone(pending)) return
yield* Effect.sleep("10 millis")
}
@@ -183,7 +186,7 @@ describe("Vcs diff", () => {
{ git: true },
)
it.live("detects current branch from the active worktree", () =>
worktreeIt.live("detects current branch from the active worktree", () =>
Effect.gen(function* () {
const tmp = yield* tmpdirScoped({ git: true })
const wt = yield* tmpdirScoped()