Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/opencode/test/fixture/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,11 @@ export function tmpdirScoped<E = never, R = never>(options?: {
}

export const provideInstance =
(directory: string) =>
(input: string | InstanceStore.LoadInput) =>
<A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R | InstanceStore.Service> =>
InstanceStore.Service.use((store) => store.provide({ directory }, self))
InstanceStore.Service.use((store) =>
store.provide(typeof input === "string" ? { directory: input } : input, self),
)

export const provideInstanceEffect =
(directory: string) =>
Expand Down
24 changes: 16 additions & 8 deletions packages/opencode/test/memory/memory-global-identity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,21 @@ describe("MEM-PR01-R1-03: memory is inert once the identity row is retired", ()
() =>
Effect.gen(function* () {
const dir = yield* tmpdirScoped({ git: true })
yield* provideInstance(dir)(
// Resolve the identity ONCE and hand it to the instance store: the
// boot-time resolution runs in a separate Effect graph (own Database)
// and can transiently degrade to the global identity on loaded CI
// runners (git failures are silently swallowed), which would make the
// stamped context and this body disagree — failing the search closed.
const project = yield* Project.Service
const { project: info } = yield* project.fromDirectory(dir)
expect(info.id).not.toBe(ProjectV2.ID.global)
yield* provideInstance({ directory: dir, worktree: info.worktree, project: info })(
Effect.gen(function* () {
const project = yield* Project.Service
const memory = yield* Memory.Service
const configStore = yield* MemoryConfig.Service
const { db } = yield* Database.Service

const { project: info } = yield* project.fromDirectory(dir)
expect(info.id).not.toBe(ProjectV2.ID.global)
yield* project.setInitialized(info.id)
yield* configStore.writeGlobal(baseConfig)

Expand Down Expand Up @@ -193,14 +199,15 @@ describe("MEM-PR01-R1-23: the runtime admission snapshot covers every registered
Effect.gen(function* () {
const dir = yield* tmpdirScoped({ git: true })
const sandbox = yield* tmpdirScoped()
yield* provideInstance(dir)(
const project = yield* Project.Service
const { project: info } = yield* project.fromDirectory(dir)
yield* provideInstance({ directory: dir, worktree: info.worktree, project: info })(
Effect.gen(function* () {
const project = yield* Project.Service
const memory = yield* Memory.Service
const configStore = yield* MemoryConfig.Service
const store = yield* MemoryStore.Service

const { project: info } = yield* project.fromDirectory(dir)
yield* project.setInitialized(info.id)
yield* project.addSandbox(info.id, sandbox)
yield* configStore.writeGlobal(baseConfig)
Expand Down Expand Up @@ -353,14 +360,15 @@ describe("MEM-PR01-00: memory is inert under the shared global identity", () =>
() =>
Effect.gen(function* () {
const dir = yield* tmpdirScoped({ git: true })
yield* provideInstance(dir)(
const project = yield* Project.Service
const { project: info } = yield* project.fromDirectory(dir)
expect(info.id).not.toBe(ProjectV2.ID.global)
yield* provideInstance({ directory: dir, worktree: info.worktree, project: info })(
Effect.gen(function* () {
const project = yield* Project.Service
const memory = yield* Memory.Service
const configStore = yield* MemoryConfig.Service

const { project: info } = yield* project.fromDirectory(dir)
expect(info.id).not.toBe(ProjectV2.ID.global)
yield* project.setInitialized(info.id)
yield* configStore.writeGlobal(baseConfig)

Expand Down
Loading