@igorjpimenta/manifold 0.0.0-bootstrap.1
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.
- package/.migrations/ops/0000_futuristic_karma.sql +111 -0
- package/.migrations/ops/0001_low_maximus.sql +7 -0
- package/.migrations/ops/meta/0000_snapshot.json +763 -0
- package/.migrations/ops/meta/0001_snapshot.json +173 -0
- package/.migrations/ops/meta/_journal.json +20 -0
- package/.migrations/runtime/0000_real_boomer.sql +180 -0
- package/.migrations/runtime/0001_hot_dakota_north.sql +2 -0
- package/.migrations/runtime/0002_breezy_vertigo.sql +8 -0
- package/.migrations/runtime/0003_dashing_jack_flag.sql +5 -0
- package/.migrations/runtime/0004_panoramic_ego.sql +1 -0
- package/.migrations/runtime/0005_tidy_ben_grimm.sql +10 -0
- package/.migrations/runtime/0006_wet_nightmare.sql +57 -0
- package/.migrations/runtime/0007_ambiguous_chronomancer.sql +8 -0
- package/.migrations/runtime/0008_wealthy_thundra.sql +301 -0
- package/.migrations/runtime/0009_lying_shocker.sql +96 -0
- package/.migrations/runtime/0010_solid_phantom_reporter.sql +160 -0
- package/.migrations/runtime/0011_windy_demogoblin.sql +175 -0
- package/.migrations/runtime/0012_restore_harness_fks.sql +103 -0
- package/.migrations/runtime/meta/0000_snapshot.json +1181 -0
- package/.migrations/runtime/meta/0001_snapshot.json +1209 -0
- package/.migrations/runtime/meta/0002_snapshot.json +1261 -0
- package/.migrations/runtime/meta/0003_snapshot.json +1292 -0
- package/.migrations/runtime/meta/0004_snapshot.json +1240 -0
- package/.migrations/runtime/meta/0006_snapshot.json +1310 -0
- package/.migrations/runtime/meta/0007_snapshot.json +1362 -0
- package/.migrations/runtime/meta/0008_snapshot.json +1742 -0
- package/.migrations/runtime/meta/0009_snapshot.json +2413 -0
- package/.migrations/runtime/meta/0010_snapshot.json +2562 -0
- package/.migrations/runtime/meta/0011_snapshot.json +2812 -0
- package/.migrations/runtime/meta/0012_snapshot.json +2812 -0
- package/.migrations/runtime/meta/_journal.json +97 -0
- package/README.md +1584 -0
- package/RELEASING.md +89 -0
- package/agent/fleet.js +100 -0
- package/bin/cli.js +854 -0
- package/bin/manifold.js +4 -0
- package/boot/flow-revival.js +536 -0
- package/budget/index.js +495 -0
- package/budget/lib.js +59 -0
- package/dashboard/cost.js +528 -0
- package/dashboard/dist/assets/index-CUfp63sj.css +1 -0
- package/dashboard/dist/assets/index-Qy9JMpma.js +371 -0
- package/dashboard/dist/index.html +13 -0
- package/dashboard/event-log.js +267 -0
- package/dashboard/index.html +12 -0
- package/dashboard/package-lock.json +2877 -0
- package/dashboard/package.json +37 -0
- package/dashboard/pipeline-graph.js +131 -0
- package/dashboard/postcss.config.js +6 -0
- package/dashboard/search.js +183 -0
- package/dashboard/server.js +1015 -0
- package/dashboard/src/App.tsx +42 -0
- package/dashboard/src/api/client.ts +118 -0
- package/dashboard/src/api/types.ts +510 -0
- package/dashboard/src/api/ws.tsx +112 -0
- package/dashboard/src/components/CancelButton.tsx +63 -0
- package/dashboard/src/components/ClickToCopy.tsx +68 -0
- package/dashboard/src/components/CopyButton.tsx +61 -0
- package/dashboard/src/components/DailyCostTrend.tsx +85 -0
- package/dashboard/src/components/DailyTimeTrend.tsx +94 -0
- package/dashboard/src/components/Funnel.tsx +149 -0
- package/dashboard/src/components/GateForm.tsx +158 -0
- package/dashboard/src/components/GraphView.tsx +302 -0
- package/dashboard/src/components/GroupPathsSummary.tsx +47 -0
- package/dashboard/src/components/Histogram.tsx +292 -0
- package/dashboard/src/components/Layout.tsx +28 -0
- package/dashboard/src/components/NeedsAttention.tsx +98 -0
- package/dashboard/src/components/NodeContextCard.tsx +132 -0
- package/dashboard/src/components/PathTrail.tsx +35 -0
- package/dashboard/src/components/PipelineCostBreakdown.tsx +277 -0
- package/dashboard/src/components/RerunButton.tsx +46 -0
- package/dashboard/src/components/RunComparison.tsx +53 -0
- package/dashboard/src/components/Sparkline.tsx +94 -0
- package/dashboard/src/components/StatStrip.tsx +147 -0
- package/dashboard/src/components/StateTree.tsx +84 -0
- package/dashboard/src/components/StatusBadge.tsx +18 -0
- package/dashboard/src/components/SubflowPathPills.tsx +38 -0
- package/dashboard/src/components/SubflowSummary.tsx +24 -0
- package/dashboard/src/components/SubflowsCard.tsx +327 -0
- package/dashboard/src/components/TodayStrip.tsx +86 -0
- package/dashboard/src/components/TranscriptPane.tsx +99 -0
- package/dashboard/src/components/TranscriptRow.tsx +69 -0
- package/dashboard/src/components/ui/badge.tsx +38 -0
- package/dashboard/src/components/ui/button.tsx +28 -0
- package/dashboard/src/components/ui/card.tsx +42 -0
- package/dashboard/src/components/ui/skeleton.tsx +9 -0
- package/dashboard/src/components/ui/table.tsx +62 -0
- package/dashboard/src/index.css +26 -0
- package/dashboard/src/lib/anomaly.ts +42 -0
- package/dashboard/src/lib/format.ts +30 -0
- package/dashboard/src/lib/step-history.ts +13 -0
- package/dashboard/src/lib/subflow.ts +154 -0
- package/dashboard/src/lib/use-click-outside.ts +28 -0
- package/dashboard/src/lib/use-ignored-clusters.ts +67 -0
- package/dashboard/src/lib/utils.ts +6 -0
- package/dashboard/src/main.tsx +10 -0
- package/dashboard/src/types/shims.d.ts +4 -0
- package/dashboard/src/views/Home.tsx +478 -0
- package/dashboard/src/views/PipelineDetail.tsx +1185 -0
- package/dashboard/src/views/PipelinesList.tsx +111 -0
- package/dashboard/src/views/RunDetail.tsx +248 -0
- package/dashboard/src/views/Search.tsx +196 -0
- package/dashboard/stats.js +668 -0
- package/dashboard/tailwind.config.ts +43 -0
- package/dashboard/tree-stats.js +12 -0
- package/dashboard/tsconfig.json +25 -0
- package/dashboard/views.js +231 -0
- package/dashboard/vite.config.ts +34 -0
- package/drizzle.config.js +12 -0
- package/drizzle.config.ops.js +12 -0
- package/elevation.js +116 -0
- package/engine/admission-promotion-resume.js +127 -0
- package/engine/agent-dispatch.js +64 -0
- package/engine/child-resume-trigger.js +315 -0
- package/engine/executor-budget.js +87 -0
- package/engine/executor-cancel.js +83 -0
- package/engine/executor-errors.js +122 -0
- package/engine/executor-helpers.js +254 -0
- package/engine/executor-nodes.js +292 -0
- package/engine/executor-persist.js +212 -0
- package/engine/executor-subflow-children.js +275 -0
- package/engine/executor.js +1013 -0
- package/engine/global-concurrency.js +33 -0
- package/engine/loader.js +528 -0
- package/engine/needs-resolver.js +229 -0
- package/engine/pipelines-watcher.js +133 -0
- package/engine/result-replay.js +34 -0
- package/engine/revival-messages.js +11 -0
- package/engine/spawn-child.js +55 -0
- package/engine/wait-for-flow-settlement.js +109 -0
- package/events/catalog.js +26 -0
- package/events/emit.js +44 -0
- package/events/kinds.js +118 -0
- package/events/serve-ws.js +74 -0
- package/events/stream.js +35 -0
- package/events/ws-dialog.js +257 -0
- package/events/ws-frame.js +194 -0
- package/events/ws-run-events.js +70 -0
- package/events.js +32 -0
- package/gates/gate-resolver.js +576 -0
- package/gates/paused-flows.js +55 -0
- package/graphql/columns.js +67 -0
- package/graphql/schema.js +333 -0
- package/index.js +49 -0
- package/mcp/http.js +159 -0
- package/mcp/identity.js +94 -0
- package/mcp/stdio.js +80 -0
- package/mcp/tools.js +245 -0
- package/mcp/wire-ops.js +178 -0
- package/package.json +51 -0
- package/routes/bearer-auth.js +57 -0
- package/routes/discuss-audio.js +87 -0
- package/routes/discuss-component.js +39 -0
- package/routes/discuss-draft.js +159 -0
- package/routes/discuss-helpers.js +20 -0
- package/routes/discuss.js +848 -0
- package/routes/failures.js +104 -0
- package/routes/graphql.js +61 -0
- package/routes/health.js +54 -0
- package/routes/operator-discuss.js +193 -0
- package/routes/operator-resume.js +32 -0
- package/routes/operator-retry.js +301 -0
- package/routes/operator.js +539 -0
- package/routes/pipelines.js +118 -0
- package/routes/runs.js +1129 -0
- package/scripts/ci/import-check.mjs +50 -0
- package/scripts/link-core-self.mjs +31 -0
- package/scripts/with-guard.sh +24 -0
- package/server/app.js +503 -0
- package/server/registry.js +53 -0
- package/server/serve.js +163 -0
- package/state/admission-queue-store.js +325 -0
- package/state/attribution-registries.js +102 -0
- package/state/batch-writer.js +162 -0
- package/state/db-guard.js +63 -0
- package/state/db-health.js +27 -0
- package/state/db.js +122 -0
- package/state/discuss-store.js +299 -0
- package/state/failure-store.js +427 -0
- package/state/migrate.js +104 -0
- package/state/node-cost.js +67 -0
- package/state/node-executions.js +775 -0
- package/state/node-health-store.js +124 -0
- package/state/ops-merge.js +93 -0
- package/state/paths.js +146 -0
- package/state/pipeline-dirs.js +99 -0
- package/state/pipeline-registry.js +449 -0
- package/state/run-store.js +697 -0
- package/state/schema.js +438 -0
- package/state/schema.ops.js +44 -0
- package/state/session-index.js +177 -0
- package/state/session-keys.js +39 -0
- package/state/state-store.js +311 -0
- package/state/subflow-state.js +126 -0
- package/state/tool-handoff.js +169 -0
- package/telemetry/budget-alert.js +353 -0
- package/telemetry/cli.js +331 -0
- package/telemetry/grammar.js +119 -0
- package/telemetry/http-budget.js +132 -0
- package/telemetry/http-cost.js +670 -0
- package/telemetry/http-helpers.js +134 -0
- package/telemetry/http-tree.js +349 -0
- package/telemetry/http.js +44 -0
- package/telemetry/index.js +307 -0
- package/telemetry/ingest.js +134 -0
- package/telemetry/labels.js +115 -0
- package/telemetry/pricer.js +77 -0
- package/telemetry/resolver.js +314 -0
- package/telemetry/store.js +147 -0
- package/utils/run-patch.js +43 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS `flow_items` (
|
|
2
|
+
`flow_id` text NOT NULL,
|
|
3
|
+
`item_key` text NOT NULL,
|
|
4
|
+
`first_seen_at` integer NOT NULL,
|
|
5
|
+
PRIMARY KEY(`flow_id`, `item_key`)
|
|
6
|
+
);
|
|
7
|
+
--> statement-breakpoint
|
|
8
|
+
CREATE INDEX IF NOT EXISTS `idx_flow_items_key` ON `flow_items` (`item_key`);--> statement-breakpoint
|
|
9
|
+
CREATE TABLE IF NOT EXISTS `pipeline_nodes` (
|
|
10
|
+
`pipeline_id` text NOT NULL,
|
|
11
|
+
`node_name` text NOT NULL,
|
|
12
|
+
`first_seen_at` integer NOT NULL,
|
|
13
|
+
PRIMARY KEY(`pipeline_id`, `node_name`),
|
|
14
|
+
FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE cascade
|
|
15
|
+
);
|
|
16
|
+
--> statement-breakpoint
|
|
17
|
+
CREATE INDEX IF NOT EXISTS `idx_pipeline_nodes_name` ON `pipeline_nodes` (`node_name`);--> statement-breakpoint
|
|
18
|
+
CREATE TABLE IF NOT EXISTS `turn_runs` (
|
|
19
|
+
`run_id` text PRIMARY KEY NOT NULL,
|
|
20
|
+
`first_seen_at` integer NOT NULL
|
|
21
|
+
);
|
|
22
|
+
--> statement-breakpoint
|
|
23
|
+
PRAGMA foreign_keys=OFF;--> statement-breakpoint
|
|
24
|
+
CREATE TABLE IF NOT EXISTS `__new_cost_by_call` (
|
|
25
|
+
`session_id` text NOT NULL,
|
|
26
|
+
`msg_id` text NOT NULL,
|
|
27
|
+
`ts` integer NOT NULL,
|
|
28
|
+
`provider` text,
|
|
29
|
+
`model` text,
|
|
30
|
+
`input_tokens` integer,
|
|
31
|
+
`output_tokens` integer,
|
|
32
|
+
`cache_read_tokens` integer,
|
|
33
|
+
`cache_write_tokens` integer,
|
|
34
|
+
`total_tokens` integer,
|
|
35
|
+
`cost_input` real,
|
|
36
|
+
`cost_output` real,
|
|
37
|
+
`cost_cache_read` real,
|
|
38
|
+
`cost_cache_write` real,
|
|
39
|
+
`cost_total` real NOT NULL,
|
|
40
|
+
`session_key` text,
|
|
41
|
+
`agent_id` text,
|
|
42
|
+
`root_session_key` text,
|
|
43
|
+
`root_kind` text,
|
|
44
|
+
`root_label` text,
|
|
45
|
+
`pipeline_id` text,
|
|
46
|
+
`flow_id` text,
|
|
47
|
+
`node_id` text,
|
|
48
|
+
`item_key` text,
|
|
49
|
+
PRIMARY KEY(`session_id`, `msg_id`),
|
|
50
|
+
FOREIGN KEY (`session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE set null,
|
|
51
|
+
FOREIGN KEY (`root_session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE set null,
|
|
52
|
+
FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE set null,
|
|
53
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null,
|
|
54
|
+
FOREIGN KEY (`pipeline_id`,`node_id`) REFERENCES `pipeline_nodes`(`pipeline_id`,`node_name`) ON UPDATE no action ON DELETE no action,
|
|
55
|
+
FOREIGN KEY (`flow_id`,`item_key`) REFERENCES `flow_items`(`flow_id`,`item_key`) ON UPDATE no action ON DELETE no action
|
|
56
|
+
);
|
|
57
|
+
--> statement-breakpoint
|
|
58
|
+
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
|
|
59
|
+
DROP TABLE `cost_by_call`;--> statement-breakpoint
|
|
60
|
+
ALTER TABLE `__new_cost_by_call` RENAME TO `cost_by_call`;--> statement-breakpoint
|
|
61
|
+
PRAGMA foreign_keys=ON;--> statement-breakpoint
|
|
62
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_ts` ON `cost_by_call` (`ts`);--> statement-breakpoint
|
|
63
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_root_key` ON `cost_by_call` (`root_session_key`);--> statement-breakpoint
|
|
64
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_root_kind_ts` ON `cost_by_call` (`root_kind`,`ts`);--> statement-breakpoint
|
|
65
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_pipeline_ts` ON `cost_by_call` (`pipeline_id`,`ts`);--> statement-breakpoint
|
|
66
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_flow_node` ON `cost_by_call` (`flow_id`,`node_id`);--> statement-breakpoint
|
|
67
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_model_ts` ON `cost_by_call` (`model`,`ts`);--> statement-breakpoint
|
|
68
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_session` ON `cost_by_call` (`session_id`);--> statement-breakpoint
|
|
69
|
+
CREATE TABLE IF NOT EXISTS `__new_flow_sessions` (
|
|
70
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
71
|
+
`flow_id` text NOT NULL,
|
|
72
|
+
`session_key` text NOT NULL,
|
|
73
|
+
`node_id` text,
|
|
74
|
+
`branch_item_id` text,
|
|
75
|
+
`spawned_at` integer NOT NULL,
|
|
76
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade,
|
|
77
|
+
FOREIGN KEY (`session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE no action,
|
|
78
|
+
FOREIGN KEY (`flow_id`,`branch_item_id`) REFERENCES `flow_items`(`flow_id`,`item_key`) ON UPDATE no action ON DELETE no action
|
|
79
|
+
);
|
|
80
|
+
--> statement-breakpoint
|
|
81
|
+
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
|
|
82
|
+
DROP TABLE `flow_sessions`;--> statement-breakpoint
|
|
83
|
+
ALTER TABLE `__new_flow_sessions` RENAME TO `flow_sessions`;--> statement-breakpoint
|
|
84
|
+
CREATE INDEX IF NOT EXISTS `idx_flow_sessions_flow_id` ON `flow_sessions` (`flow_id`);--> statement-breakpoint
|
|
85
|
+
CREATE UNIQUE INDEX IF NOT EXISTS `idx_flow_sessions_uniq` ON `flow_sessions` (`flow_id`,`session_key`);--> statement-breakpoint
|
|
86
|
+
CREATE TABLE IF NOT EXISTS `__new_node_health` (
|
|
87
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
88
|
+
`pipeline_id` text NOT NULL,
|
|
89
|
+
`node_id` text NOT NULL,
|
|
90
|
+
`status` text NOT NULL,
|
|
91
|
+
`reason` text NOT NULL,
|
|
92
|
+
`blocked_by_flow_id` text,
|
|
93
|
+
`resolved_via` text,
|
|
94
|
+
`created_at` integer NOT NULL,
|
|
95
|
+
`updated_at` integer NOT NULL,
|
|
96
|
+
`ended_at` integer,
|
|
97
|
+
FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
98
|
+
FOREIGN KEY (`blocked_by_flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null,
|
|
99
|
+
FOREIGN KEY (`pipeline_id`,`node_id`) REFERENCES `pipeline_nodes`(`pipeline_id`,`node_name`) ON UPDATE no action ON DELETE no action
|
|
100
|
+
);
|
|
101
|
+
--> statement-breakpoint
|
|
102
|
+
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
|
|
103
|
+
DROP TABLE `node_health`;--> statement-breakpoint
|
|
104
|
+
ALTER TABLE `__new_node_health` RENAME TO `node_health`;--> statement-breakpoint
|
|
105
|
+
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
|
|
106
|
+
CREATE INDEX IF NOT EXISTS `idx_node_health_pipeline` ON `node_health` (`pipeline_id`,`status`);--> statement-breakpoint
|
|
107
|
+
CREATE TABLE IF NOT EXISTS `__new_queue_items` (
|
|
108
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
109
|
+
`label` text NOT NULL,
|
|
110
|
+
`agent` text NOT NULL,
|
|
111
|
+
`agent_emoji` text DEFAULT '🤖' NOT NULL,
|
|
112
|
+
`trigger` text DEFAULT 'manual' NOT NULL,
|
|
113
|
+
`cost_low` real DEFAULT 0 NOT NULL,
|
|
114
|
+
`cost_high` real DEFAULT 0 NOT NULL,
|
|
115
|
+
`brief` text,
|
|
116
|
+
`model_chain` text,
|
|
117
|
+
`pipeline` text,
|
|
118
|
+
`node` text,
|
|
119
|
+
`token_estimate` integer,
|
|
120
|
+
`status` text DEFAULT 'pending' NOT NULL,
|
|
121
|
+
`created_at` integer NOT NULL,
|
|
122
|
+
`expires_at` integer,
|
|
123
|
+
`decided_at` integer,
|
|
124
|
+
`decision` text,
|
|
125
|
+
`pipeline_id` text,
|
|
126
|
+
`pipeline_args` text,
|
|
127
|
+
`flow_id` text,
|
|
128
|
+
`enqueuer_session_key` text,
|
|
129
|
+
`kind` text,
|
|
130
|
+
FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE set null,
|
|
131
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null,
|
|
132
|
+
FOREIGN KEY (`enqueuer_session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE set null,
|
|
133
|
+
FOREIGN KEY (`pipeline_id`,`node`) REFERENCES `pipeline_nodes`(`pipeline_id`,`node_name`) ON UPDATE no action ON DELETE no action
|
|
134
|
+
);
|
|
135
|
+
--> statement-breakpoint
|
|
136
|
+
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
|
|
137
|
+
DROP TABLE `queue_items`;--> statement-breakpoint
|
|
138
|
+
ALTER TABLE `__new_queue_items` RENAME TO `queue_items`;--> statement-breakpoint
|
|
139
|
+
CREATE INDEX IF NOT EXISTS `idx_status` ON `queue_items` (`status`);--> statement-breakpoint
|
|
140
|
+
CREATE INDEX IF NOT EXISTS `idx_created_at` ON `queue_items` ("created_at" desc);--> statement-breakpoint
|
|
141
|
+
CREATE INDEX IF NOT EXISTS `idx_flow_node` ON `queue_items` (`flow_id`,`node`);--> statement-breakpoint
|
|
142
|
+
CREATE TABLE IF NOT EXISTS `__new_session_lineage` (
|
|
143
|
+
`child_session_key` text PRIMARY KEY NOT NULL,
|
|
144
|
+
`parent_session_key` text,
|
|
145
|
+
`root_session_key` text NOT NULL,
|
|
146
|
+
`kind` text NOT NULL,
|
|
147
|
+
`root_kind` text NOT NULL,
|
|
148
|
+
`root_label` text,
|
|
149
|
+
`agent_id` text,
|
|
150
|
+
`pipeline_id` text,
|
|
151
|
+
`flow_id` text,
|
|
152
|
+
`node_id` text,
|
|
153
|
+
`item_key` text,
|
|
154
|
+
`first_seen_at` integer NOT NULL,
|
|
155
|
+
`source` text NOT NULL,
|
|
156
|
+
`run_id` text,
|
|
157
|
+
FOREIGN KEY (`child_session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE no action,
|
|
158
|
+
FOREIGN KEY (`parent_session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE set null,
|
|
159
|
+
FOREIGN KEY (`root_session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE no action,
|
|
160
|
+
FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE set null,
|
|
161
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null,
|
|
162
|
+
FOREIGN KEY (`run_id`) REFERENCES `turn_runs`(`run_id`) ON UPDATE no action ON DELETE set null,
|
|
163
|
+
FOREIGN KEY (`pipeline_id`,`node_id`) REFERENCES `pipeline_nodes`(`pipeline_id`,`node_name`) ON UPDATE no action ON DELETE no action,
|
|
164
|
+
FOREIGN KEY (`flow_id`,`item_key`) REFERENCES `flow_items`(`flow_id`,`item_key`) ON UPDATE no action ON DELETE no action
|
|
165
|
+
);
|
|
166
|
+
--> statement-breakpoint
|
|
167
|
+
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
|
|
168
|
+
DROP TABLE `session_lineage`;--> statement-breakpoint
|
|
169
|
+
ALTER TABLE `__new_session_lineage` RENAME TO `session_lineage`;--> statement-breakpoint
|
|
170
|
+
CREATE INDEX IF NOT EXISTS `idx_lineage_root` ON `session_lineage` (`root_session_key`);--> statement-breakpoint
|
|
171
|
+
CREATE INDEX IF NOT EXISTS `idx_lineage_parent` ON `session_lineage` (`parent_session_key`);--> statement-breakpoint
|
|
172
|
+
CREATE INDEX IF NOT EXISTS `idx_lineage_pipeline` ON `session_lineage` (`pipeline_id`);--> statement-breakpoint
|
|
173
|
+
CREATE INDEX IF NOT EXISTS `idx_lineage_flow` ON `session_lineage` (`flow_id`);--> statement-breakpoint
|
|
174
|
+
CREATE INDEX IF NOT EXISTS `idx_lineage_root_kind` ON `session_lineage` (`root_kind`);--> statement-breakpoint
|
|
175
|
+
CREATE INDEX IF NOT EXISTS `idx_lineage_run` ON `session_lineage` (`run_id`);
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
-- Restore the harness / parent-invocation constraints on databases that
|
|
2
|
+
-- applied an earlier revision of 0008/0009 before those FKs were added to the
|
|
3
|
+
-- files. drizzle records an applied migration by timestamp, so editing an
|
|
4
|
+
-- already-applied file never re-runs it: the table keeps its old shape while
|
|
5
|
+
-- the snapshot says it is current.
|
|
6
|
+
--
|
|
7
|
+
-- Adds:
|
|
8
|
+
-- pipelines.harness -> harnesses(id) ON DELETE set null
|
|
9
|
+
-- pipeline_dirs.harness -> harnesses(id) ON DELETE cascade
|
|
10
|
+
-- flow_runs.parent_invocation_id -> flow_node_invocations(id) ON DELETE set null
|
|
11
|
+
-- flow_admission_queue.flow_id -> flow_runs(flow_id) ON DELETE cascade
|
|
12
|
+
--
|
|
13
|
+
-- The 12-step rebuild is not guardable: CREATE/RENAME fail if the target
|
|
14
|
+
-- exists, so this migration runs exactly once per database. Column lists are
|
|
15
|
+
-- explicit and ordered as the source tables define them.
|
|
16
|
+
CREATE TABLE `__new_pipelines` (
|
|
17
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
18
|
+
`name` text NOT NULL,
|
|
19
|
+
`harness` text,
|
|
20
|
+
`created_at` integer NOT NULL,
|
|
21
|
+
`updated_at` integer NOT NULL,
|
|
22
|
+
`deleted_at` integer,
|
|
23
|
+
FOREIGN KEY (`harness`) REFERENCES `harnesses`(`id`) ON UPDATE no action ON DELETE set null
|
|
24
|
+
);
|
|
25
|
+
--> statement-breakpoint
|
|
26
|
+
INSERT INTO `__new_pipelines`(`id`, `name`, `harness`, `created_at`, `updated_at`, `deleted_at`) SELECT `id`, `name`, `harness`, `created_at`, `updated_at`, `deleted_at` FROM `pipelines`;
|
|
27
|
+
--> statement-breakpoint
|
|
28
|
+
DROP TABLE `pipelines`;
|
|
29
|
+
--> statement-breakpoint
|
|
30
|
+
ALTER TABLE `__new_pipelines` RENAME TO `pipelines`;
|
|
31
|
+
--> statement-breakpoint
|
|
32
|
+
CREATE INDEX IF NOT EXISTS `idx_pipelines_harness_name` ON `pipelines` (`harness`,`name`);
|
|
33
|
+
--> statement-breakpoint
|
|
34
|
+
CREATE TABLE `__new_pipeline_dirs` (
|
|
35
|
+
`harness` text PRIMARY KEY NOT NULL,
|
|
36
|
+
`path` text NOT NULL,
|
|
37
|
+
`created_at` integer NOT NULL,
|
|
38
|
+
FOREIGN KEY (`harness`) REFERENCES `harnesses`(`id`) ON UPDATE no action ON DELETE cascade
|
|
39
|
+
);
|
|
40
|
+
--> statement-breakpoint
|
|
41
|
+
INSERT INTO `__new_pipeline_dirs`(`harness`, `path`, `created_at`) SELECT `harness`, `path`, `created_at` FROM `pipeline_dirs`;
|
|
42
|
+
--> statement-breakpoint
|
|
43
|
+
DROP TABLE `pipeline_dirs`;
|
|
44
|
+
--> statement-breakpoint
|
|
45
|
+
ALTER TABLE `__new_pipeline_dirs` RENAME TO `pipeline_dirs`;
|
|
46
|
+
--> statement-breakpoint
|
|
47
|
+
CREATE TABLE `__new_flow_admission_queue` (
|
|
48
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
49
|
+
`kind` text NOT NULL,
|
|
50
|
+
`flow_id` text NOT NULL,
|
|
51
|
+
`node_id` text,
|
|
52
|
+
`status` text NOT NULL,
|
|
53
|
+
`created_at` integer NOT NULL,
|
|
54
|
+
`admitted_at` integer,
|
|
55
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade
|
|
56
|
+
);
|
|
57
|
+
--> statement-breakpoint
|
|
58
|
+
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`;
|
|
59
|
+
--> statement-breakpoint
|
|
60
|
+
DROP TABLE `flow_admission_queue`;
|
|
61
|
+
--> statement-breakpoint
|
|
62
|
+
ALTER TABLE `__new_flow_admission_queue` RENAME TO `flow_admission_queue`;
|
|
63
|
+
--> statement-breakpoint
|
|
64
|
+
CREATE INDEX IF NOT EXISTS `idx_admission_status` ON `flow_admission_queue` (`status`);
|
|
65
|
+
--> statement-breakpoint
|
|
66
|
+
CREATE INDEX IF NOT EXISTS `idx_admission_flow` ON `flow_admission_queue` (`flow_id`);
|
|
67
|
+
--> statement-breakpoint
|
|
68
|
+
CREATE INDEX IF NOT EXISTS `idx_admission_status_created` ON `flow_admission_queue` (`status`,`created_at`);
|
|
69
|
+
--> statement-breakpoint
|
|
70
|
+
CREATE TABLE `__new_flow_runs` (
|
|
71
|
+
`flow_id` text PRIMARY KEY NOT NULL,
|
|
72
|
+
`owner_key` text DEFAULT '' NOT NULL,
|
|
73
|
+
`revision` integer DEFAULT 0 NOT NULL,
|
|
74
|
+
`status` text NOT NULL,
|
|
75
|
+
`last_step` text,
|
|
76
|
+
`status_reason` text,
|
|
77
|
+
`state_json` text DEFAULT '{}' NOT NULL,
|
|
78
|
+
`wait_json` text,
|
|
79
|
+
`cancel_requested_at` integer,
|
|
80
|
+
`created_at` integer NOT NULL,
|
|
81
|
+
`updated_at` integer NOT NULL,
|
|
82
|
+
`ended_at` integer,
|
|
83
|
+
`parent_invocation_id` text,
|
|
84
|
+
`pipeline_id` text,
|
|
85
|
+
FOREIGN KEY (`parent_invocation_id`) REFERENCES `flow_node_invocations`(`id`) ON UPDATE no action ON DELETE set null,
|
|
86
|
+
FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE set null
|
|
87
|
+
);
|
|
88
|
+
--> statement-breakpoint
|
|
89
|
+
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`;
|
|
90
|
+
--> statement-breakpoint
|
|
91
|
+
DROP TABLE `flow_runs`;
|
|
92
|
+
--> statement-breakpoint
|
|
93
|
+
ALTER TABLE `__new_flow_runs` RENAME TO `flow_runs`;
|
|
94
|
+
--> statement-breakpoint
|
|
95
|
+
CREATE INDEX IF NOT EXISTS `idx_pfr_status` ON `flow_runs` (`status`) WHERE "flow_runs"."ended_at" IS NULL;
|
|
96
|
+
--> statement-breakpoint
|
|
97
|
+
CREATE INDEX IF NOT EXISTS `idx_pfr_updated` ON `flow_runs` (`updated_at` DESC);
|
|
98
|
+
--> statement-breakpoint
|
|
99
|
+
CREATE INDEX IF NOT EXISTS `idx_pfr_created` ON `flow_runs` (`created_at` DESC);
|
|
100
|
+
--> statement-breakpoint
|
|
101
|
+
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;
|
|
102
|
+
--> statement-breakpoint
|
|
103
|
+
CREATE INDEX IF NOT EXISTS `idx_flow_runs_pipeline_id` ON `flow_runs` (`pipeline_id`);
|