lastlight-core 0.24.2 → 0.24.4

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 (58) hide show
  1. package/config/default.yaml +19 -0
  2. package/deploy/slack/README.md +15 -0
  3. package/deploy/slack/slack-manifest.json +4 -1
  4. package/dist/admin/routes.js +40 -0
  5. package/dist/admin/routes.js.map +1 -1
  6. package/dist/config/config.d.ts +42 -0
  7. package/dist/config/config.js +36 -0
  8. package/dist/config/config.js.map +1 -1
  9. package/dist/connectors/messaging/base.d.ts +15 -0
  10. package/dist/connectors/messaging/base.js +29 -1
  11. package/dist/connectors/messaging/base.js.map +1 -1
  12. package/dist/connectors/messaging/types.d.ts +25 -0
  13. package/dist/connectors/slack/connector.d.ts +27 -0
  14. package/dist/connectors/slack/connector.js +52 -0
  15. package/dist/connectors/slack/connector.js.map +1 -1
  16. package/dist/cron/feedback-poll.d.ts +72 -0
  17. package/dist/cron/feedback-poll.js +161 -0
  18. package/dist/cron/feedback-poll.js.map +1 -0
  19. package/dist/engine/feedback/ingest.d.ts +61 -0
  20. package/dist/engine/feedback/ingest.js +150 -0
  21. package/dist/engine/feedback/ingest.js.map +1 -0
  22. package/dist/engine/feedback/reactions.d.ts +58 -0
  23. package/dist/engine/feedback/reactions.js +153 -0
  24. package/dist/engine/feedback/reactions.js.map +1 -0
  25. package/dist/engine/feedback/slack.d.ts +61 -0
  26. package/dist/engine/feedback/slack.js +73 -0
  27. package/dist/engine/feedback/slack.js.map +1 -0
  28. package/dist/engine/github/github.d.ts +51 -0
  29. package/dist/engine/github/github.js +111 -0
  30. package/dist/engine/github/github.js.map +1 -1
  31. package/dist/engine/review-check.js +1 -1
  32. package/dist/index.js +95 -4
  33. package/dist/index.js.map +1 -1
  34. package/dist/notify/transports/slack.d.ts +9 -0
  35. package/dist/notify/transports/slack.js +7 -2
  36. package/dist/notify/transports/slack.js.map +1 -1
  37. package/dist/state/db.d.ts +5 -0
  38. package/dist/state/db.js +5 -0
  39. package/dist/state/db.js.map +1 -1
  40. package/dist/state/feedback-store.d.ts +181 -0
  41. package/dist/state/feedback-store.js +345 -0
  42. package/dist/state/feedback-store.js.map +1 -0
  43. package/dist/state/migrate.js +123 -0
  44. package/dist/state/migrate.js.map +1 -1
  45. package/dist/state/workflow-run-store.d.ts +37 -9
  46. package/dist/state/workflow-run-store.js +41 -12
  47. package/dist/state/workflow-run-store.js.map +1 -1
  48. package/dist/telemetry/feedback.d.ts +18 -0
  49. package/dist/telemetry/feedback.js +115 -0
  50. package/dist/telemetry/feedback.js.map +1 -0
  51. package/dist/telemetry/index.js +8 -0
  52. package/dist/telemetry/index.js.map +1 -1
  53. package/dist/telemetry/openinference.d.ts +7 -0
  54. package/dist/telemetry/openinference.js +7 -0
  55. package/dist/telemetry/openinference.js.map +1 -1
  56. package/dist/workflows/runner.js +38 -1
  57. package/dist/workflows/runner.js.map +1 -1
  58. package/package.json +3 -3
@@ -0,0 +1,181 @@
1
+ import type Database from "better-sqlite3";
2
+ import type { FeedbackSentiment, FeedbackSource } from "../engine/feedback/reactions.js";
3
+ /**
4
+ * The feedback ledger (issue #255) — 👍/👎 on the bot's own output, scored
5
+ * against the workflow run that produced it.
6
+ *
7
+ * Two tables with one job each (schema + rationale in `migrate.ts`):
8
+ *
9
+ * - **anchors** are the reactable artefacts we posted, each carrying the run it
10
+ * came from. They are how a reaction — which names a *message* — finds a run.
11
+ * - **signals** are the reactions themselves, one row per (anchor, reactor,
12
+ * emoji), with the run attribution denormalized on so no analytics query
13
+ * needs a join.
14
+ *
15
+ * Two invariants worth keeping in mind when extending this:
16
+ *
17
+ * 1. **Ingest is idempotent.** Slack delivers at-least-once and the GitHub
18
+ * poller re-reads the same reactions every tick, so `recordSignal` is an
19
+ * upsert on `(anchor, reactor, emoji)` and callers may replay freely.
20
+ * 2. **A retraction is a fact, not a delete.** Removing a reaction stamps
21
+ * `removed_at`; the row stays. "Somebody thumbed this and then thought
22
+ * better of it" is itself signal, and every scoring query filters on
23
+ * `removed_at IS NULL` rather than relying on the row being gone.
24
+ */
25
+ /** What kind of thing was reacted to. */
26
+ export type FeedbackAnchorKind = "slack_message" | "issue_comment" | "review_comment" | "issue";
27
+ export interface FeedbackAnchor {
28
+ id: string;
29
+ source: FeedbackSource;
30
+ kind: FeedbackAnchorKind;
31
+ externalId: string;
32
+ nodeId: string | null;
33
+ channel: string | null;
34
+ owner: string | null;
35
+ repo: string | null;
36
+ issueNumber: number | null;
37
+ workflowRunId: string | null;
38
+ workflowName: string | null;
39
+ messagingSessionId: string | null;
40
+ createdAt: string;
41
+ lastPolledAt: string | null;
42
+ }
43
+ /** The fields a caller supplies to register an anchor. */
44
+ export type FeedbackAnchorInput = Omit<FeedbackAnchor, "id" | "createdAt" | "lastPolledAt"> & Partial<Pick<FeedbackAnchor, "createdAt">>;
45
+ export interface FeedbackSignal {
46
+ id: string;
47
+ anchorId: string;
48
+ source: FeedbackSource;
49
+ workflowRunId: string | null;
50
+ workflowName: string | null;
51
+ messagingSessionId: string | null;
52
+ owner: string | null;
53
+ repo: string | null;
54
+ issueNumber: number | null;
55
+ emoji: string;
56
+ score: number;
57
+ sentiment: FeedbackSentiment;
58
+ reactor: string | null;
59
+ reactedAt: string | null;
60
+ observedAt: string;
61
+ removedAt: string | null;
62
+ exportedAt: string | null;
63
+ }
64
+ export interface RecordSignalInput {
65
+ anchor: FeedbackAnchor;
66
+ emoji: string;
67
+ score: number;
68
+ sentiment: FeedbackSentiment;
69
+ reactor?: string;
70
+ reactedAt?: string;
71
+ }
72
+ /** One workflow's standing, for the dashboard leaderboard. */
73
+ export interface FeedbackSummaryRow {
74
+ workflowName: string | null;
75
+ /** Every live signal, 👀 included. */
76
+ total: number;
77
+ positive: number;
78
+ negative: number;
79
+ /** Recorded-but-unscored (👀). Excluded from `averageScore`. */
80
+ neutral: number;
81
+ /** Mean over SCORED signals only — a neutral 👀 must not drag it toward 0. */
82
+ averageScore: number;
83
+ }
84
+ export interface FeedbackDailyRow {
85
+ date: string;
86
+ total: number;
87
+ positive: number;
88
+ negative: number;
89
+ averageScore: number;
90
+ }
91
+ export interface FeedbackListOptions {
92
+ limit?: number;
93
+ offset?: number;
94
+ workflowName?: string;
95
+ repo?: string;
96
+ source?: FeedbackSource;
97
+ sinceIso?: string;
98
+ /** Include retracted rows (default false). */
99
+ includeRemoved?: boolean;
100
+ }
101
+ export declare class FeedbackStore {
102
+ private db;
103
+ constructor(db: Database.Database);
104
+ /**
105
+ * Register (or re-register) a reactable artefact. Idempotent on
106
+ * `(source, channel, external_id)`: re-posting the same Slack ts, or
107
+ * re-discovering the same GitHub comment on a later tick, updates the
108
+ * attribution in place rather than forking a second anchor — which would
109
+ * split one comment's reactions across two rows.
110
+ */
111
+ upsertAnchor(input: FeedbackAnchorInput): FeedbackAnchor;
112
+ /** The reverse lookup a reaction hits. */
113
+ findAnchor(source: FeedbackSource, channel: string | null, externalId: string): FeedbackAnchor | null;
114
+ getAnchor(id: string): FeedbackAnchor | null;
115
+ /**
116
+ * The GitHub poller's rotation: anchors still inside the reaction window,
117
+ * least-recently-polled first, capped. Bounding it here rather than in the
118
+ * cron is what keeps the API spend a property of the data (a fixed-size
119
+ * working set) instead of of the schedule.
120
+ */
121
+ anchorsToPoll(opts: {
122
+ windowDays: number;
123
+ limit: number;
124
+ now?: Date;
125
+ }): FeedbackAnchor[];
126
+ markPolled(anchorIds: string[], at?: string): void;
127
+ /** Drop anchors past the retention horizon. Signals are kept — they are the data. */
128
+ pruneAnchors(retentionDays: number, now?: Date): number;
129
+ /**
130
+ * Record one reaction. Returns the signal when it is NEW (or a revival of a
131
+ * retracted one), and null when it was already known — so the caller can emit
132
+ * telemetry exactly once without tracking state itself.
133
+ */
134
+ recordSignal(input: RecordSignalInput): FeedbackSignal | null;
135
+ /** Retract one reaction. Returns true when a live row was actually retracted. */
136
+ removeSignal(anchorId: string, reactor: string | null, emoji: string, at?: string): boolean;
137
+ /**
138
+ * Retract every live signal on an anchor that is NOT in `keep`. The GitHub
139
+ * poller's reconciliation step: a reaction that has disappeared between two
140
+ * batches has no event to announce it, so absence from the fresh read is the
141
+ * only evidence there is.
142
+ */
143
+ reconcileAnchor(anchorId: string, keep: Array<{
144
+ reactor: string | null;
145
+ emoji: string;
146
+ }>): number;
147
+ list(opts?: FeedbackListOptions): {
148
+ signals: FeedbackSignal[];
149
+ total: number;
150
+ };
151
+ /** Every live signal on one run — powers the run-detail badge. */
152
+ forRun(workflowRunId: string): FeedbackSignal[];
153
+ /**
154
+ * Per-workflow standing over the last N days.
155
+ *
156
+ * `averageScore` deliberately averages only over SCORED signals (`score != 0`).
157
+ * 👀 is in the vocabulary at 0 so we can see engagement, but letting it into
158
+ * the mean would make a well-received workflow look mediocre purely because
159
+ * people also glanced at it.
160
+ */
161
+ summaryByWorkflow(days: number, now?: Date): FeedbackSummaryRow[];
162
+ /**
163
+ * Daily score series, zero-filled across the whole window so a chart shows
164
+ * gaps as gaps rather than closing over them. Same UTC key generation as
165
+ * `ExecutionStore.dailyStats`.
166
+ */
167
+ dailyScores(days: number, workflowName?: string, now?: Date): FeedbackDailyRow[];
168
+ /**
169
+ * Signals not yet exported to OTel, oldest first.
170
+ *
171
+ * **Retracted signals are excluded.** A reaction added and then withdrawn
172
+ * while telemetry was off has no `exported_at` and a `removed_at`; exporting
173
+ * it on the backlog drain would put a +1 the person explicitly took back onto
174
+ * the trace, with nothing to say it was withdrawn. The live path never has
175
+ * this problem (a retraction can't reach `exportSignal`), so the gap was
176
+ * only ever reachable through the backfill.
177
+ */
178
+ pendingExport(limit?: number): FeedbackSignal[];
179
+ markExported(ids: string[], at?: string): void;
180
+ private deserializeAnchor;
181
+ }
@@ -0,0 +1,345 @@
1
+ import { randomUUID } from "crypto";
2
+ /** Columns shared by every signal read, aliased snake → camel. */
3
+ const SIGNAL_COLUMNS = `
4
+ id, anchor_id AS anchorId, source, workflow_run_id AS workflowRunId,
5
+ workflow_name AS workflowName, messaging_session_id AS messagingSessionId, owner, repo,
6
+ issue_number AS issueNumber, emoji, score, sentiment, reactor,
7
+ reacted_at AS reactedAt, observed_at AS observedAt, removed_at AS removedAt,
8
+ exported_at AS exportedAt
9
+ `;
10
+ export class FeedbackStore {
11
+ db;
12
+ constructor(db) {
13
+ this.db = db;
14
+ }
15
+ // ── Anchors ────────────────────────────────────────────────────
16
+ /**
17
+ * Register (or re-register) a reactable artefact. Idempotent on
18
+ * `(source, channel, external_id)`: re-posting the same Slack ts, or
19
+ * re-discovering the same GitHub comment on a later tick, updates the
20
+ * attribution in place rather than forking a second anchor — which would
21
+ * split one comment's reactions across two rows.
22
+ */
23
+ upsertAnchor(input) {
24
+ const now = new Date().toISOString();
25
+ const id = randomUUID();
26
+ this.db
27
+ .prepare(`INSERT INTO feedback_anchors
28
+ (id, source, kind, external_id, node_id, channel, owner, repo, issue_number,
29
+ workflow_run_id, workflow_name, messaging_session_id, created_at)
30
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
31
+ ON CONFLICT(source, channel, external_id) DO UPDATE SET
32
+ node_id = COALESCE(excluded.node_id, feedback_anchors.node_id),
33
+ workflow_run_id = COALESCE(excluded.workflow_run_id, feedback_anchors.workflow_run_id),
34
+ workflow_name = COALESCE(excluded.workflow_name, feedback_anchors.workflow_name),
35
+ messaging_session_id = COALESCE(excluded.messaging_session_id, feedback_anchors.messaging_session_id),
36
+ owner = COALESCE(excluded.owner, feedback_anchors.owner),
37
+ repo = COALESCE(excluded.repo, feedback_anchors.repo),
38
+ issue_number = COALESCE(excluded.issue_number, feedback_anchors.issue_number)`)
39
+ .run(id, input.source, input.kind, input.externalId, input.nodeId ?? null, channelKey(input.channel), input.owner ?? null, input.repo ?? null, input.issueNumber ?? null, input.workflowRunId ?? null, input.workflowName ?? null, input.messagingSessionId ?? null, input.createdAt ?? now);
40
+ // Read back rather than trusting `id`: on the conflict branch the existing
41
+ // row keeps its own id, and callers need the one the signals will point at.
42
+ return this.findAnchor(input.source, input.channel ?? null, input.externalId);
43
+ }
44
+ /** The reverse lookup a reaction hits. */
45
+ findAnchor(source, channel, externalId) {
46
+ const row = this.db
47
+ .prepare(`SELECT * FROM feedback_anchors
48
+ WHERE source = ? AND external_id = ? AND channel = ?`)
49
+ .get(source, externalId, channelKey(channel));
50
+ return row ? this.deserializeAnchor(row) : null;
51
+ }
52
+ getAnchor(id) {
53
+ const row = this.db
54
+ .prepare(`SELECT * FROM feedback_anchors WHERE id = ?`)
55
+ .get(id);
56
+ return row ? this.deserializeAnchor(row) : null;
57
+ }
58
+ /**
59
+ * The GitHub poller's rotation: anchors still inside the reaction window,
60
+ * least-recently-polled first, capped. Bounding it here rather than in the
61
+ * cron is what keeps the API spend a property of the data (a fixed-size
62
+ * working set) instead of of the schedule.
63
+ */
64
+ anchorsToPoll(opts) {
65
+ const now = opts.now ?? new Date();
66
+ const cutoff = new Date(now.getTime() - opts.windowDays * 86_400_000).toISOString();
67
+ const rows = this.db
68
+ .prepare(`SELECT * FROM feedback_anchors
69
+ WHERE source = 'github' AND node_id IS NOT NULL AND created_at >= ?
70
+ ORDER BY last_polled_at IS NOT NULL, last_polled_at ASC
71
+ LIMIT ?`)
72
+ .all(cutoff, opts.limit);
73
+ return rows.map((r) => this.deserializeAnchor(r));
74
+ }
75
+ markPolled(anchorIds, at = new Date().toISOString()) {
76
+ if (anchorIds.length === 0)
77
+ return;
78
+ const stmt = this.db.prepare(`UPDATE feedback_anchors SET last_polled_at = ? WHERE id = ?`);
79
+ const tx = this.db.transaction((ids) => {
80
+ for (const id of ids)
81
+ stmt.run(at, id);
82
+ });
83
+ tx(anchorIds);
84
+ }
85
+ /** Drop anchors past the retention horizon. Signals are kept — they are the data. */
86
+ pruneAnchors(retentionDays, now = new Date()) {
87
+ const cutoff = new Date(now.getTime() - retentionDays * 86_400_000).toISOString();
88
+ const res = this.db
89
+ .prepare(`DELETE FROM feedback_anchors WHERE created_at < ?`)
90
+ .run(cutoff);
91
+ return res.changes;
92
+ }
93
+ // ── Signals ────────────────────────────────────────────────────
94
+ /**
95
+ * Record one reaction. Returns the signal when it is NEW (or a revival of a
96
+ * retracted one), and null when it was already known — so the caller can emit
97
+ * telemetry exactly once without tracking state itself.
98
+ */
99
+ recordSignal(input) {
100
+ const { anchor } = input;
101
+ const now = new Date().toISOString();
102
+ const existing = this.db
103
+ .prepare(`SELECT ${SIGNAL_COLUMNS} FROM feedback_signals
104
+ WHERE anchor_id = ? AND reactor IS ? AND emoji = ?`)
105
+ .get(anchor.id, input.reactor ?? null, input.emoji);
106
+ if (existing) {
107
+ // Already live — nothing happened.
108
+ if (!existing.removedAt)
109
+ return null;
110
+ // Reacted, un-reacted, reacted again. Revive the row and let it export
111
+ // again: the person changed their mind twice and both are real events.
112
+ this.db
113
+ .prepare(`UPDATE feedback_signals
114
+ SET removed_at = NULL, observed_at = ?, reacted_at = ?, exported_at = NULL
115
+ WHERE id = ?`)
116
+ .run(now, input.reactedAt ?? now, existing.id);
117
+ return { ...existing, removedAt: null, observedAt: now, exportedAt: null };
118
+ }
119
+ const signal = {
120
+ id: randomUUID(),
121
+ anchorId: anchor.id,
122
+ source: anchor.source,
123
+ workflowRunId: anchor.workflowRunId,
124
+ workflowName: anchor.workflowName,
125
+ messagingSessionId: anchor.messagingSessionId,
126
+ owner: anchor.owner,
127
+ repo: anchor.repo,
128
+ issueNumber: anchor.issueNumber,
129
+ emoji: input.emoji,
130
+ score: input.score,
131
+ sentiment: input.sentiment,
132
+ reactor: input.reactor ?? null,
133
+ reactedAt: input.reactedAt ?? now,
134
+ observedAt: now,
135
+ removedAt: null,
136
+ exportedAt: null,
137
+ };
138
+ this.db
139
+ .prepare(`INSERT INTO feedback_signals
140
+ (id, anchor_id, source, workflow_run_id, workflow_name, messaging_session_id, owner, repo,
141
+ issue_number, emoji, score, sentiment, reactor, reacted_at, observed_at)
142
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
143
+ .run(signal.id, signal.anchorId, signal.source, signal.workflowRunId, signal.workflowName, signal.messagingSessionId, signal.owner, signal.repo, signal.issueNumber, signal.emoji, signal.score, signal.sentiment, signal.reactor, signal.reactedAt, signal.observedAt);
144
+ return signal;
145
+ }
146
+ /** Retract one reaction. Returns true when a live row was actually retracted. */
147
+ removeSignal(anchorId, reactor, emoji, at) {
148
+ const res = this.db
149
+ .prepare(`UPDATE feedback_signals SET removed_at = ?
150
+ WHERE anchor_id = ? AND reactor IS ? AND emoji = ? AND removed_at IS NULL`)
151
+ .run(at ?? new Date().toISOString(), anchorId, reactor, emoji);
152
+ return res.changes > 0;
153
+ }
154
+ /**
155
+ * Retract every live signal on an anchor that is NOT in `keep`. The GitHub
156
+ * poller's reconciliation step: a reaction that has disappeared between two
157
+ * batches has no event to announce it, so absence from the fresh read is the
158
+ * only evidence there is.
159
+ */
160
+ reconcileAnchor(anchorId, keep) {
161
+ const live = this.db
162
+ .prepare(`SELECT id, reactor, emoji FROM feedback_signals
163
+ WHERE anchor_id = ? AND removed_at IS NULL`)
164
+ .all(anchorId);
165
+ const keepKeys = new Set(keep.map((k) => `${k.reactor ?? ""}${k.emoji}`));
166
+ const stale = live.filter((s) => !keepKeys.has(`${s.reactor ?? ""}${s.emoji}`));
167
+ if (stale.length === 0)
168
+ return 0;
169
+ const now = new Date().toISOString();
170
+ const stmt = this.db.prepare(`UPDATE feedback_signals SET removed_at = ? WHERE id = ?`);
171
+ const tx = this.db.transaction((rows) => {
172
+ for (const r of rows)
173
+ stmt.run(now, r.id);
174
+ });
175
+ tx(stale);
176
+ return stale.length;
177
+ }
178
+ // ── Reads ──────────────────────────────────────────────────────
179
+ list(opts = {}) {
180
+ const where = [];
181
+ const params = [];
182
+ if (!opts.includeRemoved)
183
+ where.push("removed_at IS NULL");
184
+ if (opts.workflowName) {
185
+ where.push("workflow_name = ?");
186
+ params.push(opts.workflowName);
187
+ }
188
+ if (opts.repo) {
189
+ where.push("repo = ?");
190
+ params.push(opts.repo);
191
+ }
192
+ if (opts.source) {
193
+ where.push("source = ?");
194
+ params.push(opts.source);
195
+ }
196
+ if (opts.sinceIso) {
197
+ where.push("observed_at >= ?");
198
+ params.push(opts.sinceIso);
199
+ }
200
+ const clause = where.length ? `WHERE ${where.join(" AND ")}` : "";
201
+ const total = this.db
202
+ .prepare(`SELECT COUNT(*) AS n FROM feedback_signals ${clause}`)
203
+ .get(...params).n;
204
+ const signals = this.db
205
+ .prepare(`SELECT ${SIGNAL_COLUMNS} FROM feedback_signals ${clause}
206
+ ORDER BY observed_at DESC LIMIT ? OFFSET ?`)
207
+ .all(...params, opts.limit ?? 50, opts.offset ?? 0);
208
+ return { signals, total };
209
+ }
210
+ /** Every live signal on one run — powers the run-detail badge. */
211
+ forRun(workflowRunId) {
212
+ return this.db
213
+ .prepare(`SELECT ${SIGNAL_COLUMNS} FROM feedback_signals
214
+ WHERE workflow_run_id = ? AND removed_at IS NULL
215
+ ORDER BY observed_at ASC`)
216
+ .all(workflowRunId);
217
+ }
218
+ /**
219
+ * Per-workflow standing over the last N days.
220
+ *
221
+ * `averageScore` deliberately averages only over SCORED signals (`score != 0`).
222
+ * 👀 is in the vocabulary at 0 so we can see engagement, but letting it into
223
+ * the mean would make a well-received workflow look mediocre purely because
224
+ * people also glanced at it.
225
+ */
226
+ summaryByWorkflow(days, now = new Date()) {
227
+ const since = new Date(now.getTime() - days * 86_400_000).toISOString();
228
+ const rows = this.db
229
+ .prepare(`SELECT
230
+ workflow_name AS workflowName,
231
+ COUNT(*) AS total,
232
+ SUM(CASE WHEN score > 0 THEN 1 ELSE 0 END) AS positive,
233
+ SUM(CASE WHEN score < 0 THEN 1 ELSE 0 END) AS negative,
234
+ SUM(CASE WHEN score = 0 THEN 1 ELSE 0 END) AS neutral,
235
+ COALESCE(AVG(CASE WHEN score != 0 THEN score END), 0) AS averageScore
236
+ FROM feedback_signals
237
+ WHERE removed_at IS NULL AND observed_at >= ?
238
+ GROUP BY workflow_name
239
+ ORDER BY total DESC`)
240
+ .all(since);
241
+ return rows.map((r) => ({ ...r, averageScore: round2(r.averageScore) }));
242
+ }
243
+ /**
244
+ * Daily score series, zero-filled across the whole window so a chart shows
245
+ * gaps as gaps rather than closing over them. Same UTC key generation as
246
+ * `ExecutionStore.dailyStats`.
247
+ */
248
+ dailyScores(days, workflowName, now = new Date()) {
249
+ const startUtc = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() - (days - 1)));
250
+ const dateKeys = [];
251
+ for (let i = 0; i < days; i++) {
252
+ const d = new Date(startUtc);
253
+ d.setUTCDate(startUtc.getUTCDate() + i);
254
+ dateKeys.push(d.toISOString().slice(0, 10));
255
+ }
256
+ const params = [dateKeys[0]];
257
+ let filter = "";
258
+ if (workflowName) {
259
+ filter = " AND workflow_name = ?";
260
+ params.push(workflowName);
261
+ }
262
+ const rows = this.db
263
+ .prepare(`SELECT
264
+ date(observed_at) AS date,
265
+ COUNT(*) AS total,
266
+ SUM(CASE WHEN score > 0 THEN 1 ELSE 0 END) AS positive,
267
+ SUM(CASE WHEN score < 0 THEN 1 ELSE 0 END) AS negative,
268
+ COALESCE(AVG(CASE WHEN score != 0 THEN score END), 0) AS averageScore
269
+ FROM feedback_signals
270
+ WHERE removed_at IS NULL AND date(observed_at) >= ?${filter}
271
+ GROUP BY date(observed_at)`)
272
+ .all(...params);
273
+ const byDate = new Map(rows.map((r) => [r.date, r]));
274
+ return dateKeys.map((date) => {
275
+ const row = byDate.get(date);
276
+ return row
277
+ ? { ...row, averageScore: round2(row.averageScore) }
278
+ : { date, total: 0, positive: 0, negative: 0, averageScore: 0 };
279
+ });
280
+ }
281
+ // ── OTel export watermark ──────────────────────────────────────
282
+ /**
283
+ * Signals not yet exported to OTel, oldest first.
284
+ *
285
+ * **Retracted signals are excluded.** A reaction added and then withdrawn
286
+ * while telemetry was off has no `exported_at` and a `removed_at`; exporting
287
+ * it on the backlog drain would put a +1 the person explicitly took back onto
288
+ * the trace, with nothing to say it was withdrawn. The live path never has
289
+ * this problem (a retraction can't reach `exportSignal`), so the gap was
290
+ * only ever reachable through the backfill.
291
+ */
292
+ pendingExport(limit = 200) {
293
+ return this.db
294
+ .prepare(`SELECT ${SIGNAL_COLUMNS} FROM feedback_signals
295
+ WHERE exported_at IS NULL AND removed_at IS NULL
296
+ ORDER BY observed_at ASC LIMIT ?`)
297
+ .all(limit);
298
+ }
299
+ markExported(ids, at = new Date().toISOString()) {
300
+ if (ids.length === 0)
301
+ return;
302
+ const stmt = this.db.prepare(`UPDATE feedback_signals SET exported_at = ? WHERE id = ?`);
303
+ const tx = this.db.transaction((rows) => {
304
+ for (const id of rows)
305
+ stmt.run(at, id);
306
+ });
307
+ tx(ids);
308
+ }
309
+ // ── Deserialization ────────────────────────────────────────────
310
+ deserializeAnchor(row) {
311
+ return {
312
+ id: row.id,
313
+ source: row.source,
314
+ kind: row.kind,
315
+ externalId: row.external_id,
316
+ nodeId: row.node_id ?? null,
317
+ channel: row.channel || null,
318
+ owner: row.owner ?? null,
319
+ repo: row.repo ?? null,
320
+ issueNumber: row.issue_number ?? null,
321
+ workflowRunId: row.workflow_run_id ?? null,
322
+ workflowName: row.workflow_name ?? null,
323
+ messagingSessionId: row.messaging_session_id ?? null,
324
+ createdAt: row.created_at,
325
+ lastPolledAt: row.last_polled_at ?? null,
326
+ };
327
+ }
328
+ }
329
+ function round2(n) {
330
+ return Math.round(n * 100) / 100;
331
+ }
332
+ /**
333
+ * The stored form of `channel`: '' for a surface that has none (GitHub).
334
+ *
335
+ * SQLite treats NULLs as DISTINCT in a UNIQUE constraint, so a nullable channel
336
+ * makes `UNIQUE(source, channel, external_id)` — and the `ON CONFLICT` that
337
+ * targets it — silently inoperative for every GitHub anchor. Normalizing here
338
+ * keeps that one constraint honest for both surfaces without a second upsert
339
+ * path; {@link FeedbackStore.deserializeAnchor} maps it back to null so the
340
+ * type callers see is still `string | null`.
341
+ */
342
+ function channelKey(channel) {
343
+ return channel ?? "";
344
+ }
345
+ //# sourceMappingURL=feedback-store.js.map
@@ -0,0 +1 @@
1
+ {"version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