Add agent session identity to orchestration runs

This commit is contained in:
Merge Sim
2026-09-08 14:42:09 -07:00
parent 4f0e3806a9
commit 5d374e967c
6 changed files with 36 additions and 2 deletions
+19
View File
@@ -6,6 +6,9 @@ importers:
.:
configDependencies: {}
packageManagerDependencies:
'@pnpm/exe':
specifier: 12.0.0
version: 12.0.0
pnpm:
specifier: 12.0.0
version: 12.0.0
@@ -56,6 +59,11 @@ packages:
cpu: [x64]
os: [win32]
'@pnpm/exe@12.0.0':
resolution: {integrity: sha512-405vw2qYPPghNxoPRt2cvkGtGNU5gnInDcIe5TztQxe73yUZLqFJN/jCJFGs1xbVaIWDXEVuQ71P8npFZeatZQ==}
engines: {node: '>=18.*'}
hasBin: true
pnpm@12.0.0:
resolution: {integrity: sha512-ni49w5EZlYaNyUuBdcIXwn6VQI+gO0oidJd48rNPdzt3zdOznt6BcbIvzVO+ajU0Lp+smUimjvWN9kiM6Jp+Zw==}
engines: {node: '>=18.*'}
@@ -87,6 +95,17 @@ snapshots:
'@pnpm/exe.win32-x64@12.0.0':
optional: true
'@pnpm/exe@12.0.0':
optionalDependencies:
'@pnpm/exe.darwin-arm64': 12.0.0
'@pnpm/exe.darwin-x64': 12.0.0
'@pnpm/exe.linux-arm64': 12.0.0
'@pnpm/exe.linux-arm64-musl': 12.0.0
'@pnpm/exe.linux-x64': 12.0.0
'@pnpm/exe.linux-x64-musl': 12.0.0
'@pnpm/exe.win32-arm64': 12.0.0
'@pnpm/exe.win32-x64': 12.0.0
pnpm@12.0.0:
optionalDependencies:
'@pnpm/exe.darwin-arm64': 12.0.0
@@ -12,6 +12,7 @@ export const RUN_COLUMNS = [
'objective',
'home_database',
'coordinator_handle',
'coordinator_agent_session_id',
'coordinator_pane_key',
'consumer_generation',
'legacy',
@@ -10,6 +10,7 @@ export function createRun(
objective: string
coordinatorHandle: string
coordinatorPaneKey: string
coordinatorAgentSessionId?: string | null
}
): RunRow {
const id = generateId('run')
@@ -19,11 +20,17 @@ export function createRun(
this.db
.prepare(
`INSERT INTO runs (
id, objective, coordinator_handle, coordinator_pane_key,
id, objective, coordinator_handle, coordinator_pane_key, coordinator_agent_session_id,
consumer_generation, legacy
) VALUES (?, ?, ?, ?, 1, 0)`
)
.run(id, params.objective, params.coordinatorHandle, params.coordinatorPaneKey)
.run(
id,
params.objective,
params.coordinatorHandle,
params.coordinatorPaneKey,
params.coordinatorAgentSessionId ?? null
)
this.rememberRunCoordinatorHandle(id, params.coordinatorHandle)
this.db.exec('COMMIT')
} catch (error) {
@@ -7,6 +7,7 @@ CREATE TABLE IF NOT EXISTS runs (
objective TEXT NOT NULL,
home_database TEXT NOT NULL DEFAULT 'this_database',
coordinator_handle TEXT,
coordinator_agent_session_id TEXT,
coordinator_pane_key TEXT,
consumer_generation INTEGER NOT NULL DEFAULT 0,
legacy INTEGER NOT NULL DEFAULT 0,
@@ -2,6 +2,10 @@ import { LEGACY_RUN_ID } from '../contract-constants'
import type { OrchestrationDb } from '../orchestration-db'
export function applySchemaMigrationsV2ToV12(this: OrchestrationDb, current: number): void {
// Session identity is authoritative for orchestration; retain terminal columns during migration.
if (!this.hasColumn('runs', 'coordinator_agent_session_id')) {
this.db.exec('ALTER TABLE runs ADD COLUMN coordinator_agent_session_id TEXT')
}
// v1 → v2: SQLite can't ALTER a CHECK, so rebuild messages to allow 'heartbeat'; fold in v3's delivered_at to skip a second rebuild.
if (current < 2) {
if (!this.hasColumn('dispatch_contexts', 'last_heartbeat_at')) {
+2
View File
@@ -45,6 +45,8 @@ export type RunRow = {
objective: string
home_database: string
coordinator_handle: string | null
coordinator_agent_session_id: string | null
coordinator_agent_session_id: string | null
coordinator_pane_key: string | null
consumer_generation: number
legacy: number