Add agent session identity columns to orchestration records

This commit is contained in:
Merge Sim
2026-09-08 14:44:36 -07:00
parent 5d374e967c
commit 1e6f94dbd2
5 changed files with 15 additions and 1 deletions
@@ -7,4 +7,4 @@ export const LEGACY_CONTRACT_VERSION = 0
export const CURRENT_CONTRACT_VERSION = ORCHESTRATION_CONTRACT_VERSION
// Schema versions: v2 'heartbeat'+last_heartbeat_at, v3 delivered_at, v4 task-creator terminal, v5 task_title/display_name, v6 pane identity, v7 lightweight Runs, v8 crash-safe Run deliveries, v9 durable question threads, v10 Dispatch capabilities, v11 durable mutation receipts, v12 composed worker state, v18 post-v6 version-skew repair, v19 adopted legacy Runs and compatibility receipts, v20 legacy question backfill, v21 legacy scheduler-loss provenance, v22 dispatch assignee lookup, v23 worker terminal resource ownership, v24 creator-incarnation authority, v25 active Dispatch handle lookup, v26 indexed mutation receipt capacity, v27 durable federation acknowledgments, v28 durable local mutation caller identity, v31 dispatch/resource identity links, v32 bounded worker-terminal recovery metadata, v33 durable mailbox pointer Enter state, v34 role-addressed mailbox deliveries, v35 mailbox delivery default and index-predicate repair, v36 dispatch mailbox consumer generation, v37 recorded dispatch creator identity, v39 structured session journal archives.
export const SCHEMA_VERSION = 40
export const SCHEMA_VERSION = 41
@@ -13,6 +13,7 @@ export const RUN_COLUMNS = [
'home_database',
'coordinator_handle',
'coordinator_agent_session_id',
'coordinator_agent_session_id',
'coordinator_pane_key',
'consumer_generation',
'legacy',
@@ -45,6 +46,7 @@ export const DISPATCH_CONTEXT_COLUMNS = [
'contract_version',
'launch_token_hash',
'assignee_handle',
'assignee_agent_session_id',
'assignee_pane_key',
'capability_hash',
'process_incarnation',
@@ -0,0 +1,9 @@
import type { OrchestrationDb } from '../orchestration-db'
export function migrateV41(this: OrchestrationDb, current: number): void {
if (current >= 41) {
return
}
this.db.exec('ALTER TABLE runs ADD COLUMN coordinator_agent_session_id TEXT')
this.db.exec('ALTER TABLE dispatch_contexts ADD COLUMN assignee_agent_session_id TEXT')
}
@@ -11,6 +11,7 @@ import { migrateV37 } from './migrate-v37'
import { migrateV38 } from './migrate-v38'
import { migrateV39 } from './migrate-v39'
import { migrateV40 } from './migrate-v40'
import { migrateV41 } from './migrate-v41'
// Why: CREATE TABLE IF NOT EXISTS won't alter existing DBs; migrate in a txn that bumps user_version only on success (atomic all-or-nothing).
export function migrate(this: OrchestrationDb): void {
@@ -32,6 +33,7 @@ export function migrate(this: OrchestrationDb): void {
migrateV38.call(this, current)
migrateV39.call(this, current)
migrateV40.call(this, current)
migrateV41.call(this, current)
this.createMailboxDeliveryIndexesIfPossible()
this.db.pragma(`user_version = ${SCHEMA_VERSION}`)
this.db.exec('COMMIT')
+1
View File
@@ -273,6 +273,7 @@ export type TaskRow = {
}
export type DispatchContextRow = {
assignee_agent_session_id: string | null
id: string
run_id: string
task_id: string