@urateam/core 0.1.46 → 0.1.47

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.
@@ -0,0 +1,58 @@
1
+ import { eq } from "drizzle-orm";
2
+ import { triageResults } from "../db/schema.js";
3
+ import { createLogger } from "../logger.js";
4
+ const log = createLogger({ component: "triage-results-store" });
5
+ /**
6
+ * Persist the v2 prediction extracted by triage v2 (affectedFiles, examples,
7
+ * etc.) for an issue. Upsert keyed by `issue_id` so re-triage replaces the
8
+ * prior prediction. Empty `prediction` objects are still written so the
9
+ * runner can distinguish "triage v2 ran but emitted nothing" (record present,
10
+ * no `affectedFiles`) from "triage hasn't run for this issue" (no record).
11
+ *
12
+ * Fail-open: any error is logged and swallowed — telemetry never blocks the
13
+ * triage path.
14
+ */
15
+ export async function upsertTriageResult(db, issueId, prediction) {
16
+ try {
17
+ const json = JSON.stringify(prediction);
18
+ await db
19
+ .insert(triageResults)
20
+ .values({
21
+ issueId,
22
+ v2Prediction: json,
23
+ })
24
+ .onConflictDoUpdate({
25
+ target: triageResults.issueId,
26
+ set: {
27
+ v2Prediction: json,
28
+ triagedAt: new Date(),
29
+ },
30
+ });
31
+ }
32
+ catch (err) {
33
+ log.warn({ err, issueId }, "upsertTriageResult failed");
34
+ }
35
+ }
36
+ /**
37
+ * Read the most recent v2 prediction for an issue. Returns `undefined` when
38
+ * no record exists (no triage v2 run yet) OR when the stored JSON fails to
39
+ * parse (defensive — malformed rows shouldn't crash the runner).
40
+ */
41
+ export async function getTriageResult(db, issueId) {
42
+ try {
43
+ const rows = await db
44
+ .select()
45
+ .from(triageResults)
46
+ .where(eq(triageResults.issueId, issueId))
47
+ .limit(1);
48
+ const row = rows[0];
49
+ if (!row)
50
+ return undefined;
51
+ return JSON.parse(row.v2Prediction);
52
+ }
53
+ catch (err) {
54
+ log.warn({ err, issueId }, "getTriageResult failed — treating as missing");
55
+ return undefined;
56
+ }
57
+ }
58
+ //# sourceMappingURL=triage-results-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"triage-results-store.js","sourceRoot":"","sources":["../../src/pm/triage-results-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,MAAM,GAAG,GAAG,YAAY,CAAC,EAAE,SAAS,EAAE,sBAAsB,EAAE,CAAC,CAAC;AAEhE;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,EAAS,EACT,OAAe,EACf,UAA8B;IAE9B,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QACxC,MAAM,EAAE;aACL,MAAM,CAAC,aAAa,CAAC;aACrB,MAAM,CAAC;YACN,OAAO;YACP,YAAY,EAAE,IAAI;SACnB,CAAC;aACD,kBAAkB,CAAC;YAClB,MAAM,EAAE,aAAa,CAAC,OAAO;YAC7B,GAAG,EAAE;gBACH,YAAY,EAAE,IAAI;gBAClB,SAAS,EAAE,IAAI,IAAI,EAAE;aACtB;SACF,CAAC,CAAC;IACP,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,2BAA2B,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,EAAS,EACT,OAAe;IAEf,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,EAAE;aAClB,MAAM,EAAE;aACR,IAAI,CAAC,aAAa,CAAC;aACnB,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;aACzC,KAAK,CAAC,CAAC,CAAC,CAAC;QACZ,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,CAAC,GAAG;YAAE,OAAO,SAAS,CAAC;QAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAuB,CAAC;IAC5D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,8CAA8C,CAAC,CAAC;QAC3E,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urateam/core",
3
- "version": "0.1.46",
3
+ "version": "0.1.47",
4
4
  "license": "BUSL-1.1",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",