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 +1 @@
1
- {"version":3,"file":"approval-store.js","sourceRoot":"","sources":["../../src/state/approval-store.ts"],"names":[],"mappings":"AA0BA;;;;;;;;;GASG;AACH,MAAM,OAAO,aAAa;IACJ;IAApB,YAAoB,EAAqB;QAArB,OAAE,GAAF,EAAE,CAAmB;IAAG,CAAC;IAE7C,4CAA4C;IAC5C,MAAM,CACJ,QAEC;QAED,IAAI,CAAC,EAAE;aACJ,OAAO,CACN;;;KAGH,CACE;aACA,GAAG,CACF,QAAQ,CAAC,EAAE,EACX,QAAQ,CAAC,aAAa,EACtB,QAAQ,CAAC,IAAI,EACb,QAAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,IAAI,IAAI,SAAS,EAC1B,QAAQ,CAAC,QAAQ,IAAI,IAAI,EACzB,QAAQ,CAAC,WAAW,IAAI,IAAI,EAC5B,QAAQ,CAAC,SAAS,CACnB,CAAC;IACN,CAAC;IAED;;;;;;;;;;;OAWG;IACH,gBAAgB,CAAC,EAAU,EAAE,SAAiB,EAAE,SAAiB;QAC/D,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,IAAI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IACnC,MAAM,CAAC,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAChC,OAAO;QACL,GAAG,CAAC;QACJ,MAAM,EAAE,CAAC,CAAC,MAAoC;QAC9C,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,SAAS,CAA6B;KACxD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * The Drizzle client seam.
3
+ *
4
+ * Store code is written ONCE, typed against the sqlite Drizzle instance — the
5
+ * production path. A Postgres instance (Phase 4, PGlite in tests) is adapted
6
+ * through the `asStateClient()` cast below. That is sound because the
7
+ * query-builder surface the stores use (`select` / `insert` / `update` /
8
+ * `delete` / `transaction`) is structurally identical across drivers; the two
9
+ * genuinely divergent surfaces — raw SQL execution and rows-affected shape —
10
+ * are funneled through `rows()` / `run()` / `changes()` in `dialect.ts`.
11
+ *
12
+ * **The cast alone is NOT enough, and this is the one thing to remember here.**
13
+ * The query-builder surface is portable but PER-COLUMN VALUE MAPPING is not: a
14
+ * `sqliteTable` object driven by a PG client sends `1` into a `boolean` column
15
+ * (sqlite's `mapToDriverValue`; `PgBoolean` has none) and runs `JSON.parse`
16
+ * over an already-parsed jsonb object. Booleans break on WRITE, JSON on READ,
17
+ * and `dialect.ts` cannot see either. So no store may import its tables from
18
+ * `./schema/sqlite.js` — they resolve them per dialect through
19
+ * {@link tablesOf}, which hands back `schema/sqlite.ts`'s objects on the sqlite
20
+ * leg and `schema/pg.ts`'s on the Postgres one, from the same code.
21
+ *
22
+ * Backend selection is construction-time injection (`StateDb.open` /
23
+ * `StateDb.fromClient`), never a module-load env global, so both dialects can
24
+ * be constructed in one test process.
25
+ */
26
+ import type { LibSQLDatabase } from "drizzle-orm/libsql";
27
+ import * as sqliteSchema from "./schema/sqlite.js";
28
+ /** Runtime discriminator carried by StateDb. Branches `dialect.ts` helpers only. */
29
+ export type Dialect = "sqlite" | "postgres";
30
+ export type StateClient = LibSQLDatabase<typeof sqliteSchema>;
31
+ /** The transaction handle `client.transaction()` passes to its callback. */
32
+ export type StateTx = Parameters<Parameters<StateClient["transaction"]>[0]>[0];
33
+ /**
34
+ * Anything a store method can run queries against: the root client, or an
35
+ * enclosing transaction. Methods that participate in a cross-store atomic op
36
+ * take this as a trailing `dbc` parameter defaulting to `this.client`.
37
+ */
38
+ export type StateDbc = StateClient | StateTx;
39
+ /**
40
+ * The ONE documented cast that lets a non-libsql Drizzle instance (PGlite in
41
+ * Phase 4 tests) drive the sqlite-typed stores. Do not add a second cast site.
42
+ *
43
+ * Two obligations the cast cannot enforce, both on the caller:
44
+ *
45
+ * 1. **Build the instance with its own schema** — `drizzle(pglite, { schema:
46
+ * pgSchema })`. {@link tablesOf} reads the tables back off it, and throws
47
+ * loudly rather than silently mis-mapping if the schema was omitted.
48
+ * 2. **Normalize int8.** Postgres returns `COUNT(*)` / `SUM(...)` as int8,
49
+ * which node-postgres hands back as a STRING. PGlite ≥0.5 parses it to a
50
+ * number by default; a real PG client must be configured to
51
+ * (`types.setTypeParser(20, Number)`), or every aggregate silently arrives
52
+ * stringified.
53
+ */
54
+ export declare function asStateClient(db: unknown): StateClient;
55
+ /**
56
+ * The dialect-resolved table objects. Typed as the sqlite schema because that
57
+ * is the production path and the two schemas mirror each other export-for-export
58
+ * and property-for-property (`tests/state/schema-parity.test.ts` is the guard).
59
+ */
60
+ export type StateTables = typeof sqliteSchema;
61
+ /**
62
+ * The table objects belonging to a client — `schema/sqlite.ts`'s on a libsql
63
+ * client, `schema/pg.ts`'s on a Postgres one.
64
+ *
65
+ * Drizzle already carries the schema it was constructed with (`db._.fullSchema`
66
+ * is the object handed to `drizzle(client, { schema })`, and is typed for us),
67
+ * so this needs no extra constructor parameter and no second cast — the PG leg
68
+ * just passes `pgSchema` where production passes `sqliteSchema`. That also
69
+ * keeps `schema/pg.ts` out of the runtime import graph entirely: nothing under
70
+ * `src/` names it.
71
+ *
72
+ * A client built WITHOUT `{ schema }` would leave this empty and every store
73
+ * would then dereference `undefined`, so validate once, here, where the message
74
+ * can say what to fix.
75
+ */
76
+ export declare function tablesOf(client: StateClient): StateTables;
77
+ /**
78
+ * Serializes the operations that open a transaction (README locked decision 8).
79
+ *
80
+ * ONE per CONNECTION, shared by every store that transacts — not one per store.
81
+ * `WorkflowRunStore` owns five transacting ops and `TeamStore` four, all on the
82
+ * same libsql client; a store-scoped chain would leave run-op-vs-team-op races
83
+ * completely unguarded. Overlapping libsql interactive transactions fail in
84
+ * ways beyond SQLITE_BUSY (nested BEGIN, shared-handle interleaving), and
85
+ * `busy_timeout` cannot help because it is connection-scoped and the client
86
+ * swaps connections after each transaction. So this mutex, not the pragma, is
87
+ * the load-bearing defense — and it is semantically free in a single-writer
88
+ * process.
89
+ */
90
+ export type OpSerializer = <T>(fn: () => Promise<T>) => Promise<T>;
91
+ export declare function makeOpSerializer(): OpSerializer;
92
+ /** `{ a: string | null }` → `{ a: string | undefined }`, leaving the rest alone. */
93
+ export type NullsToUndefined<T> = {
94
+ [K in keyof T]: null extends T[K] ? Exclude<T[K], null> | undefined : T[K];
95
+ };
96
+ /**
97
+ * Drizzle returns `null` for a nullable column; the record types spell those
98
+ * fields as optionals (`foo?: string`). Strip the nulls at the store boundary
99
+ * so `record.foo === undefined` behaves as it always has.
100
+ *
101
+ * The return type is transformed too, not just the value — otherwise every
102
+ * caller needs an `as unknown as Record` double cast to hand the result back as
103
+ * its public record type, which would defeat the point of having one helper.
104
+ */
105
+ export declare function nullsToUndefined<T extends Record<string, unknown>>(row: T): NullsToUndefined<T>;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * The ONE documented cast that lets a non-libsql Drizzle instance (PGlite in
3
+ * Phase 4 tests) drive the sqlite-typed stores. Do not add a second cast site.
4
+ *
5
+ * Two obligations the cast cannot enforce, both on the caller:
6
+ *
7
+ * 1. **Build the instance with its own schema** — `drizzle(pglite, { schema:
8
+ * pgSchema })`. {@link tablesOf} reads the tables back off it, and throws
9
+ * loudly rather than silently mis-mapping if the schema was omitted.
10
+ * 2. **Normalize int8.** Postgres returns `COUNT(*)` / `SUM(...)` as int8,
11
+ * which node-postgres hands back as a STRING. PGlite ≥0.5 parses it to a
12
+ * number by default; a real PG client must be configured to
13
+ * (`types.setTypeParser(20, Number)`), or every aggregate silently arrives
14
+ * stringified.
15
+ */
16
+ export function asStateClient(db) {
17
+ return db;
18
+ }
19
+ /**
20
+ * The table objects belonging to a client — `schema/sqlite.ts`'s on a libsql
21
+ * client, `schema/pg.ts`'s on a Postgres one.
22
+ *
23
+ * Drizzle already carries the schema it was constructed with (`db._.fullSchema`
24
+ * is the object handed to `drizzle(client, { schema })`, and is typed for us),
25
+ * so this needs no extra constructor parameter and no second cast — the PG leg
26
+ * just passes `pgSchema` where production passes `sqliteSchema`. That also
27
+ * keeps `schema/pg.ts` out of the runtime import graph entirely: nothing under
28
+ * `src/` names it.
29
+ *
30
+ * A client built WITHOUT `{ schema }` would leave this empty and every store
31
+ * would then dereference `undefined`, so validate once, here, where the message
32
+ * can say what to fix.
33
+ */
34
+ export function tablesOf(client) {
35
+ const tables = client._?.fullSchema;
36
+ if (!tables?.executions) {
37
+ throw new Error("StateClient was constructed without its schema — call " +
38
+ "drizzle(client, { schema }) with schema/sqlite.js or schema/pg.js. " +
39
+ "Stores resolve their table objects from it (per-dialect value mapping).");
40
+ }
41
+ return tables;
42
+ }
43
+ export function makeOpSerializer() {
44
+ let chain = Promise.resolve();
45
+ return (fn) => {
46
+ // Run regardless of how the previous op settled…
47
+ const next = chain.then(fn, fn);
48
+ // …and never let a rejection poison the chain for everyone behind it.
49
+ chain = next.catch(() => { });
50
+ return next;
51
+ };
52
+ }
53
+ /**
54
+ * Drizzle returns `null` for a nullable column; the record types spell those
55
+ * fields as optionals (`foo?: string`). Strip the nulls at the store boundary
56
+ * so `record.foo === undefined` behaves as it always has.
57
+ *
58
+ * The return type is transformed too, not just the value — otherwise every
59
+ * caller needs an `as unknown as Record` double cast to hand the result back as
60
+ * its public record type, which would defeat the point of having one helper.
61
+ */
62
+ export function nullsToUndefined(row) {
63
+ const out = {};
64
+ for (const [key, value] of Object.entries(row))
65
+ out[key] = value === null ? undefined : value;
66
+ return out;
67
+ }
68
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/state/client.ts"],"names":[],"mappings":"AA2CA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,aAAa,CAAC,EAAW;IACvC,OAAO,EAAiB,CAAC;AAC3B,CAAC;AASD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAmB;IAC1C,MAAM,MAAM,GAAI,MAA+C,CAAC,CAAC,EAAE,UAAU,CAAC;IAC9E,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,wDAAwD;YACtD,qEAAqE;YACrE,yEAAyE,CAC5E,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAiBD,MAAM,UAAU,gBAAgB;IAC9B,IAAI,KAAK,GAAqB,OAAO,CAAC,OAAO,EAAE,CAAC;IAChD,OAAO,CAAI,EAAoB,EAAc,EAAE;QAC7C,iDAAiD;QACjD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAChC,sEAAsE;QACtE,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAOD;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAoC,GAAM;IACxE,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;IAC9F,OAAO,GAA0B,CAAC;AACpC,CAAC"}
@@ -0,0 +1,108 @@
1
+ import { type StateClient } from "./client.js";
2
+ /** How a fire was started. */
3
+ export type CronRunSource = "schedule" | "manual";
4
+ /**
5
+ * `running` while in flight; then `ok` (including a legitimate no-op),
6
+ * `partial` (ran, but one or more dispatches failed), or `failed` (threw
7
+ * before completing).
8
+ */
9
+ export type CronRunStatus = "running" | "ok" | "partial" | "failed";
10
+ export interface CronRunRecord {
11
+ id: string;
12
+ cronName: string;
13
+ /** The dispatched workflow. Null for a `handler:` cron. */
14
+ workflow: string | null;
15
+ /** The host-side handler. Null for a `workflow:` cron. */
16
+ handler: string | null;
17
+ source: CronRunSource;
18
+ /** Who pressed "Run now". Null for a scheduled fire. */
19
+ actor: string | null;
20
+ startedAt: string;
21
+ finishedAt: string | null;
22
+ status: CronRunStatus;
23
+ /** Managed repos the tick considered, BEFORE per-repo participation. */
24
+ reposEligible: number | null;
25
+ /** Repos that actually participated, AFTER narrowing (issue #180). */
26
+ reposScanned: number | null;
27
+ /** PRs a discovery cron found. Null for a non-discovery cron. */
28
+ discovered: number | null;
29
+ dispatched: number | null;
30
+ failures: number | null;
31
+ error: string | null;
32
+ }
33
+ export interface CronRunStart {
34
+ cronName: string;
35
+ workflow?: string | null;
36
+ handler?: string | null;
37
+ source: CronRunSource;
38
+ actor: string | null;
39
+ }
40
+ export interface CronRunFinish {
41
+ status: Exclude<CronRunStatus, "running">;
42
+ reposEligible?: number | null;
43
+ reposScanned?: number | null;
44
+ discovered?: number | null;
45
+ dispatched?: number | null;
46
+ failures?: number | null;
47
+ error?: string;
48
+ }
49
+ /**
50
+ * Owns the `cron_runs` ledger — one row per cron FIRE, scheduled or manual,
51
+ * for `workflow:` and `handler:` crons alike.
52
+ *
53
+ * Peer of {@link ExecutionStore}, constructed on the shared connection. Two
54
+ * properties are load-bearing:
55
+ *
56
+ * 1. **A no-op fire still writes a row.** A cron whose discovery finds nothing
57
+ * dispatches nothing, so it creates no `workflow_runs` and no `executions`
58
+ * row. This ledger is then the ONLY evidence it ran — which is the whole
59
+ * reason it exists (issue #341).
60
+ * 2. **Rows are keyed on the CRON name, never the workflow.** The same workflow
61
+ * is reachable from `/api/run`, a GitHub comment and a Slack message; keyed
62
+ * on the workflow, a hand-triggered failure would inflate the cron's health
63
+ * and vice versa (issue #327).
64
+ */
65
+ export declare class CronRunStore {
66
+ private client;
67
+ /**
68
+ * Table objects for THIS client's dialect. Every method destructures what it
69
+ * needs off this instead of importing from `schema/sqlite.js` — see
70
+ * `client.ts` → {@link tablesOf} for why the cast alone cannot do it.
71
+ */
72
+ private readonly t;
73
+ constructor(client: StateClient);
74
+ /** Insert a `running` row and return its id. */
75
+ start(meta: CronRunStart): Promise<string>;
76
+ /** Stamp `finished_at` and the terminal fields. */
77
+ finish(id: string, result: CronRunFinish): Promise<void>;
78
+ /**
79
+ * Most recent row per cron name — what the dashboard's crons list reads.
80
+ *
81
+ * A window function, so it stays raw SQL. Two portability notes: the derived
82
+ * table carries an explicit alias (Postgres rejects a `FROM` subquery without
83
+ * one), and `rn` is a `ROW_NUMBER()` rank — `rn = 1` is an integer compare,
84
+ * not a boolean. The tiebreak is `id DESC` — a real recency order, because
85
+ * the ids are minted in creation order ({@link creationOrderedId}); picking
86
+ * the wrong row of a tie here would show the dashboard the wrong outcome.
87
+ *
88
+ * `rows()` results are NOT column-mapped, so {@link mapCronRunRow} reads the
89
+ * raw snake_case column names.
90
+ */
91
+ latestByCron(): Promise<Map<string, CronRunRecord>>;
92
+ /**
93
+ * Consecutive non-`ok` TERMINAL fires, newest first.
94
+ *
95
+ * A `running` row is skipped rather than counted or treated as a stop: a fire
96
+ * in flight is not yet a failure, and must not mask the terminal row beneath
97
+ * it. Mirrors `ExecutionStore.consecutiveFailures` in shape so the
98
+ * scheduler's call site changes key and table but not logic.
99
+ *
100
+ * `id DESC` breaks ties on `started_at`, and the ids are minted in creation
101
+ * order for exactly that purpose — see {@link creationOrderedId}. A merely
102
+ * DETERMINISTIC tiebreak is not sufficient here, which is the trap: this walk
103
+ * stops at the first `ok`, so a tie holding one `ok` and one `failed` returns
104
+ * a different count depending which sorts first. It has to be the RIGHT
105
+ * order, not just a stable one.
106
+ */
107
+ recentFailures(cronName: string): Promise<number>;
108
+ }
@@ -0,0 +1,173 @@
1
+ import { randomUUID } from "crypto";
2
+ import { and, desc, eq, isNotNull, sql } from "drizzle-orm";
3
+ import { tablesOf } from "./client.js";
4
+ import { rows } from "./dialect.js";
5
+ /**
6
+ * A lexicographically-sortable row id: a fixed-width millisecond stamp, a
7
+ * per-process counter, then a uuid.
8
+ *
9
+ * `started_at` has millisecond resolution, so two fires in the same millisecond
10
+ * tie — and both reads below break that tie on `id`. Under sqlite the tiebreak
11
+ * used to be `rowid`, i.e. INSERTION ORDER, which PostgreSQL has no equivalent
12
+ * of; a plain `randomUUID()` is a total order but an ARBITRARY one, and
13
+ * arbitrary is not good enough here. `recentFailures` walks newest-first until
14
+ * it meets an `ok`, so a tie straddling an `ok` and a `failed` yields a
15
+ * different count depending which way it happened to sort — the failure alert
16
+ * flickering on a cron that is fine, or staying quiet on one that is not. This
17
+ * restores insertion order without a schema change and reads identically in
18
+ * both dialects.
19
+ *
20
+ * Rows written before this existed carry a bare uuid, which sorts differently —
21
+ * harmless, because the tiebreak only ever compares rows from the SAME
22
+ * millisecond and no millisecond spans the deploy that introduced it.
23
+ */
24
+ let idSeq = 0;
25
+ function creationOrderedId() {
26
+ const stamp = Date.now().toString(16).padStart(12, "0");
27
+ idSeq = (idSeq + 1) & 0xffffff;
28
+ return `${stamp}-${idSeq.toString(16).padStart(6, "0")}-${randomUUID()}`;
29
+ }
30
+ /**
31
+ * Owns the `cron_runs` ledger — one row per cron FIRE, scheduled or manual,
32
+ * for `workflow:` and `handler:` crons alike.
33
+ *
34
+ * Peer of {@link ExecutionStore}, constructed on the shared connection. Two
35
+ * properties are load-bearing:
36
+ *
37
+ * 1. **A no-op fire still writes a row.** A cron whose discovery finds nothing
38
+ * dispatches nothing, so it creates no `workflow_runs` and no `executions`
39
+ * row. This ledger is then the ONLY evidence it ran — which is the whole
40
+ * reason it exists (issue #341).
41
+ * 2. **Rows are keyed on the CRON name, never the workflow.** The same workflow
42
+ * is reachable from `/api/run`, a GitHub comment and a Slack message; keyed
43
+ * on the workflow, a hand-triggered failure would inflate the cron's health
44
+ * and vice versa (issue #327).
45
+ */
46
+ export class CronRunStore {
47
+ client;
48
+ /**
49
+ * Table objects for THIS client's dialect. Every method destructures what it
50
+ * needs off this instead of importing from `schema/sqlite.js` — see
51
+ * `client.ts` → {@link tablesOf} for why the cast alone cannot do it.
52
+ */
53
+ t;
54
+ constructor(client) {
55
+ this.client = client;
56
+ this.t = tablesOf(client);
57
+ }
58
+ /** Insert a `running` row and return its id. */
59
+ async start(meta) {
60
+ const { cronRuns } = this.t;
61
+ const id = creationOrderedId();
62
+ await this.client.insert(cronRuns).values({
63
+ id,
64
+ cronName: meta.cronName,
65
+ workflow: meta.workflow ?? null,
66
+ handler: meta.handler ?? null,
67
+ source: meta.source,
68
+ actor: meta.actor,
69
+ startedAt: new Date().toISOString(),
70
+ status: "running",
71
+ });
72
+ return id;
73
+ }
74
+ /** Stamp `finished_at` and the terminal fields. */
75
+ async finish(id, result) {
76
+ const { cronRuns } = this.t;
77
+ await this.client
78
+ .update(cronRuns)
79
+ .set({
80
+ finishedAt: new Date().toISOString(),
81
+ status: result.status,
82
+ reposEligible: result.reposEligible ?? null,
83
+ reposScanned: result.reposScanned ?? null,
84
+ discovered: result.discovered ?? null,
85
+ dispatched: result.dispatched ?? null,
86
+ failures: result.failures ?? null,
87
+ error: result.error ?? null,
88
+ })
89
+ .where(eq(cronRuns.id, id));
90
+ }
91
+ /**
92
+ * Most recent row per cron name — what the dashboard's crons list reads.
93
+ *
94
+ * A window function, so it stays raw SQL. Two portability notes: the derived
95
+ * table carries an explicit alias (Postgres rejects a `FROM` subquery without
96
+ * one), and `rn` is a `ROW_NUMBER()` rank — `rn = 1` is an integer compare,
97
+ * not a boolean. The tiebreak is `id DESC` — a real recency order, because
98
+ * the ids are minted in creation order ({@link creationOrderedId}); picking
99
+ * the wrong row of a tie here would show the dashboard the wrong outcome.
100
+ *
101
+ * `rows()` results are NOT column-mapped, so {@link mapCronRunRow} reads the
102
+ * raw snake_case column names.
103
+ */
104
+ async latestByCron() {
105
+ const { cronRuns } = this.t;
106
+ const ranked = await rows(this.client, sql `SELECT * FROM (
107
+ SELECT *, ROW_NUMBER() OVER (
108
+ PARTITION BY ${cronRuns.cronName}
109
+ ORDER BY ${cronRuns.startedAt} DESC, ${cronRuns.id} DESC
110
+ ) AS rn
111
+ FROM ${cronRuns}
112
+ ) AS ranked
113
+ WHERE rn = 1`);
114
+ const map = new Map();
115
+ for (const row of ranked) {
116
+ const record = mapCronRunRow(row);
117
+ map.set(record.cronName, record);
118
+ }
119
+ return map;
120
+ }
121
+ /**
122
+ * Consecutive non-`ok` TERMINAL fires, newest first.
123
+ *
124
+ * A `running` row is skipped rather than counted or treated as a stop: a fire
125
+ * in flight is not yet a failure, and must not mask the terminal row beneath
126
+ * it. Mirrors `ExecutionStore.consecutiveFailures` in shape so the
127
+ * scheduler's call site changes key and table but not logic.
128
+ *
129
+ * `id DESC` breaks ties on `started_at`, and the ids are minted in creation
130
+ * order for exactly that purpose — see {@link creationOrderedId}. A merely
131
+ * DETERMINISTIC tiebreak is not sufficient here, which is the trap: this walk
132
+ * stops at the first `ok`, so a tie holding one `ok` and one `failed` returns
133
+ * a different count depending which sorts first. It has to be the RIGHT
134
+ * order, not just a stable one.
135
+ */
136
+ async recentFailures(cronName) {
137
+ const { cronRuns } = this.t;
138
+ const recent = await this.client
139
+ .select({ status: cronRuns.status })
140
+ .from(cronRuns)
141
+ .where(and(eq(cronRuns.cronName, cronName), isNotNull(cronRuns.finishedAt)))
142
+ .orderBy(desc(cronRuns.startedAt), desc(cronRuns.id))
143
+ .limit(10);
144
+ let count = 0;
145
+ for (const row of recent) {
146
+ if (row.status !== "ok")
147
+ count++;
148
+ else
149
+ break;
150
+ }
151
+ return count;
152
+ }
153
+ }
154
+ function mapCronRunRow(row) {
155
+ return {
156
+ id: row.id,
157
+ cronName: row.cron_name,
158
+ workflow: row.workflow ?? null,
159
+ handler: row.handler ?? null,
160
+ source: row.source,
161
+ actor: row.actor ?? null,
162
+ startedAt: row.started_at,
163
+ finishedAt: row.finished_at ?? null,
164
+ status: row.status,
165
+ reposEligible: row.repos_eligible ?? null,
166
+ reposScanned: row.repos_scanned ?? null,
167
+ discovered: row.discovered ?? null,
168
+ dispatched: row.dispatched ?? null,
169
+ failures: row.failures ?? null,
170
+ error: row.error ?? null,
171
+ };
172
+ }
173
+ //# sourceMappingURL=cron-run-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cron-run-store.js","sourceRoot":"","sources":["../../src/state/cron-run-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAsC,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC;;;;;;;;;;;;;;;;;;GAkBG;AACH,IAAI,KAAK,GAAG,CAAC,CAAC;AACd,SAAS,iBAAiB;IACxB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IACxD,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;IAC/B,OAAO,GAAG,KAAK,IAAI,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,UAAU,EAAE,EAAE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
2
  import { ExecutionStore } from "./execution-store.js";
3
+ import { CronRunStore } from "./cron-run-store.js";
3
4
  import { ApprovalStore } from "./approval-store.js";
4
5
  import { WorkflowRunStore } from "./workflow-run-store.js";
5
6
  import { UserStore } from "./user-store.js";
@@ -9,6 +10,7 @@ export type { ExecutionRecord } from "./execution-store.js";
9
10
  export type { WorkflowApproval } from "./approval-store.js";
10
11
  export type { WorkflowRun, PhaseHistoryEntry, PhaseMarker } from "./workflow-run-store.js";
11
12
  export type { User, TriggerActorType } from "./user-store.js";
13
+ export type { CronRunRecord, CronRunSource, CronRunStatus } from "./cron-run-store.js";
12
14
  export type { ResolvedTeam, CachedVisibility, VisibilitySync, VisibilitySyncStatus, } from "./team-store.js";
13
15
  export type { FeedbackAnchor, FeedbackAnchorInput, FeedbackAnchorKind, FeedbackSignal, FeedbackSummaryRow, FeedbackDailyRow, FeedbackListOptions, } from "./feedback-store.js";
14
16
  export { ExecutionStore } from "./execution-store.js";
@@ -17,6 +19,7 @@ export { WorkflowRunStore } from "./workflow-run-store.js";
17
19
  export { UserStore, TRIGGER_ACTOR_TYPES, isTriggerActorType } from "./user-store.js";
18
20
  export { TeamStore } from "./team-store.js";
19
21
  export { FeedbackStore } from "./feedback-store.js";
22
+ export { CronRunStore } from "./cron-run-store.js";
20
23
  export interface CronOverride {
21
24
  name: string;
22
25
  enabled: boolean;
@@ -41,16 +44,21 @@ export interface WorkflowOverride {
41
44
  * Lightweight SQLite state for operational tracking.
42
45
  * NOT for conversation history — only execution logs and rate limits.
43
46
  *
44
- * Construction root for the three per-table stores (issue #97): it opens the
45
- * single `Database` connection, runs {@link migrate}, and builds
46
- * {@link ExecutionStore} / {@link ApprovalStore} / {@link WorkflowRunStore} on
47
- * top of it (all sharing the one connection so better-sqlite3 transactions
48
- * span every store). Callers reach the stores via `db.runs` / `db.approvals` /
49
- * `db.executions`. StateDb itself retains only the cross-cutting cron-override
50
- * and workflow kill-switch concerns.
47
+ * Construction root for the seven per-table stores (issue #97): it opens the
48
+ * single Drizzle client, runs the compat pre-step + migrations, and builds the
49
+ * stores on top of it (all sharing the one client so transactions span every
50
+ * store). Callers reach the stores via `db.runs` / `db.approvals` /
51
+ * `db.executions` / …. StateDb itself retains only the cross-cutting
52
+ * cron-override and workflow kill-switch concerns.
53
+ *
54
+ * Construction is async — the driver is — so it is a static factory rather
55
+ * than a constructor: {@link StateDb.open} for production, {@link
56
+ * StateDb.fromClient} to adopt an existing Drizzle instance.
51
57
  */
52
58
  export declare class StateDb {
53
- private db;
59
+ private readonly _client;
60
+ private readonly _dialect;
61
+ private readonly closer?;
54
62
  /** Owns the `executions` ledger. */
55
63
  readonly executions: ExecutionStore;
56
64
  /** Owns the `workflow_approvals` table. */
@@ -67,11 +75,50 @@ export declare class StateDb {
67
75
  readonly teams: TeamStore;
68
76
  /** Reaction-derived eval signals + the anchors they hang on (issue #255). */
69
77
  readonly feedback: FeedbackStore;
70
- constructor(dbPath?: string);
78
+ /**
79
+ * One row per cron FIRE (issues #341/#327). The only record a zero-discovery
80
+ * backstop fire leaves — it dispatches nothing, so it writes no
81
+ * `workflow_runs` and no `executions` row.
82
+ */
83
+ readonly cronRuns: CronRunStore;
84
+ /**
85
+ * Table objects for THIS client's dialect. Every method destructures what it
86
+ * needs off this instead of importing from `schema/sqlite.js` — see
87
+ * `client.ts` → {@link tablesOf} for why the cast alone cannot do it.
88
+ */
89
+ private readonly t;
90
+ private constructor();
91
+ /**
92
+ * Production entry: open (or create) the SQLite database, apply the legacy
93
+ * compat pre-step, then run migrations.
94
+ *
95
+ * Normalizes every accepted form HERE so no caller ever builds a `file:` URL:
96
+ * `:memory:` passes through, `file:` URLs pass through, and anything else is
97
+ * treated as a filesystem path.
98
+ *
99
+ * **`:memory:` is only safe for a caller that never opens a transaction.**
100
+ * The libsql client lazily opens a NEW connection after every
101
+ * `client.transaction()`, and for `:memory:` a new connection is a new, EMPTY
102
+ * database — so the first committed transaction silently discards the schema
103
+ * and every subsequent query fails with `no such table`. Verified on
104
+ * @libsql/client 0.17. Nothing in production uses `:memory:`; a test that
105
+ * touches `WorkflowRunStore`'s named ops or any `TeamStore` write must use a
106
+ * temp FILE instead.
107
+ */
108
+ static open(pathOrUrl?: string): Promise<StateDb>;
109
+ /**
110
+ * Test / Phase-4 entry: adopt an existing Drizzle instance. Runs no
111
+ * migrations — the caller owns the schema.
112
+ */
113
+ static fromClient(client: StateClient, dialect: Dialect, opts?: {
114
+ close?: () => void;
115
+ }): StateDb;
116
+ get client(): StateClient;
117
+ get dialect(): Dialect;
71
118
  /** Get the override row for a single cron, or null if none. */
72
- getCronOverride(name: string): CronOverride | null;
119
+ getCronOverride(name: string): Promise<CronOverride | null>;
73
120
  /** All override rows keyed by cron name. */
74
- getAllCronOverrides(): Map<string, CronOverride>;
121
+ getAllCronOverrides(): Promise<Map<string, CronOverride>>;
75
122
  /**
76
123
  * Upsert an override. Pass only the fields you want to change — undefined
77
124
  * fields preserve the existing value (or default to enabled=1, schedule=null
@@ -81,20 +128,20 @@ export declare class StateDb {
81
128
  enabled?: boolean;
82
129
  schedule?: string | null;
83
130
  updatedBy?: string;
84
- }): void;
131
+ }): Promise<void>;
85
132
  /** Remove the override entirely (revert to YAML defaults). */
86
- clearCronOverride(name: string): void;
87
- private deserializeCronOverride;
133
+ clearCronOverride(name: string): Promise<void>;
88
134
  /**
89
135
  * Cheap check used by every dispatch path. Returns true unless an explicit
90
136
  * `workflow_overrides` row says otherwise.
91
137
  */
92
- isWorkflowEnabled(name: string): boolean;
93
- getWorkflowOverride(name: string): WorkflowOverride | null;
94
- getAllWorkflowOverrides(): Map<string, WorkflowOverride>;
95
- setWorkflowEnabled(name: string, enabled: boolean, updatedBy?: string): void;
96
- private deserializeWorkflowOverride;
97
- /** Expose the underlying Database instance (for SessionManager, etc.) */
98
- get database(): Database.Database;
99
- close(): void;
138
+ isWorkflowEnabled(name: string): Promise<boolean>;
139
+ getWorkflowOverride(name: string): Promise<WorkflowOverride | null>;
140
+ getAllWorkflowOverrides(): Promise<Map<string, WorkflowOverride>>;
141
+ setWorkflowEnabled(name: string, enabled: boolean, updatedBy?: string): Promise<void>;
142
+ /**
143
+ * Async by contract: libsql's `close()` is synchronous today, but a Postgres
144
+ * pool's is not, and every caller already awaits this.
145
+ */
146
+ close(): Promise<void>;
100
147
  }