GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(session,server,tui,core,enterprise,sdk): wave 7–11 hardening — au… · anomalyco/opencode@56feb5c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages
    • core
      • schema.json
      • src
        • background-job.ts
        • cross-spawn-spawner.ts
        • database
          • migration.gen.ts
          • migration
            • 20260917225834_wave7_l3_event_tombstone_and_shell_index.ts
          • schema.gen.ts
        • event.ts
        • event
          • sql.ts
        • fs-util.ts
        • permission.ts
        • session
          • projector.ts
          • sql.ts
        • snapshot.ts
        • util
          • wildcard.ts
      • test
        • background-job.test.ts
        • database-migration.test.ts
        • event.test.ts
        • process
          • process.test.ts
        • session-projector.test.ts
        • wildcard.test.ts
    • enterprise
      • src
        • core
          • share.ts
          • storage.ts
        • routes
          • api
            • [...path].ts
          • share
            • [shareID].tsx
      • test/core
        • share-schema.test.ts
        • share.test.ts
    • opencode
      • src
        • acp
          • event.ts
          • service.ts
        • background
          • job.ts
        • cli
          • cmd
            • acp.ts
            • import.ts
            • run.ts
            • run
              • runtime.stdin.ts
              • stream.transport.ts
              • subagent-data.ts
            • tui.ts
          • tui
            • worker.ts
        • control-plane
          • workspace.ts
        • index.ts
        • lsp
          • client.ts
          • lsp.ts
        • mcp
          • catalog.ts
          • index.ts
          • oauth-callback.ts
        • permission
          • index.ts
        • plugin/openai
          • ws-pool.ts
        • provider
          • auth.ts
          • provider.ts
        • server
          • routes/instance/httpapi
            • groups
              • experimental.ts
              • session.ts
              • sync.ts
            • handlers
              • event-desync.ts
              • event.ts
              • experimental.ts
              • global.ts
              • session.ts
              • sse-frame.ts
              • sync.ts
            • middleware
              • proxy.ts
              • workspace-routing.ts
          • shared
            • ui.ts
            • workspace-routing.ts
        • session
          • compaction.ts
          • durable-parent-cache.ts
          • message-v2.ts
          • processor.ts
          • prompt.ts
          • retry.ts
          • session.ts
          • summary.ts
          • tools.ts
        • share
          • share-next.ts
        • tool
          • apply_patch.ts
          • edit.ts
          • external-directory.ts
          • shell.ts
          • task.ts
          • webfetch.ts
          • write.ts
        • util
          • plugin-env.ts
          • process.ts
      • test
        • acp
          • event.test.ts
        • cli
          • acp
            • lifecycle.test.ts
          • help/__snapshots__
            • help-snapshots.test.ts.snap
          • import.test.ts
          • run
            • subagent-data.test.ts
        • mcp
          • catalog.test.ts
          • lifecycle.test.ts
        • permission
          • next.test.ts
        • plugin
          • openai-ws.test.ts
        • provider
          • sse-watchdog.test.ts
        • server
          • event-desync.test.ts
          • httpapi-experimental.test.ts
          • httpapi-query-schema-drift.test.ts
          • httpapi-sync.test.ts
          • httpapi-v2-location.test.ts
          • httpapi-workspace-routing.test.ts
          • session-message-diff-events.test.ts
          • sse-frame.test.ts
          • workspace-proxy.test.ts
          • workspace-routing.test.ts
        • session
          • compaction.test.ts
          • durable-parent-cache.test.ts
          • message-v2.test.ts
          • processor-effect.test.ts
          • prompt.test.ts
          • retry.test.ts
          • snapshot-tool-race.test.ts
          • tools.test.ts
        • share
          • share-next.test.ts
        • skill
          • skill.test.ts
        • tool
          • apply_patch.test.ts
          • external-directory.test.ts
          • shell.test.ts
          • webfetch.test.ts
        • util
          • process.test.ts
    • sdk/js
      • src
        • process.ts
        • server.ts
        • v2
          • server.ts
      • test
        • process.test.ts
    • server/src
      • handlers
        • pty.ts
      • location.ts
    • tui/src/context
      • data.tsx
      • local.tsx
      • project.tsx
      • sdk.tsx
      • sync.tsx

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/core/schema.json‎

Copy file name to clipboardExpand all lines: packages/core/schema.json
+34-2Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"version": "7",
33
"dialect": "sqlite",
4-
"id": "9f5f9a05-d53b-40e9-abd3-67e93c5f9829",
5-
"prevIds": ["f3e4e554-6717-4c4c-87e3-4cda84056492"],
4+
"id": "1c58c2e1-5cbe-4c41-b1b9-62b6e04da763",
5+
"prevIds": ["9f5f9a05-d53b-40e9-abd3-67e93c5f9829"],
66
"ddl": [
77
{
88
"name": "workspace",
@@ -544,6 +544,16 @@
544544
"entityType": "columns",
545545
"table": "event"
546546
},
547+
{
548+
"type": "text",
549+
"notNull": false,
550+
"autoincrement": false,
551+
"default": null,
552+
"generated": null,
553+
"name": "tombstone_digest",
554+
"entityType": "columns",
555+
"table": "event"
556+
},
547557
{
548558
"type": "text",
549559
"notNull": false,
@@ -2087,6 +2097,28 @@
20872097
"entityType": "indexes",
20882098
"table": "session_message"
20892099
},
2100+
{
2101+
"columns": [
2102+
{
2103+
"value": "session_id",
2104+
"isExpression": false
2105+
},
2106+
{
2107+
"value": "json_extract(\"data\", '$.callID')",
2108+
"isExpression": true
2109+
},
2110+
{
2111+
"value": "seq",
2112+
"isExpression": false
2113+
}
2114+
],
2115+
"isUnique": false,
2116+
"where": null,
2117+
"origin": "manual",
2118+
"name": "session_message_session_call_id_seq_idx",
2119+
"entityType": "indexes",
2120+
"table": "session_message"
2121+
},
20902122
{
20912123
"columns": [
20922124
{
Collapse file

‎packages/core/src/background-job.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/background-job.ts
+11-3Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export * as BackgroundJob from "./background-job"
22

3-
import { Cause, Clock, Context, Deferred, Effect, Exit, Layer, Scope, SynchronizedRef } from "effect"
3+
import { Cause, Clock, Context, Deferred, Effect, Exit, Layer, Scope, Schema, SynchronizedRef } from "effect"
44
import { Identifier } from "./id/id"
55
import { makeGlobalNode } from "./effect/app-node"
66

@@ -87,13 +87,18 @@ export type WaitResult = {
8787
timedOut: boolean
8888
}
8989

90+
/** A promoted-result waiter raced a job that is no longer retained (missing or pruned). */
91+
export class NotFoundError extends Schema.TaggedErrorClass<NotFoundError>()("BackgroundJob.NotFound", {
92+
id: Schema.String,
93+
}) {}
94+
9095
export interface Interface {
9196
readonly list: () => Effect.Effect<Info[]>
9297
readonly get: (id: string) => Effect.Effect<Info | undefined>
9398
readonly start: (input: StartInput) => Effect.Effect<Info>
9499
readonly extend: (input: ExtendInput) => Effect.Effect<boolean>
95100
readonly wait: (input: WaitInput) => Effect.Effect<WaitResult>
96-
readonly waitForPromotion: (id: string) => Effect.Effect<Info>
101+
readonly waitForPromotion: (id: string) => Effect.Effect<Info | undefined, NotFoundError>
97102
readonly promote: (id: string) => Effect.Effect<Info | undefined>
98103
readonly cancel: (id: string) => Effect.Effect<Info | undefined>
99104
}
@@ -336,8 +341,11 @@ export const make = Effect.gen(function* () {
336341

337342
const waitForPromotion: Interface["waitForPromotion"] = Effect.fn("BackgroundJob.waitForPromotion")(function* (id) {
338343
const job = (yield* SynchronizedRef.get(state.jobs)).get(id)
339-
if (!job || job.info.status !== "running" || !job.promoted) return yield* Effect.never
344+
if (!job) return yield* new NotFoundError({ id })
340345
if (job.info.metadata?.background === true) return snapshot(job)
346+
// A settled job can never be promoted; resolving its terminal snapshot avoids a waiter hang.
347+
if (job.info.status !== "running") return snapshot(job)
348+
if (!job.promoted) return yield* Effect.never
341349
return yield* Deferred.await(job.promoted)
342350
})
343351

Collapse file

‎packages/core/src/cross-spawn-spawner.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/cross-spawn-spawner.ts
+22-14Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ import { filesystem, path } from "./effect/app-node-platform"
2929

3030
const toError = (err: unknown): Error => (err instanceof globalThis.Error ? err : new globalThis.Error(String(err)))
3131

32+
/** Teardown bound when `forceKillAfter` is unset, so a child that ignores the kill signal cannot stall scope exit. */
33+
const DEFAULT_FORCE_KILL_AFTER = "5 seconds" as const
34+
3235
const toTag = (err: NodeJS.ErrnoException): PlatformError.SystemErrorTag => {
3336
switch (err.code) {
3437
case "ENOENT":
@@ -284,8 +287,12 @@ export const make = Effect.gen(function* () {
284287
proc.on("spawn", () => {
285288
resume(Effect.succeed([proc, signal]))
286289
})
287-
return Effect.sync(() => {
290+
return Effect.suspend(() => {
288291
proc.kill("SIGTERM")
292+
return Effect.timeoutOrElse(Deferred.await(signal), {
293+
duration: command.options.forceKillAfter ?? DEFAULT_FORCE_KILL_AFTER,
294+
orElse: () => Effect.sync(() => void proc.kill("SIGKILL")),
295+
}).pipe(Effect.asVoid)
289296
})
290297
})
291298

@@ -315,10 +322,15 @@ export const make = Effect.gen(function* () {
315322
command: ChildProcess.StandardCommand,
316323
proc: NodeChildProcess.ChildProcess,
317324
signal: NodeJS.Signals,
325+
exited: Effect.Effect<boolean>,
318326
) =>
319327
Effect.suspend(() => {
320328
if (proc.kill(signal)) return Effect.void
321-
return Effect.fail(toPlatformError("kill", new Error("Failed to kill child process"), command))
329+
return exited.pipe(
330+
Effect.flatMap((done) =>
331+
done ? Effect.void : Effect.fail(toPlatformError("kill", new Error("Failed to kill child process"), command)),
332+
),
333+
)
322334
})
323335

324336
const timeout =
@@ -335,9 +347,8 @@ export const make = Effect.gen(function* () {
335347
) => Effect.Effect<A, E, R>,
336348
) => {
337349
const signal = opts?.killSignal ?? "SIGTERM"
338-
if (Predicate.isUndefined(opts?.forceKillAfter)) return f(command, proc, signal)
339350
return Effect.timeoutOrElse(f(command, proc, signal), {
340-
duration: opts.forceKillAfter,
351+
duration: opts?.forceKillAfter ?? DEFAULT_FORCE_KILL_AFTER,
341352
orElse: () => f(command, proc, "SIGKILL"),
342353
})
343354
}
@@ -389,15 +400,13 @@ export const make = Effect.gen(function* () {
389400
return yield* Effect.void
390401
}
391402
const send = (s: NodeJS.Signals) =>
392-
Effect.catch(killGroup(command, proc, s), () => killOne(command, proc, s))
403+
Effect.catch(killGroup(command, proc, s), () => killOne(command, proc, s, Deferred.isDone(signal)))
393404
const sig = command.options.killSignal ?? "SIGTERM"
394405
const attempt = send(sig).pipe(Effect.andThen(Deferred.await(signal)), Effect.asVoid)
395-
const escalated = command.options.forceKillAfter
396-
? Effect.timeoutOrElse(attempt, {
397-
duration: command.options.forceKillAfter,
398-
orElse: () => send("SIGKILL").pipe(Effect.andThen(Deferred.await(signal)), Effect.asVoid),
399-
})
400-
: attempt
406+
const escalated = Effect.timeoutOrElse(attempt, {
407+
duration: command.options.forceKillAfter ?? DEFAULT_FORCE_KILL_AFTER,
408+
orElse: () => send("SIGKILL").pipe(Effect.andThen(Deferred.await(signal)), Effect.asVoid),
409+
})
401410
return yield* Effect.ignore(escalated)
402411
}),
403412
)
@@ -427,11 +436,10 @@ export const make = Effect.gen(function* () {
427436
kill: (opts?: ChildProcess.KillOptions) => {
428437
const sig = opts?.killSignal ?? "SIGTERM"
429438
const send = (s: NodeJS.Signals) =>
430-
Effect.catch(killGroup(command, proc, s), () => killOne(command, proc, s))
439+
Effect.catch(killGroup(command, proc, s), () => killOne(command, proc, s, Deferred.isDone(signal)))
431440
const attempt = send(sig).pipe(Effect.andThen(Deferred.await(signal)), Effect.asVoid)
432-
if (!opts?.forceKillAfter) return attempt
433441
return Effect.timeoutOrElse(attempt, {
434-
duration: opts.forceKillAfter,
442+
duration: opts?.forceKillAfter ?? DEFAULT_FORCE_KILL_AFTER,
435443
orElse: () => send("SIGKILL").pipe(Effect.andThen(Deferred.await(signal)), Effect.asVoid),
436444
})
437445
},
Collapse file

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

Copy file name to clipboardExpand all lines: packages/core/src/database/migration.gen.ts
+1Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎packages/core/src/database/migration/20260917225834_wave7_l3_event_tombstone_and_shell_index.ts‎

Copy file name to clipboard
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Effect } from "effect"
2+
import type { DatabaseMigration } from "../migration"
3+
4+
export default {
5+
id: "20260917225834_wave7_l3_event_tombstone_and_shell_index",
6+
up(tx) {
7+
return Effect.gen(function* () {
8+
yield* tx.run(`ALTER TABLE \`event\` ADD \`tombstone_digest\` text;`)
9+
yield* tx.run(
10+
`CREATE INDEX \`session_message_session_call_id_seq_idx\` ON \`session_message\` (\`session_id\`,json_extract("data", '$.callID'),\`seq\`);`,
11+
)
12+
})
13+
},
14+
} satisfies DatabaseMigration.Migration
Collapse file

‎packages/core/src/database/schema.gen.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/database/schema.gen.ts
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export default {
8383
\`seq\` integer NOT NULL,
8484
\`type\` text NOT NULL,
8585
\`data\` text NOT NULL,
86+
\`tombstone_digest\` text,
8687
CONSTRAINT \`fk_event_aggregate_id_event_sequence_aggregate_id_fk\` FOREIGN KEY (\`aggregate_id\`) REFERENCES \`event_sequence\`(\`aggregate_id\`) ON DELETE CASCADE
8788
);
8889
`)
@@ -275,6 +276,9 @@ export default {
275276
yield* tx.run(
276277
`CREATE INDEX \`session_message_session_time_created_id_idx\` ON \`session_message\` (\`session_id\`,\`time_created\`,\`id\`);`,
277278
)
279+
yield* tx.run(
280+
`CREATE INDEX \`session_message_session_call_id_seq_idx\` ON \`session_message\` (\`session_id\`,json_extract("data", '$.callID'),\`seq\`);`,
281+
)
278282
yield* tx.run(`CREATE INDEX \`session_project_idx\` ON \`session\` (\`project_id\`);`)
279283
yield* tx.run(`CREATE INDEX \`session_workspace_idx\` ON \`session\` (\`workspace_id\`);`)
280284
yield* tx.run(`CREATE INDEX \`session_parent_idx\` ON \`session\` (\`parent_id\`);`)

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.