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
@@ -1,6 +1,6 @@
1
- import type Database from "better-sqlite3";
2
1
  import type { ApprovalStore } from "./approval-store.js";
3
2
  import type { TriggerActorType } from "./user-store.js";
3
+ import { type OpSerializer, type StateClient, type StateDbc } from "./client.js";
4
4
  export interface PhaseHistoryEntry {
5
5
  phase: string;
6
6
  timestamp: string;
@@ -85,20 +85,26 @@ export interface PhaseMarker {
85
85
  * Carved out of the old `StateDb` god-class (issue #97). The deepening: every
86
86
  * multi-step mutation that previously lived as an un-guarded read-modify-write
87
87
  * chain in `index.ts` / `admin/routes.ts` / `phase-executor.ts` is now a
88
- * single named operation wrapped in ONE `better-sqlite3` transaction — a throw
89
- * partway through rolls the whole thing back, so a run can never be left
90
- * marked `running` with its gate unresolved (the hazard the issue calls out).
88
+ * single named operation wrapped in ONE transaction — a throw partway through
89
+ * rolls the whole thing back, so a run can never be left marked `running` with
90
+ * its gate unresolved (the hazard the issue calls out).
91
91
  *
92
92
  * Constructed with an injected {@link ApprovalStore}: an approval has no life
93
93
  * independent of its run, so the cross-table ops call the approval store's
94
- * single-table writes from inside this store's transaction. Both stores MUST
95
- * be built from the same `Database` — better-sqlite3 transactions are
96
- * per-connection.
94
+ * single-table writes from inside this store's transaction, passing the
95
+ * transaction handle as their trailing `dbc` argument. Both stores MUST be
96
+ * built from the same client — a transaction is per-connection.
97
+ *
98
+ * Every op that opens a transaction runs through the injected
99
+ * {@link OpSerializer}, the ONE connection-scoped mutex shared with
100
+ * `TeamStore`: overlapping libsql interactive transactions fail in ways
101
+ * `busy_timeout` cannot help with (it is connection-scoped, and the client
102
+ * swaps connections after each transaction).
97
103
  *
98
104
  * The long-running re-dispatch (`dispatchWorkflow`, which spawns a Docker
99
- * sandbox for minutes) is deliberately NOT part of any transaction here —
100
- * better-sqlite3 transactions are synchronous. The atomic boundary is the DB
101
- * mutations only; the caller dispatches after the transaction commits.
105
+ * sandbox for minutes) is deliberately NOT part of any transaction here. The
106
+ * atomic boundary is the DB mutations only; the caller dispatches after the
107
+ * op returns.
102
108
  */
103
109
  /**
104
110
  * Notified once a run reaches a TERMINAL status, whichever path took it there.
@@ -127,11 +133,19 @@ export interface PhaseMarker {
127
133
  */
128
134
  export type TerminalRunObserver = (run: WorkflowRun, status: "succeeded" | "failed" | "cancelled") => void;
129
135
  export declare class WorkflowRunStore {
130
- private db;
136
+ private client;
131
137
  private approvals;
138
+ private serialize;
132
139
  private terminalObservers;
133
- constructor(db: Database.Database, deps: {
140
+ /**
141
+ * Table objects for THIS client's dialect. Every method destructures what it
142
+ * needs off this instead of importing from `schema/sqlite.js` — see
143
+ * `client.ts` → {@link tablesOf} for why the cast alone cannot do it.
144
+ */
145
+ private readonly t;
146
+ constructor(client: StateClient, deps: {
134
147
  approvals: ApprovalStore;
148
+ serialize: OpSerializer;
135
149
  });
136
150
  /** Add a {@link TerminalRunObserver}. Wired at boot; order is registration order. */
137
151
  addTerminalObserver(fn: TerminalRunObserver): void;
@@ -142,6 +156,18 @@ export declare class WorkflowRunStore {
142
156
  * failing must not cost the others their notification.
143
157
  */
144
158
  private notifyTerminal;
159
+ /**
160
+ * Read a run's `context` object for an app-side read-modify-write.
161
+ *
162
+ * The three context mutations in this store — the error annotation in
163
+ * {@link expireQueued} and {@link flipFinished}, the error clear in
164
+ * {@link restartRun} — used to be `json_patch` / `json_remove` SQL, which
165
+ * Postgres has no equivalent for. `context` is a json-mode column, so the
166
+ * builder hands the object over and takes one back and the merge is plain JS.
167
+ * A missing row (or a NULL column) reads as `{}`, exactly what the
168
+ * `COALESCE(context, '{}')` those statements opened with produced.
169
+ */
170
+ private readContext;
145
171
  /**
146
172
  * Create a new workflow run record.
147
173
  *
@@ -150,17 +176,18 @@ export declare class WorkflowRunStore {
150
176
  * passing `"owner/repo"` is split rather than stored as a third shape. See
151
177
  * `state/repo-ref.ts`.
152
178
  */
153
- createRun(run: Omit<WorkflowRun, "phaseHistory" | "updatedAt">): void;
179
+ createRun(run: Omit<WorkflowRun, "phaseHistory" | "updatedAt">): Promise<void>;
154
180
  /**
155
181
  * Top-level merge of `patch` into the workflow run's scratch state.
156
182
  * Loop iterations can append to `scratch.socratic.qa` without clobbering
157
183
  * other keys.
158
184
  *
159
185
  * Throws if `patch` is not JSON-serializable (e.g. it contains a BigInt) —
160
- * which is exactly how the atomic ops prove their rollback: a poison patch
161
- * makes `JSON.stringify` throw mid-transaction.
186
+ * which is exactly how the atomic ops prove their rollback: Drizzle
187
+ * serializes the json-mode column when it executes the UPDATE, so a poison
188
+ * patch throws from the statement itself, before it has mutated anything.
162
189
  */
163
- mergeScratch(id: string, patch: Record<string, unknown>): void;
190
+ mergeScratch(id: string, patch: Record<string, unknown>, dbc?: StateDbc): Promise<void>;
164
191
  /**
165
192
  * Remember which OTel trace this run is being exported under (issue #255).
166
193
  *
@@ -172,7 +199,7 @@ export declare class WorkflowRunStore {
172
199
  * repeated — a resume re-opens a span under a new trace, and the newest trace
173
200
  * is the right one for a signal arriving now.
174
201
  */
175
- setTraceContext(id: string, traceId: string, spanId: string): void;
202
+ setTraceContext(id: string, traceId: string, spanId: string): Promise<void>;
176
203
  /**
177
204
  * Update the current phase and append to phase history. This is the single
178
205
  * seam through which all phase-history writes flow (issue #97 defers the
@@ -180,25 +207,25 @@ export declare class WorkflowRunStore {
180
207
  * routes every write through here so that future change touches one method
181
208
  * instead of ~10 call sites).
182
209
  */
183
- appendPhase(id: string, phase: string, entry: PhaseHistoryEntry): void;
210
+ appendPhase(id: string, phase: string, entry: PhaseHistoryEntry, dbc?: StateDbc): Promise<void>;
184
211
  /** Get a single workflow run by ID */
185
- getRun(id: string): WorkflowRun | null;
212
+ getRun(id: string, dbc?: StateDbc): Promise<WorkflowRun | null>;
186
213
  /** Find the most recent active (running, paused, or queued) workflow run for a trigger */
187
- getByTrigger(triggerId: string): WorkflowRun | null;
214
+ getByTrigger(triggerId: string): Promise<WorkflowRun | null>;
188
215
  /**
189
216
  * True if any run of `workflowName` exists for this trigger, in ANY status.
190
217
  * Unlike `getByTrigger` (active runs only), this also sees a build that has
191
218
  * already succeeded/failed/cancelled — the signal the router uses to gate
192
219
  * reporter-driven re-triage to the pre-build window.
193
220
  */
194
- hasRunForTrigger(triggerId: string, workflowName: string): boolean;
221
+ hasRunForTrigger(triggerId: string, workflowName: string): Promise<boolean>;
195
222
  /**
196
223
  * The most recent SUCCEEDED run of `workflowName` for this trigger, or null.
197
224
  * Unlike `getByTrigger` (active rows only), this reads terminal history: the
198
225
  * dependency-workflow dedup guard reads the winner's stored `context.headSha`
199
226
  * to skip re-assessing a PR at a head SHA it already handled.
200
227
  */
201
- latestSucceededForTrigger(workflowName: string, triggerId: string): WorkflowRun | null;
228
+ latestSucceededForTrigger(workflowName: string, triggerId: string): Promise<WorkflowRun | null>;
202
229
  /**
203
230
  * The most recent run for this trigger belonging to ANY of `workflowNames`,
204
231
  * in ANY status.
@@ -219,7 +246,7 @@ export declare class WorkflowRunStore {
219
246
  * would make a crash look like "no prior attempt" and re-arm the loop
220
247
  * from zero.
221
248
  */
222
- latestForTrigger(workflowNames: string[], triggerId: string): WorkflowRun | null;
249
+ latestForTrigger(workflowNames: string[], triggerId: string): Promise<WorkflowRun | null>;
223
250
  /**
224
251
  * The oldest still-live (queued / running / paused) run for this trigger
225
252
  * among `workflowNames` — the PR-scoped run lock (09-state-machine.md → S4).
@@ -232,7 +259,7 @@ export declare class WorkflowRunStore {
232
259
  * would have two agents fetch/reset/push the same branch through the same
233
260
  * directory.
234
261
  */
235
- activeForTrigger(workflowNames: string[], triggerId: string): WorkflowRun | null;
262
+ activeForTrigger(workflowNames: string[], triggerId: string): Promise<WorkflowRun | null>;
236
263
  /**
237
264
  * The most recent SUCCEEDED run of EACH of `workflowNames` for this trigger,
238
265
  * keyed by workflow name. Absent keys mean "never succeeded here".
@@ -242,11 +269,11 @@ export declare class WorkflowRunStore {
242
269
  * having succeeded at a SHA says nothing about whether `dependabot-pr-merge`
243
270
  * has assessed it. One small indexed lookup per name — the set is four.
244
271
  */
245
- latestSucceededForTriggers(workflowNames: string[], triggerId: string): Record<string, WorkflowRun>;
272
+ latestSucceededForTriggers(workflowNames: string[], triggerId: string): Promise<Record<string, WorkflowRun>>;
246
273
  /** List all active (queued, running, or paused) workflow runs */
247
- listActive(): WorkflowRun[];
274
+ listActive(): Promise<WorkflowRun[]>;
248
275
  /** List recent workflow runs, ordered by start time descending */
249
- listRecent(limit?: number): WorkflowRun[];
276
+ listRecent(limit?: number): Promise<WorkflowRun[]>;
250
277
  /**
251
278
  * List workflow runs with pagination + filters. Returns the page slice
252
279
  * AND the post-filter total so the dashboard knows how many remain.
@@ -273,22 +300,22 @@ export declare class WorkflowRunStore {
273
300
  */
274
301
  repos?: string[];
275
302
  statuses?: string[];
276
- }): {
303
+ }): Promise<{
277
304
  runs: WorkflowRun[];
278
305
  total: number;
279
- };
306
+ }>;
280
307
  /**
281
308
  * Count workflow runs with status 'running'. Excludes 'queued' and 'paused'
282
309
  * since those are not holding a sandbox slot. Used by the concurrency cap
283
310
  * (issue #172) to decide whether to queue a fresh run.
284
311
  */
285
- countRunning(): number;
312
+ countRunning(): Promise<number>;
286
313
  /**
287
314
  * List all queued runs ordered by started_at ascending (FIFO enqueue order).
288
315
  * Used by the admission controller to pick the next run to promote and to
289
316
  * perform TTL expiry.
290
317
  */
291
- listQueued(): WorkflowRun[];
318
+ listQueued(): Promise<WorkflowRun[]>;
292
319
  /**
293
320
  * CAS: transition a queued run to running. Returns the number of rows changed
294
321
  * (1 = winner, 0 = already admitted or run not found). The guard
@@ -298,16 +325,23 @@ export declare class WorkflowRunStore {
298
325
  * Does NOT touch started_at or restart_count — those stay at their enqueue
299
326
  * values so TTL sweep can detect staleness and dashboards show enqueue time.
300
327
  */
301
- admitRun(id: string): number;
328
+ admitRun(id: string): Promise<number>;
302
329
  /**
303
330
  * CAS: transition a queued run to cancelled, recording the reason in
304
331
  * context.error. Returns the number of rows changed (1 on success, 0 if the
305
332
  * run was no longer queued). Used by the TTL sweep in the admission
306
333
  * controller to drop stale queued runs.
307
- */
308
- expireQueued(id: string, reason: string): number;
334
+ *
335
+ * The context annotation is an app-side read-modify-write (see
336
+ * {@link readContext}), but the write still carries the whole compare-and-set
337
+ * in its own `WHERE`, so the rows-affected count keeps its exact meaning. The
338
+ * read cannot go stale underneath it either: nothing else writes the context
339
+ * of a run that is still `queued`, and a run that stopped being queued loses
340
+ * the CAS.
341
+ */
342
+ expireQueued(id: string, reason: string): Promise<number>;
309
343
  /** Distinct workflow_name values, sorted alphabetically. */
310
- distinctNames(): string[];
344
+ distinctNames(): Promise<string[]>;
311
345
  /**
312
346
  * Per-repo run activity — one row per distinct `owner/repo`, with the run
313
347
  * count and the most-recent `started_at`. Powers the dashboard's Repos tab,
@@ -323,11 +357,11 @@ export declare class WorkflowRunStore {
323
357
  * correctly: two rows for the same repo that disagree about shape collapse
324
358
  * into one bucket here rather than after the fact.
325
359
  */
326
- distinctRepos(): {
360
+ distinctRepos(): Promise<{
327
361
  repo: string;
328
362
  runCount: number;
329
363
  lastRunAt: string;
330
- }[];
364
+ }[]>;
331
365
  /**
332
366
  * What Last Light did for ONE repo since `sinceIso` — a count per
333
367
  * (workflow, status) pair. The bot half of the weekly digest.
@@ -338,29 +372,30 @@ export declare class WorkflowRunStore {
338
372
  * written before the owner/repo backfill carry `owner/repo` in the repo
339
373
  * column, and a bare-name filter silently misses every one of them.
340
374
  */
341
- summarizeRepoActivity(owner: string, repo: string, sinceIso: string): {
375
+ summarizeRepoActivity(owner: string, repo: string, sinceIso: string): Promise<{
342
376
  workflowName: string;
343
377
  status: string;
344
378
  count: number;
345
- }[];
379
+ }[]>;
346
380
  /**
347
- * Mark a workflow run as finished. Plain status flip when called with just
348
- * `{ error }`; when a `terminalMarker` is supplied (the runner's
349
- * `on_success.set_phase`), the phase-history append and the status flip
350
- * happen in ONE transaction so the dashboard never sees the terminal phase
351
- * without the finished status, or vice versa.
381
+ * Mark a workflow run as finished. Plain status flip when called with
382
+ * neither an `error` nor a `terminalMarker`; with either, the work spans two
383
+ * statements — the phase-history append and/or the `context.error`
384
+ * read-modify-write, plus the status flip — so it runs in ONE transaction
385
+ * and the dashboard never sees the terminal phase without the finished
386
+ * status, or vice versa.
352
387
  */
353
388
  finishRun(id: string, status: "succeeded" | "failed" | "cancelled", opts?: {
354
389
  error?: string;
355
390
  terminalMarker?: PhaseMarker;
356
- }): void;
391
+ }): Promise<void>;
357
392
  private flipFinished;
358
393
  /** Cancel a workflow run */
359
- cancelRun(id: string): void;
394
+ cancelRun(id: string): Promise<void>;
360
395
  /** Pause a workflow run (waiting for approval) */
361
- setPaused(id: string): void;
396
+ setPaused(id: string, dbc?: StateDbc): Promise<void>;
362
397
  /** Resume a paused workflow run (set back to running) */
363
- setRunning(id: string): void;
398
+ setRunning(id: string, dbc?: StateDbc): Promise<void>;
364
399
  /**
365
400
  * Restart a FAILED or CANCELLED run so it can be retried from where it
366
401
  * stopped. Unlike {@link setRunning} this also clears the terminal markers the
@@ -377,8 +412,12 @@ export declare class WorkflowRunStore {
377
412
  * `WHERE status IN ('failed','cancelled')` and returns the changed-row count
378
413
  * so the caller can make retry a compare-and-set: a second concurrent retry
379
414
  * click sees 0 rows changed and does NOT dispatch again.
415
+ *
416
+ * Clearing the error is an app-side read-modify-write now (see
417
+ * {@link readContext}); the CAS still rides on this one UPDATE, and a run in a
418
+ * terminal status has no other writer to race the read against.
380
419
  */
381
- restartRun(id: string): number;
420
+ restartRun(id: string): Promise<number>;
382
421
  /**
383
422
  * Refresh a QUEUED run's enqueue clock to now. Used by boot recovery: a run
384
423
  * that was `queued` when the harness died carries a stale `started_at`, so the
@@ -387,7 +426,7 @@ export declare class WorkflowRunStore {
387
426
  * `maxQueueWaitMs` window so the AdmissionController admits it normally as
388
427
  * slots free. CAS-guarded on `status = 'queued'`; returns rows changed.
389
428
  */
390
- requeue(id: string): number;
429
+ requeue(id: string): Promise<number>;
391
430
  /**
392
431
  * Backpressure requeue: flip a RUNNING run back to `queued` and re-stamp its
393
432
  * enqueue clock. Used by the k8s backend when a pod-create is rejected by the
@@ -398,14 +437,14 @@ export declare class WorkflowRunStore {
398
437
  * CAS-guarded on `status = 'running'`; returns rows changed (0 = safe no-op,
399
438
  * e.g. the run already finished or was cancelled between phases).
400
439
  */
401
- requeueRunning(id: string): number;
440
+ requeueRunning(id: string): Promise<number>;
402
441
  /**
403
442
  * Increment the restart counter and return the new value. Used by
404
443
  * `resumeOrphanedWorkflows` to enforce a retry budget so a run that
405
444
  * crashes the host (agent OOM, etc.) eventually self-terminates instead
406
445
  * of being re-dispatched on every boot.
407
446
  */
408
- incrementRestartCount(id: string): number;
447
+ incrementRestartCount(id: string): Promise<number>;
409
448
  private deserialize;
410
449
  /**
411
450
  * Resolve a socratic reply gate and resume the run, atomically: the reply
@@ -435,7 +474,7 @@ export declare class WorkflowRunStore {
435
474
  * ApprovalStore participates in the same transaction); ordering is invisible
436
475
  * outside the transaction.
437
476
  */
438
- pauseForApproval(runId: string, approval: Parameters<ApprovalStore["create"]>[0], marker: PhaseMarker, scratchPatch?: Record<string, unknown>): void;
477
+ pauseForApproval(runId: string, approval: Parameters<ApprovalStore["create"]>[0], marker: PhaseMarker, scratchPatch?: Record<string, unknown>): Promise<void>;
439
478
  /**
440
479
  * Approve a gate and resume its run, atomically. Reads the approval to find
441
480
  * its run, records the `approved` response, and flips the run back to
@@ -446,12 +485,12 @@ export declare class WorkflowRunStore {
446
485
  * will follow before responding, so it records the approval and lets
447
486
  * `resumeWorkflow` flip the run only as part of an actual dispatch.
448
487
  */
449
- resolveGateAndResume(approvalId: string, responder: string): WorkflowRun | null;
488
+ resolveGateAndResume(approvalId: string, responder: string): Promise<WorkflowRun | null>;
450
489
  /**
451
490
  * Reject a gate and fail its run, atomically: record the `rejected` response
452
491
  * (with reason) and flip the run to `failed` in one transaction. Returns the
453
492
  * run (or null if the approval's run was already gone).
454
493
  */
455
- resolveGateAndFail(approvalId: string, responder: string, reason?: string): WorkflowRun | null;
456
- resolveReplyGateAndResume(runId: string, approvalId: string, replyText: string, responder: string, scratchPatch: Record<string, unknown>): WorkflowRun | null;
494
+ resolveGateAndFail(approvalId: string, responder: string, reason?: string): Promise<WorkflowRun | null>;
495
+ resolveReplyGateAndResume(runId: string, approvalId: string, replyText: string, responder: string, scratchPatch: Record<string, unknown>): Promise<WorkflowRun | null>;
457
496
  }