@axiom-lattice/pg-stores 2.0.2 → 2.0.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiom-lattice/pg-stores",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "PG stores implementation for Axiom Lattice framework",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -25,8 +25,8 @@
25
25
  "@langchain/core": "1.1.30",
26
26
  "pg": "^8.16.3",
27
27
  "uuid": "^9.0.1",
28
- "@axiom-lattice/core": "3.0.2",
29
- "@axiom-lattice/protocols": "3.0.1"
28
+ "@axiom-lattice/core": "3.0.3",
29
+ "@axiom-lattice/protocols": "3.0.2"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/jest": "^29.5.14",
@@ -133,6 +133,9 @@ export const createEvalRunsTable: Migration = {
133
133
  failed_cases INTEGER NOT NULL DEFAULT 0,
134
134
  avg_score FLOAT NOT NULL DEFAULT 0,
135
135
  error TEXT,
136
+ holdout BOOLEAN NOT NULL DEFAULT FALSE,
137
+ env_project_id TEXT,
138
+ env_workspace_id TEXT,
136
139
  created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
137
140
  started_at TIMESTAMPTZ,
138
141
  completed_at TIMESTAMPTZ
@@ -208,6 +211,43 @@ export const createEvalRunResultsTable: Migration = {
208
211
  },
209
212
  };
210
213
 
214
+ /** Add holdout flag to eval runs (existing installs) */
215
+ export const addHoldoutToEvalRuns: Migration = {
216
+ version: 109,
217
+ name: "add_holdout_to_eval_runs",
218
+ up: async (client: PoolClient) => {
219
+ await client.query(`
220
+ ALTER TABLE lattice_eval_runs
221
+ ADD COLUMN IF NOT EXISTS holdout BOOLEAN NOT NULL DEFAULT FALSE
222
+ `);
223
+ },
224
+ down: async (client: PoolClient) => {
225
+ await client.query(`
226
+ ALTER TABLE lattice_eval_runs DROP COLUMN IF EXISTS holdout
227
+ `);
228
+ },
229
+ };
230
+
231
+ /** Add env columns (run environment) to eval runs (existing installs) */
232
+ export const addEnvToEvalRuns: Migration = {
233
+ version: 110,
234
+ name: "add_env_to_eval_runs",
235
+ up: async (client: PoolClient) => {
236
+ await client.query(`
237
+ ALTER TABLE lattice_eval_runs
238
+ ADD COLUMN IF NOT EXISTS env_project_id TEXT,
239
+ ADD COLUMN IF NOT EXISTS env_workspace_id TEXT
240
+ `);
241
+ },
242
+ down: async (client: PoolClient) => {
243
+ await client.query(`
244
+ ALTER TABLE lattice_eval_runs
245
+ DROP COLUMN IF EXISTS env_project_id,
246
+ DROP COLUMN IF EXISTS env_workspace_id
247
+ `);
248
+ },
249
+ };
250
+
211
251
  /** All eval migrations in version order */
212
252
  export const evalMigrations: Migration[] = [
213
253
  createEvalProjectsTable,
@@ -215,4 +255,6 @@ export const evalMigrations: Migration[] = [
215
255
  createEvalCasesTable,
216
256
  createEvalRunsTable,
217
257
  createEvalRunResultsTable,
258
+ addHoldoutToEvalRuns,
259
+ addEnvToEvalRuns,
218
260
  ];
@@ -177,6 +177,9 @@ export class PostgreSQLEvalStore implements EvalStore {
177
177
  failedCases: (row.failed_cases as number) ?? 0,
178
178
  avgScore: (row.avg_score as number) ?? 0,
179
179
  error: row.error as string | undefined,
180
+ holdout: row.holdout as boolean | undefined,
181
+ envProjectId: row.env_project_id as string | undefined,
182
+ envWorkspaceId: row.env_workspace_id as string | undefined,
180
183
  createdAt: new Date(row.created_at as string),
181
184
  startedAt: row.started_at ? new Date(row.started_at as string) : undefined,
182
185
  completedAt: row.completed_at ? new Date(row.completed_at as string) : undefined,
@@ -596,7 +599,7 @@ export class PostgreSQLEvalStore implements EvalStore {
596
599
  `SELECT id, project_id, tenant_id,
597
600
  status, concurrency, total_cases,
598
601
  passed_cases, failed_cases, avg_score,
599
- error, created_at, started_at, completed_at
602
+ error, holdout, env_project_id, env_workspace_id, created_at, started_at, completed_at
600
603
  FROM lattice_eval_runs
601
604
  WHERE ${conditions.join(" AND ")}
602
605
  ORDER BY created_at DESC`,
@@ -618,7 +621,7 @@ export class PostgreSQLEvalStore implements EvalStore {
618
621
  `SELECT id, project_id, tenant_id,
619
622
  status, concurrency, total_cases,
620
623
  passed_cases, failed_cases, avg_score,
621
- error, created_at, started_at, completed_at
624
+ error, holdout, env_project_id, env_workspace_id, created_at, started_at, completed_at
622
625
  FROM lattice_eval_runs
623
626
  WHERE id = $1 AND tenant_id = $2`,
624
627
  [id, tenantId]
@@ -643,12 +646,12 @@ export class PostgreSQLEvalStore implements EvalStore {
643
646
  completed_at: string | null;
644
647
  }>(
645
648
  `INSERT INTO lattice_eval_runs
646
- (id, project_id, tenant_id, status, concurrency, total_cases, passed_cases, failed_cases, avg_score, started_at)
647
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
649
+ (id, project_id, tenant_id, status, concurrency, total_cases, passed_cases, failed_cases, avg_score, holdout, env_project_id, env_workspace_id, started_at)
650
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)
648
651
  RETURNING id, project_id, tenant_id,
649
652
  status, concurrency, total_cases,
650
653
  passed_cases, failed_cases, avg_score,
651
- error, created_at, started_at, completed_at`,
654
+ error, holdout, env_project_id, env_workspace_id, created_at, started_at, completed_at`,
652
655
  [
653
656
  actualId,
654
657
  projectId,
@@ -659,6 +662,9 @@ export class PostgreSQLEvalStore implements EvalStore {
659
662
  0,
660
663
  0,
661
664
  0,
665
+ data.holdout ?? false,
666
+ data.envProjectId || null,
667
+ data.envWorkspaceId || null,
662
668
  new Date(),
663
669
  ]
664
670
  );
@@ -702,7 +708,7 @@ export class PostgreSQLEvalStore implements EvalStore {
702
708
  RETURNING id, project_id, tenant_id,
703
709
  status, concurrency, total_cases,
704
710
  passed_cases, failed_cases, avg_score,
705
- error, created_at, started_at, completed_at`,
711
+ error, holdout, env_project_id, env_workspace_id, created_at, started_at, completed_at`,
706
712
  vals
707
713
  );
708
714
  return rows.length ? this.mapRowToRun(rows[0] as unknown as Record<string, unknown>) : null;