@opengeni/db 0.9.3 → 0.12.0

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.
Files changed (54) hide show
  1. package/dist/{chunk-4LG5NBTC.js → chunk-VUKRIBO5.js} +577 -12
  2. package/dist/chunk-VUKRIBO5.js.map +1 -0
  3. package/dist/{chunk-KW526IJA.js → chunk-Y5WZZVQK.js} +80 -4
  4. package/dist/chunk-Y5WZZVQK.js.map +1 -0
  5. package/dist/index.d.ts +4 -2
  6. package/dist/index.js +6372 -2189
  7. package/dist/index.js.map +1 -1
  8. package/dist/migrate.d.ts +6 -3
  9. package/dist/migrate.js +1 -1
  10. package/dist/provision-roles.d.ts +1122 -91
  11. package/dist/{schema-CdPGTHlD.d.ts → schema-CnpD6BcX.d.ts} +5908 -3626
  12. package/dist/schema.d.ts +1 -1
  13. package/dist/schema.js +19 -1
  14. package/drizzle/0053_codex_credential_leases.sql +2 -2
  15. package/drizzle/0057_durable_queue_control.sql +1 -1
  16. package/drizzle/0061_session_workflow_wake_outbox.sql +1 -1
  17. package/drizzle/0062_session_list_snapshot_reaper.sql +1 -1
  18. package/drizzle/0063_session_control_mega_foundation.sql +1 -1
  19. package/drizzle/0064_rotation_strategy_sharded_backfill.sql +1 -1
  20. package/drizzle/0065_codex_subscription_overview.sql +168 -0
  21. package/drizzle/0065_session_tool_policy.sql +38 -0
  22. package/drizzle/0067_session_event_payload_bounds.sql +2 -2
  23. package/drizzle/0068_workspace_control_event_bounds.sql +2 -2
  24. package/drizzle/0069_session_event_history_backfill.sql +2 -2
  25. package/drizzle/0074_session_activity_revisions.sql +2 -2
  26. package/drizzle/0106_session_attempt_mcp_approval_policies.sql +29 -0
  27. package/drizzle/0107_host_export_lineage_contract.sql +381 -0
  28. package/drizzle/0108_fence_invalidated_warming_epochs.sql +76 -0
  29. package/drizzle/0109_nested_agent_depth_expand.sql +42 -0
  30. package/drizzle/0110_nested_agent_depth_boundary.sql +480 -0
  31. package/drizzle/0111_nested_agent_depth_backfill.sql +49 -0
  32. package/drizzle/0112_nested_agent_depth_contract.sql +38 -0
  33. package/drizzle/0113_nested_agent_depth_validate.sql +13 -0
  34. package/drizzle/0114_nested_agent_depth_contract.sql +49 -0
  35. package/drizzle/0115_nested_agent_depth_validate.sql +11 -0
  36. package/drizzle/0116_nested_agent_depth_index.sql +4 -0
  37. package/drizzle/0117_sandbox_recovery_generations.sql +699 -0
  38. package/drizzle/0118_new_session_drafts.sql +59 -0
  39. package/drizzle/0119_pending_tool_output_policy.sql +5 -0
  40. package/drizzle/0120_durable_goal_wake.sql +360 -0
  41. package/drizzle/0121_goal_update_idempotency.sql +11 -0
  42. package/package.json +5 -4
  43. package/src/codex-token-resolver.ts +175 -14
  44. package/src/connection-token-resolver.ts +143 -120
  45. package/src/event-payload-sanitizer.ts +32 -2
  46. package/src/index.ts +7734 -1330
  47. package/src/migrate.ts +131 -2
  48. package/src/new-session-drafts.ts +144 -0
  49. package/src/schema.ts +626 -16
  50. package/src/session-control.ts +44 -18
  51. package/src/session-queue-commands.ts +94 -21
  52. package/src/session-tool-call-settlement.ts +6 -1
  53. package/dist/chunk-4LG5NBTC.js.map +0 -1
  54. package/dist/chunk-KW526IJA.js.map +0 -1
@@ -13,6 +13,7 @@ __export(schema_exports, {
13
13
  capabilityInstallations: () => capabilityInstallations,
14
14
  codexCapacityWaiters: () => codexCapacityWaiters,
15
15
  codexCredentialLeases: () => codexCredentialLeases,
16
+ codexResetRedemptionAttempts: () => codexResetRedemptionAttempts,
16
17
  codexRotationSettings: () => codexRotationSettings,
17
18
  codexSubscriptionCredentials: () => codexSubscriptionCredentials,
18
19
  composerDrafts: () => composerDrafts,
@@ -43,6 +44,8 @@ __export(schema_exports, {
43
44
  machineMetricsLatest: () => machineMetricsLatest,
44
45
  machineMetricsSeries: () => machineMetricsSeries,
45
46
  managedAccounts: () => managedAccounts,
47
+ nestedAgentDepthConfiguration: () => nestedAgentDepthConfiguration,
48
+ newSessionDrafts: () => newSessionDrafts,
46
49
  packInstallations: () => packInstallations,
47
50
  rigChanges: () => rigChanges,
48
51
  rigVersions: () => rigVersions,
@@ -52,7 +55,12 @@ __export(schema_exports, {
52
55
  sandboxLeaseLivenessValues: () => sandboxLeaseLivenessValues,
53
56
  sandboxLeases: () => sandboxLeases,
54
57
  sandboxPtySessions: () => sandboxPtySessions,
58
+ sandboxRetainedProcessStateValues: () => sandboxRetainedProcessStateValues,
59
+ sandboxRetainedProcesses: () => sandboxRetainedProcesses,
55
60
  sandboxSessionEnvelopes: () => sandboxSessionEnvelopes,
61
+ sandboxWorkspaceMutationActorKindValues: () => sandboxWorkspaceMutationActorKindValues,
62
+ sandboxWorkspaceMutationAdmissions: () => sandboxWorkspaceMutationAdmissions,
63
+ sandboxWorkspaceMutationHolderKindValues: () => sandboxWorkspaceMutationHolderKindValues,
56
64
  sandboxes: () => sandboxes,
57
65
  scheduledTaskRuns: () => scheduledTaskRuns,
58
66
  scheduledTasks: () => scheduledTasks,
@@ -70,6 +78,7 @@ __export(schema_exports, {
70
78
  sessionRecordingModeValues: () => sessionRecordingModeValues,
71
79
  sessionRecordingStateValues: () => sessionRecordingStateValues,
72
80
  sessionRecordings: () => sessionRecordings,
81
+ sessionSpawnDenials: () => sessionSpawnDenials,
73
82
  sessionSystemUpdateOutbox: () => sessionSystemUpdateOutbox,
74
83
  sessionSystemUpdates: () => sessionSystemUpdates,
75
84
  sessionTurnAttempts: () => sessionTurnAttempts,
@@ -163,6 +172,29 @@ var workspaces = pgTable(
163
172
  external: uniqueIndex("workspaces_external_idx").on(table.externalSource, table.externalId)
164
173
  })
165
174
  );
175
+ var nestedAgentDepthConfiguration = pgTable(
176
+ "nested_agent_depth_configuration",
177
+ {
178
+ singleton: boolean("singleton").primaryKey().notNull().default(true),
179
+ maxNestedAgentDepth: integer("max_nested_agent_depth").notNull(),
180
+ policySource: text("policy_source").$type().notNull(),
181
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
182
+ },
183
+ (table) => ({
184
+ singletonOnly: check(
185
+ "nested_agent_depth_configuration_singleton_check",
186
+ sql`${table.singleton}`
187
+ ),
188
+ maxValid: check(
189
+ "nested_agent_depth_configuration_max_check",
190
+ sql`${table.maxNestedAgentDepth} >= 0`
191
+ ),
192
+ sourceValid: check(
193
+ "nested_agent_depth_configuration_source_check",
194
+ sql`${table.policySource} in ('deployment', 'default')`
195
+ )
196
+ })
197
+ );
166
198
  var workspaceInferenceControls = pgTable(
167
199
  "workspace_inference_controls",
168
200
  {
@@ -373,6 +405,19 @@ var codexSubscriptionCredentials = pgTable(
373
405
  // refresh, encrypted material, and already-frozen/in-flight turns are
374
406
  // intentionally independent. account eligibility policy owns toggle OCC/audit and product UI.
375
407
  allocatorEnabled: boolean("allocator_enabled").notNull().default(true),
408
+ // Independent OCC/audit sequence for the allocator toggle. Token refresh
409
+ // continues to own `version`; quota/cache writes own neither counter.
410
+ allocatorVersion: integer("allocator_version").notNull().default(1),
411
+ allocatorUpdatedBySubjectId: text("allocator_updated_by_subject_id"),
412
+ allocatorUpdatedAt: timestamp("allocator_updated_at", { withTimezone: true }),
413
+ // Authoritative count-only summary cached from /wham/usage. Detailed rows
414
+ // are never persisted as redemption authority; every first POST preflights
415
+ // the provider's fresh detail endpoint.
416
+ resetCreditAvailableCount: integer("reset_credit_available_count"),
417
+ resetCreditsCheckedAt: timestamp("reset_credits_checked_at", { withTimezone: true }),
418
+ // Set only by a direct Better Auth cookie connection/reconnection. Legacy,
419
+ // configured, delegated, API-key, and agent-created rows remain view-only.
420
+ connectedBySubjectId: text("connected_by_subject_id"),
376
421
  selectionCount: integer("selection_count").notNull().default(0),
377
422
  lastSelectedAt: timestamp("last_selected_at", { withTimezone: true }),
378
423
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
@@ -393,6 +438,69 @@ var codexSubscriptionCredentials = pgTable(
393
438
  )
394
439
  })
395
440
  );
441
+ var codexResetRedemptionAttempts = pgTable(
442
+ "codex_reset_redemption_attempts",
443
+ {
444
+ id: uuid("id").primaryKey(),
445
+ accountId: uuid("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
446
+ workspaceId: uuid("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
447
+ credentialId: uuid("credential_id").notNull(),
448
+ subjectId: text("subject_id").notNull(),
449
+ browserSessionHash: text("browser_session_hash").notNull(),
450
+ creditId: text("credit_id").notNull(),
451
+ upstreamIdempotencyKey: uuid("upstream_idempotency_key").notNull().defaultRandom(),
452
+ status: text("status").notNull().default("processing"),
453
+ outcome: text("outcome"),
454
+ claimHolderId: uuid("claim_holder_id"),
455
+ claimExpiresAt: timestamp("claim_expires_at", { withTimezone: true }),
456
+ confirmationExpiresAt: timestamp("confirmation_expires_at", { withTimezone: true }).notNull(),
457
+ providerStartedAt: timestamp("provider_started_at", { withTimezone: true }),
458
+ completedAt: timestamp("completed_at", { withTimezone: true }),
459
+ lastFailureKind: text("last_failure_kind"),
460
+ retryCount: integer("retry_count").notNull().default(0),
461
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
462
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
463
+ },
464
+ (table) => ({
465
+ workspaceAccount: foreignKey({
466
+ name: "codex_reset_redemption_workspace_account_fk",
467
+ columns: [table.workspaceId, table.accountId],
468
+ foreignColumns: [workspaces.id, workspaces.accountId]
469
+ }).onDelete("cascade"),
470
+ upstreamKey: uniqueIndex("codex_reset_redemption_upstream_key_idx").on(
471
+ table.upstreamIdempotencyKey
472
+ ),
473
+ credentialCredit: uniqueIndex("codex_reset_redemption_credential_credit_idx").on(table.workspaceId, table.credentialId, table.creditId).where(
474
+ sql`${table.status} <> 'completed' or ${table.outcome} in ('reset', 'alreadyRedeemed')`
475
+ ),
476
+ workspaceCredential: index("codex_reset_redemption_workspace_credential_idx").on(
477
+ table.workspaceId,
478
+ table.credentialId,
479
+ table.createdAt
480
+ ),
481
+ claimExpiry: index("codex_reset_redemption_claim_expiry_idx").on(table.claimExpiresAt).where(sql`${table.status} <> 'completed'`),
482
+ statusValid: check(
483
+ "codex_reset_redemption_status_check",
484
+ sql`${table.status} in ('processing', 'provider_started', 'completed')`
485
+ ),
486
+ outcomeValid: check(
487
+ "codex_reset_redemption_outcome_check",
488
+ sql`${table.outcome} is null or ${table.outcome} in ('reset', 'nothingToReset', 'noCredit', 'alreadyRedeemed')`
489
+ ),
490
+ completionConsistent: check(
491
+ "codex_reset_redemption_completed_check",
492
+ sql`(${table.status} = 'completed') = (${table.outcome} is not null and ${table.completedAt} is not null)`
493
+ ),
494
+ retryCountValid: check(
495
+ "codex_reset_redemption_retry_count_check",
496
+ sql`${table.retryCount} >= 0`
497
+ ),
498
+ humanSubjectValid: check(
499
+ "codex_reset_redemption_human_subject_check",
500
+ sql`${table.subjectId} like 'user:_%'`
501
+ )
502
+ })
503
+ );
396
504
  var connections = pgTable(
397
505
  "connections",
398
506
  {
@@ -617,6 +725,10 @@ var sessions = pgTable(
617
725
  // Non-default first-party MCP token permissions (manager-style sessions);
618
726
  // null means the fixed worker default set in @opengeni/runtime.
619
727
  firstPartyMcpPermissions: jsonb("first_party_mcp_permissions").$type(),
728
+ // Durable tool-policy origin. NULL is retained for pre-migration rows;
729
+ // mapSession exposes those rows as `legacy` instead of guessing omitted vs
730
+ // explicit [].
731
+ toolPolicy: jsonb("tool_policy").$type(),
620
732
  // The manager session that spawned this one via session_create. Set only
621
733
  // when the creating grant carried a worker-signed sessionId claim (a session
622
734
  // spawning a worker); null for direct API creates and scheduled-task runs.
@@ -630,6 +742,15 @@ var sessions = pgTable(
630
742
  // workspace to a single session row — the dedup that closes the
631
743
  // double-submit/double-dispatch stuck-queued bug.
632
744
  createIdempotencyKey: text("create_idempotency_key"),
745
+ // Immutable creation-time hierarchy and policy snapshot. These values are
746
+ // populated by the database admission boundary and never re-derived from
747
+ // a live workspace setting for an existing session.
748
+ rootSessionId: uuid("root_session_id").notNull(),
749
+ nestedAgentDepth: integer("nested_agent_depth").notNull(),
750
+ maxNestedAgentDepthOverride: integer("max_nested_agent_depth_override"),
751
+ effectiveMaxNestedAgentDepth: integer("effective_max_nested_agent_depth").notNull(),
752
+ nestedAgentDepthPolicySource: text("nested_agent_depth_policy_source").notNull(),
753
+ nestedAgentDepthPolicySessionId: uuid("nested_agent_depth_policy_session_id"),
633
754
  temporalWorkflowId: text("temporal_workflow_id"),
634
755
  activeTurnId: uuid("active_turn_id"),
635
756
  // Actual input tokens reported for the last model call of the most recent
@@ -712,10 +833,56 @@ var sessions = pgTable(
712
833
  // point and enumerate all sessions in a group for attribution/disclosure.
713
834
  sandboxGroup: index("sessions_sandbox_group_idx").on(table.workspaceId, table.sandboxGroupId),
714
835
  // Partial unique index: one session per (workspace, create_idempotency_key)
715
- // when a key is present. Concurrent creates racing on the same key see a
716
- // unique violation on all but one; the domain layer catches it and returns
717
- // the winning row instead of erroring.
718
- createIdempotency: uniqueIndex("sessions_workspace_create_idempotency_idx").on(table.workspaceId, table.createIdempotencyKey).where(sql`${table.createIdempotencyKey} is not null`)
836
+ // when a key is present. The boundary trigger reserves the cross-outcome
837
+ // winner before this source row commits; a losing source insert is
838
+ // suppressed and the domain layer replays the durable winner.
839
+ createIdempotency: uniqueIndex("sessions_workspace_create_idempotency_idx").on(table.workspaceId, table.createIdempotencyKey).where(sql`${table.createIdempotencyKey} is not null`),
840
+ rootDepth: index("sessions_workspace_root_depth_idx").on(
841
+ table.workspaceId,
842
+ table.rootSessionId,
843
+ table.nestedAgentDepth
844
+ )
845
+ })
846
+ );
847
+ var sessionSpawnDenials = pgTable(
848
+ "session_spawn_denials",
849
+ {
850
+ id: uuid("id").primaryKey().defaultRandom(),
851
+ accountId: uuid("account_id").notNull(),
852
+ workspaceId: uuid("workspace_id").notNull(),
853
+ parentSessionId: uuid("parent_session_id"),
854
+ rootSessionId: uuid("root_session_id"),
855
+ currentDepth: integer("current_depth").notNull(),
856
+ attemptedDepth: bigint("attempted_depth", { mode: "number" }).notNull(),
857
+ effectiveMaxNestedAgentDepth: integer("effective_max_nested_agent_depth").notNull(),
858
+ requestedMaxNestedAgentDepthOverride: integer("requested_max_nested_agent_depth_override"),
859
+ policySource: text("policy_source").notNull(),
860
+ policySessionId: uuid("policy_session_id"),
861
+ subjectId: text("subject_id"),
862
+ code: text("code").notNull(),
863
+ idempotencyKey: text("idempotency_key"),
864
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
865
+ },
866
+ (table) => ({
867
+ workspaceIdentity: uniqueIndex("session_spawn_denials_workspace_id_uq").on(
868
+ table.workspaceId,
869
+ table.id
870
+ ),
871
+ workspaceCreated: index("session_spawn_denials_workspace_created_idx").on(
872
+ table.workspaceId,
873
+ table.createdAt
874
+ ),
875
+ parent: index("session_spawn_denials_parent_idx").on(
876
+ table.workspaceId,
877
+ table.parentSessionId,
878
+ table.createdAt
879
+ ),
880
+ idempotency: uniqueIndex("session_spawn_denials_workspace_idempotency_idx").on(table.workspaceId, table.idempotencyKey).where(sql`${table.idempotencyKey} is not null`),
881
+ workspaceAccount: foreignKey({
882
+ name: "session_spawn_denials_workspace_account_fk",
883
+ columns: [table.workspaceId, table.accountId],
884
+ foreignColumns: [workspaces.id, workspaces.accountId]
885
+ }).onDelete("cascade")
719
886
  })
720
887
  );
721
888
  var sessionPins = pgTable(
@@ -1051,6 +1218,9 @@ var sessionTurns = pgTable(
1051
1218
  turnInstructions: text("turn_instructions"),
1052
1219
  resources: jsonb("resources").$type().notNull().default([]),
1053
1220
  tools: jsonb("tools").$type().notNull().default([]),
1221
+ // false = inherit the durable session policy; true = this turn explicitly
1222
+ // replaces it with `tools` after the core subset fence.
1223
+ toolsProvided: boolean("tools_provided").notNull().default(false),
1054
1224
  model: text("model").notNull(),
1055
1225
  reasoningEffort: text("reasoning_effort").notNull(),
1056
1226
  sandboxBackend: text("sandbox_backend").notNull(),
@@ -1116,6 +1286,8 @@ var sessionTurnAttempts = pgTable(
1116
1286
  verifiedControlRevision: bigint("verified_control_revision", {
1117
1287
  mode: "number"
1118
1288
  }).notNull(),
1289
+ // Immutable policy snapshot captured under the session lock at claim.
1290
+ mcpApprovalPolicies: jsonb("mcp_approval_policies").$type().notNull(),
1119
1291
  startedAt: timestamp("started_at", { withTimezone: true }).notNull().defaultNow(),
1120
1292
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
1121
1293
  closedAt: timestamp("closed_at", { withTimezone: true }),
@@ -1239,6 +1411,7 @@ var sessionCommandReceipts = pgTable(
1239
1411
  table.targetSessionId,
1240
1412
  table.createdAt
1241
1413
  ),
1414
+ goalUpdateOperation: uniqueIndex("session_command_receipts_goal_update_operation_uq").on(table.workspaceId, table.action, table.targetSessionId, table.operationKey).where(sql`${table.action} = 'goal.update'`),
1242
1415
  actorValid: check(
1243
1416
  "session_command_receipts_actor_check",
1244
1417
  sql`(
@@ -1364,6 +1537,7 @@ var composerDrafts = pgTable(
1364
1537
  text: text("text").notNull().default(""),
1365
1538
  resources: jsonb("resources").$type().notNull().default([]),
1366
1539
  tools: jsonb("tools").$type().notNull().default([]),
1540
+ toolsProvided: boolean("tools_provided").notNull().default(false),
1367
1541
  model: text("model").notNull(),
1368
1542
  reasoningEffort: text("reasoning_effort").notNull(),
1369
1543
  sourceTurnId: uuid("source_turn_id"),
@@ -1399,6 +1573,40 @@ var composerDrafts = pgTable(
1399
1573
  revisionValid: check("composer_drafts_revision_check", sql`${table.revision} >= 1`)
1400
1574
  })
1401
1575
  );
1576
+ var newSessionDrafts = pgTable(
1577
+ "new_session_drafts",
1578
+ {
1579
+ id: uuid("id").primaryKey().defaultRandom(),
1580
+ accountId: uuid("account_id").notNull(),
1581
+ workspaceId: uuid("workspace_id").notNull(),
1582
+ subjectId: text("subject_id").notNull(),
1583
+ revision: bigint("revision", { mode: "number" }).notNull().default(1),
1584
+ text: text("text").notNull().default(""),
1585
+ resources: jsonb("resources").$type().notNull().default([]),
1586
+ tools: jsonb("tools").$type().notNull().default([]),
1587
+ model: text("model").notNull(),
1588
+ reasoningEffort: text("reasoning_effort").notNull(),
1589
+ sessionOptions: jsonb("session_options").$type().notNull().default({}),
1590
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
1591
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
1592
+ },
1593
+ (table) => ({
1594
+ workspaceAccount: foreignKey({
1595
+ name: "new_session_drafts_workspace_account_fk",
1596
+ columns: [table.workspaceId, table.accountId],
1597
+ foreignColumns: [workspaces.id, workspaces.accountId]
1598
+ }).onDelete("cascade"),
1599
+ subjectWorkspace: uniqueIndex("new_session_drafts_subject_workspace_uq").on(
1600
+ table.workspaceId,
1601
+ table.subjectId
1602
+ ),
1603
+ subjectValid: check(
1604
+ "new_session_drafts_subject_check",
1605
+ sql`length(btrim(${table.subjectId})) > 0`
1606
+ ),
1607
+ revisionValid: check("new_session_drafts_revision_check", sql`${table.revision} >= 1`)
1608
+ })
1609
+ );
1402
1610
  var sessionSystemUpdates = pgTable(
1403
1611
  "session_system_updates",
1404
1612
  {
@@ -1510,6 +1718,10 @@ var sessionWorkflowWakeOutbox = pgTable(
1510
1718
  "session_workflow_wake_outbox_revision_check",
1511
1719
  sql`${table.wakeRevision} > 0 and ${table.deliveredRevision} >= 0 and ${table.deliveredRevision} <= ${table.wakeRevision}`
1512
1720
  ),
1721
+ revisionSafe: check(
1722
+ "session_workflow_wake_outbox_revision_safe_check",
1723
+ sql`${table.wakeRevision} <= 9007199254740991 and ${table.deliveredRevision} <= 9007199254740991`
1724
+ ),
1513
1725
  workspaceAccount: foreignKey({
1514
1726
  name: "session_workflow_wake_outbox_workspace_account_fk",
1515
1727
  columns: [table.workspaceId, table.accountId],
@@ -1554,6 +1766,14 @@ var sessionGoals = pgTable(
1554
1766
  // per-goal override; a configured settings cap (if any) remains the hard ceiling
1555
1767
  lastContinuationTurnId: uuid("last_continuation_turn_id"),
1556
1768
  versionAtLastContinuation: integer("version_at_last_continuation"),
1769
+ // Postgres owns the continuation obligation. Terminal settlement advances
1770
+ // wakeRevision in the same transaction that makes the session idle;
1771
+ // materialization advances observedRevision only alongside the one typed
1772
+ // update, timeline events, usage row, and workflow-wake outbox row.
1773
+ // Temporal signals and workflow history are replaceable nudges over these
1774
+ // monotonic revisions.
1775
+ continuationWakeRevision: bigint("continuation_wake_revision", { mode: "number" }).notNull().default(0),
1776
+ continuationObservedRevision: bigint("continuation_observed_revision", { mode: "number" }).notNull().default(0),
1557
1777
  metadata: jsonb("metadata").$type().notNull().default({}),
1558
1778
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
1559
1779
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -1567,7 +1787,11 @@ var sessionGoals = pgTable(
1567
1787
  table.workspaceId,
1568
1788
  table.sessionId
1569
1789
  ),
1570
- status: index("session_goals_workspace_status_idx").on(table.workspaceId, table.status)
1790
+ status: index("session_goals_workspace_status_idx").on(table.workspaceId, table.status),
1791
+ continuationRevisionValid: check(
1792
+ "session_goals_continuation_revision_check",
1793
+ sql`${table.continuationWakeRevision} >= 0 and ${table.continuationObservedRevision} >= 0 and ${table.continuationObservedRevision} <= ${table.continuationWakeRevision} and ${table.continuationWakeRevision} <= 9007199254740991 and ${table.continuationObservedRevision} <= 9007199254740991`
1794
+ )
1571
1795
  })
1572
1796
  );
1573
1797
  var codexCapacityWaiters = pgTable(
@@ -1856,6 +2080,7 @@ var sessionPendingToolCalls = pgTable(
1856
2080
  callId: text("call_id").notNull(),
1857
2081
  callType: text("call_type").notNull(),
1858
2082
  callItem: jsonb("call_item").$type().notNull(),
2083
+ modelToolOutputTruncationTokens: integer("model_tool_output_truncation_tokens"),
1859
2084
  resultItem: jsonb("result_item").$type(),
1860
2085
  resultRecordedAt: timestamp("result_recorded_at", { withTimezone: true }),
1861
2086
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
@@ -1938,6 +2163,13 @@ var sandboxLeases = pgTable(
1938
2163
  // was always-true → every turn fenced); int4 returns a JS number, the fix.
1939
2164
  // Epochs never approach 2^31, so the narrower type loses nothing.
1940
2165
  leaseEpoch: integer("lease_epoch").notNull().default(0),
2166
+ // Monotonic mutation intent for the live workspace. Every acknowledged
2167
+ // filesystem-writing operation advances this under the exact lease epoch +
2168
+ // provider-instance fence BEFORE it reaches the provider. A verified
2169
+ // archive fold copies the exact captured value into archive_generation in
2170
+ // the same row update; equality is the only durable completeness proof.
2171
+ workspaceGeneration: integer("workspace_generation").notNull().default(0),
2172
+ archiveGeneration: integer("archive_generation"),
1941
2173
  // The group box-envelope (the "envelope split" Critical): the small recovery
1942
2174
  // descriptor to resume()-by-id the group's box without a per-session join.
1943
2175
  resumeBackendId: text("resume_backend_id"),
@@ -1953,7 +2185,28 @@ var sandboxLeases = pgTable(
1953
2185
  },
1954
2186
  (table) => ({
1955
2187
  groupIdx: uniqueIndex("sandbox_leases_group_idx").on(table.workspaceId, table.sandboxGroupId),
1956
- reaperIdx: index("sandbox_leases_reaper_idx").on(table.expiresAt).where(sql`${table.liveness} in ('warming','warm','draining')`)
2188
+ scopedId: uniqueIndex("sandbox_leases_scoped_id_uq").on(
2189
+ table.accountId,
2190
+ table.workspaceId,
2191
+ table.sandboxGroupId,
2192
+ table.id
2193
+ ),
2194
+ accountWorkspaceId: uniqueIndex("sandbox_leases_account_workspace_id_uq").on(
2195
+ table.accountId,
2196
+ table.workspaceId,
2197
+ table.id
2198
+ ),
2199
+ reaperIdx: index("sandbox_leases_reaper_idx").on(table.expiresAt).where(sql`${table.liveness} in ('warming','warm','draining')`),
2200
+ workspaceGenerationValid: check(
2201
+ "sandbox_leases_workspace_generation_check",
2202
+ sql`${table.workspaceGeneration} >= 0`
2203
+ ),
2204
+ archiveGenerationValid: check(
2205
+ "sandbox_leases_archive_generation_check",
2206
+ sql`${table.archiveGeneration} is null
2207
+ or (${table.archiveGeneration} >= 0
2208
+ and ${table.archiveGeneration} <= ${table.workspaceGeneration})`
2209
+ )
1957
2210
  })
1958
2211
  );
1959
2212
  var sandboxLeaseHolders = pgTable(
@@ -1963,7 +2216,7 @@ var sandboxLeaseHolders = pgTable(
1963
2216
  accountId: uuid("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
1964
2217
  workspaceId: uuid("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
1965
2218
  leaseId: uuid("lease_id").notNull().references(() => sandboxLeases.id, { onDelete: "cascade" }),
1966
- kind: text("kind", { enum: ["turn", "viewer"] }).notNull(),
2219
+ kind: text("kind", { enum: ["turn", "viewer", "direct", "process"] }).notNull(),
1967
2220
  holderId: text("holder_id").notNull(),
1968
2221
  // The attributing session within the (possibly shared) group.
1969
2222
  subjectId: uuid("subject_id"),
@@ -1971,6 +2224,11 @@ var sandboxLeaseHolders = pgTable(
1971
2224
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
1972
2225
  },
1973
2226
  (table) => ({
2227
+ leaseScope: foreignKey({
2228
+ name: "sandbox_lease_holders_lease_scope_fk",
2229
+ columns: [table.accountId, table.workspaceId, table.leaseId],
2230
+ foreignColumns: [sandboxLeases.accountId, sandboxLeases.workspaceId, sandboxLeases.id]
2231
+ }).onDelete("cascade"),
1974
2232
  holderIdx: uniqueIndex("sandbox_lease_holders_holder_idx").on(
1975
2233
  table.leaseId,
1976
2234
  table.kind,
@@ -1980,6 +2238,258 @@ var sandboxLeaseHolders = pgTable(
1980
2238
  leaseIdx: index("sandbox_lease_holders_lease_idx").on(table.leaseId)
1981
2239
  })
1982
2240
  );
2241
+ var sandboxWorkspaceMutationActorKindValues = ["turn", "direct", "process"];
2242
+ var sandboxWorkspaceMutationHolderKindValues = ["turn", "direct", "process"];
2243
+ var sandboxWorkspaceMutationAdmissions = pgTable(
2244
+ "sandbox_workspace_mutation_admissions",
2245
+ {
2246
+ id: uuid("id").primaryKey().defaultRandom(),
2247
+ accountId: uuid("account_id").notNull(),
2248
+ workspaceId: uuid("workspace_id").notNull(),
2249
+ leaseId: uuid("lease_id").notNull().references(() => sandboxLeases.id, { onDelete: "cascade" }),
2250
+ sandboxGroupId: uuid("sandbox_group_id").notNull(),
2251
+ sessionId: uuid("session_id").notNull(),
2252
+ actorKind: text("actor_kind", { enum: sandboxWorkspaceMutationActorKindValues }).notNull(),
2253
+ actorId: uuid("actor_id").notNull(),
2254
+ // Exact turn authority is present only for actor_kind='turn'. Direct HTTP
2255
+ // requests and retained processes never invent a turn or quiescence owner.
2256
+ turnId: uuid("turn_id"),
2257
+ attemptId: uuid("attempt_id"),
2258
+ executionGeneration: integer("execution_generation"),
2259
+ holderKind: text("holder_kind", {
2260
+ enum: sandboxWorkspaceMutationHolderKindValues
2261
+ }).notNull(),
2262
+ holderId: text("holder_id").notNull(),
2263
+ leaseEpoch: integer("lease_epoch").notNull(),
2264
+ providerBackend: text("provider_backend").notNull(),
2265
+ providerInstanceId: text("provider_instance_id").notNull(),
2266
+ routeKind: text("route_kind", { enum: ["home", "active"] }).notNull(),
2267
+ // null route target means the persistable home/group provider. A non-null
2268
+ // target is pinned together with the active pointer epoch observed when the
2269
+ // operation was admitted.
2270
+ routeTargetId: uuid("route_target_id"),
2271
+ routeEpoch: integer("route_epoch").notNull(),
2272
+ workspaceGeneration: integer("workspace_generation").notNull(),
2273
+ operation: text("operation").notNull(),
2274
+ providerOutcome: text("provider_outcome", {
2275
+ enum: ["resolved", "rejected", "retained"]
2276
+ }),
2277
+ admittedAt: timestamp("admitted_at", { withTimezone: true }).notNull().defaultNow(),
2278
+ settledAt: timestamp("settled_at", { withTimezone: true })
2279
+ },
2280
+ (table) => ({
2281
+ workspaceAccount: foreignKey({
2282
+ name: "sandbox_workspace_mutation_admissions_workspace_account_fk",
2283
+ columns: [table.workspaceId, table.accountId],
2284
+ foreignColumns: [workspaces.id, workspaces.accountId]
2285
+ }).onDelete("cascade"),
2286
+ workspaceSession: foreignKey({
2287
+ name: "sandbox_workspace_mutation_admissions_workspace_session_fk",
2288
+ columns: [table.workspaceId, table.sessionId],
2289
+ foreignColumns: [sessions.workspaceId, sessions.id]
2290
+ }).onDelete("restrict"),
2291
+ workspaceTurn: foreignKey({
2292
+ name: "sandbox_workspace_mutation_admissions_workspace_turn_fk",
2293
+ columns: [table.workspaceId, table.turnId],
2294
+ foreignColumns: [sessionTurns.workspaceId, sessionTurns.id]
2295
+ }).onDelete("restrict"),
2296
+ workspaceAttempt: foreignKey({
2297
+ name: "sandbox_workspace_mutation_admissions_workspace_attempt_fk",
2298
+ columns: [table.workspaceId, table.attemptId],
2299
+ foreignColumns: [sessionTurnAttempts.workspaceId, sessionTurnAttempts.id]
2300
+ }).onDelete("restrict"),
2301
+ leaseGeneration: uniqueIndex("sandbox_workspace_mutation_admissions_lease_generation_uq").on(
2302
+ table.leaseId,
2303
+ table.workspaceGeneration
2304
+ ),
2305
+ scopedId: uniqueIndex("sandbox_workspace_mutation_admissions_scoped_id_uq").on(
2306
+ table.accountId,
2307
+ table.workspaceId,
2308
+ table.sessionId,
2309
+ table.leaseId,
2310
+ table.id
2311
+ ),
2312
+ blocking: index("sandbox_workspace_mutation_admissions_blocking_idx").on(table.leaseId, table.workspaceGeneration).where(sql`${table.settledAt} is null`),
2313
+ attempt: index("sandbox_workspace_mutation_admissions_attempt_idx").on(
2314
+ table.workspaceId,
2315
+ table.attemptId
2316
+ ),
2317
+ actor: index("sandbox_workspace_mutation_admissions_actor_idx").on(
2318
+ table.workspaceId,
2319
+ table.actorKind,
2320
+ table.actorId
2321
+ ),
2322
+ generationValid: check(
2323
+ "sandbox_workspace_mutation_admissions_generation_check",
2324
+ sql`${table.workspaceGeneration} > 0
2325
+ and ${table.leaseEpoch} >= 0
2326
+ and ${table.routeEpoch} >= 0
2327
+ and (${table.executionGeneration} is null or ${table.executionGeneration} > 0)`
2328
+ ),
2329
+ actorValid: check(
2330
+ "sandbox_workspace_mutation_admissions_actor_check",
2331
+ sql`(
2332
+ ${table.actorKind} = 'turn'
2333
+ and ${table.actorId} = ${table.attemptId}
2334
+ and ${table.turnId} is not null
2335
+ and ${table.attemptId} is not null
2336
+ and ${table.executionGeneration} is not null
2337
+ and ${table.holderKind} = 'turn'
2338
+ ) or (
2339
+ ${table.actorKind} = 'direct'
2340
+ and ${table.turnId} is null
2341
+ and ${table.attemptId} is null
2342
+ and ${table.executionGeneration} is null
2343
+ and ${table.holderKind} = 'direct'
2344
+ ) or (
2345
+ ${table.actorKind} = 'process'
2346
+ and ${table.turnId} is null
2347
+ and ${table.attemptId} is null
2348
+ and ${table.executionGeneration} is null
2349
+ and ${table.holderKind} = 'process'
2350
+ )`
2351
+ ),
2352
+ routeValid: check(
2353
+ "sandbox_workspace_mutation_admissions_route_check",
2354
+ sql`${table.actorKind} in ('turn', 'direct', 'process')
2355
+ and ${table.holderKind} in ('turn', 'direct', 'process')
2356
+ and octet_length(${table.holderId}) between 1 and 256
2357
+ and octet_length(${table.providerBackend}) between 1 and 64
2358
+ and octet_length(${table.providerInstanceId}) between 1 and 512
2359
+ and ${table.routeKind} in ('home', 'active')
2360
+ and (${table.routeKind} = 'active' or ${table.routeTargetId} is null)`
2361
+ ),
2362
+ operationValid: check(
2363
+ "sandbox_workspace_mutation_admissions_operation_check",
2364
+ sql`octet_length(${table.operation}) between 1 and 128`
2365
+ ),
2366
+ outcomeValid: check(
2367
+ "sandbox_workspace_mutation_admissions_outcome_check",
2368
+ sql`${table.providerOutcome} is null or ${table.providerOutcome} in ('resolved', 'rejected', 'retained')`
2369
+ ),
2370
+ settlementConsistent: check(
2371
+ "sandbox_workspace_mutation_admissions_settlement_check",
2372
+ sql`(${table.providerOutcome} is null and ${table.settledAt} is null)
2373
+ or (${table.providerOutcome} = 'retained' and ${table.settledAt} is null)
2374
+ or (${table.providerOutcome} in ('resolved', 'rejected') and ${table.settledAt} is not null)`
2375
+ )
2376
+ })
2377
+ );
2378
+ var sandboxRetainedProcessStateValues = ["active", "exited", "lost"];
2379
+ var sandboxRetainedProcesses = pgTable(
2380
+ "sandbox_retained_processes",
2381
+ {
2382
+ id: uuid("id").primaryKey().defaultRandom(),
2383
+ accountId: uuid("account_id").notNull(),
2384
+ workspaceId: uuid("workspace_id").notNull(),
2385
+ sessionId: uuid("session_id").notNull(),
2386
+ leaseId: uuid("lease_id").notNull(),
2387
+ sandboxGroupId: uuid("sandbox_group_id").notNull(),
2388
+ parentAdmissionId: uuid("parent_admission_id").notNull(),
2389
+ holderId: text("holder_id").notNull(),
2390
+ ownerActorKind: text("owner_actor_kind", { enum: ["turn", "direct"] }).notNull(),
2391
+ ownerActorId: uuid("owner_actor_id").notNull(),
2392
+ ownerTurnId: uuid("owner_turn_id"),
2393
+ ownerAttemptId: uuid("owner_attempt_id"),
2394
+ ownerExecutionGeneration: integer("owner_execution_generation"),
2395
+ leaseEpoch: integer("lease_epoch").notNull(),
2396
+ providerBackend: text("provider_backend").notNull(),
2397
+ providerInstanceId: text("provider_instance_id").notNull(),
2398
+ routeKind: text("route_kind", { enum: ["home", "active"] }).notNull(),
2399
+ routeTargetId: uuid("route_target_id"),
2400
+ routeEpoch: integer("route_epoch").notNull(),
2401
+ providerSessionId: integer("provider_session_id").notNull(),
2402
+ state: text("state", { enum: sandboxRetainedProcessStateValues }).notNull().default("active"),
2403
+ exitCode: integer("exit_code"),
2404
+ settlementReason: text("settlement_reason"),
2405
+ startedAt: timestamp("started_at", { withTimezone: true }).notNull().defaultNow(),
2406
+ settledAt: timestamp("settled_at", { withTimezone: true })
2407
+ },
2408
+ (table) => ({
2409
+ workspaceAccount: foreignKey({
2410
+ name: "sandbox_retained_processes_workspace_account_fk",
2411
+ columns: [table.workspaceId, table.accountId],
2412
+ foreignColumns: [workspaces.id, workspaces.accountId]
2413
+ }).onDelete("cascade"),
2414
+ workspaceSession: foreignKey({
2415
+ name: "sandbox_retained_processes_workspace_session_fk",
2416
+ columns: [table.workspaceId, table.sessionId],
2417
+ foreignColumns: [sessions.workspaceId, sessions.id]
2418
+ }).onDelete("restrict"),
2419
+ parentAdmissionScope: foreignKey({
2420
+ name: "sandbox_retained_processes_parent_admission_scope_fk",
2421
+ columns: [
2422
+ table.accountId,
2423
+ table.workspaceId,
2424
+ table.sessionId,
2425
+ table.leaseId,
2426
+ table.parentAdmissionId
2427
+ ],
2428
+ foreignColumns: [
2429
+ sandboxWorkspaceMutationAdmissions.accountId,
2430
+ sandboxWorkspaceMutationAdmissions.workspaceId,
2431
+ sandboxWorkspaceMutationAdmissions.sessionId,
2432
+ sandboxWorkspaceMutationAdmissions.leaseId,
2433
+ sandboxWorkspaceMutationAdmissions.id
2434
+ ]
2435
+ }).onDelete("restrict"),
2436
+ scopedId: uniqueIndex("sandbox_retained_processes_scoped_id_uq").on(
2437
+ table.accountId,
2438
+ table.workspaceId,
2439
+ table.sessionId,
2440
+ table.leaseId,
2441
+ table.id
2442
+ ),
2443
+ parentAdmission: uniqueIndex("sandbox_retained_processes_parent_admission_uq").on(
2444
+ table.parentAdmissionId
2445
+ ),
2446
+ liveProviderSession: uniqueIndex("sandbox_retained_processes_live_provider_session_uq").on(
2447
+ table.leaseId,
2448
+ table.leaseEpoch,
2449
+ table.providerInstanceId,
2450
+ table.routeEpoch,
2451
+ table.providerSessionId
2452
+ ).where(sql`${table.state} = 'active'`),
2453
+ holder: uniqueIndex("sandbox_retained_processes_holder_uq").on(table.leaseId, table.holderId),
2454
+ active: index("sandbox_retained_processes_active_idx").on(table.workspaceId, table.sessionId, table.startedAt).where(sql`${table.state} = 'active'`),
2455
+ identityValid: check(
2456
+ "sandbox_retained_processes_identity_check",
2457
+ sql`${table.leaseEpoch} >= 0
2458
+ and ${table.routeEpoch} >= 0
2459
+ and ${table.providerSessionId} > 0
2460
+ and octet_length(${table.holderId}) between 1 and 256
2461
+ and octet_length(${table.providerBackend}) between 1 and 64
2462
+ and octet_length(${table.providerInstanceId}) between 1 and 512
2463
+ and (${table.routeKind} = 'active' or ${table.routeTargetId} is null)`
2464
+ ),
2465
+ ownerValid: check(
2466
+ "sandbox_retained_processes_owner_check",
2467
+ sql`(
2468
+ ${table.ownerActorKind} = 'turn'
2469
+ and ${table.ownerActorId} = ${table.ownerAttemptId}
2470
+ and ${table.ownerTurnId} is not null
2471
+ and ${table.ownerAttemptId} is not null
2472
+ and ${table.ownerExecutionGeneration} > 0
2473
+ ) or (
2474
+ ${table.ownerActorKind} = 'direct'
2475
+ and ${table.ownerTurnId} is null
2476
+ and ${table.ownerAttemptId} is null
2477
+ and ${table.ownerExecutionGeneration} is null
2478
+ )`
2479
+ ),
2480
+ settlementValid: check(
2481
+ "sandbox_retained_processes_settlement_check",
2482
+ sql`(${table.state} = 'active' and ${table.settledAt} is null and ${table.exitCode} is null)
2483
+ or (${table.state} = 'exited' and ${table.settledAt} is not null)
2484
+ or (${table.state} = 'lost' and ${table.settledAt} is not null and ${table.exitCode} is null)`
2485
+ ),
2486
+ reasonValid: check(
2487
+ "sandbox_retained_processes_reason_check",
2488
+ sql`${table.settlementReason} is null
2489
+ or octet_length(${table.settlementReason}) between 1 and 512`
2490
+ )
2491
+ })
2492
+ );
1983
2493
  var sessionRecordingStateValues = [
1984
2494
  "recording",
1985
2495
  "finalizing",
@@ -2064,11 +2574,18 @@ var sandboxPtySessions = pgTable(
2064
2574
  accountId: uuid("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
2065
2575
  workspaceId: uuid("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
2066
2576
  sessionId: uuid("session_id").notNull().references(() => sessions.id, { onDelete: "cascade" }),
2067
- // The SDK numeric exec-session id used by writeStdin({ sessionId }). Null until
2068
- // the open exec yields a still-running process (a fast-exiting shell has none).
2577
+ leaseId: uuid("lease_id"),
2578
+ sandboxGroupId: uuid("sandbox_group_id"),
2579
+ retainedProcessId: uuid("retained_process_id"),
2580
+ openAdmissionId: uuid("open_admission_id"),
2581
+ // Copied provider locator for the adopted retained process.
2069
2582
  execSessionId: integer("exec_session_id"),
2070
2583
  leaseEpoch: integer("lease_epoch").notNull(),
2071
- // fenced to the box that opened it
2584
+ providerBackend: text("provider_backend"),
2585
+ providerInstanceId: text("provider_instance_id"),
2586
+ routeKind: text("route_kind", { enum: ["home", "active"] }),
2587
+ routeTargetId: uuid("route_target_id"),
2588
+ routeEpoch: integer("route_epoch"),
2072
2589
  cols: integer("cols").notNull(),
2073
2590
  rows: integer("rows").notNull(),
2074
2591
  shell: text("shell").notNull(),
@@ -2083,7 +2600,42 @@ var sandboxPtySessions = pgTable(
2083
2600
  closedAt: timestamp("closed_at", { withTimezone: true })
2084
2601
  },
2085
2602
  (table) => ({
2086
- openIdx: index("sandbox_pty_sessions_session_idx").on(table.workspaceId, table.sessionId).where(sql`${table.status} = 'open'`)
2603
+ retainedProcessScope: foreignKey({
2604
+ name: "sandbox_pty_sessions_retained_process_scope_fk",
2605
+ columns: [
2606
+ table.accountId,
2607
+ table.workspaceId,
2608
+ table.sessionId,
2609
+ table.leaseId,
2610
+ table.retainedProcessId
2611
+ ],
2612
+ foreignColumns: [
2613
+ sandboxRetainedProcesses.accountId,
2614
+ sandboxRetainedProcesses.workspaceId,
2615
+ sandboxRetainedProcesses.sessionId,
2616
+ sandboxRetainedProcesses.leaseId,
2617
+ sandboxRetainedProcesses.id
2618
+ ]
2619
+ }).onDelete("restrict"),
2620
+ openIdx: index("sandbox_pty_sessions_session_idx").on(table.workspaceId, table.sessionId).where(sql`${table.status} = 'open'`),
2621
+ processIdx: uniqueIndex("sandbox_pty_sessions_open_process_uq").on(table.retainedProcessId).where(sql`${table.status} = 'open'`),
2622
+ openIdentityValid: check(
2623
+ "sandbox_pty_sessions_open_identity_check",
2624
+ sql`${table.status} <> 'open' or (
2625
+ ${table.leaseId} is not null
2626
+ and ${table.sandboxGroupId} is not null
2627
+ and ${table.retainedProcessId} is not null
2628
+ and ${table.openAdmissionId} is not null
2629
+ and ${table.execSessionId} > 0
2630
+ and octet_length(${table.providerBackend}) between 1 and 64
2631
+ and octet_length(${table.providerInstanceId}) between 1 and 512
2632
+ and ${table.routeKind} in ('home', 'active')
2633
+ and (${table.routeKind} = 'active' or ${table.routeTargetId} is null)
2634
+ and ${table.routeEpoch} is not null
2635
+ and ${table.leaseEpoch} >= 0
2636
+ and ${table.routeEpoch} >= 0
2637
+ )`
2638
+ )
2087
2639
  })
2088
2640
  );
2089
2641
  var enrollmentExposureValues = ["whole-machine"];
@@ -2535,6 +3087,10 @@ var hostExportOutbox = pgTable(
2535
3087
  "host_export_outbox_kind_check",
2536
3088
  sql`${table.exportKind} in ('session_event', 'usage_event')`
2537
3089
  ),
3090
+ rootSessionCaptured: check(
3091
+ "host_export_outbox_root_session_check",
3092
+ sql`${table.sessionId} is null or ${table.rootSessionId} is not null`
3093
+ ),
2538
3094
  sourceUnique: uniqueIndex("host_export_outbox_source_uq").on(table.exportKind, table.sourceId),
2539
3095
  cursorUnique: uniqueIndex("host_export_outbox_cursor_uq").on(table.exportKind, table.exportCursor).where(sql`${table.exportCursor} is not null`),
2540
3096
  unassigned: index("host_export_outbox_unassigned_idx").on(table.exportKind, table.enqueuedAt, table.id).where(sql`${table.exportCursor} is null`),
@@ -3026,6 +3582,7 @@ var rigChanges = pgTable(
3026
3582
  export {
3027
3583
  managedAccounts,
3028
3584
  workspaces,
3585
+ nestedAgentDepthConfiguration,
3029
3586
  workspaceInferenceControls,
3030
3587
  workspaceSessionActivityRevisions,
3031
3588
  workspaceMemberships,
@@ -3033,6 +3590,7 @@ export {
3033
3590
  workspaceVariableSets,
3034
3591
  workspaceVariableSetVariables,
3035
3592
  codexSubscriptionCredentials,
3593
+ codexResetRedemptionAttempts,
3036
3594
  connections,
3037
3595
  integrationOauthClients,
3038
3596
  integrationOauthStateNonces,
@@ -3040,6 +3598,7 @@ export {
3040
3598
  workspaceModelPolicies,
3041
3599
  codexCredentialLeases,
3042
3600
  sessions,
3601
+ sessionSpawnDenials,
3043
3602
  sessionPins,
3044
3603
  sessionListSnapshots,
3045
3604
  sessionMcpServers,
@@ -3055,6 +3614,7 @@ export {
3055
3614
  workspaceControlEvents,
3056
3615
  sessionAttemptInterruptions,
3057
3616
  composerDrafts,
3617
+ newSessionDrafts,
3058
3618
  sessionSystemUpdates,
3059
3619
  sessionSystemUpdateOutbox,
3060
3620
  sessionWorkflowWakeOutbox,
@@ -3069,6 +3629,11 @@ export {
3069
3629
  sandboxLeaseLivenessValues,
3070
3630
  sandboxLeases,
3071
3631
  sandboxLeaseHolders,
3632
+ sandboxWorkspaceMutationActorKindValues,
3633
+ sandboxWorkspaceMutationHolderKindValues,
3634
+ sandboxWorkspaceMutationAdmissions,
3635
+ sandboxRetainedProcessStateValues,
3636
+ sandboxRetainedProcesses,
3072
3637
  sessionRecordingStateValues,
3073
3638
  sessionRecordingModeValues,
3074
3639
  sessionRecordingCodecValues,
@@ -3111,4 +3676,4 @@ export {
3111
3676
  rigChanges,
3112
3677
  schema_exports
3113
3678
  };
3114
- //# sourceMappingURL=chunk-4LG5NBTC.js.map
3679
+ //# sourceMappingURL=chunk-VUKRIBO5.js.map