lastlight-core 0.25.8 → 0.26.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 (172) hide show
  1. package/config/default.yaml +31 -6
  2. package/dist/admin/chat-session-reader.d.ts +3 -3
  3. package/dist/admin/chat-session-reader.js +8 -8
  4. package/dist/admin/chat-session-reader.js.map +1 -1
  5. package/dist/admin/routes.js +119 -124
  6. package/dist/admin/routes.js.map +1 -1
  7. package/dist/admin/sessions.d.ts +7 -7
  8. package/dist/admin/sessions.js +6 -4
  9. package/dist/admin/sessions.js.map +1 -1
  10. package/dist/config/config.d.ts +21 -2
  11. package/dist/config/config.js +33 -0
  12. package/dist/config/config.js.map +1 -1
  13. package/dist/config/repo-config.js +6 -7
  14. package/dist/config/repo-config.js.map +1 -1
  15. package/dist/connectors/messaging/base.js +2 -2
  16. package/dist/connectors/messaging/base.js.map +1 -1
  17. package/dist/connectors/messaging/session-manager.d.ts +29 -31
  18. package/dist/connectors/messaging/session-manager.js +156 -189
  19. package/dist/connectors/messaging/session-manager.js.map +1 -1
  20. package/dist/connectors/messaging/thread-transcript.d.ts +2 -2
  21. package/dist/connectors/messaging/thread-transcript.js +14 -8
  22. package/dist/connectors/messaging/thread-transcript.js.map +1 -1
  23. package/dist/connectors/slack/connector.js +5 -5
  24. package/dist/connectors/slack/connector.js.map +1 -1
  25. package/dist/connectors/slack/mrkdwn.d.ts +4 -0
  26. package/dist/connectors/slack/mrkdwn.js +2 -2
  27. package/dist/connectors/slack/mrkdwn.js.map +1 -1
  28. package/dist/cron/feedback-poll.js +6 -6
  29. package/dist/cron/feedback-poll.js.map +1 -1
  30. package/dist/cron/handlers.d.ts +16 -8
  31. package/dist/cron/handlers.js +49 -31
  32. package/dist/cron/handlers.js.map +1 -1
  33. package/dist/cron/jobs.d.ts +1 -1
  34. package/dist/cron/jobs.js +5 -2
  35. package/dist/cron/jobs.js.map +1 -1
  36. package/dist/cron/repo-digest.d.ts +54 -7
  37. package/dist/cron/repo-digest.js +236 -23
  38. package/dist/cron/repo-digest.js.map +1 -1
  39. package/dist/cron/runner.d.ts +59 -0
  40. package/dist/cron/runner.js +224 -0
  41. package/dist/cron/runner.js.map +1 -0
  42. package/dist/cron/scheduler.js +19 -9
  43. package/dist/cron/scheduler.js.map +1 -1
  44. package/dist/engine/chat/chat-prompt.d.ts +11 -4
  45. package/dist/engine/chat/chat-prompt.js.map +1 -1
  46. package/dist/engine/chat/chat-runner.d.ts +3 -2
  47. package/dist/engine/chat/chat-runner.js +9 -7
  48. package/dist/engine/chat/chat-runner.js.map +1 -1
  49. package/dist/engine/dispatcher.js +29 -25
  50. package/dist/engine/dispatcher.js.map +1 -1
  51. package/dist/engine/executors/orchestrator.d.ts +28 -0
  52. package/dist/engine/executors/orchestrator.js +70 -1
  53. package/dist/engine/executors/orchestrator.js.map +1 -1
  54. package/dist/engine/feedback/ingest.d.ts +4 -4
  55. package/dist/engine/feedback/ingest.js +13 -13
  56. package/dist/engine/feedback/ingest.js.map +1 -1
  57. package/dist/engine/feedback/slack.d.ts +2 -2
  58. package/dist/engine/feedback/slack.js +6 -6
  59. package/dist/engine/feedback/slack.js.map +1 -1
  60. package/dist/engine/fix-harvest.d.ts +1 -1
  61. package/dist/engine/fix-harvest.js +3 -3
  62. package/dist/engine/fix-harvest.js.map +1 -1
  63. package/dist/engine/github/github.d.ts +79 -0
  64. package/dist/engine/github/github.js +111 -0
  65. package/dist/engine/github/github.js.map +1 -1
  66. package/dist/engine/github/team-visibility.js +7 -7
  67. package/dist/engine/github/team-visibility.js.map +1 -1
  68. package/dist/engine/pr-escalation.js +7 -7
  69. package/dist/engine/pr-escalation.js.map +1 -1
  70. package/dist/engine/pr-state.d.ts +1 -1
  71. package/dist/engine/pr-state.js +12 -10
  72. package/dist/engine/pr-state.js.map +1 -1
  73. package/dist/engine/review-check.d.ts +1 -1
  74. package/dist/engine/review-check.js +5 -5
  75. package/dist/engine/review-check.js.map +1 -1
  76. package/dist/engine/router.js +3 -3
  77. package/dist/engine/router.js.map +1 -1
  78. package/dist/index.js +115 -152
  79. package/dist/index.js.map +1 -1
  80. package/dist/notify/digest-blocks.d.ts +61 -0
  81. package/dist/notify/digest-blocks.js +150 -22
  82. package/dist/notify/digest-blocks.js.map +1 -1
  83. package/dist/sandbox/docker.d.ts +33 -1
  84. package/dist/sandbox/docker.js +95 -1
  85. package/dist/sandbox/docker.js.map +1 -1
  86. package/dist/sandbox/k8s/kubernetes-sandbox.d.ts +3 -0
  87. package/dist/sandbox/k8s/kubernetes-sandbox.js +9 -0
  88. package/dist/sandbox/k8s/kubernetes-sandbox.js.map +1 -1
  89. package/dist/sandbox/k8s/pod.d.ts +11 -0
  90. package/dist/sandbox/k8s/pod.js +11 -6
  91. package/dist/sandbox/k8s/pod.js.map +1 -1
  92. package/dist/sandbox/k8s/service-containers.d.ts +43 -0
  93. package/dist/sandbox/k8s/service-containers.js +87 -0
  94. package/dist/sandbox/k8s/service-containers.js.map +1 -0
  95. package/dist/sandbox/reap.d.ts +9 -0
  96. package/dist/sandbox/reap.js +36 -0
  97. package/dist/sandbox/reap.js.map +1 -1
  98. package/dist/sandbox/sandbox.d.ts +14 -0
  99. package/dist/sandbox/sandbox.js +9 -0
  100. package/dist/sandbox/sandbox.js.map +1 -1
  101. package/dist/sandbox/service-containers-docker.d.ts +45 -0
  102. package/dist/sandbox/service-containers-docker.js +78 -0
  103. package/dist/sandbox/service-containers-docker.js.map +1 -0
  104. package/dist/state/approval-store.d.ts +23 -14
  105. package/dist/state/approval-store.js +137 -86
  106. package/dist/state/approval-store.js.map +1 -1
  107. package/dist/state/client.d.ts +105 -0
  108. package/dist/state/client.js +68 -0
  109. package/dist/state/client.js.map +1 -0
  110. package/dist/state/cron-run-store.d.ts +108 -0
  111. package/dist/state/cron-run-store.js +173 -0
  112. package/dist/state/cron-run-store.js.map +1 -0
  113. package/dist/state/db.d.ts +70 -23
  114. package/dist/state/db.js +179 -104
  115. package/dist/state/db.js.map +1 -1
  116. package/dist/state/dialect.d.ts +77 -0
  117. package/dist/state/dialect.js +129 -0
  118. package/dist/state/dialect.js.map +1 -0
  119. package/dist/state/execution-store.d.ts +124 -103
  120. package/dist/state/execution-store.js +569 -374
  121. package/dist/state/execution-store.js.map +1 -1
  122. package/dist/state/feedback-store.d.ts +20 -20
  123. package/dist/state/feedback-store.js +241 -187
  124. package/dist/state/feedback-store.js.map +1 -1
  125. package/dist/state/legacy-sqlite.d.ts +15 -0
  126. package/dist/state/legacy-sqlite.js +131 -0
  127. package/dist/state/legacy-sqlite.js.map +1 -0
  128. package/dist/state/repo-ref.d.ts +9 -4
  129. package/dist/state/repo-ref.js +12 -6
  130. package/dist/state/repo-ref.js.map +1 -1
  131. package/dist/state/schema/pg.d.ts +2788 -0
  132. package/dist/state/schema/pg.js +301 -0
  133. package/dist/state/schema/pg.js.map +1 -0
  134. package/dist/state/schema/sqlite.d.ts +3063 -0
  135. package/dist/state/schema/sqlite.js +391 -0
  136. package/dist/state/schema/sqlite.js.map +1 -0
  137. package/dist/state/team-store.d.ts +26 -13
  138. package/dist/state/team-store.js +140 -93
  139. package/dist/state/team-store.js.map +1 -1
  140. package/dist/state/user-store.d.ts +31 -13
  141. package/dist/state/user-store.js +180 -80
  142. package/dist/state/user-store.js.map +1 -1
  143. package/dist/state/workflow-run-store.d.ts +95 -56
  144. package/dist/state/workflow-run-store.js +419 -314
  145. package/dist/state/workflow-run-store.js.map +1 -1
  146. package/dist/telemetry/index.d.ts +8 -0
  147. package/dist/telemetry/index.js +11 -0
  148. package/dist/telemetry/index.js.map +1 -1
  149. package/dist/workflows/admission.d.ts +4 -3
  150. package/dist/workflows/admission.js +34 -10
  151. package/dist/workflows/admission.js.map +1 -1
  152. package/dist/workflows/handlers/post-review.js +3 -3
  153. package/dist/workflows/handlers/post-review.js.map +1 -1
  154. package/dist/workflows/resume.js +22 -15
  155. package/dist/workflows/resume.js.map +1 -1
  156. package/dist/workflows/runner.js +27 -12
  157. package/dist/workflows/runner.js.map +1 -1
  158. package/dist/workflows/simple.d.ts +23 -0
  159. package/dist/workflows/simple.js +40 -16
  160. package/dist/workflows/simple.js.map +1 -1
  161. package/drizzle/pg/0000_init.sql +235 -0
  162. package/drizzle/pg/meta/0000_snapshot.json +1751 -0
  163. package/drizzle/pg/meta/_journal.json +13 -0
  164. package/drizzle/sqlite/0000_baseline.sql +257 -0
  165. package/drizzle/sqlite/0001_backfill_repo_refs.sql +74 -0
  166. package/drizzle/sqlite/meta/0000_snapshot.json +1593 -0
  167. package/drizzle/sqlite/meta/0001_snapshot.json +1593 -0
  168. package/drizzle/sqlite/meta/_journal.json +20 -0
  169. package/package.json +15 -9
  170. package/dist/state/migrate.d.ts +0 -15
  171. package/dist/state/migrate.js +0 -493
  172. package/dist/state/migrate.js.map +0 -1
@@ -119,21 +119,6 @@ export function rangeResponse(rangeHeader, buf, mime, cacheControl) {
119
119
  headers: { ...baseHeaders, "Content-Length": String(total) },
120
120
  });
121
121
  }
122
- /**
123
- * Parse a JSON status column (`extension_status` / `skills_status`) into the
124
- * object the dashboard renders. Tolerates null / malformed JSON (returns
125
- * undefined) so a bad row never breaks the executions endpoint.
126
- */
127
- function parseJsonColumn(raw) {
128
- if (!raw)
129
- return undefined;
130
- try {
131
- return JSON.parse(raw);
132
- }
133
- catch {
134
- return undefined;
135
- }
136
- }
137
122
  /**
138
123
  * Check if a session is live by matching against running container taskIds.
139
124
  * Sessions are live if they were recently active (within 5 min) and a container
@@ -178,7 +163,7 @@ function mountSessionRoutes(app, sessions, prefix) {
178
163
  // Session list — enriched with live container status
179
164
  app.get(`${prefix}`, async (c) => {
180
165
  const limit = Number(c.req.query("limit") ?? 200);
181
- const allIds = sessions.listSessionIds();
166
+ const allIds = await sessions.listSessionIds();
182
167
  const [metas, containers] = await Promise.all([
183
168
  Promise.all(allIds.slice(0, limit * 2).map((id) => sessions.getSessionMeta(id))),
184
169
  listRunningContainers(),
@@ -201,7 +186,7 @@ function mountSessionRoutes(app, sessions, prefix) {
201
186
  stream.onAbort(() => { stopped = true; });
202
187
  const push = async () => {
203
188
  const [allIds, containers] = await Promise.all([
204
- Promise.resolve(sessions.listSessionIds()),
189
+ sessions.listSessionIds(),
205
190
  listRunningContainers(),
206
191
  ]);
207
192
  const liveTaskIds = new Set(containers.map((c) => c.taskId).filter(Boolean));
@@ -232,7 +217,7 @@ function mountSessionRoutes(app, sessions, prefix) {
232
217
  // Single session
233
218
  app.get(`${prefix}/:id`, async (c) => {
234
219
  const id = c.req.param("id");
235
- if (sessions.exists(id)) {
220
+ if (await sessions.exists(id)) {
236
221
  const meta = await sessions.getSessionMeta(id);
237
222
  if (meta)
238
223
  return c.json({ session: meta });
@@ -243,7 +228,7 @@ function mountSessionRoutes(app, sessions, prefix) {
243
228
  app.get(`${prefix}/:id/messages`, async (c) => {
244
229
  const id = c.req.param("id");
245
230
  const sinceIndex = Number(c.req.query("since") ?? -1);
246
- if (sessions.exists(id)) {
231
+ if (await sessions.exists(id)) {
247
232
  const all = await sessions.read(id);
248
233
  const next = all.filter((x) => x.index > sinceIndex);
249
234
  return c.json({
@@ -258,10 +243,10 @@ function mountSessionRoutes(app, sessions, prefix) {
258
243
  app.get(`${prefix}/:id/stream`, async (c) => {
259
244
  const id = c.req.param("id");
260
245
  const sinceIndex = Number(c.req.query("since") ?? -1);
261
- if (!sessions.exists(id)) {
246
+ if (!(await sessions.exists(id))) {
262
247
  return c.json({ error: "session not found" }, 404);
263
248
  }
264
- const filePath = sessions.getFilePath(id);
249
+ const filePath = await sessions.getFilePath(id);
265
250
  if (!filePath) {
266
251
  return c.json({ error: "session file not found" }, 404);
267
252
  }
@@ -379,24 +364,6 @@ const COMMENT_CLASSIFIER_TYPES = new Set([
379
364
  "message",
380
365
  "pr_review.submitted",
381
366
  ]);
382
- /**
383
- * The last tick of a `handler:` cron, projected into the `{ startedAt, status }`
384
- * shape the crons list already reads off a `workflow_runs` row.
385
- *
386
- * A handler cron dispatches nothing, so it has no run row — its only trace is
387
- * the `executions` row `withLedger` writes per tick (`cron/handlers.ts`). The
388
- * status vocabulary is narrowed to what a tick can actually be: it never
389
- * queues, pauses or gets cancelled.
390
- */
391
- function lastHandlerTick(db, cronName) {
392
- const [row] = db.executions.recentExecutions(cronName, 1);
393
- if (!row)
394
- return undefined;
395
- return {
396
- startedAt: row.startedAt,
397
- status: !row.finishedAt ? "running" : row.success ? "succeeded" : "failed",
398
- };
399
- }
400
367
  function playgroundRouting(type) {
401
368
  return PLAYGROUND_EVENT_TYPES.find((e) => e.type === type)?.routing ?? "deterministic";
402
369
  }
@@ -814,7 +781,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
814
781
  const slackUserId = userInfo["https://slack.com/user_id"];
815
782
  if (slackUserId) {
816
783
  try {
817
- const user = db.users.upsertSlackUser({
784
+ const user = await db.users.upsertSlackUser({
818
785
  slackUserId,
819
786
  name: userInfo.name ?? null,
820
787
  email: userInfo.email ?? null,
@@ -944,7 +911,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
944
911
  }
945
912
  if (typeof userInfo.id === "number") {
946
913
  try {
947
- db.users.getOrCreateUserByGithub({
914
+ await db.users.getOrCreateUserByGithub({
948
915
  githubId: userInfo.id,
949
916
  login,
950
917
  name: userInfo.name ?? null,
@@ -979,23 +946,23 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
979
946
  // Stats — running count uses live Docker containers, not stale DB records
980
947
  app.get("/stats", async (c) => {
981
948
  const [stats, containers] = await Promise.all([
982
- Promise.resolve(db.executions.executionStats()),
949
+ db.executions.executionStats(),
983
950
  listRunningContainers(),
984
951
  ]);
985
952
  stats.running = containers.length;
986
953
  return c.json(stats);
987
954
  });
988
955
  // Daily aggregated stats (last N days)
989
- app.get("/stats/daily", (c) => {
956
+ app.get("/stats/daily", async (c) => {
990
957
  const daysParam = c.req.query("days");
991
958
  const days = Math.min(Math.max(1, parseInt(daysParam ?? "30", 10) || 30), 90);
992
- return c.json({ daily: db.executions.dailyStats(days) });
959
+ return c.json({ daily: await db.executions.dailyStats(days) });
993
960
  });
994
961
  // Hourly aggregated stats (rolling last N hours, default 24)
995
- app.get("/stats/hourly", (c) => {
962
+ app.get("/stats/hourly", async (c) => {
996
963
  const hoursParam = c.req.query("hours");
997
964
  const hours = Math.min(Math.max(1, parseInt(hoursParam ?? "24", 10) || 24), 168);
998
- return c.json({ hourly: db.executions.hourlyStats(hours) });
965
+ return c.json({ hourly: await db.executions.hourlyStats(hours) });
999
966
  });
1000
967
  // ── Feedback signals (issue #255) ─────────────────────────────────────────
1001
968
  // A 👍/👎 on something the bot wrote, scored against the run that wrote it.
@@ -1003,11 +970,11 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1003
970
  // poller, never by an operator — the whole point is that the data is what
1004
971
  // people actually did.
1005
972
  // The raw feed, newest first. Retracted signals are excluded unless asked for.
1006
- app.get("/feedback/signals", (c) => {
973
+ app.get("/feedback/signals", async (c) => {
1007
974
  const limit = Math.min(Math.max(parseInt(c.req.query("limit") ?? "50", 10) || 50, 1), 200);
1008
975
  const offset = Math.max(parseInt(c.req.query("offset") ?? "0", 10) || 0, 0);
1009
976
  const source = c.req.query("source");
1010
- const { signals, total } = db.feedback.list({
977
+ const { signals, total } = await db.feedback.list({
1011
978
  limit,
1012
979
  offset,
1013
980
  workflowName: c.req.query("workflow") || undefined,
@@ -1020,22 +987,22 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1020
987
  // Per-workflow standing — the leaderboard. `averageScore` covers scored
1021
988
  // signals only, so a run everybody merely glanced at (👀) isn't reported as
1022
989
  // mediocre.
1023
- app.get("/feedback/summary", (c) => {
990
+ app.get("/feedback/summary", async (c) => {
1024
991
  const days = Math.min(Math.max(1, parseInt(c.req.query("days") ?? "30", 10) || 30), 365);
1025
- return c.json({ summary: db.feedback.summaryByWorkflow(days), days });
992
+ return c.json({ summary: await db.feedback.summaryByWorkflow(days), days });
1026
993
  });
1027
994
  // Zero-filled daily series for the chart, optionally for one workflow.
1028
- app.get("/feedback/daily", (c) => {
995
+ app.get("/feedback/daily", async (c) => {
1029
996
  const days = Math.min(Math.max(1, parseInt(c.req.query("days") ?? "30", 10) || 30), 90);
1030
997
  const workflow = c.req.query("workflow") || undefined;
1031
- return c.json({ daily: db.feedback.dailyScores(days, workflow) });
998
+ return c.json({ daily: await db.feedback.dailyScores(days, workflow) });
1032
999
  });
1033
1000
  // Everything said about one run — the run-detail badge.
1034
- app.get("/workflow-runs/:id/feedback", (c) => {
1035
- const run = db.runs.getRun(c.req.param("id"));
1001
+ app.get("/workflow-runs/:id/feedback", async (c) => {
1002
+ const run = await db.runs.getRun(c.req.param("id"));
1036
1003
  if (!run)
1037
1004
  return c.json({ error: "workflow run not found" }, 404);
1038
- return c.json({ signals: db.feedback.forRun(run.id) });
1005
+ return c.json({ signals: await db.feedback.forRun(run.id) });
1039
1006
  });
1040
1007
  // Running Docker containers
1041
1008
  app.get("/containers", async (c) => {
@@ -1116,11 +1083,11 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1116
1083
  const taskId = match[1];
1117
1084
  // Mark any running executions with matching skill as failed. Phase
1118
1085
  // skill keys are `<workflowName>:<phaseName>` — match on the colon.
1119
- const skills = db.executions.runningExecutions()
1086
+ const skills = (await db.executions.runningExecutions())
1120
1087
  .filter((e) => e.skill.includes(":") || e.skill === "pr-fix")
1121
1088
  .filter((e) => taskId.includes(e.triggerId?.replace(/[^a-z0-9]/gi, "") || "---"));
1122
1089
  for (const e of skills) {
1123
- db.executions.recordFinish(e.id, { success: false, error: "terminated via admin dashboard" });
1090
+ await db.executions.recordFinish(e.id, { success: false, error: "terminated via admin dashboard" });
1124
1091
  }
1125
1092
  }
1126
1093
  return c.json({ killed: name });
@@ -1130,10 +1097,10 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1130
1097
  }
1131
1098
  });
1132
1099
  // Execution records from DB
1133
- app.get("/executions", (c) => {
1100
+ app.get("/executions", async (c) => {
1134
1101
  const limit = Number(c.req.query("limit") ?? 100);
1135
1102
  const offset = Number(c.req.query("offset") ?? 0);
1136
- const executions = db.executions.allExecutions(limit, offset);
1103
+ const executions = await db.executions.allExecutions(limit, offset);
1137
1104
  return c.json({ executions });
1138
1105
  });
1139
1106
  // Free-text log search — the backbone of remote debugging via the CLI
@@ -1152,7 +1119,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1152
1119
  const limit = Math.min(Math.max(parseInt(c.req.query("limit") ?? "50", 10) || 50, 1), 200);
1153
1120
  const results = [];
1154
1121
  if (scope === "errors" || scope === "all") {
1155
- for (const r of db.executions.searchErrors(q, limit)) {
1122
+ for (const r of await db.executions.searchErrors(q, limit)) {
1156
1123
  results.push({
1157
1124
  source: "error",
1158
1125
  executionId: r.id,
@@ -1169,7 +1136,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1169
1136
  if (scope === "messages" || scope === "all") {
1170
1137
  const needle = q.toLowerCase();
1171
1138
  const maxSessions = 200; // newest-first cap on transcripts scanned
1172
- const ids = sessions.listSessionIds().slice(0, maxSessions);
1139
+ const ids = (await sessions.listSessionIds()).slice(0, maxSessions);
1173
1140
  outer: for (const id of ids) {
1174
1141
  let msgs;
1175
1142
  try {
@@ -1202,7 +1169,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1202
1169
  // status. Returns `total` so the dashboard can drive a "load more" pager.
1203
1170
  // `status=active` is shorthand for ('running','paused') — used by the
1204
1171
  // header's "live" filter on the workflows tab.
1205
- app.get("/workflow-runs", (c) => {
1172
+ app.get("/workflow-runs", async (c) => {
1206
1173
  const rawLimit = c.req.query("limit");
1207
1174
  const rawOffset = c.req.query("offset");
1208
1175
  const since = c.req.query("since") || undefined;
@@ -1233,7 +1200,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1233
1200
  else if (statusParam) {
1234
1201
  statuses = statusParam.split(",").filter(Boolean);
1235
1202
  }
1236
- const { runs, total } = db.runs.list({
1203
+ const { runs, total } = await db.runs.list({
1237
1204
  limit,
1238
1205
  offset,
1239
1206
  sinceIso: since,
@@ -1245,19 +1212,19 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1245
1212
  return c.json({ workflowRuns: runs, total });
1246
1213
  });
1247
1214
  // Distinct workflow names — used to populate the dashboard's filter row.
1248
- app.get("/workflow-names", (c) => {
1249
- return c.json({ names: db.runs.distinctNames() });
1215
+ app.get("/workflow-names", async (c) => {
1216
+ return c.json({ names: await db.runs.distinctNames() });
1250
1217
  });
1251
- app.get("/workflow-runs/:id", (c) => {
1218
+ app.get("/workflow-runs/:id", async (c) => {
1252
1219
  const id = c.req.param("id");
1253
- const run = db.runs.getRun(id);
1220
+ const run = await db.runs.getRun(id);
1254
1221
  if (!run)
1255
1222
  return c.json({ error: "workflow run not found" }, 404);
1256
1223
  // Enrich the actor with the `users` identity (issue #205) so the run
1257
1224
  // detail panel can show a real name + avatar, not just the raw login.
1258
1225
  // Best-effort: absent (password/cron/system actors, or a login with no
1259
1226
  // row) → the panel falls back to the login string + actor-type badge.
1260
- const triggeredByUser = run.triggeredBy ? db.users.findByLogin(run.triggeredBy) : null;
1227
+ const triggeredByUser = run.triggeredBy ? await db.users.findByLogin(run.triggeredBy) : null;
1261
1228
  return c.json({
1262
1229
  workflowRun: run,
1263
1230
  triggeredByUser: triggeredByUser
@@ -1272,12 +1239,12 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1272
1239
  // List the executions belonging to a workflow run, ordered by start time.
1273
1240
  // Used by the dashboard's pipeline-detail view to look up the session id
1274
1241
  // (and usage metrics) for any phase the user clicks.
1275
- app.get("/workflow-runs/:id/executions", (c) => {
1242
+ app.get("/workflow-runs/:id/executions", async (c) => {
1276
1243
  const id = c.req.param("id");
1277
- const run = db.runs.getRun(id);
1244
+ const run = await db.runs.getRun(id);
1278
1245
  if (!run)
1279
1246
  return c.json({ error: "workflow run not found" }, 404);
1280
- const rows = db.executions.getExecutionsForWorkflowRun(run.id, run.triggerId, run.workflowName);
1247
+ const rows = await db.executions.getExecutionsForWorkflowRun(run.id, run.triggerId, run.workflowName);
1281
1248
  const prefix = `${run.workflowName}:`;
1282
1249
  const executions = rows.map((r) => ({
1283
1250
  id: r.id,
@@ -1298,8 +1265,11 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1298
1265
  outputTokens: r.outputTokens,
1299
1266
  apiDurationMs: r.apiDurationMs,
1300
1267
  stopReason: r.stopReason,
1301
- extensions: parseJsonColumn(r.extensionStatus),
1302
- skills: parseJsonColumn(r.skillsStatus),
1268
+ // Already parsed objects on the way out of the store — passed through as
1269
+ // they are. Re-parsing them would throw, and the old helper's `catch`
1270
+ // swallowed that into `undefined`, silently emptying the panel.
1271
+ extensions: r.extensionStatus,
1272
+ skills: r.skillsStatus,
1303
1273
  }));
1304
1274
  return c.json({ executions });
1305
1275
  });
@@ -1307,17 +1277,17 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1307
1277
  // the pipeline's approval-gate nodes + the detail panel's read-only approval
1308
1278
  // history (status, who responded, when, and any comment). The global
1309
1279
  // /approvals endpoint only lists pending ones, so it can't show history.
1310
- app.get("/workflow-runs/:id/approvals", (c) => {
1280
+ app.get("/workflow-runs/:id/approvals", async (c) => {
1311
1281
  const id = c.req.param("id");
1312
- const run = db.runs.getRun(id);
1282
+ const run = await db.runs.getRun(id);
1313
1283
  if (!run)
1314
1284
  return c.json({ error: "workflow run not found" }, 404);
1315
- const approvals = db.approvals.listForWorkflow(run.id);
1285
+ const approvals = await db.approvals.listForWorkflow(run.id);
1316
1286
  return c.json({ approvals });
1317
1287
  });
1318
1288
  app.post("/workflow-runs/:id/cancel", async (c) => {
1319
1289
  const id = c.req.param("id");
1320
- const run = db.runs.getRun(id);
1290
+ const run = await db.runs.getRun(id);
1321
1291
  if (!run)
1322
1292
  return c.json({ error: "workflow run not found" }, 404);
1323
1293
  if (run.status !== "running" && run.status !== "paused" && run.status !== "queued") {
@@ -1327,7 +1297,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1327
1297
  // executions ledger (via the finish error below), never overwriting the
1328
1298
  // run's original `triggered_by`.
1329
1299
  const actor = actorFromContext(c) ?? "admin";
1330
- db.runs.cancelRun(id);
1300
+ await db.runs.cancelRun(id);
1331
1301
  // Flipping the DB row alone only stops the runner before the NEXT phase.
1332
1302
  // Kill any sandbox container currently executing a phase of this run so
1333
1303
  // the in-flight phase stops too. Container names are
@@ -1354,9 +1324,9 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1354
1324
  // avoids clobbering a sibling run that happens to share the same
1355
1325
  // trigger — e.g. two webhook deliveries for the same PR that
1356
1326
  // raced before dedup closed.
1357
- for (const e of db.executions.runningExecutions()) {
1327
+ for (const e of await db.executions.runningExecutions()) {
1358
1328
  if (e.workflowRunId === id) {
1359
- db.executions.recordFinish(e.id, { success: false, error: `cancelled via admin dashboard by ${actor}` });
1329
+ await db.executions.recordFinish(e.id, { success: false, error: `cancelled via admin dashboard by ${actor}` });
1360
1330
  }
1361
1331
  }
1362
1332
  }
@@ -1439,7 +1409,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1439
1409
  // like cancel/respond.
1440
1410
  app.post("/workflow-runs/:id/retry", async (c) => {
1441
1411
  const id = c.req.param("id");
1442
- const run = db.runs.getRun(id);
1412
+ const run = await db.runs.getRun(id);
1443
1413
  if (!run)
1444
1414
  return c.json({ error: "workflow run not found" }, 404);
1445
1415
  if (run.status !== "failed" && run.status !== "cancelled") {
@@ -1459,9 +1429,9 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1459
1429
  // it can render exactly the phases the YAML file declares — including
1460
1430
  // user-defined custom workflows. No hardcoded phase list, no fallback.
1461
1431
  // List all agent workflows for the dashboard's Workflows browser.
1462
- app.get("/workflows", (c) => {
1432
+ app.get("/workflows", async (c) => {
1463
1433
  const defs = listAgentWorkflows();
1464
- const overrides = db.getAllWorkflowOverrides();
1434
+ const overrides = await db.getAllWorkflowOverrides();
1465
1435
  const workflows = defs.map((def) => ({
1466
1436
  name: def.name,
1467
1437
  kind: def.kind,
@@ -1504,14 +1474,14 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1504
1474
  });
1505
1475
  // Full structured definition: every phase field, used by the definition
1506
1476
  // browser to render phase details and the diagram.
1507
- app.get("/workflows/:name/full", (c) => {
1477
+ app.get("/workflows/:name/full", async (c) => {
1508
1478
  const name = c.req.param("name");
1509
1479
  try {
1510
1480
  const def = getWorkflow(name);
1511
1481
  return c.json({
1512
1482
  workflow: def,
1513
1483
  triggers: getWorkflowTriggers(name),
1514
- enabled: db.isWorkflowEnabled(name),
1484
+ enabled: await db.isWorkflowEnabled(name),
1515
1485
  });
1516
1486
  }
1517
1487
  catch (err) {
@@ -1532,9 +1502,9 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1532
1502
  catch {
1533
1503
  return c.json({ error: `unknown workflow: ${name}` }, 404);
1534
1504
  }
1535
- const current = db.isWorkflowEnabled(name);
1505
+ const current = await db.isWorkflowEnabled(name);
1536
1506
  const next = !current;
1537
- db.setWorkflowEnabled(name, next, "admin");
1507
+ await db.setWorkflowEnabled(name, next, "admin");
1538
1508
  return c.json({ name, enabled: next });
1539
1509
  });
1540
1510
  // Raw YAML file content — preserves comments and formatting for the
@@ -1631,17 +1601,19 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1631
1601
  return false;
1632
1602
  return runOwner === owner && runRepo === repo && issueKey === key;
1633
1603
  }
1634
- function computeArtifactMetadata(owner, repo, key, doc) {
1635
- const approvals = db.approvals.listByArtifact(doc);
1604
+ async function computeArtifactMetadata(owner, repo, key, doc) {
1605
+ const approvals = await db.approvals.listByArtifact(doc);
1636
1606
  if (approvals.length === 0) {
1637
1607
  // No approval references this artifact. Docs that aren't guarded by an
1638
1608
  // approval remain editable (status.md, executor-summary.md, etc.).
1639
1609
  return { editable: true, lock: null };
1640
1610
  }
1641
- const enriched = approvals.map((approval) => ({
1642
- approval,
1643
- run: db.runs.getRun(approval.workflowRunId),
1644
- }));
1611
+ // Sequential on purpose: one run lookup per approval, in the store's order,
1612
+ // rather than fanning N reads at the DB at once.
1613
+ const enriched = [];
1614
+ for (const approval of approvals) {
1615
+ enriched.push({ approval, run: await db.runs.getRun(approval.workflowRunId) });
1616
+ }
1645
1617
  const matching = enriched.filter(({ run }) => runMatchesArtifactTarget(run, owner, repo, key));
1646
1618
  const latestMatching = matching[0];
1647
1619
  if (latestMatching && latestMatching.approval.status === "pending") {
@@ -1677,7 +1649,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1677
1649
  // the server keeps returning global data (see issue #169).
1678
1650
  app.get("/repos", async (c) => {
1679
1651
  const managed = new Set(getManagedRepos());
1680
- const activity = new Map(db.runs.distinctRepos().map((r) => [r.repo, r]));
1652
+ const activity = new Map((await db.runs.distinctRepos()).map((r) => [r.repo, r]));
1681
1653
  // Fold in artifact-key counts (bounded scan — the tab is a browse view, not
1682
1654
  // a report). A repo may have artifacts but no runs, so union it in too.
1683
1655
  const artifactCounts = new Map();
@@ -1871,14 +1843,14 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1871
1843
  return c.json({ error: err instanceof Error ? err.message : String(err) }, 400);
1872
1844
  }
1873
1845
  });
1874
- app.get("/artifacts/:owner/:repo/:key/:doc/metadata", (c) => {
1846
+ app.get("/artifacts/:owner/:repo/:key/:doc/metadata", async (c) => {
1875
1847
  if (!buildAssetStore)
1876
1848
  return c.json({ error: "build-assets store not configured" }, 404);
1877
1849
  const { owner, repo, key, doc } = c.req.param();
1878
1850
  try {
1879
1851
  // Validate the doc path upfront so traversal attempts surface as 400s.
1880
1852
  buildAssetStore.fileFor({ owner, repo, issueKey: key }, doc);
1881
- const metadata = computeArtifactMetadata(owner, repo, key, doc);
1853
+ const metadata = await computeArtifactMetadata(owner, repo, key, doc);
1882
1854
  return c.json(metadata);
1883
1855
  }
1884
1856
  catch (err) {
@@ -1894,7 +1866,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1894
1866
  try {
1895
1867
  // Validate the doc path before hitting the approval gate.
1896
1868
  buildAssetStore.fileFor({ owner, repo, issueKey: key }, doc);
1897
- const metadata = computeArtifactMetadata(owner, repo, key, doc);
1869
+ const metadata = await computeArtifactMetadata(owner, repo, key, doc);
1898
1870
  if (!metadata.editable) {
1899
1871
  return c.json({ error: "artifact_locked", lock: metadata.lock }, 403);
1900
1872
  }
@@ -1907,19 +1879,19 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1907
1879
  }
1908
1880
  });
1909
1881
  // ── Approval Gates ─────────────────────────────────────────────
1910
- app.get("/approvals", (c) => {
1911
- const approvals = db.approvals.listPending();
1882
+ app.get("/approvals", async (c) => {
1883
+ const approvals = await db.approvals.listPending();
1912
1884
  return c.json({ approvals });
1913
1885
  });
1914
1886
  // Single approval, enriched with an `artifactRef` the focused approval view
1915
1887
  // uses to open the right doc. `artifactRef` is null when the gate carries no
1916
1888
  // artifact. In server mode the ref points at the editable store doc; in repo
1917
1889
  // mode it carries a GitHub blob URL (the doc is committed on the branch).
1918
- app.get("/approvals/:id", (c) => {
1919
- const approval = db.approvals.getById(c.req.param("id"));
1890
+ app.get("/approvals/:id", async (c) => {
1891
+ const approval = await db.approvals.getById(c.req.param("id"));
1920
1892
  if (!approval)
1921
1893
  return c.json({ error: "approval not found" }, 404);
1922
- const run = db.runs.getRun(approval.workflowRunId);
1894
+ const run = await db.runs.getRun(approval.workflowRunId);
1923
1895
  let artifactRef = null;
1924
1896
  if (approval.artifact && run && run.repo) {
1925
1897
  // The row is the (owner, BARE repo) pair (issue #279); `context.owner` is
@@ -1944,7 +1916,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1944
1916
  app.post("/approvals/:id/respond", async (c) => {
1945
1917
  const id = c.req.param("id");
1946
1918
  const body = await c.req.json();
1947
- const approval = db.approvals.getById(id);
1919
+ const approval = await db.approvals.getById(id);
1948
1920
  if (!approval)
1949
1921
  return c.json({ error: "approval not found" }, 404);
1950
1922
  if (approval.status !== "pending")
@@ -1954,7 +1926,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1954
1926
  const actor = actorFromContext(c) ?? "admin";
1955
1927
  if (body.decision === "rejected") {
1956
1928
  // One transaction: respond 'rejected' + fail the run.
1957
- db.runs.resolveGateAndFail(id, actor, body.reason);
1929
+ await db.runs.resolveGateAndFail(id, actor, body.reason);
1958
1930
  }
1959
1931
  else {
1960
1932
  // Record the approval, then let resumeWorkflow flip the run back to
@@ -1970,11 +1942,11 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1970
1942
  // respond() is a compare-and-set on the still-pending row, so a racing
1971
1943
  // responder (the status check above is a TOCTOU read) changes 0 rows.
1972
1944
  // Only the winner resumes — the loser must not dispatch a second time.
1973
- const changed = db.approvals.respond(id, "approved", actor, body.reason);
1945
+ const changed = await db.approvals.respond(id, "approved", actor, body.reason);
1974
1946
  if (changed !== 1) {
1975
1947
  return c.json({ error: "already resolved" }, 409);
1976
1948
  }
1977
- const workflowRun = db.runs.getRun(approval.workflowRunId);
1949
+ const workflowRun = await db.runs.getRun(approval.workflowRunId);
1978
1950
  if (workflowRun && config.resumeWorkflow) {
1979
1951
  config.resumeWorkflow(workflowRun, actor).catch((err) => {
1980
1952
  log.error("Failed to resume workflow", { workflowRunId: workflowRun.id, err });
@@ -2031,8 +2003,8 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
2031
2003
  const optedInRepos = (cron, repos, policy) => repos.filter((repo) => cronVote(cron, repoCronPrefs(getCachedRepoLayer(repo)?.config, policy)) === "enable");
2032
2004
  // List every cron defined in workflows/cron-*.yaml, merged with the
2033
2005
  // override row (if any) and the live scheduler state.
2034
- app.get("/crons", (c) => {
2035
- const overrides = db.getAllCronOverrides();
2006
+ app.get("/crons", async (c) => {
2007
+ const overrides = await db.getAllCronOverrides();
2036
2008
  const liveByName = new Map((config.cronScheduler?.list() ?? []).map((j) => [j.name, j]));
2037
2009
  const defs = getCronWorkflows();
2038
2010
  const managedRepos = getManagedRepos();
@@ -2041,6 +2013,17 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
2041
2013
  // cache lookups rather than asking each repo a question with one answer.
2042
2014
  const policy = repoConfigPolicy();
2043
2015
  const mayVote = repoLayerMayVote(policy);
2016
+ // One query for the whole list rather than one per cron, under the
2017
+ // dashboard's 10s poll.
2018
+ const latestCronRuns = await db.cronRuns.latestByCron();
2019
+ // Same rule for the failure counts, hoisted out of the map below for the
2020
+ // same reason: the store exposes no batch form of `recentFailures`, so this
2021
+ // is a sequential walk rather than N reads fanned at the DB at once from
2022
+ // inside the render loop.
2023
+ const failuresByCron = new Map();
2024
+ for (const def of defs) {
2025
+ failuresByCron.set(def.name, await db.cronRuns.recentFailures(def.name));
2026
+ }
2044
2027
  const crons = defs.map((def) => {
2045
2028
  const override = overrides.get(def.name) ?? null;
2046
2029
  const enabled = override ? override.enabled : true;
@@ -2051,12 +2034,13 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
2051
2034
  // `withLedger` in `cron/handlers.ts`). This used to report a hardcoded
2052
2035
  // `0 / null` for handler crons, so the dashboard showed a healthy-looking
2053
2036
  // zero beside a cron that could have been failing for weeks.
2054
- const recentFailures = db.executions.consecutiveFailures(def.workflow ?? def.name);
2055
- // Last run: a workflow cron has a `workflow_runs` row (richer — it is the
2056
- // dispatched run, not the tick); a handler cron only ever has its ledger row.
2057
- const recent = def.workflow
2058
- ? db.runs.listRecent(50).find((r) => r.workflowName === def.workflow)
2059
- : lastHandlerTick(db, def.name);
2037
+ // ONE ledger, keyed on the cron's own name, for both kinds of cron —
2038
+ // which is why there is no longer a branch here. The old workflow-cron
2039
+ // path read `db.runs.listRecent(50)` and showed whichever of the tick's
2040
+ // dispatched children sorted first: an arbitrary run, not the tick. A
2041
+ // zero-discovery fire dispatched no children at all, so it showed nothing.
2042
+ const last = latestCronRuns.get(def.name) ?? null;
2043
+ const recentFailures = failuresByCron.get(def.name) ?? 0;
2060
2044
  return {
2061
2045
  name: def.name,
2062
2046
  workflow: def.workflow ?? null,
@@ -2066,9 +2050,13 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
2066
2050
  enabled,
2067
2051
  registered: !!live,
2068
2052
  nextRun: live?.nextRun?.toISOString() ?? null,
2069
- lastRun: recent?.startedAt ?? null,
2070
- lastStatus: recent?.status ?? null,
2053
+ lastRun: last?.startedAt ?? null,
2054
+ lastStatus: last?.status ?? null,
2071
2055
  recentFailures,
2056
+ reposEligible: last?.reposEligible ?? null,
2057
+ reposScanned: last?.reposScanned ?? null,
2058
+ discovered: last?.discovered ?? null,
2059
+ dispatched: last?.dispatched ?? null,
2072
2060
  optedInRepos: mayVote ? optedInRepos(def.name, managedRepos, policy) : [],
2073
2061
  context: { repos: managedRepos, ...def.context },
2074
2062
  override: override
@@ -2092,10 +2080,10 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
2092
2080
  const def = getCronWorkflows().find((d) => d.name === name);
2093
2081
  if (!def)
2094
2082
  return c.json({ error: `cron not found: ${name}` }, 404);
2095
- const override = db.getCronOverride(name);
2083
+ const override = await db.getCronOverride(name);
2096
2084
  const currentlyEnabled = override ? override.enabled : true;
2097
2085
  const nextEnabled = !currentlyEnabled;
2098
- db.setCronOverride(name, { enabled: nextEnabled, updatedBy: "admin" });
2086
+ await db.setCronOverride(name, { enabled: nextEnabled, updatedBy: "admin" });
2099
2087
  // Off is "off BY DEFAULT", not "unregistered" (issue #180): a managed repo
2100
2088
  // may opt itself back into a globally-off cron from its `.lastlight/`, and
2101
2089
  // that is resolved at TICK time — so the tick has to keep running. It just
@@ -2143,8 +2131,8 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
2143
2131
  const msg = err instanceof Error ? err.message : String(err);
2144
2132
  return c.json({ error: `invalid schedule: ${msg}` }, 400);
2145
2133
  }
2146
- db.setCronOverride(name, { schedule, updatedBy: "admin" });
2147
- const override = db.getCronOverride(name);
2134
+ await db.setCronOverride(name, { schedule, updatedBy: "admin" });
2135
+ const override = await db.getCronOverride(name);
2148
2136
  if (override?.enabled !== false) {
2149
2137
  config.cronScheduler.update({
2150
2138
  name,
@@ -2156,7 +2144,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
2156
2144
  return c.json({ name, schedule });
2157
2145
  });
2158
2146
  // Drop the override row and re-register the cron at its YAML default.
2159
- app.delete("/crons/:name/override", (c) => {
2147
+ app.delete("/crons/:name/override", async (c) => {
2160
2148
  if (!config.cronScheduler) {
2161
2149
  return c.json({ error: "cron scheduler not configured" }, 503);
2162
2150
  }
@@ -2164,7 +2152,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
2164
2152
  const def = getCronWorkflows().find((d) => d.name === name);
2165
2153
  if (!def)
2166
2154
  return c.json({ error: `cron not found: ${name}` }, 404);
2167
- db.clearCronOverride(name);
2155
+ await db.clearCronOverride(name);
2168
2156
  const job = {
2169
2157
  name,
2170
2158
  schedule: def.schedule,
@@ -2217,11 +2205,18 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
2217
2205
  // button. A cron YAML pinning `context.repos` still overrides the managed
2218
2206
  // list, as everywhere else.
2219
2207
  const { [CRON_GLOBALLY_ENABLED_KEY]: _yamlEnabled, ...defContext } = def.context ?? {};
2208
+ const actor = actorFromContext(c);
2220
2209
  const context = {
2221
2210
  repos: getManagedRepos(),
2222
2211
  ...defContext,
2212
+ // Injected LAST, same rule as `jobs.ts` and for the same reason: operator
2213
+ // YAML must not be able to spoof any of these. `_cronSource` decides
2214
+ // whether the ledger records this fire as a human pressing "Run now" or
2215
+ // as the scheduler, and `_cronActor` is who to attribute it to.
2223
2216
  [CRON_NAME_KEY]: def.name,
2224
- sender: actorFromContext(c),
2217
+ _cronSource: "manual",
2218
+ _cronActor: actor ?? null,
2219
+ sender: actor,
2225
2220
  };
2226
2221
  const fire = def.handler
2227
2222
  ? config.runCronHandler(def.handler, context)
@@ -2300,7 +2295,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
2300
2295
  // stuck (`dependabot-ci-fix` for a dependency PR, `pr-fix` otherwise)
2301
2296
  // without a second GitHub read to re-derive what the router already decided
2302
2297
  // once. A PR we have never fixed falls back to the configured `pr_fix` route.
2303
- const prior = db.runs.latestForTrigger([...PR_FIX_SHAPED_WORKFLOWS], prTriggerId(repo, prNumber));
2298
+ const prior = await db.runs.latestForTrigger([...PR_FIX_SHAPED_WORKFLOWS], prTriggerId(repo, prNumber));
2304
2299
  const workflowName = prior?.workflowName ?? getRoutes().github?.pr_fix ?? "pr-fix";
2305
2300
  const state = await resolvePrState(owner, name, prNumber, {
2306
2301
  github,