Skip to content
This repository was archived by the owner on Nov 7, 2026. It is now read-only.

Commit c6056f3

Browse files
authored
chore: upgrade effect to 4.1.0 and fix a SQLite lock-up on interrupt (anomalyco#60651)
1 parent 12f7e1b commit c6056f3

33 files changed

Lines changed: 7569 additions & 2196 deletions

‎bun.lock‎

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

‎package.json‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545
"packages/stats/*"
4646
],
4747
"catalog": {
48-
"@effect/opentelemetry": "4.0.6",
49-
"@effect/platform-node": "4.0.6",
50-
"@effect/platform-node-shared": "4.0.6",
51-
"@effect/sql-sqlite-bun": "4.0.6",
48+
"@effect/opentelemetry": "4.1.0",
49+
"@effect/platform-node": "4.1.0",
50+
"@effect/platform-node-shared": "4.1.0",
51+
"@effect/sql-sqlite-bun": "4.1.0",
5252
"@npmcli/arborist": "9.4.0",
5353
"@types/bun": "1.4.3",
5454
"@types/cross-spawn": "6.0.6",
@@ -79,7 +79,7 @@
7979
"dompurify": "3.4.17",
8080
"drizzle-kit": "1.0.0-rc.5-ab785fc",
8181
"drizzle-orm": "1.0.0-rc.5-169397b",
82-
"effect": "4.0.6",
82+
"effect": "4.1.0",
8383
"fast-check": "4.9.0",
8484
"cross-spawn": "7.0.6",
8585
"hono": "4.13.13",

‎packages/ai/test/recorded-test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { HttpRecorder } from "@opencode/http-recorder"
2-
import { NodeSocket } from "@effect/platform-node"
2+
import { NodeWS } from "@effect/platform-node"
33
import { Effect, Layer } from "effect"
44
import { Socket } from "effect/socket"
55
import * as path from "node:path"
@@ -100,7 +100,7 @@ export const recordedTests = (options: RecordedTestsOptions) =>
100100
...recorderOptions,
101101
directory: FIXTURES_DIR,
102102
metadata: recorderMetadata,
103-
}).pipe(Layer.provide(NodeSocket.layerWebSocketConstructorWS))
103+
}).pipe(Layer.provide(NodeWS.layerWebSocketConstructor))
104104
const layer = Layer.mergeAll(
105105
requestExecutor,
106106
LLMClient.layer.pipe(Layer.provide(requestExecutor)),

‎packages/app/src/composer/schema.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ export const LineComment = Persistence.struct({
392392
export type LineComment = typeof LineComment.Type
393393

394394
export const CommentStore = Persistence.struct({
395-
comments: Schema.Record(Schema.String, Schema.mutableKey(Persistence.array(LineComment))),
395+
comments: Schema.Record(Schema.String, Persistence.entry(Persistence.array(LineComment))),
396396
})
397397

398398
export type CommentStore = typeof CommentStore.Type

‎packages/app/src/providers/models/selection.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type State = typeof StateSchema.Type
4141

4242
const SessionsSchema = Schema.Record(
4343
Schema.String,
44-
Schema.mutableKey(Persistence.fallback(Schema.UndefinedOr(StateSchema), () => undefined)),
44+
Persistence.entry(Persistence.fallback(Schema.UndefinedOr(StateSchema), () => undefined)),
4545
)
4646

4747
const Current = Persistence.struct({ session: SessionsSchema })

‎packages/app/src/runtime/persistence/README.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ migration rules remain explicit in their schemas.
4343
each field's optionality and codec. It does not add defaults or error recovery.
4444
- `Persistence.record(valueSchema)` creates a mutable string-keyed record, defaulting
4545
missing or invalid records to a fresh `{}`. Its value schema determines entry
46-
recovery: pass `Persistence.optional(valueSchema)` to discard only invalid entries,
47-
or `Persistence.fallback(valueSchema, factory)` to replace those entries.
46+
recovery: pass `valueSchema.pipe(Schema.catchDecoding(() => Effect.succeed(Option.none())))`
47+
to discard only invalid entries, or `Persistence.fallback(valueSchema, factory)` to
48+
replace those entries. Don't pass `Persistence.optional(valueSchema)`: Effect rejects
49+
optional record values, and the record throws when it is built.
4850
- `Persistence.array(schema)` defaults to an empty mutable array and discards
4951
invalid entries individually. Valid entries still pass through their codecs.
5052
- Recovery is not a substitute for an explicit historical shape transformation.

‎packages/app/src/runtime/persistence/schema.test.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, test } from "bun:test"
2-
import { Effect, Predicate, Schema, SchemaGetter } from "effect"
2+
import { Effect, Option, Predicate, Schema, SchemaGetter } from "effect"
33
import { Persistence } from "./schema"
44

55
describe("persistence schemas", () => {
@@ -87,7 +87,9 @@ describe("persistence schemas", () => {
8787
})
8888

8989
const decode = Schema.decodeUnknownSync(schema)
90-
expect(decode({ general: { expanded: true, theme: "dark", nested: { keep: true } }, other: { flag: true } })).toEqual({
90+
expect(
91+
decode({ general: { expanded: true, theme: "dark", nested: { keep: true } }, other: { flag: true } }),
92+
).toEqual({
9193
general: { mode: "full", theme: "dark", nested: { keep: true } },
9294
other: { flag: true },
9395
})
@@ -169,7 +171,7 @@ describe("persistence schemas", () => {
169171
first.changed = true
170172
expect(decode(undefined)).toEqual({})
171173

172-
const recover = Persistence.record(Persistence.optional(Schema.Boolean))
174+
const recover = Persistence.record(Schema.Boolean.pipe(Schema.catchDecoding(() => Effect.succeed(Option.none()))))
173175
const state = Schema.decodeUnknownSync(recover)({ valid: true, invalid: "true" })
174176
expect(state).toEqual({ valid: true })
175177
expect(Schema.encodeSync(recover)(state)).toEqual({ valid: true })

‎packages/app/src/runtime/persistence/schema.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,18 @@ export function struct<const Fields extends Schema.Struct.Fields>(fields: Fields
9797
return Schema.Struct(fields).mapFields(Struct.map(Schema.mutableKey))
9898
}
9999

100+
// Record values can't have an optional encoded side (as `fallback` does), so each entry decodes from
101+
// `Unknown` and keeps its own recovery.
102+
export function entry<S extends Schema.ConstraintCodec<unknown, unknown>>(schema: S) {
103+
return Schema.mutableKey(
104+
Schema.Unknown.pipe(
105+
Schema.decodeTo(schema, { decode: SchemaGetter.passthrough(), encode: SchemaGetter.passthrough() }),
106+
),
107+
)
108+
}
109+
100110
export function record<S extends Schema.ConstraintCodec<unknown, unknown>>(schema: S) {
101-
const entries = Schema.Record(Schema.String, Schema.mutableKey(schema))
111+
const entries = Schema.Record(Schema.String, entry(schema))
102112

103113
return fallback(entries, () => Schema.decodeUnknownSync(entries)({}))
104114
}

‎packages/cli/test/updater-install.test.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Global } from "@opencode/util/global"
55
import { AppProcess } from "@opencode/util/process"
66
import { expect, spyOn, test } from "bun:test"
77
import { Effect, FileSystem, Layer, PlatformError, Stream } from "effect"
8-
import { ChildProcess, ChildProcessSpawner } from "effect/process"
8+
import { ChildProcessSpawner } from "effect/process"
99
import { existsSync, readdirSync, readFileSync } from "node:fs"
1010
import path from "node:path"
1111
import { Updater } from "../src/services/updater"
@@ -16,7 +16,10 @@ const it = testEffect(NodeServices.layer)
1616
declare const OPENCODE_CLI_NAME: string | undefined
1717

1818
function fixture(
19-
respond: (command: ChildProcess.StandardCommand) => Partial<AppProcess.RunResult> & {
19+
respond: (command: {
20+
readonly command: string
21+
readonly args: ReadonlyArray<string>
22+
}) => Partial<AppProcess.RunResult> & {
2023
error?: AppProcess.AppProcessError
2124
} = () => ({}),
2225
name = "@opencode/cli",
@@ -110,11 +113,12 @@ function fixture(
110113
run: (command) =>
111114
Effect.suspend(() => {
112115
if (command._tag !== "StandardCommand") return Effect.die("Unexpected piped install command")
113-
const lookup = command.command === "git" && command.args[0] === "--exec-path"
114-
if (!lookup) commands.push([command.command, ...command.args])
116+
const args = command.args.map(String)
117+
const lookup = command.command === "git" && args[0] === "--exec-path"
118+
if (!lookup) commands.push([command.command, ...args])
115119
const result = lookup
116120
? { stdout: Buffer.from(`${path.join(git, "mingw64", "libexec", "git-core")}\n`) }
117-
: respond(command)
121+
: respond({ command: command.command, args })
118122
if (result.error) return Effect.fail(result.error)
119123
return Effect.succeed({
120124
command: command.command,

‎packages/core/src/config/plugin/skill-scan.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,27 @@ export const scan = Effect.fn("SkillScan.scan")(function* (root: string) {
1818
entries.filter((entry) => !entry.name.startsWith(".") && !FSUtil.ignoredDirectories.includes(entry.name)),
1919
(entry) => {
2020
const target = path.join(item.directory, entry.name)
21-
if (entry.type !== "symlink") return Effect.succeed({ name: entry.name, path: target, type: entry.type })
21+
if (entry.type !== "SymbolicLink") return Effect.succeed({ name: entry.name, path: target, type: entry.type })
2222
return fs.stat(target).pipe(
23-
Effect.map((info) => (info.type === "Directory" ? "directory" : info.type === "File" ? "file" : "other")),
24-
Effect.orElseSucceed(() => "other" as const),
23+
Effect.map((info) => info.type),
24+
Effect.orElseSucceed(() => "Unknown" as const),
2525
Effect.map((type) => ({ name: entry.name, path: target, type })),
2626
)
2727
},
2828
)
29-
const skill = children.find((child) => child.type === "file" && child.name === "SKILL.md")
29+
const skill = children.find((child) => child.type === "File" && child.name === "SKILL.md")
3030
if (skill) {
3131
files.push(skill.path)
3232
continue
3333
}
3434
if (item.depth === 0)
3535
files.push(
36-
...children.filter((child) => child.type === "file" && child.name.endsWith(".md")).map((child) => child.path),
36+
...children.filter((child) => child.type === "File" && child.name.endsWith(".md")).map((child) => child.path),
3737
)
3838
if (item.depth < MAX_DEPTH)
3939
queue.push(
4040
...children
41-
.filter((child) => child.type === "directory")
41+
.filter((child) => child.type === "Directory")
4242
.map((child) => ({ directory: child.path, depth: item.depth + 1 })),
4343
)
4444
}

0 commit comments

Comments
 (0)