@sixb/pg 0.1.24 → 0.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../src/migrations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAGV,YAAY,EACZ,aAAa,EACb,oBAAoB,EACrB,MAAM,oBAAoB,CAAA;AAqH3B,OAAO,KAAK,EAAe,GAAG,EAAa,MAAM,aAAa,CAAA;AAG9D,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACrC;AAED,eAAO,MAAM,2BAA2B,wBAAwB,CAAA;AAEhE,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC,wBAAwB,CAAC,CAE1F;AAED,wBAAgB,MAAM,CACpB,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC/D,OAAO,GAAE,oBAAyB,GACjC,aAAa,CAAC,wBAAwB,CAAC,CAEzC;AAED,wBAAgB,8BAA8B,CAC5C,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,MAAM,GACjB,SAAS,eAAe,EAAE,CAQ5B;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE;IAC7C,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAA;IACjB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC,wBAAwB,CAAC,CAAA;CAC5D,GAAG,eAAe,CAqBlB;AAED,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,GAAG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wBAAwB,CAAC,CAAA;CAC5D,GAAG,eAAe,CAqBlB;AAED,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMxF;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5E;AAED,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAKrD;AAuKD,eAAO,MAAM,yBAAyB,wCAuFpC,CAAA"}
@@ -1,2 +1,3 @@
1
+ export { PgSortIndexCatalog } from "./query-indexes";
1
2
  export { PgObjectStorage } from "./storage";
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/objects/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/objects/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"query-compiler.d.ts","sourceRoot":"","sources":["../../src/objects/query-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAEhB,KAAK,oBAAoB,EAGzB,KAAK,eAAe,EACrB,MAAM,YAAY,CAAA;AAQnB,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,OAAO,CAAA;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B;AAED,MAAM,WAAW,qBAAqB;IACpC,cAAc,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAA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xD,YAAY,UAAQ,GACnB,oBAAoB,CAiCtB;AA6mCD,+FAA+F;AAC/F,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,oBAAoB,GAAG,iBAAiB,CA6DnF;AAohBD,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,eAAe,GAAG,SAAS,GAAG,OAAO,CAEjF"}
@@ -37,7 +37,25 @@ export declare function ensurePgObjectQueryIndexes(sql: SQL | ReservedSQL, schem
37
37
  export declare function sortIndexBound(index: Extract<PgObjectQueryIndex, {
38
38
  kind: "sort";
39
39
  }>): string;
40
+ type PgSortIndex = Extract<PgObjectQueryIndex, {
41
+ kind: "sort";
42
+ }>;
43
+ /**
44
+ * The prepared sort indexes of one schema, read from their catalog comments at most once a minute.
45
+ *
46
+ * The read costs more than many of the queries it serves, so queries share one per minute.
47
+ * A stale read cannot change a result: the bounded read and its overflow branch together cover
48
+ * every row whether or not the index exists, so an index prepared since the last read is only
49
+ * used a little later. Preparing in this process refreshes at once.
50
+ */
51
+ export declare class PgSortIndexCatalog {
52
+ #private;
53
+ /** Read through the caller's client, so a transaction never waits for a second connection. */
54
+ indexes(sql: SQLClient): Promise<readonly PgSortIndex[]>;
55
+ invalidate(): void;
56
+ }
40
57
  /** Only split a flat, bounded ordered read; joins, nested limits and projections keep the
41
58
  * general compiler. Its unrestricted fallback always preserves semantics. */
42
- export declare function findPgSortIndexBound(sql: SQLClient, projectId: string, query: ObjectQuery): Promise<string | undefined>;
59
+ export declare function findPgSortIndexBound(sql: SQLClient, catalog: PgSortIndexCatalog, projectId: string, query: ObjectQuery): Promise<string | undefined>;
60
+ export {};
43
61
  //# sourceMappingURL=query-indexes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-indexes.d.ts","sourceRoot":"","sources":["../../src/objects/query-indexes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG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EACd,OAAO,EAAE,kBAAkB,EAC3B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,WAAW,GACjB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAuE7B"}
@@ -2,13 +2,15 @@ import type { CountObjectsInput, CountObjectsResult, ExistsObjectsInput, ExistsO
2
2
  import type { SQLClient } from "../pg-client";
3
3
  import type { PgAggregateAdmission } from "./aggregate-admission";
4
4
  import { type PgObjectQuerySource } from "./query-compiler";
5
+ import { type PgSortIndexCatalog } from "./query-indexes";
5
6
  import type { PgSelectedObjectReadSource } from "./read-scope";
6
7
  /** Execute object and link reads, using prepared access paths when the query shape allows it. */
7
8
  export declare class PgObjectReader {
8
9
  private readonly sql;
9
10
  private readonly source;
10
11
  private readonly aggregateAdmission?;
11
- constructor(sql: SQLClient, source: PgObjectQuerySource | PgSelectedObjectReadSource, aggregateAdmission?: PgAggregateAdmission | undefined);
12
+ private readonly sortIndexes?;
13
+ constructor(sql: SQLClient, source: PgObjectQuerySource | PgSelectedObjectReadSource, aggregateAdmission?: PgAggregateAdmission | undefined, sortIndexes?: PgSortIndexCatalog | undefined);
12
14
  private assertVectorSearch;
13
15
  queryObjects(params: QueryObjectsInput): Promise<QueryObjectsResult>;
14
16
  /** Use the ordered traversal path only when its bounded probe finds a broad fanout. */
@@ -1 +1 @@
1
- {"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../src/objects/reader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,SAAS,EAAgB,MAAM,cAAc,CAAA;AAC3D,OAAO,KAAK,EAAE,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,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,aAAa,EAAE,CAAC,CAAC;IAuFzC,UAAU,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAuG1E,IAAI,CACR,MAAM,EAAE,UAAU,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAC/C,OAAO,CAAC;QAAE,OAAO,EAAE,SAAS,SAAS,EAAE,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAmF/E;AAwDD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAIxD"}
@@ -1,11 +1,13 @@
1
1
  import type { CompiledConditionalObjectReadScope, CompiledSelectedObjectReadScope, CountObjectsInput, CountObjectsResult, ExistsObjectsInput, ExistsObjectsResult, FacetObjectsInput, FacetObjectsResult, LinkBatchKey, LinkDirection, ObjectBatchKey, ObjectLinkRow, ObjectQueryCapabilities, ObjectReadExecutionLimits, ObjectReadStorage, ObjectRow, ObjectStorage, QueryObjectLinksInput, QueryObjectLinksResult, QueryObjectsInput, QueryObjectsResult } from "@sixb/core/storage";
2
2
  import { type PgStoreClient } from "../transactions";
3
+ import { PgSortIndexCatalog } from "./query-indexes";
3
4
  /** PostgreSQL object provider; interactive reads share one source-aware reader. */
4
5
  export declare class PgObjectStorage implements ObjectStorage {
5
6
  private readonly sql;
7
+ private readonly sortIndexes;
6
8
  private readonly aggregateAdmission?;
7
9
  private readonly reader;
8
- constructor(sql: PgStoreClient, maxConcurrentAggregates?: number);
10
+ constructor(sql: PgStoreClient, sortIndexes?: PgSortIndexCatalog, maxConcurrentAggregates?: number);
9
11
  queryCapabilities(): ObjectQueryCapabilities;
10
12
  createSelectedReadScope(params: {
11
13
  projectId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/objects/storage.ts"],"names":[],"mappings":"AAC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AAC;QAAE,OAAO,EAAE,SAAS,SAAS,EAAE,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAGhF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sixb/pg",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "description": "PostgreSQL storage provider for Sixb",
5
5
  "keywords": [
6
6
  "sixb",
@@ -40,10 +40,10 @@
40
40
  "postgres": "^3.4.5"
41
41
  },
42
42
  "peerDependencies": {
43
- "@sixb/core": "0.1.24"
43
+ "@sixb/core": "0.1.26"
44
44
  },
45
45
  "devDependencies": {
46
- "@sixb/core": "0.1.24",
46
+ "@sixb/core": "0.1.26",
47
47
  "@types/bun": "latest",
48
48
  "typescript": "^5.7.0"
49
49
  },
@@ -115,6 +115,21 @@ export class PgAgentMessageStore implements AgentMessageStore {
115
115
 
116
116
  async deleteByRunId(input: DeleteAgentMessagesByRunInput): Promise<number> {
117
117
  return runPgTransaction(this.sql, async (tx) => {
118
+ // The run before the thread, the order a spawn takes them in.
119
+ if (input.fence) {
120
+ const [owner] = await tx<{ id: string }[]>`
121
+ SELECT id FROM agent_runs
122
+ WHERE project_id = ${input.projectId} AND id = ${input.fence.runId}
123
+ AND status = 'running' AND execution_token = ${input.fence.executionToken}
124
+ FOR SHARE
125
+ `
126
+ if (!owner) {
127
+ throw new AgentStorageError(
128
+ "execution_lost",
129
+ `[SixbPg] Execution token is no longer current on agent run '${input.fence.runId}'.`
130
+ )
131
+ }
132
+ }
118
133
  const [thread] = await tx<{ id: string }[]>`
119
134
  SELECT id FROM agent_threads
120
135
  WHERE project_id = ${input.projectId} AND id = ${input.threadId}
@@ -32,6 +32,8 @@ export interface AgentThreadRow {
32
32
  title: string | null
33
33
  sandbox_params: JsonValue | string | null
34
34
  sandbox_state: AgentThreadSandboxState | string | null
35
+ runs_on: "computer" | null
36
+ computer_id: string | null
35
37
  status: AgentThreadRecord["status"]
36
38
  active_run_id: string | null
37
39
  last_message_at: Date | string | null
@@ -69,6 +71,7 @@ export interface AgentRunRow {
69
71
  attempt: number | string
70
72
  execution_token: string | null
71
73
  execution_queue_lease_expires_at: Date | string | null
74
+ cancel_requested_at: Date | string | null
72
75
  created_at: Date | string
73
76
  started_at: Date | string | null
74
77
  completed_at: Date | string | null
@@ -142,6 +145,8 @@ export function rowToThreadRecord(row: AgentThreadRow): AgentThreadRecord {
142
145
  : row.sandbox_params
143
146
  ),
144
147
  }),
148
+ ...(row.runs_on == null ? {} : { runsOn: row.runs_on }),
149
+ ...(row.computer_id == null ? {} : { computerId: row.computer_id }),
145
150
  status: row.status,
146
151
  activeRunId: row.active_run_id,
147
152
  lastMessageAt: row.last_message_at ? new Date(row.last_message_at) : undefined,
@@ -169,6 +174,7 @@ export function rowToRunRecord(row: AgentRunRow): AgentRunRecord {
169
174
  queueLeaseExpiresAt: new Date(row.execution_queue_lease_expires_at),
170
175
  }
171
176
  : undefined,
177
+ cancelRequestedAt: row.cancel_requested_at ? new Date(row.cancel_requested_at) : undefined,
172
178
  createdAt: new Date(row.created_at),
173
179
  startedAt: row.started_at ? new Date(row.started_at) : undefined,
174
180
  completedAt: row.completed_at ? new Date(row.completed_at) : undefined,
@@ -28,6 +28,7 @@ import {
28
28
  type ListAgentRunsResult,
29
29
  type ListThreadSubagentsInput,
30
30
  type ReclaimAgentRunInput,
31
+ type RequestAgentRunCancelInput,
31
32
  type StartAgentRunInput,
32
33
  type SubagentRunRecord,
33
34
  } from "@sixb/core/storage"
@@ -283,7 +284,17 @@ export class PgAgentRunStore implements AgentRunStore {
283
284
 
284
285
  async reclaim(input: ReclaimAgentRunInput): Promise<AgentRunRecord> {
285
286
  return runPgTransaction(this.sql, async (tx) => {
286
- await this.lockRunning(tx, input.projectId, input.id)
287
+ const run = await this.lockRunning(tx, input.projectId, input.id)
288
+ if (
289
+ input.ifLapsedBy &&
290
+ run.execution_queue_lease_expires_at !== null &&
291
+ new Date(run.execution_queue_lease_expires_at).getTime() > input.ifLapsedBy.getTime()
292
+ ) {
293
+ throw new AgentStorageError(
294
+ "invalid_state",
295
+ `[SixbPg] Agent run '${input.id}' is still held by its runner, whose lease has not lapsed.`
296
+ )
297
+ }
287
298
  const [row] = await tx<AgentRunRow[]>`
288
299
  UPDATE agent_runs
289
300
  SET
@@ -323,6 +334,25 @@ export class PgAgentRunStore implements AgentRunStore {
323
334
  })
324
335
  }
325
336
 
337
+ async requestCancel(input: RequestAgentRunCancelInput): Promise<AgentRunRecord> {
338
+ const [updated] = await this.sql<AgentRunRow[]>`
339
+ UPDATE agent_runs
340
+ SET cancel_requested_at = ${input.at ?? new Date()}
341
+ WHERE project_id = ${input.projectId} AND id = ${input.id}
342
+ AND status = 'running' AND cancel_requested_at IS NULL
343
+ RETURNING *
344
+ `
345
+ if (updated) return rowToRunRecord(updated)
346
+ const current = await this.getById(input)
347
+ if (!current) {
348
+ throw new AgentStorageError(
349
+ "run_not_found",
350
+ `[SixbPg] Agent run '${input.id}' not found for project '${input.projectId}'.`
351
+ )
352
+ }
353
+ return current
354
+ }
355
+
326
356
  async finish(input: FinishAgentRunInput): Promise<AgentRunRecord> {
327
357
  const completedAt = input.completedAt ?? new Date()
328
358
  const errorValue =
@@ -1,5 +1,8 @@
1
1
  import {
2
+ assertAssignableComputer,
3
+ assertComputerId,
2
4
  assertConversationThreadRow,
5
+ assertRunsOn,
3
6
  participantsToAdd,
4
7
  planAgentThreadFork,
5
8
  remapArtifactIds,
@@ -14,6 +17,7 @@ import {
14
17
  type AgentThreadRecord,
15
18
  type AgentThreadSandboxState,
16
19
  type AgentThreadStore,
20
+ type AssignAgentThreadComputerInput,
17
21
  type CreateAgentThreadInput,
18
22
  type ForkAgentThreadInput,
19
23
  type ListAgentThreadChildrenInput,
@@ -70,12 +74,18 @@ export class PgAgentThreadStore implements AgentThreadStore {
70
74
  }
71
75
 
72
76
  async create(input: CreateAgentThreadInput): Promise<AgentThreadRecord> {
77
+ assertRunsOn(input.runsOn, "Agent thread", "SixbPg")
73
78
  const sandboxParams =
74
79
  input.sandboxParams === undefined
75
80
  ? null
76
81
  : JSON.stringify(snapshotAgentThreadSandboxParams(input.sandboxParams))
77
82
  const createdAt = input.createdAt ?? new Date()
78
83
  const updatedAt = input.updatedAt ?? createdAt
84
+ // A cloud thread leaves the column to its default, as it did before the column existed.
85
+ const runsOn =
86
+ input.runsOn === undefined
87
+ ? { column: this.sql``, value: this.sql`` }
88
+ : { column: this.sql`runs_on,`, value: this.sql`${input.runsOn},` }
79
89
 
80
90
  try {
81
91
  const [row] = await this.sql<AgentThreadRow[]>`
@@ -86,6 +96,7 @@ export class PgAgentThreadStore implements AgentThreadStore {
86
96
  owner_principal_id,
87
97
  title,
88
98
  sandbox_params,
99
+ ${runsOn.column}
89
100
  status,
90
101
  created_at,
91
102
  updated_at
@@ -96,6 +107,7 @@ export class PgAgentThreadStore implements AgentThreadStore {
96
107
  ${input.ownerPrincipal.id},
97
108
  ${input.title ?? null},
98
109
  ${sandboxParams}::text::jsonb,
110
+ ${runsOn.value}
99
111
  ${input.status ?? "active"},
100
112
  ${createdAt},
101
113
  ${updatedAt}
@@ -432,6 +444,24 @@ export class PgAgentThreadStore implements AgentThreadStore {
432
444
  return rows.length > 0
433
445
  }
434
446
 
447
+ async assignComputer(input: AssignAgentThreadComputerInput): Promise<AgentThreadRecord> {
448
+ assertComputerId(input.computerId, "SixbPg")
449
+ const [row] = await this.sql<AgentThreadRow[]>`
450
+ UPDATE agent_threads SET computer_id = ${input.computerId}
451
+ WHERE project_id = ${input.projectId}
452
+ AND id = ${input.id}
453
+ AND runs_on = 'computer'
454
+ ${input.ifUnassigned ? this.sql`AND computer_id IS NULL` : this.sql``}
455
+ RETURNING *
456
+ `
457
+ if (row) return rowToThreadRecord(row)
458
+
459
+ // Nothing changed: a cloud thread, none at all, or one a computer runs already.
460
+ const thread = await this.getById(input)
461
+ assertAssignableComputer(thread, input.id, "SixbPg")
462
+ return thread
463
+ }
464
+
435
465
  async listParticipants(
436
466
  input: ListAgentThreadParticipantsInput
437
467
  ): Promise<readonly AgentThreadParticipantRecord[]> {
package/src/index.ts CHANGED
@@ -37,7 +37,7 @@ import { PgAgentStorage } from "./agents"
37
37
  import { PgAuthStorage } from "./auth-storage"
38
38
  import { PgConnectorConnectionStorage } from "./connector-connection-storage"
39
39
  import { createPostgresStorageMigrators, dropSchema } from "./migrations"
40
- import { PgObjectStorage } from "./objects"
40
+ import { PgObjectStorage, PgSortIndexCatalog } from "./objects"
41
41
  import { preparePgObjectQueries } from "./objects/prepare-queries"
42
42
  import { ensurePgObjectQueryIndexes, type PgObjectQueryIndex } from "./objects/query-indexes"
43
43
 
@@ -77,9 +77,9 @@ export interface PostgresStorageOptions {
77
77
  * Full connection string (e.g. DATABASE_URL). Takes precedence over individual fields.
78
78
  *
79
79
  * Add `sslnegotiation=direct` (with `sslmode=require`, `verify-ca` or `verify-full`) to open TLS
80
- * directly, as libpq does against PostgreSQL 17 or later. It saves a round trip per connection
81
- * and avoids a Bun 1.4.0–1.4.2 bug that keeps in memory every byte read over a TLS connection
82
- * negotiated the classic way.
80
+ * directly, as libpq does against PostgreSQL 17 or later. It saves a round trip per connection.
81
+ * On Bun 1.4.0–1.4.2 it also avoids a bug that keeps in memory every byte read over a TLS
82
+ * connection negotiated the classic way.
83
83
  */
84
84
  connectionString?: string
85
85
 
@@ -193,6 +193,7 @@ export class PostgresStorage implements MigrationCapableStorage, QueryPreparatio
193
193
  private readonly schemaName: string
194
194
  private readonly shutdownTimeoutSeconds: number
195
195
  private readonly transactionScope = new AsyncLocalStorage<boolean>()
196
+ private readonly sortIndexes = new PgSortIndexCatalog()
196
197
 
197
198
  constructor(options: PostgresStorageOptions) {
198
199
  if (
@@ -240,6 +241,7 @@ export class PostgresStorage implements MigrationCapableStorage, QueryPreparatio
240
241
 
241
242
  this.migrators = createPostgresStorageMigrators(this.sql, this.schemaName)
242
243
  const stores = createPostgresStores(this.sql, {
244
+ sortIndexes: this.sortIndexes,
243
245
  maxConcurrentAggregates: options.maxConcurrentAggregates,
244
246
  runOntologyOperation: (run) => runPgTransaction(this.sql, run),
245
247
  transactionContext: null,
@@ -335,7 +337,11 @@ export class PostgresStorage implements MigrationCapableStorage, QueryPreparatio
335
337
  plan: ObjectQueryPreparationPlan
336
338
  ): Promise<ObjectQueryPreparationResult> {
337
339
  this.assertRootOperationAvailable()
338
- return preparePgObjectQueries(this.sql, this.schemaName, plan)
340
+ try {
341
+ return await preparePgObjectQueries(this.sql, this.schemaName, plan)
342
+ } finally {
343
+ this.sortIndexes.invalidate()
344
+ }
339
345
  }
340
346
 
341
347
  /** Build workload-specific indexes concurrently, after migrations, outside transactions. */
@@ -343,7 +349,12 @@ export class PostgresStorage implements MigrationCapableStorage, QueryPreparatio
343
349
  indexes: readonly PgObjectQueryIndex[]
344
350
  ): Promise<readonly string[]> {
345
351
  this.assertRootOperationAvailable()
346
- return ensurePgObjectQueryIndexes(this.sql, this.schemaName, indexes)
352
+ try {
353
+ return await ensurePgObjectQueryIndexes(this.sql, this.schemaName, indexes)
354
+ } finally {
355
+ // Even a build that failed partway may have created some of them.
356
+ this.sortIndexes.invalidate()
357
+ }
347
358
  }
348
359
 
349
360
  /** Offline maintenance: STORED columns rewrite the objects table before concurrent index builds. */
@@ -385,6 +396,7 @@ export class PostgresStorage implements MigrationCapableStorage, QueryPreparatio
385
396
  ): Storage & { readonly ontology: PgOntologyStorage; readonly aiLimits: PgAiLimitStorage } {
386
397
  return {
387
398
  ...createPostgresStores(client, {
399
+ sortIndexes: this.sortIndexes,
388
400
  runOntologyOperation: async (run) => run(client),
389
401
  transactionContext,
390
402
  }),
@@ -403,6 +415,7 @@ function createPostgresStores(
403
415
  options: {
404
416
  readonly runOntologyOperation: <T>(run: (sql: SQLClient) => Promise<T>) => Promise<T>
405
417
  readonly transactionContext: PgOntologyTransactionContext | null
418
+ readonly sortIndexes: PgSortIndexCatalog
406
419
  readonly maxConcurrentAggregates?: number
407
420
  }
408
421
  ): PostgresStoreSet {
@@ -411,7 +424,7 @@ function createPostgresStores(
411
424
  const shareSessions = new PgShareSessionStorage(sql)
412
425
  const executions = new PgExecutionStorage(sql, auth, shareSessions)
413
426
  return {
414
- objects: new PgObjectStorage(sql, options.maxConcurrentAggregates),
427
+ objects: new PgObjectStorage(sql, options.sortIndexes, options.maxConcurrentAggregates),
415
428
  ontology: new PgOntologyStorage({
416
429
  sql,
417
430
  runRootOperation: options.runOntologyOperation,
@@ -0,0 +1,3 @@
1
+ -- A cancel is recorded on the run, not only broadcast: a runner that never hears the broker learns
2
+ -- of it at its next lease renewal, and the run token stops working at once.
3
+ ALTER TABLE agent_runs ADD COLUMN cancel_requested_at TIMESTAMPTZ;
@@ -0,0 +1,4 @@
1
+ -- Where a conversation's turns run: NULL in the cloud, 'computer' on its owner's computer.
2
+ ALTER TABLE agent_threads ADD COLUMN runs_on TEXT CHECK (runs_on IS NULL OR runs_on = 'computer');
3
+ -- Which of its owner's computers runs a computer's thread: NULL until one claims its first turn.
4
+ ALTER TABLE agent_threads ADD COLUMN computer_id TEXT;
package/src/migrations.ts CHANGED
@@ -452,6 +452,8 @@ export const postgresStorageMigrations = defineMigrations<PostgresMigrationConte
452
452
  pgSql("079-agent-approval-resume", agentApprovalResumeSql),
453
453
  pgSql("080-subagent-threads", subagentThreadsSql),
454
454
  pgSql("081-subagent-questions", subagentQuestionsSql),
455
+ pgSql("082-agent-run-cancel-requests", agentRunCancelRequestsSql),
456
+ pgSql("083-agent-thread-runs-on", agentThreadRunsOnSql),
455
457
  ],
456
458
  })
457
459
 
@@ -515,3 +517,7 @@ import agentApprovalResumeSql from "./migrations/079-agent-approval-resume.sql"
515
517
  }
516
518
  import subagentThreadsSql from "./migrations/080-subagent-threads.sql" with { type: "text" }
517
519
  import subagentQuestionsSql from "./migrations/081-subagent-questions.sql" with { type: "text" }
520
+ import agentRunCancelRequestsSql from "./migrations/082-agent-run-cancel-requests.sql" with {
521
+ type: "text",
522
+ }
523
+ import agentThreadRunsOnSql from "./migrations/083-agent-thread-runs-on.sql" with { type: "text" }
@@ -1 +1,2 @@
1
+ export { PgSortIndexCatalog } from "./query-indexes"
1
2
  export { PgObjectStorage } from "./storage"
@@ -134,11 +134,15 @@ export function compilePgObjectQuery(
134
134
  )
135
135
  if (options.sortIndexBound && source === DEFAULT_OBJECT_QUERY_SOURCE) {
136
136
  let bounded = query
137
- while (bounded.kind === "expand") bounded = bounded.input
137
+ const expansions: (readonly ObjectExpansion[])[] = []
138
+ while (bounded.kind === "expand") {
139
+ expansions.unshift(bounded.expansions)
140
+ bounded = bounded.input
141
+ }
138
142
  if (bounded.kind === "page" || bounded.kind === "limit") {
139
143
  const branches = [options.sortIndexBound, `NOT (${options.sortIndexBound})`].map(
140
144
  (startPredicate, branch) =>
141
- compileObjectQueryInternal(projectId, query, {
145
+ compileObjectQueryInternal(projectId, bounded, {
142
146
  probeLimit: options.includeTotal === false,
143
147
  source,
144
148
  startPredicate,
@@ -150,11 +154,19 @@ export function compilePgObjectQuery(
150
154
  bounded.kind === "page"
151
155
  ? bounded.pageSize + 1
152
156
  : bounded.limit + (options.includeTotal === false ? 1 : 0)
153
- compiled = {
154
- ...compiled,
157
+ // Links are expanded once, for the page the branches merge into: each further reference
158
+ // to objects costs the planner a few milliseconds over its prepared indexes.
159
+ let rows: CompiledPredicate = {
155
160
  sql: `SELECT * FROM ((${branches[0]!.sql}) UNION ALL (${branches[1]!.sql})) AS input ORDER BY ${compiled.order.sql} LIMIT ?`,
156
161
  args: [...branches[0]!.args, ...branches[1]!.args, ...compiled.order.args, limit],
157
162
  }
163
+ for (const expansion of expansions) {
164
+ rows = expandRows({ ...rows, order: compiled.order }, expansion, {
165
+ probeLimit: options.includeTotal === false,
166
+ source,
167
+ })
168
+ }
169
+ compiled = { ...compiled, ...rows }
158
170
  }
159
171
  }
160
172
  const traversal = !options.correlatedTraversal && boundedTraversal(query)
@@ -926,6 +938,25 @@ function compileExpand(
926
938
  ctx: CompileContext
927
939
  ): CompiledPgObjectQuery {
928
940
  const input = compileObjectQueryInternal(projectId, inputQuery, exactContext(ctx))
941
+ return {
942
+ ...expandRows(input, expansions, ctx),
943
+ totalSql: input.totalSql,
944
+ totalArgs: input.totalArgs,
945
+ vectorProbe: input.vectorProbe,
946
+ order: input.order,
947
+ hasMoreProbe: input.hasMoreProbe,
948
+ hasMore: input.hasMore,
949
+ trimRows: input.trimRows,
950
+ nextPageToken: input.nextPageToken,
951
+ }
952
+ }
953
+
954
+ /** Add the `_expand` column to already selected, ordered rows, keeping their order. */
955
+ function expandRows(
956
+ input: { readonly sql: string; readonly args: readonly unknown[]; readonly order: CompiledOrder },
957
+ expansions: readonly ObjectExpansion[],
958
+ ctx: CompileContext
959
+ ): CompiledPredicate {
929
960
  const expand = compileExpansionsObject(
930
961
  expansions,
931
962
  { project: "input.project_id", type: "input.object_type_id", id: "input.primary_id" },
@@ -933,23 +964,13 @@ function compileExpand(
933
964
  ctx
934
965
  )
935
966
  const inputOrder = compileOrder(input.order.fields, "input", "input._cursor_properties")
936
- const sql = `
967
+ return {
968
+ sql: `
937
969
  SELECT input.*, ${expand.sql} AS _expand
938
970
  FROM (${input.sql}) AS input
939
971
  ORDER BY ${inputOrder.sql}
940
- `
941
-
942
- return {
943
- sql,
972
+ `,
944
973
  args: [...expand.args, ...input.args, ...inputOrder.args],
945
- totalSql: input.totalSql,
946
- totalArgs: input.totalArgs,
947
- vectorProbe: input.vectorProbe,
948
- order: input.order,
949
- hasMoreProbe: input.hasMoreProbe,
950
- hasMore: input.hasMore,
951
- trimRows: input.trimRows,
952
- nextPageToken: input.nextPageToken,
953
974
  }
954
975
  }
955
976
 
@@ -973,12 +994,12 @@ function compileExpansionsObject(
973
994
  return { sql: `jsonb_build_object(${parts.join(", ")})`, args }
974
995
  }
975
996
 
976
- // One expansion's hydrated value. `row_number()` numbers a parent's links by the
977
- // order from `compileExpansionOrder` (the expansion's `orderBy` against the target
978
- // object's properties, then an identity tiebreak); `WHERE _ord <= N` keeps the
979
- // top-N per parent in-DB; each retained neighbour becomes a JSONB object; and the
980
- // value is an ordered array ("many") or the first element or null ("one"). The
981
- // cardinality is core-resolved before pushdown.
997
+ // One expansion's hydrated value. A parent's links are read in the order from
998
+ // `compileExpansionOrder` (the expansion's `orderBy` against the target object's
999
+ // properties, then an identity tiebreak) and `LIMIT N` keeps the top-N per parent
1000
+ // in-DB; each retained neighbour becomes a JSONB object; and the value is an
1001
+ // ordered array ("many", numbered by `row_number()` for `jsonb_agg`) or the first
1002
+ // neighbour or null ("one"). The cardinality is core-resolved before pushdown.
982
1003
  function compileExpansionValue(
983
1004
  expansion: ObjectExpansion,
984
1005
  parent: ExpansionParent,
@@ -1011,8 +1032,7 @@ function compileExpansionValue(
1011
1032
  whereArgs.push(expansion.sourceObjectTypeId)
1012
1033
  }
1013
1034
 
1014
- const inner = `
1015
- SELECT ${child.sql} AS elem, row_number() OVER (ORDER BY ${order.sql}) AS _ord
1035
+ const from = `
1016
1036
  FROM ${ctx.source.linksTable} AS ${edge}
1017
1037
  JOIN ${ctx.source.objectsTable} AS ${target}
1018
1038
  ON ${target}.project_id = ${edge}.project_id
@@ -1020,20 +1040,26 @@ function compileExpansionValue(
1020
1040
  AND ${target}.primary_id = ${neighborId}
1021
1041
  WHERE ${whereParts.join(" AND ")}
1022
1042
  `
1023
- const innerArgs = [...child.args, ...order.args, ...whereArgs]
1024
1043
 
1044
+ // ORDER BY ... LIMIT stops at the kept neighbours, so only they are built as JSONB. Filtering
1045
+ // on row_number() would build every neighbour first.
1025
1046
  if (expansion.cardinality === "one") {
1026
1047
  return {
1027
- sql: `(SELECT ${ranked}.elem FROM (${inner}) AS ${ranked} WHERE ${ranked}._ord = 1)`,
1028
- args: innerArgs,
1048
+ sql: `(SELECT ${child.sql} ${from} ORDER BY ${order.sql} LIMIT 1)`,
1049
+ args: [...child.args, ...whereArgs, ...order.args],
1029
1050
  }
1030
1051
  }
1031
1052
 
1032
1053
  // The fanout cap is baked into `limit` by the core executor before pushdown.
1033
1054
  const limit = expansion.limit ?? DEFAULT_EXPANSION_FANOUT
1034
1055
  return {
1035
- sql: `COALESCE((SELECT jsonb_agg(${ranked}.elem ORDER BY ${ranked}._ord) FROM (${inner}) AS ${ranked} WHERE ${ranked}._ord <= ?), '[]'::jsonb)`,
1036
- args: [...innerArgs, limit],
1056
+ sql: `COALESCE((SELECT jsonb_agg(${ranked}.elem ORDER BY ${ranked}._ord) FROM (
1057
+ SELECT ${child.sql} AS elem, row_number() OVER (ORDER BY ${order.sql}) AS _ord
1058
+ ${from}
1059
+ ORDER BY ${order.sql}
1060
+ LIMIT ?
1061
+ ) AS ${ranked}), '[]'::jsonb)`,
1062
+ args: [...child.args, ...order.args, ...whereArgs, ...order.args, limit],
1037
1063
  }
1038
1064
  }
1039
1065