@igorjpimenta/manifold 0.0.0-bootstrap.1 → 0.0.0-stage

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 (210) hide show
  1. package/README.md +2 -1583
  2. package/package.json +4 -49
  3. package/.migrations/ops/0000_futuristic_karma.sql +0 -111
  4. package/.migrations/ops/0001_low_maximus.sql +0 -7
  5. package/.migrations/ops/meta/0000_snapshot.json +0 -763
  6. package/.migrations/ops/meta/0001_snapshot.json +0 -173
  7. package/.migrations/ops/meta/_journal.json +0 -20
  8. package/.migrations/runtime/0000_real_boomer.sql +0 -180
  9. package/.migrations/runtime/0001_hot_dakota_north.sql +0 -2
  10. package/.migrations/runtime/0002_breezy_vertigo.sql +0 -8
  11. package/.migrations/runtime/0003_dashing_jack_flag.sql +0 -5
  12. package/.migrations/runtime/0004_panoramic_ego.sql +0 -1
  13. package/.migrations/runtime/0005_tidy_ben_grimm.sql +0 -10
  14. package/.migrations/runtime/0006_wet_nightmare.sql +0 -57
  15. package/.migrations/runtime/0007_ambiguous_chronomancer.sql +0 -8
  16. package/.migrations/runtime/0008_wealthy_thundra.sql +0 -301
  17. package/.migrations/runtime/0009_lying_shocker.sql +0 -96
  18. package/.migrations/runtime/0010_solid_phantom_reporter.sql +0 -160
  19. package/.migrations/runtime/0011_windy_demogoblin.sql +0 -175
  20. package/.migrations/runtime/0012_restore_harness_fks.sql +0 -103
  21. package/.migrations/runtime/meta/0000_snapshot.json +0 -1181
  22. package/.migrations/runtime/meta/0001_snapshot.json +0 -1209
  23. package/.migrations/runtime/meta/0002_snapshot.json +0 -1261
  24. package/.migrations/runtime/meta/0003_snapshot.json +0 -1292
  25. package/.migrations/runtime/meta/0004_snapshot.json +0 -1240
  26. package/.migrations/runtime/meta/0006_snapshot.json +0 -1310
  27. package/.migrations/runtime/meta/0007_snapshot.json +0 -1362
  28. package/.migrations/runtime/meta/0008_snapshot.json +0 -1742
  29. package/.migrations/runtime/meta/0009_snapshot.json +0 -2413
  30. package/.migrations/runtime/meta/0010_snapshot.json +0 -2562
  31. package/.migrations/runtime/meta/0011_snapshot.json +0 -2812
  32. package/.migrations/runtime/meta/0012_snapshot.json +0 -2812
  33. package/.migrations/runtime/meta/_journal.json +0 -97
  34. package/RELEASING.md +0 -89
  35. package/agent/fleet.js +0 -100
  36. package/bin/cli.js +0 -854
  37. package/bin/manifold.js +0 -4
  38. package/boot/flow-revival.js +0 -536
  39. package/budget/index.js +0 -495
  40. package/budget/lib.js +0 -59
  41. package/dashboard/cost.js +0 -528
  42. package/dashboard/dist/assets/index-CUfp63sj.css +0 -1
  43. package/dashboard/dist/assets/index-Qy9JMpma.js +0 -371
  44. package/dashboard/dist/index.html +0 -13
  45. package/dashboard/event-log.js +0 -267
  46. package/dashboard/index.html +0 -12
  47. package/dashboard/package-lock.json +0 -2877
  48. package/dashboard/package.json +0 -37
  49. package/dashboard/pipeline-graph.js +0 -131
  50. package/dashboard/postcss.config.js +0 -6
  51. package/dashboard/search.js +0 -183
  52. package/dashboard/server.js +0 -1015
  53. package/dashboard/src/App.tsx +0 -42
  54. package/dashboard/src/api/client.ts +0 -118
  55. package/dashboard/src/api/types.ts +0 -510
  56. package/dashboard/src/api/ws.tsx +0 -112
  57. package/dashboard/src/components/CancelButton.tsx +0 -63
  58. package/dashboard/src/components/ClickToCopy.tsx +0 -68
  59. package/dashboard/src/components/CopyButton.tsx +0 -61
  60. package/dashboard/src/components/DailyCostTrend.tsx +0 -85
  61. package/dashboard/src/components/DailyTimeTrend.tsx +0 -94
  62. package/dashboard/src/components/Funnel.tsx +0 -149
  63. package/dashboard/src/components/GateForm.tsx +0 -158
  64. package/dashboard/src/components/GraphView.tsx +0 -302
  65. package/dashboard/src/components/GroupPathsSummary.tsx +0 -47
  66. package/dashboard/src/components/Histogram.tsx +0 -292
  67. package/dashboard/src/components/Layout.tsx +0 -28
  68. package/dashboard/src/components/NeedsAttention.tsx +0 -98
  69. package/dashboard/src/components/NodeContextCard.tsx +0 -132
  70. package/dashboard/src/components/PathTrail.tsx +0 -35
  71. package/dashboard/src/components/PipelineCostBreakdown.tsx +0 -277
  72. package/dashboard/src/components/RerunButton.tsx +0 -46
  73. package/dashboard/src/components/RunComparison.tsx +0 -53
  74. package/dashboard/src/components/Sparkline.tsx +0 -94
  75. package/dashboard/src/components/StatStrip.tsx +0 -147
  76. package/dashboard/src/components/StateTree.tsx +0 -84
  77. package/dashboard/src/components/StatusBadge.tsx +0 -18
  78. package/dashboard/src/components/SubflowPathPills.tsx +0 -38
  79. package/dashboard/src/components/SubflowSummary.tsx +0 -24
  80. package/dashboard/src/components/SubflowsCard.tsx +0 -327
  81. package/dashboard/src/components/TodayStrip.tsx +0 -86
  82. package/dashboard/src/components/TranscriptPane.tsx +0 -99
  83. package/dashboard/src/components/TranscriptRow.tsx +0 -69
  84. package/dashboard/src/components/ui/badge.tsx +0 -38
  85. package/dashboard/src/components/ui/button.tsx +0 -28
  86. package/dashboard/src/components/ui/card.tsx +0 -42
  87. package/dashboard/src/components/ui/skeleton.tsx +0 -9
  88. package/dashboard/src/components/ui/table.tsx +0 -62
  89. package/dashboard/src/index.css +0 -26
  90. package/dashboard/src/lib/anomaly.ts +0 -42
  91. package/dashboard/src/lib/format.ts +0 -30
  92. package/dashboard/src/lib/step-history.ts +0 -13
  93. package/dashboard/src/lib/subflow.ts +0 -154
  94. package/dashboard/src/lib/use-click-outside.ts +0 -28
  95. package/dashboard/src/lib/use-ignored-clusters.ts +0 -67
  96. package/dashboard/src/lib/utils.ts +0 -6
  97. package/dashboard/src/main.tsx +0 -10
  98. package/dashboard/src/types/shims.d.ts +0 -4
  99. package/dashboard/src/views/Home.tsx +0 -478
  100. package/dashboard/src/views/PipelineDetail.tsx +0 -1185
  101. package/dashboard/src/views/PipelinesList.tsx +0 -111
  102. package/dashboard/src/views/RunDetail.tsx +0 -248
  103. package/dashboard/src/views/Search.tsx +0 -196
  104. package/dashboard/stats.js +0 -668
  105. package/dashboard/tailwind.config.ts +0 -43
  106. package/dashboard/tree-stats.js +0 -12
  107. package/dashboard/tsconfig.json +0 -25
  108. package/dashboard/views.js +0 -231
  109. package/dashboard/vite.config.ts +0 -34
  110. package/drizzle.config.js +0 -12
  111. package/drizzle.config.ops.js +0 -12
  112. package/elevation.js +0 -116
  113. package/engine/admission-promotion-resume.js +0 -127
  114. package/engine/agent-dispatch.js +0 -64
  115. package/engine/child-resume-trigger.js +0 -315
  116. package/engine/executor-budget.js +0 -87
  117. package/engine/executor-cancel.js +0 -83
  118. package/engine/executor-errors.js +0 -122
  119. package/engine/executor-helpers.js +0 -254
  120. package/engine/executor-nodes.js +0 -292
  121. package/engine/executor-persist.js +0 -212
  122. package/engine/executor-subflow-children.js +0 -275
  123. package/engine/executor.js +0 -1013
  124. package/engine/global-concurrency.js +0 -33
  125. package/engine/loader.js +0 -528
  126. package/engine/needs-resolver.js +0 -229
  127. package/engine/pipelines-watcher.js +0 -133
  128. package/engine/result-replay.js +0 -34
  129. package/engine/revival-messages.js +0 -11
  130. package/engine/spawn-child.js +0 -55
  131. package/engine/wait-for-flow-settlement.js +0 -109
  132. package/events/catalog.js +0 -26
  133. package/events/emit.js +0 -44
  134. package/events/kinds.js +0 -118
  135. package/events/serve-ws.js +0 -74
  136. package/events/stream.js +0 -35
  137. package/events/ws-dialog.js +0 -257
  138. package/events/ws-frame.js +0 -194
  139. package/events/ws-run-events.js +0 -70
  140. package/events.js +0 -32
  141. package/gates/gate-resolver.js +0 -576
  142. package/gates/paused-flows.js +0 -55
  143. package/graphql/columns.js +0 -67
  144. package/graphql/schema.js +0 -333
  145. package/index.js +0 -49
  146. package/mcp/http.js +0 -159
  147. package/mcp/identity.js +0 -94
  148. package/mcp/stdio.js +0 -80
  149. package/mcp/tools.js +0 -245
  150. package/mcp/wire-ops.js +0 -178
  151. package/routes/bearer-auth.js +0 -57
  152. package/routes/discuss-audio.js +0 -87
  153. package/routes/discuss-component.js +0 -39
  154. package/routes/discuss-draft.js +0 -159
  155. package/routes/discuss-helpers.js +0 -20
  156. package/routes/discuss.js +0 -848
  157. package/routes/failures.js +0 -104
  158. package/routes/graphql.js +0 -61
  159. package/routes/health.js +0 -54
  160. package/routes/operator-discuss.js +0 -193
  161. package/routes/operator-resume.js +0 -32
  162. package/routes/operator-retry.js +0 -301
  163. package/routes/operator.js +0 -539
  164. package/routes/pipelines.js +0 -118
  165. package/routes/runs.js +0 -1129
  166. package/scripts/ci/import-check.mjs +0 -50
  167. package/scripts/link-core-self.mjs +0 -31
  168. package/scripts/with-guard.sh +0 -24
  169. package/server/app.js +0 -503
  170. package/server/registry.js +0 -53
  171. package/server/serve.js +0 -163
  172. package/state/admission-queue-store.js +0 -325
  173. package/state/attribution-registries.js +0 -102
  174. package/state/batch-writer.js +0 -162
  175. package/state/db-guard.js +0 -63
  176. package/state/db-health.js +0 -27
  177. package/state/db.js +0 -122
  178. package/state/discuss-store.js +0 -299
  179. package/state/failure-store.js +0 -427
  180. package/state/migrate.js +0 -104
  181. package/state/node-cost.js +0 -67
  182. package/state/node-executions.js +0 -775
  183. package/state/node-health-store.js +0 -124
  184. package/state/ops-merge.js +0 -93
  185. package/state/paths.js +0 -146
  186. package/state/pipeline-dirs.js +0 -99
  187. package/state/pipeline-registry.js +0 -449
  188. package/state/run-store.js +0 -697
  189. package/state/schema.js +0 -438
  190. package/state/schema.ops.js +0 -44
  191. package/state/session-index.js +0 -177
  192. package/state/session-keys.js +0 -39
  193. package/state/state-store.js +0 -311
  194. package/state/subflow-state.js +0 -126
  195. package/state/tool-handoff.js +0 -169
  196. package/telemetry/budget-alert.js +0 -353
  197. package/telemetry/cli.js +0 -331
  198. package/telemetry/grammar.js +0 -119
  199. package/telemetry/http-budget.js +0 -132
  200. package/telemetry/http-cost.js +0 -670
  201. package/telemetry/http-helpers.js +0 -134
  202. package/telemetry/http-tree.js +0 -349
  203. package/telemetry/http.js +0 -44
  204. package/telemetry/index.js +0 -307
  205. package/telemetry/ingest.js +0 -134
  206. package/telemetry/labels.js +0 -115
  207. package/telemetry/pricer.js +0 -77
  208. package/telemetry/resolver.js +0 -314
  209. package/telemetry/store.js +0 -147
  210. package/utils/run-patch.js +0 -43
@@ -1,301 +0,0 @@
1
- -- FK retrofit + pipelines registry.
2
- --
3
- -- SQLite has no ALTER TABLE ADD CONSTRAINT: every FK on an existing table is
4
- -- applied by the 12-step rebuild (create __new, copy, DROP, RENAME). The
5
- -- foreign_keys is off for the whole run, set by state/migrate.js before
6
- -- drizzle begins its snapshot transaction (a PRAGMA inside that transaction
7
- -- is a no-op). Existing rows already violate two of these edges (22
8
- -- invocations without a run, 38 failure rows without an execution); they copy
9
- -- as-is and stay violations until cleaned. pipelines is backfilled from the
10
- -- union of every pipeline_id column before any rebuilt table references it.
11
-
12
- CREATE TABLE IF NOT EXISTS `harnesses` (
13
- `id` text PRIMARY KEY NOT NULL,
14
- `created_at` integer NOT NULL,
15
- `updated_at` integer NOT NULL
16
- );
17
- --> statement-breakpoint
18
- INSERT OR IGNORE INTO `harnesses` (`id`, `created_at`, `updated_at`)
19
- SELECT `harness`, `created_at`, `created_at` FROM `pipeline_dirs` WHERE `harness` IS NOT NULL;--> statement-breakpoint
20
-
21
- CREATE TABLE IF NOT EXISTS `pipelines` (
22
- `id` text PRIMARY KEY NOT NULL,
23
- `name` text NOT NULL,
24
- `harness` text,
25
- `created_at` integer NOT NULL,
26
- `updated_at` integer NOT NULL,
27
- `deleted_at` integer,
28
- FOREIGN KEY (`harness`) REFERENCES `harnesses`(`id`) ON UPDATE no action ON DELETE set null
29
- );
30
- --> statement-breakpoint
31
- CREATE INDEX IF NOT EXISTS `idx_pipelines_harness_name` ON `pipelines` (`harness`,`name`);--> statement-breakpoint
32
- INSERT OR IGNORE INTO `pipelines` (`id`, `name`, `harness`, `created_at`, `updated_at`)
33
- SELECT `id`, `id`, NULL, CAST(strftime('%s','now') AS INTEGER) * 1000, CAST(strftime('%s','now') AS INTEGER) * 1000
34
- FROM (
35
- SELECT `pipeline_id` AS `id` FROM `flow_runs` WHERE `pipeline_id` IS NOT NULL
36
- UNION SELECT `pipeline_id` FROM `pipeline_versions`
37
- UNION SELECT `pipeline_id` FROM `pipeline_node_versions`
38
- UNION SELECT `pipeline_id` FROM `node_health`
39
- UNION SELECT `parent_pipeline_id` FROM `pipeline_versions` WHERE `parent_pipeline_id` IS NOT NULL
40
- );--> statement-breakpoint
41
- INSERT OR IGNORE INTO `harnesses` (`id`, `created_at`, `updated_at`)
42
- SELECT `harness`, `created_at`, `created_at` FROM `pipelines` WHERE `harness` IS NOT NULL;--> statement-breakpoint
43
- CREATE TABLE IF NOT EXISTS `__new_pipeline_dirs` (
44
- `harness` text PRIMARY KEY NOT NULL,
45
- `path` text NOT NULL,
46
- `created_at` integer NOT NULL,
47
- FOREIGN KEY (`harness`) REFERENCES `harnesses`(`id`) ON UPDATE no action ON DELETE cascade
48
- );
49
- --> statement-breakpoint
50
- INSERT INTO `__new_pipeline_dirs`("harness", "path", "created_at") SELECT "harness", "path", "created_at" FROM `pipeline_dirs`;--> statement-breakpoint
51
- DROP TABLE `pipeline_dirs`;--> statement-breakpoint
52
- ALTER TABLE `__new_pipeline_dirs` RENAME TO `pipeline_dirs`;--> statement-breakpoint
53
- CREATE TABLE IF NOT EXISTS `__new_pipeline_node_versions` (
54
- `id` text PRIMARY KEY NOT NULL,
55
- `pipeline_version_id` text NOT NULL,
56
- `pipeline_id` text NOT NULL,
57
- `node_name` text NOT NULL,
58
- `node_id` text,
59
- `kind` text NOT NULL,
60
- `agent` text,
61
- `mode` text,
62
- `content_hash` text NOT NULL,
63
- `registered_at` integer NOT NULL,
64
- `retired_at` integer,
65
- FOREIGN KEY (`pipeline_version_id`) REFERENCES `pipeline_versions`(`id`) ON UPDATE no action ON DELETE cascade,
66
- FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE restrict
67
- );
68
- --> statement-breakpoint
69
- INSERT INTO `__new_pipeline_node_versions`("id", "pipeline_version_id", "pipeline_id", "node_name", "node_id", "kind", "agent", "mode", "content_hash", "registered_at", "retired_at") SELECT "id", "pipeline_version_id", "pipeline_id", "node_name", "node_id", "kind", "agent", "mode", "content_hash", "registered_at", "retired_at" FROM `pipeline_node_versions`;--> statement-breakpoint
70
- DROP TABLE `pipeline_node_versions`;--> statement-breakpoint
71
- ALTER TABLE `__new_pipeline_node_versions` RENAME TO `pipeline_node_versions`;--> statement-breakpoint
72
- CREATE INDEX IF NOT EXISTS `idx_pnv_lookup` ON `pipeline_node_versions` (`pipeline_id`,`node_name`,`registered_at`);--> statement-breakpoint
73
- CREATE UNIQUE INDEX IF NOT EXISTS `idx_pnv_active` ON `pipeline_node_versions` (`pipeline_id`,`node_name`) WHERE "pipeline_node_versions"."retired_at" IS NULL;--> statement-breakpoint
74
- CREATE TABLE IF NOT EXISTS `__new_discuss_state` (
75
- `flow_id` text NOT NULL,
76
- `item_id` text NOT NULL,
77
- `messages_json` text DEFAULT '[]' NOT NULL,
78
- `turn_status` text DEFAULT 'idle' NOT NULL,
79
- `active_turn_id` text,
80
- `pending_json` text,
81
- `updated_at` integer NOT NULL,
82
- `components_json` text DEFAULT '[]' NOT NULL,
83
- FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade
84
- );
85
- --> statement-breakpoint
86
- INSERT INTO `__new_discuss_state`("flow_id", "item_id", "messages_json", "turn_status", "active_turn_id", "pending_json", "updated_at", "components_json") SELECT "flow_id", "item_id", "messages_json", "turn_status", "active_turn_id", "pending_json", "updated_at", "components_json" FROM `discuss_state`;--> statement-breakpoint
87
- DROP TABLE `discuss_state`;--> statement-breakpoint
88
- ALTER TABLE `__new_discuss_state` RENAME TO `discuss_state`;--> statement-breakpoint
89
- CREATE INDEX IF NOT EXISTS `idx_discuss_updated` ON `discuss_state` (`updated_at`);--> statement-breakpoint
90
- CREATE UNIQUE INDEX IF NOT EXISTS `idx_discuss_state_unique` ON `discuss_state` (`flow_id`,`item_id`);--> statement-breakpoint
91
- CREATE TABLE IF NOT EXISTS `__new_discuss_threads` (
92
- `flow_id` text NOT NULL,
93
- `gate_node_id` text NOT NULL,
94
- `item_id` text NOT NULL,
95
- `agent_id` text,
96
- `session_key` text NOT NULL,
97
- `updated_at` integer NOT NULL,
98
- FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade
99
- );
100
- --> statement-breakpoint
101
- INSERT INTO `__new_discuss_threads`("flow_id", "gate_node_id", "item_id", "agent_id", "session_key", "updated_at") SELECT "flow_id", "gate_node_id", "item_id", "agent_id", "session_key", "updated_at" FROM `discuss_threads`;--> statement-breakpoint
102
- DROP TABLE `discuss_threads`;--> statement-breakpoint
103
- ALTER TABLE `__new_discuss_threads` RENAME TO `discuss_threads`;--> statement-breakpoint
104
- CREATE UNIQUE INDEX IF NOT EXISTS `idx_discuss_threads_unique` ON `discuss_threads` (`flow_id`,`gate_node_id`,`item_id`);--> statement-breakpoint
105
- CREATE TABLE IF NOT EXISTS `__new_failure_events` (
106
- `id` text PRIMARY KEY NOT NULL,
107
- `flow_id` text NOT NULL,
108
- `failed_at` integer NOT NULL,
109
- `failure_summary` text NOT NULL,
110
- `invocation_id` text,
111
- `execution_id` text,
112
- `error_type` text,
113
- FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade,
114
- FOREIGN KEY (`invocation_id`) REFERENCES `flow_node_invocations`(`id`) ON UPDATE no action ON DELETE set null,
115
- FOREIGN KEY (`execution_id`) REFERENCES `flow_node_executions`(`id`) ON UPDATE no action ON DELETE set null
116
- );
117
- --> statement-breakpoint
118
- INSERT INTO `__new_failure_events`("id", "flow_id", "failed_at", "failure_summary", "invocation_id", "execution_id", "error_type") SELECT "id", "flow_id", "failed_at", "failure_summary", "invocation_id", "execution_id", "error_type" FROM `failure_events`;--> statement-breakpoint
119
- DROP TABLE `failure_events`;--> statement-breakpoint
120
- ALTER TABLE `__new_failure_events` RENAME TO `failure_events`;--> statement-breakpoint
121
- CREATE INDEX IF NOT EXISTS `idx_failures_flow` ON `failure_events` (`flow_id`);--> statement-breakpoint
122
- CREATE INDEX IF NOT EXISTS `idx_failures_failed_at` ON `failure_events` (`failed_at` DESC);--> statement-breakpoint
123
- CREATE INDEX IF NOT EXISTS `idx_failures_invocation` ON `failure_events` (`invocation_id`);--> statement-breakpoint
124
- CREATE UNIQUE INDEX IF NOT EXISTS `idx_failures_execution` ON `failure_events` (`execution_id`) WHERE "failure_events"."execution_id" IS NOT NULL;--> statement-breakpoint
125
- CREATE TABLE IF NOT EXISTS `__new_flow_admission_queue` (
126
- `id` text PRIMARY KEY NOT NULL,
127
- `kind` text NOT NULL,
128
- `flow_id` text NOT NULL,
129
- `node_id` text,
130
- `status` text NOT NULL,
131
- `created_at` integer NOT NULL,
132
- `admitted_at` integer,
133
- FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade
134
- );
135
- --> statement-breakpoint
136
- INSERT INTO `__new_flow_admission_queue`("id", "kind", "flow_id", "node_id", "status", "created_at", "admitted_at") SELECT "id", "kind", "flow_id", "node_id", "status", "created_at", "admitted_at" FROM `flow_admission_queue`;--> statement-breakpoint
137
- DROP TABLE `flow_admission_queue`;--> statement-breakpoint
138
- ALTER TABLE `__new_flow_admission_queue` RENAME TO `flow_admission_queue`;--> statement-breakpoint
139
- CREATE INDEX IF NOT EXISTS `idx_admission_status` ON `flow_admission_queue` (`status`);--> statement-breakpoint
140
- CREATE INDEX IF NOT EXISTS `idx_admission_flow` ON `flow_admission_queue` (`flow_id`);--> statement-breakpoint
141
- CREATE INDEX IF NOT EXISTS `idx_admission_status_created` ON `flow_admission_queue` (`status`,`created_at`);--> statement-breakpoint
142
- CREATE TABLE IF NOT EXISTS `__new_flow_events` (
143
- `id` text PRIMARY KEY NOT NULL,
144
- `flow_id` text NOT NULL,
145
- `event_type` text NOT NULL,
146
- `prev_step` text,
147
- `curr_step` text,
148
- `prev_status` text,
149
- `curr_status` text,
150
- `wait_kind` text,
151
- `occurred_at` integer NOT NULL,
152
- FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade
153
- );
154
- --> statement-breakpoint
155
- INSERT INTO `__new_flow_events`("id", "flow_id", "event_type", "prev_step", "curr_step", "prev_status", "curr_status", "wait_kind", "occurred_at") SELECT "id", "flow_id", "event_type", "prev_step", "curr_step", "prev_status", "curr_status", "wait_kind", "occurred_at" FROM `flow_events`;--> statement-breakpoint
156
- DROP TABLE `flow_events`;--> statement-breakpoint
157
- ALTER TABLE `__new_flow_events` RENAME TO `flow_events`;--> statement-breakpoint
158
- CREATE INDEX IF NOT EXISTS `idx_flow_events_flow_id` ON `flow_events` (`flow_id`);--> statement-breakpoint
159
- CREATE INDEX IF NOT EXISTS `idx_flow_events_occurred_at` ON `flow_events` (`occurred_at`);--> statement-breakpoint
160
- CREATE TABLE IF NOT EXISTS `__new_flow_node_executions` (
161
- `id` text PRIMARY KEY NOT NULL,
162
- `invocation_id` text NOT NULL,
163
- `entered_at` integer NOT NULL,
164
- `exited_at` integer NOT NULL,
165
- `kind` text DEFAULT 'legacy' NOT NULL,
166
- FOREIGN KEY (`invocation_id`) REFERENCES `flow_node_invocations`(`id`) ON UPDATE no action ON DELETE cascade
167
- );
168
- --> statement-breakpoint
169
- INSERT INTO `__new_flow_node_executions`("id", "invocation_id", "entered_at", "exited_at", "kind") SELECT "id", "invocation_id", "entered_at", "exited_at", "kind" FROM `flow_node_executions`;--> statement-breakpoint
170
- DROP TABLE `flow_node_executions`;--> statement-breakpoint
171
- ALTER TABLE `__new_flow_node_executions` RENAME TO `flow_node_executions`;--> statement-breakpoint
172
- CREATE INDEX IF NOT EXISTS `idx_fne_invocation` ON `flow_node_executions` (`invocation_id`);--> statement-breakpoint
173
- CREATE INDEX IF NOT EXISTS `idx_fne_exited` ON `flow_node_executions` (`exited_at`);--> statement-breakpoint
174
- CREATE TABLE IF NOT EXISTS `__new_flow_node_invocations` (
175
- `id` text PRIMARY KEY NOT NULL,
176
- `flow_id` text NOT NULL,
177
- `pipeline_id` text,
178
- `node_id` text NOT NULL,
179
- `subflow_key` text,
180
- `visit_seq` integer DEFAULT 1 NOT NULL,
181
- `invoked_at` integer NOT NULL,
182
- `result_json` text,
183
- `result_written_at` integer,
184
- `result_too_large_bytes` integer,
185
- FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade
186
- );
187
- --> statement-breakpoint
188
- INSERT INTO `__new_flow_node_invocations`("id", "flow_id", "pipeline_id", "node_id", "subflow_key", "visit_seq", "invoked_at", "result_json", "result_written_at", "result_too_large_bytes") SELECT "id", "flow_id", "pipeline_id", "node_id", "subflow_key", "visit_seq", "invoked_at", "result_json", "result_written_at", "result_too_large_bytes" FROM `flow_node_invocations`;--> statement-breakpoint
189
- DROP TABLE `flow_node_invocations`;--> statement-breakpoint
190
- ALTER TABLE `__new_flow_node_invocations` RENAME TO `flow_node_invocations`;--> statement-breakpoint
191
- CREATE INDEX IF NOT EXISTS `idx_invocations_flow` ON `flow_node_invocations` (`flow_id`);--> statement-breakpoint
192
- CREATE INDEX IF NOT EXISTS `idx_invocations_node_subflow` ON `flow_node_invocations` (`node_id`,`subflow_key`);--> statement-breakpoint
193
- CREATE INDEX IF NOT EXISTS `idx_invocations_pipe_node` ON `flow_node_invocations` (`pipeline_id`,`node_id`);--> statement-breakpoint
194
- CREATE UNIQUE INDEX IF NOT EXISTS `idx_invocations_identity` ON `flow_node_invocations` (`flow_id`,`node_id`,COALESCE(`subflow_key`, ''),`visit_seq`);--> statement-breakpoint
195
- CREATE TABLE IF NOT EXISTS `__new_flow_runs` (
196
- `flow_id` text PRIMARY KEY NOT NULL,
197
- `owner_key` text DEFAULT '' NOT NULL,
198
- `revision` integer DEFAULT 0 NOT NULL,
199
- `status` text NOT NULL,
200
- `last_step` text,
201
- `status_reason` text,
202
- `state_json` text DEFAULT '{}' NOT NULL,
203
- `wait_json` text,
204
- `cancel_requested_at` integer,
205
- `created_at` integer NOT NULL,
206
- `updated_at` integer NOT NULL,
207
- `ended_at` integer,
208
- `parent_invocation_id` text,
209
- `pipeline_id` text,
210
- FOREIGN KEY (`parent_invocation_id`) REFERENCES `flow_node_invocations`(`id`) ON UPDATE no action ON DELETE set null,
211
- FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE set null
212
- );
213
- --> statement-breakpoint
214
- INSERT INTO `__new_flow_runs`("flow_id", "owner_key", "revision", "status", "last_step", "status_reason", "state_json", "wait_json", "cancel_requested_at", "created_at", "updated_at", "ended_at", "parent_invocation_id", "pipeline_id") SELECT "flow_id", "owner_key", "revision", "status", "last_step", "status_reason", "state_json", "wait_json", "cancel_requested_at", "created_at", "updated_at", "ended_at", "parent_invocation_id", "pipeline_id" FROM `flow_runs`;--> statement-breakpoint
215
- DROP TABLE `flow_runs`;--> statement-breakpoint
216
- ALTER TABLE `__new_flow_runs` RENAME TO `flow_runs`;--> statement-breakpoint
217
- CREATE INDEX IF NOT EXISTS `idx_pfr_status` ON `flow_runs` (`status`) WHERE "flow_runs"."ended_at" IS NULL;--> statement-breakpoint
218
- CREATE INDEX IF NOT EXISTS `idx_pfr_updated` ON `flow_runs` (`updated_at` DESC);--> statement-breakpoint
219
- CREATE INDEX IF NOT EXISTS `idx_pfr_created` ON `flow_runs` (`created_at` DESC);--> statement-breakpoint
220
- CREATE UNIQUE INDEX IF NOT EXISTS `idx_pfr_parent_invocation` ON `flow_runs` (`parent_invocation_id`) WHERE "flow_runs"."parent_invocation_id" IS NOT NULL;--> statement-breakpoint
221
- CREATE INDEX IF NOT EXISTS `idx_flow_runs_pipeline_id` ON `flow_runs` (`pipeline_id`);--> statement-breakpoint
222
- CREATE TABLE IF NOT EXISTS `__new_flow_sessions` (
223
- `id` text PRIMARY KEY NOT NULL,
224
- `flow_id` text NOT NULL,
225
- `session_key` text NOT NULL,
226
- `node_id` text,
227
- `branch_item_id` text,
228
- `spawned_at` integer NOT NULL,
229
- FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade
230
- );
231
- --> statement-breakpoint
232
- INSERT INTO `__new_flow_sessions`("id", "flow_id", "session_key", "node_id", "branch_item_id", "spawned_at") SELECT "id", "flow_id", "session_key", "node_id", "branch_item_id", "spawned_at" FROM `flow_sessions`;--> statement-breakpoint
233
- DROP TABLE `flow_sessions`;--> statement-breakpoint
234
- ALTER TABLE `__new_flow_sessions` RENAME TO `flow_sessions`;--> statement-breakpoint
235
- CREATE INDEX IF NOT EXISTS `idx_flow_sessions_flow_id` ON `flow_sessions` (`flow_id`);--> statement-breakpoint
236
- CREATE UNIQUE INDEX IF NOT EXISTS `idx_flow_sessions_uniq` ON `flow_sessions` (`flow_id`,`session_key`);--> statement-breakpoint
237
- CREATE TABLE IF NOT EXISTS `__new_gate_records` (
238
- `flow_id` text NOT NULL,
239
- `node_id` text NOT NULL,
240
- `record_json` text NOT NULL,
241
- `updated_at` integer NOT NULL,
242
- PRIMARY KEY(`flow_id`, `node_id`),
243
- FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade
244
- );
245
- --> statement-breakpoint
246
- INSERT INTO `__new_gate_records`("flow_id", "node_id", "record_json", "updated_at") SELECT "flow_id", "node_id", "record_json", "updated_at" FROM `gate_records`;--> statement-breakpoint
247
- DROP TABLE `gate_records`;--> statement-breakpoint
248
- ALTER TABLE `__new_gate_records` RENAME TO `gate_records`;--> statement-breakpoint
249
- CREATE TABLE IF NOT EXISTS `__new_node_health` (
250
- `id` text PRIMARY KEY NOT NULL,
251
- `pipeline_id` text NOT NULL,
252
- `node_id` text NOT NULL,
253
- `status` text NOT NULL,
254
- `reason` text NOT NULL,
255
- `blocked_by_flow_id` text,
256
- `resolved_via` text,
257
- `created_at` integer NOT NULL,
258
- `updated_at` integer NOT NULL,
259
- `ended_at` integer,
260
- FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE restrict,
261
- FOREIGN KEY (`blocked_by_flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null
262
- );
263
- --> statement-breakpoint
264
- INSERT INTO `__new_node_health`("id", "pipeline_id", "node_id", "status", "reason", "blocked_by_flow_id", "resolved_via", "created_at", "updated_at", "ended_at") SELECT "id", "pipeline_id", "node_id", "status", "reason", "blocked_by_flow_id", "resolved_via", "created_at", "updated_at", "ended_at" FROM `node_health`;--> statement-breakpoint
265
- DROP TABLE `node_health`;--> statement-breakpoint
266
- ALTER TABLE `__new_node_health` RENAME TO `node_health`;--> statement-breakpoint
267
- CREATE UNIQUE INDEX IF NOT EXISTS `idx_node_health_one_active` ON `node_health` (`pipeline_id`,`node_id`) WHERE "node_health"."status" = 'blocked';--> statement-breakpoint
268
- CREATE INDEX IF NOT EXISTS `idx_node_health_pipeline` ON `node_health` (`pipeline_id`,`status`);--> statement-breakpoint
269
- CREATE TABLE IF NOT EXISTS `__new_pipeline_versions` (
270
- `id` text PRIMARY KEY NOT NULL,
271
- `pipeline_id` text NOT NULL,
272
- `kind` text,
273
- `allow_concurrent` text,
274
- `is_synthetic` integer NOT NULL,
275
- `parent_pipeline_id` text,
276
- `source_path` text,
277
- `content_hash` text NOT NULL,
278
- `registered_at` integer NOT NULL,
279
- `retired_at` integer,
280
- FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE restrict,
281
- FOREIGN KEY (`parent_pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE set null
282
- );
283
- --> statement-breakpoint
284
- INSERT INTO `__new_pipeline_versions`("id", "pipeline_id", "kind", "allow_concurrent", "is_synthetic", "parent_pipeline_id", "source_path", "content_hash", "registered_at", "retired_at") SELECT "id", "pipeline_id", "kind", "allow_concurrent", "is_synthetic", "parent_pipeline_id", "source_path", "content_hash", "registered_at", "retired_at" FROM `pipeline_versions`;--> statement-breakpoint
285
- DROP TABLE `pipeline_versions`;--> statement-breakpoint
286
- ALTER TABLE `__new_pipeline_versions` RENAME TO `pipeline_versions`;--> statement-breakpoint
287
- CREATE INDEX IF NOT EXISTS `idx_pv_lookup` ON `pipeline_versions` (`pipeline_id`,`registered_at`);--> statement-breakpoint
288
- CREATE UNIQUE INDEX IF NOT EXISTS `idx_pv_active` ON `pipeline_versions` (`pipeline_id`) WHERE "pipeline_versions"."retired_at" IS NULL;--> statement-breakpoint
289
- CREATE TABLE IF NOT EXISTS `__new_tool_results` (
290
- `session_key` text PRIMARY KEY NOT NULL,
291
- `run_id` text,
292
- `agent_id` text,
293
- `kind` text,
294
- `payload_json` text NOT NULL,
295
- `updated_at` integer NOT NULL,
296
- FOREIGN KEY (`run_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null
297
- );
298
- --> statement-breakpoint
299
- INSERT INTO `__new_tool_results`("session_key", "run_id", "agent_id", "kind", "payload_json", "updated_at") SELECT "session_key", "run_id", "agent_id", "kind", "payload_json", "updated_at" FROM `tool_results`;--> statement-breakpoint
300
- DROP TABLE `tool_results`;--> statement-breakpoint
301
- ALTER TABLE `__new_tool_results` RENAME TO `tool_results`;
@@ -1,96 +0,0 @@
1
- -- Move the lineage/cost tables into runtime so their flow_id/pipeline_id
2
- -- columns can carry FKs (SQLite cannot constrain across database files).
3
- -- Data is copied once by state/ops-merge.js after this snapshot runs; the
4
- -- CREATEs stay IF NOT EXISTS so a retried migration is safe.
5
- CREATE TABLE IF NOT EXISTS `cost_by_call` (
6
- `session_id` text NOT NULL,
7
- `msg_id` text NOT NULL,
8
- `ts` integer NOT NULL,
9
- `provider` text,
10
- `model` text,
11
- `input_tokens` integer,
12
- `output_tokens` integer,
13
- `cache_read_tokens` integer,
14
- `cache_write_tokens` integer,
15
- `total_tokens` integer,
16
- `cost_input` real,
17
- `cost_output` real,
18
- `cost_cache_read` real,
19
- `cost_cache_write` real,
20
- `cost_total` real NOT NULL,
21
- `session_key` text,
22
- `agent_id` text,
23
- `root_session_key` text,
24
- `root_kind` text,
25
- `root_label` text,
26
- `pipeline_id` text,
27
- `flow_id` text,
28
- `node_id` text,
29
- `item_key` text,
30
- PRIMARY KEY(`session_id`, `msg_id`),
31
- FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE set null,
32
- FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null
33
- );
34
- --> statement-breakpoint
35
- CREATE INDEX IF NOT EXISTS `idx_cost_ts` ON `cost_by_call` (`ts`);--> statement-breakpoint
36
- CREATE INDEX IF NOT EXISTS `idx_cost_root_key` ON `cost_by_call` (`root_session_key`);--> statement-breakpoint
37
- CREATE INDEX IF NOT EXISTS `idx_cost_root_kind_ts` ON `cost_by_call` (`root_kind`,`ts`);--> statement-breakpoint
38
- CREATE INDEX IF NOT EXISTS `idx_cost_pipeline_ts` ON `cost_by_call` (`pipeline_id`,`ts`);--> statement-breakpoint
39
- CREATE INDEX IF NOT EXISTS `idx_cost_flow_node` ON `cost_by_call` (`flow_id`,`node_id`);--> statement-breakpoint
40
- CREATE INDEX IF NOT EXISTS `idx_cost_model_ts` ON `cost_by_call` (`model`,`ts`);--> statement-breakpoint
41
- CREATE INDEX IF NOT EXISTS `idx_cost_session` ON `cost_by_call` (`session_id`);--> statement-breakpoint
42
- CREATE TABLE IF NOT EXISTS `queue_items` (
43
- `id` text PRIMARY KEY NOT NULL,
44
- `label` text NOT NULL,
45
- `agent` text NOT NULL,
46
- `agent_emoji` text DEFAULT '🤖' NOT NULL,
47
- `trigger` text DEFAULT 'manual' NOT NULL,
48
- `cost_low` real DEFAULT 0 NOT NULL,
49
- `cost_high` real DEFAULT 0 NOT NULL,
50
- `brief` text,
51
- `model_chain` text,
52
- `pipeline` text,
53
- `node` text,
54
- `token_estimate` integer,
55
- `status` text DEFAULT 'pending' NOT NULL,
56
- `created_at` integer NOT NULL,
57
- `expires_at` integer,
58
- `decided_at` integer,
59
- `decision` text,
60
- `pipeline_id` text,
61
- `pipeline_args` text,
62
- `flow_id` text,
63
- `enqueuer_session_key` text,
64
- `kind` text,
65
- FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE set null,
66
- FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null
67
- );
68
- --> statement-breakpoint
69
- CREATE INDEX IF NOT EXISTS `idx_status` ON `queue_items` (`status`);--> statement-breakpoint
70
- CREATE INDEX IF NOT EXISTS `idx_created_at` ON `queue_items` ("created_at" desc);--> statement-breakpoint
71
- CREATE INDEX IF NOT EXISTS `idx_flow_node` ON `queue_items` (`flow_id`,`node`);--> statement-breakpoint
72
- CREATE TABLE IF NOT EXISTS `session_lineage` (
73
- `child_session_key` text PRIMARY KEY NOT NULL,
74
- `parent_session_key` text,
75
- `root_session_key` text NOT NULL,
76
- `kind` text NOT NULL,
77
- `root_kind` text NOT NULL,
78
- `root_label` text,
79
- `agent_id` text,
80
- `pipeline_id` text,
81
- `flow_id` text,
82
- `node_id` text,
83
- `item_key` text,
84
- `first_seen_at` integer NOT NULL,
85
- `source` text NOT NULL,
86
- `run_id` text,
87
- FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE set null,
88
- FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null
89
- );
90
- --> statement-breakpoint
91
- CREATE INDEX IF NOT EXISTS `idx_lineage_root` ON `session_lineage` (`root_session_key`);--> statement-breakpoint
92
- CREATE INDEX IF NOT EXISTS `idx_lineage_parent` ON `session_lineage` (`parent_session_key`);--> statement-breakpoint
93
- CREATE INDEX IF NOT EXISTS `idx_lineage_pipeline` ON `session_lineage` (`pipeline_id`);--> statement-breakpoint
94
- CREATE INDEX IF NOT EXISTS `idx_lineage_flow` ON `session_lineage` (`flow_id`);--> statement-breakpoint
95
- CREATE INDEX IF NOT EXISTS `idx_lineage_root_kind` ON `session_lineage` (`root_kind`);--> statement-breakpoint
96
- CREATE INDEX IF NOT EXISTS `idx_lineage_run` ON `session_lineage` (`run_id`);
@@ -1,160 +0,0 @@
1
- CREATE TABLE IF NOT EXISTS `sessions` (
2
- `session_key` text PRIMARY KEY NOT NULL,
3
- `first_seen_at` integer NOT NULL
4
- );
5
- --> statement-breakpoint
6
- CREATE INDEX IF NOT EXISTS `idx_sessions_first_seen` ON `sessions` (`first_seen_at`);--> statement-breakpoint
7
- PRAGMA foreign_keys=OFF;--> statement-breakpoint
8
- CREATE TABLE IF NOT EXISTS `__new_cost_by_call` (
9
- `session_id` text NOT NULL,
10
- `msg_id` text NOT NULL,
11
- `ts` integer NOT NULL,
12
- `provider` text,
13
- `model` text,
14
- `input_tokens` integer,
15
- `output_tokens` integer,
16
- `cache_read_tokens` integer,
17
- `cache_write_tokens` integer,
18
- `total_tokens` integer,
19
- `cost_input` real,
20
- `cost_output` real,
21
- `cost_cache_read` real,
22
- `cost_cache_write` real,
23
- `cost_total` real NOT NULL,
24
- `session_key` text,
25
- `agent_id` text,
26
- `root_session_key` text,
27
- `root_kind` text,
28
- `root_label` text,
29
- `pipeline_id` text,
30
- `flow_id` text,
31
- `node_id` text,
32
- `item_key` text,
33
- PRIMARY KEY(`session_id`, `msg_id`),
34
- FOREIGN KEY (`session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE set null,
35
- FOREIGN KEY (`root_session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE set null,
36
- FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE set null,
37
- FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null
38
- );
39
- --> statement-breakpoint
40
- INSERT INTO `__new_cost_by_call`("session_id", "msg_id", "ts", "provider", "model", "input_tokens", "output_tokens", "cache_read_tokens", "cache_write_tokens", "total_tokens", "cost_input", "cost_output", "cost_cache_read", "cost_cache_write", "cost_total", "session_key", "agent_id", "root_session_key", "root_kind", "root_label", "pipeline_id", "flow_id", "node_id", "item_key") SELECT "session_id", "msg_id", "ts", "provider", "model", "input_tokens", "output_tokens", "cache_read_tokens", "cache_write_tokens", "total_tokens", "cost_input", "cost_output", "cost_cache_read", "cost_cache_write", "cost_total", "session_key", "agent_id", "root_session_key", "root_kind", "root_label", "pipeline_id", "flow_id", "node_id", "item_key" FROM `cost_by_call`;--> statement-breakpoint
41
- DROP TABLE `cost_by_call`;--> statement-breakpoint
42
- ALTER TABLE `__new_cost_by_call` RENAME TO `cost_by_call`;--> statement-breakpoint
43
- PRAGMA foreign_keys=ON;--> statement-breakpoint
44
- CREATE INDEX IF NOT EXISTS `idx_cost_ts` ON `cost_by_call` (`ts`);--> statement-breakpoint
45
- CREATE INDEX IF NOT EXISTS `idx_cost_root_key` ON `cost_by_call` (`root_session_key`);--> statement-breakpoint
46
- CREATE INDEX IF NOT EXISTS `idx_cost_root_kind_ts` ON `cost_by_call` (`root_kind`,`ts`);--> statement-breakpoint
47
- CREATE INDEX IF NOT EXISTS `idx_cost_pipeline_ts` ON `cost_by_call` (`pipeline_id`,`ts`);--> statement-breakpoint
48
- CREATE INDEX IF NOT EXISTS `idx_cost_flow_node` ON `cost_by_call` (`flow_id`,`node_id`);--> statement-breakpoint
49
- CREATE INDEX IF NOT EXISTS `idx_cost_model_ts` ON `cost_by_call` (`model`,`ts`);--> statement-breakpoint
50
- CREATE INDEX IF NOT EXISTS `idx_cost_session` ON `cost_by_call` (`session_id`);--> statement-breakpoint
51
- CREATE TABLE IF NOT EXISTS `__new_discuss_threads` (
52
- `flow_id` text NOT NULL,
53
- `gate_node_id` text NOT NULL,
54
- `item_id` text NOT NULL,
55
- `agent_id` text,
56
- `session_key` text NOT NULL,
57
- `updated_at` integer NOT NULL,
58
- FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade,
59
- FOREIGN KEY (`session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE no action
60
- );
61
- --> statement-breakpoint
62
- INSERT INTO `__new_discuss_threads`("flow_id", "gate_node_id", "item_id", "agent_id", "session_key", "updated_at") SELECT "flow_id", "gate_node_id", "item_id", "agent_id", "session_key", "updated_at" FROM `discuss_threads`;--> statement-breakpoint
63
- DROP TABLE `discuss_threads`;--> statement-breakpoint
64
- ALTER TABLE `__new_discuss_threads` RENAME TO `discuss_threads`;--> statement-breakpoint
65
- CREATE UNIQUE INDEX IF NOT EXISTS `idx_discuss_threads_unique` ON `discuss_threads` (`flow_id`,`gate_node_id`,`item_id`);--> statement-breakpoint
66
- CREATE TABLE IF NOT EXISTS `__new_flow_sessions` (
67
- `id` text PRIMARY KEY NOT NULL,
68
- `flow_id` text NOT NULL,
69
- `session_key` text NOT NULL,
70
- `node_id` text,
71
- `branch_item_id` text,
72
- `spawned_at` integer NOT NULL,
73
- FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade,
74
- FOREIGN KEY (`session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE no action
75
- );
76
- --> statement-breakpoint
77
- INSERT INTO `__new_flow_sessions`("id", "flow_id", "session_key", "node_id", "branch_item_id", "spawned_at") SELECT "id", "flow_id", "session_key", "node_id", "branch_item_id", "spawned_at" FROM `flow_sessions`;--> statement-breakpoint
78
- DROP TABLE `flow_sessions`;--> statement-breakpoint
79
- ALTER TABLE `__new_flow_sessions` RENAME TO `flow_sessions`;--> statement-breakpoint
80
- CREATE INDEX IF NOT EXISTS `idx_flow_sessions_flow_id` ON `flow_sessions` (`flow_id`);--> statement-breakpoint
81
- CREATE UNIQUE INDEX IF NOT EXISTS `idx_flow_sessions_uniq` ON `flow_sessions` (`flow_id`,`session_key`);--> statement-breakpoint
82
- CREATE TABLE IF NOT EXISTS `__new_queue_items` (
83
- `id` text PRIMARY KEY NOT NULL,
84
- `label` text NOT NULL,
85
- `agent` text NOT NULL,
86
- `agent_emoji` text DEFAULT '🤖' NOT NULL,
87
- `trigger` text DEFAULT 'manual' NOT NULL,
88
- `cost_low` real DEFAULT 0 NOT NULL,
89
- `cost_high` real DEFAULT 0 NOT NULL,
90
- `brief` text,
91
- `model_chain` text,
92
- `pipeline` text,
93
- `node` text,
94
- `token_estimate` integer,
95
- `status` text DEFAULT 'pending' NOT NULL,
96
- `created_at` integer NOT NULL,
97
- `expires_at` integer,
98
- `decided_at` integer,
99
- `decision` text,
100
- `pipeline_id` text,
101
- `pipeline_args` text,
102
- `flow_id` text,
103
- `enqueuer_session_key` text,
104
- `kind` text,
105
- FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE set null,
106
- FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null,
107
- FOREIGN KEY (`enqueuer_session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE set null
108
- );
109
- --> statement-breakpoint
110
- INSERT INTO `__new_queue_items`("id", "label", "agent", "agent_emoji", "trigger", "cost_low", "cost_high", "brief", "model_chain", "pipeline", "node", "token_estimate", "status", "created_at", "expires_at", "decided_at", "decision", "pipeline_id", "pipeline_args", "flow_id", "enqueuer_session_key", "kind") SELECT "id", "label", "agent", "agent_emoji", "trigger", "cost_low", "cost_high", "brief", "model_chain", "pipeline", "node", "token_estimate", "status", "created_at", "expires_at", "decided_at", "decision", "pipeline_id", "pipeline_args", "flow_id", "enqueuer_session_key", "kind" FROM `queue_items`;--> statement-breakpoint
111
- DROP TABLE `queue_items`;--> statement-breakpoint
112
- ALTER TABLE `__new_queue_items` RENAME TO `queue_items`;--> statement-breakpoint
113
- CREATE INDEX IF NOT EXISTS `idx_status` ON `queue_items` (`status`);--> statement-breakpoint
114
- CREATE INDEX IF NOT EXISTS `idx_created_at` ON `queue_items` ("created_at" desc);--> statement-breakpoint
115
- CREATE INDEX IF NOT EXISTS `idx_flow_node` ON `queue_items` (`flow_id`,`node`);--> statement-breakpoint
116
- CREATE TABLE IF NOT EXISTS `__new_session_lineage` (
117
- `child_session_key` text PRIMARY KEY NOT NULL,
118
- `parent_session_key` text,
119
- `root_session_key` text NOT NULL,
120
- `kind` text NOT NULL,
121
- `root_kind` text NOT NULL,
122
- `root_label` text,
123
- `agent_id` text,
124
- `pipeline_id` text,
125
- `flow_id` text,
126
- `node_id` text,
127
- `item_key` text,
128
- `first_seen_at` integer NOT NULL,
129
- `source` text NOT NULL,
130
- `run_id` text,
131
- FOREIGN KEY (`child_session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE no action,
132
- FOREIGN KEY (`parent_session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE set null,
133
- FOREIGN KEY (`root_session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE no action,
134
- FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE set null,
135
- FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null
136
- );
137
- --> statement-breakpoint
138
- INSERT INTO `__new_session_lineage`("child_session_key", "parent_session_key", "root_session_key", "kind", "root_kind", "root_label", "agent_id", "pipeline_id", "flow_id", "node_id", "item_key", "first_seen_at", "source", "run_id") SELECT "child_session_key", "parent_session_key", "root_session_key", "kind", "root_kind", "root_label", "agent_id", "pipeline_id", "flow_id", "node_id", "item_key", "first_seen_at", "source", "run_id" FROM `session_lineage`;--> statement-breakpoint
139
- DROP TABLE `session_lineage`;--> statement-breakpoint
140
- ALTER TABLE `__new_session_lineage` RENAME TO `session_lineage`;--> statement-breakpoint
141
- CREATE INDEX IF NOT EXISTS `idx_lineage_root` ON `session_lineage` (`root_session_key`);--> statement-breakpoint
142
- CREATE INDEX IF NOT EXISTS `idx_lineage_parent` ON `session_lineage` (`parent_session_key`);--> statement-breakpoint
143
- CREATE INDEX IF NOT EXISTS `idx_lineage_pipeline` ON `session_lineage` (`pipeline_id`);--> statement-breakpoint
144
- CREATE INDEX IF NOT EXISTS `idx_lineage_flow` ON `session_lineage` (`flow_id`);--> statement-breakpoint
145
- CREATE INDEX IF NOT EXISTS `idx_lineage_root_kind` ON `session_lineage` (`root_kind`);--> statement-breakpoint
146
- CREATE INDEX IF NOT EXISTS `idx_lineage_run` ON `session_lineage` (`run_id`);--> statement-breakpoint
147
- CREATE TABLE IF NOT EXISTS `__new_tool_results` (
148
- `session_key` text PRIMARY KEY NOT NULL,
149
- `run_id` text,
150
- `agent_id` text,
151
- `kind` text,
152
- `payload_json` text NOT NULL,
153
- `updated_at` integer NOT NULL,
154
- FOREIGN KEY (`session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE no action,
155
- FOREIGN KEY (`run_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null
156
- );
157
- --> statement-breakpoint
158
- INSERT INTO `__new_tool_results`("session_key", "run_id", "agent_id", "kind", "payload_json", "updated_at") SELECT "session_key", "run_id", "agent_id", "kind", "payload_json", "updated_at" FROM `tool_results`;--> statement-breakpoint
159
- DROP TABLE `tool_results`;--> statement-breakpoint
160
- ALTER TABLE `__new_tool_results` RENAME TO `tool_results`;