@axiom-lattice/local-stores 3.3.0 → 4.0.1
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +45 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/LocalEvalStore.test.ts +13 -0
- package/src/__tests__/LocalTaskStore.test.ts +14 -0
- package/src/stores/LocalEvalStore.ts +10 -0
- package/src/stores/LocalTaskStore.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axiom-lattice/local-stores",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Local SQLite-based stores for Axiom Lattice framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@types/sql.js": "^1.4.11",
|
|
26
26
|
"sql.js": "^1.14.1",
|
|
27
27
|
"uuid": "^14.0.1",
|
|
28
|
-
"@axiom-lattice/core": "
|
|
29
|
-
"@axiom-lattice/protocols": "
|
|
28
|
+
"@axiom-lattice/core": "10.0.1",
|
|
29
|
+
"@axiom-lattice/protocols": "6.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/jest": "^29.5.14",
|
|
@@ -132,4 +132,17 @@ describe("LocalEvalStore project name uniqueness", () => {
|
|
|
132
132
|
it("returns false when deleting a project that does not exist", async () => {
|
|
133
133
|
await expect(store.deleteProject("tenant-1", "missing-project")).resolves.toBe(false);
|
|
134
134
|
});
|
|
135
|
+
it("persists the cooperative eval cancel flag", async () => {
|
|
136
|
+
await store.createRun("tenant-1", "project-1", "run-cancel", {
|
|
137
|
+
concurrency: 1,
|
|
138
|
+
totalCases: 1,
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
await expect(store.requestCancel?.("tenant-1", "run-cancel")).resolves.toBe(true);
|
|
142
|
+
expect((await store.getRunById("tenant-1", "run-cancel"))?.cancelRequested).toBe(true);
|
|
143
|
+
|
|
144
|
+
await store.updateRunStatus("tenant-1", "run-cancel", { status: "completed" });
|
|
145
|
+
await expect(store.requestCancel?.("tenant-1", "run-cancel")).resolves.toBe(false);
|
|
146
|
+
});
|
|
147
|
+
|
|
135
148
|
});
|
|
@@ -59,6 +59,20 @@ describe("LocalTaskStore metadata filter", () => {
|
|
|
59
59
|
expect(byBoolean).toHaveLength(1);
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
+
it("filters tasks by the isolated run thread in context", async () => {
|
|
63
|
+
await store.create({
|
|
64
|
+
tenantId: "t1", ownerType: "agent", ownerId: "agent-1", title: "Worker",
|
|
65
|
+
context: { thread_id: "thread-worker" },
|
|
66
|
+
} as never);
|
|
67
|
+
await store.create({
|
|
68
|
+
tenantId: "t1", ownerType: "agent", ownerId: "agent-1", title: "Other",
|
|
69
|
+
context: { thread_id: "thread-other" },
|
|
70
|
+
} as never);
|
|
71
|
+
|
|
72
|
+
const tasks = await store.list({ tenantId: "t1", threadId: "thread-worker" } as never);
|
|
73
|
+
expect(tasks.map((task) => task.title)).toEqual(["Worker"]);
|
|
74
|
+
});
|
|
75
|
+
|
|
62
76
|
it("matches numeric metadata regardless of stored string/number form", async () => {
|
|
63
77
|
await store.create({
|
|
64
78
|
tenantId: "t1", ownerType: "agent", ownerId: "a1", title: "num", metadata: { retries: 2 },
|
|
@@ -76,6 +76,7 @@ CREATE TABLE IF NOT EXISTS lt_eval_runs (
|
|
|
76
76
|
interrupted_cases INTEGER NOT NULL DEFAULT 0,
|
|
77
77
|
avg_score REAL NOT NULL DEFAULT 0,
|
|
78
78
|
error TEXT,
|
|
79
|
+
cancel_requested INTEGER NOT NULL DEFAULT 0,
|
|
79
80
|
holdout INTEGER NOT NULL DEFAULT 0,
|
|
80
81
|
env_project_id TEXT,
|
|
81
82
|
env_workspace_id TEXT,
|
|
@@ -135,6 +136,7 @@ export class LocalEvalStore implements EvalStore {
|
|
|
135
136
|
this.ensureColumn("lt_eval_run_results", "interrupted", "interrupted INTEGER NOT NULL DEFAULT 0");
|
|
136
137
|
this.ensureColumn("lt_eval_cases", "interrupt_policy", "interrupt_policy TEXT");
|
|
137
138
|
this.ensureColumn("lt_eval_runs", "task_id", "task_id TEXT");
|
|
139
|
+
this.ensureColumn("lt_eval_runs", "cancel_requested", "cancel_requested INTEGER NOT NULL DEFAULT 0");
|
|
138
140
|
// Project name must be unique per tenant (eval-{agent-id} convention).
|
|
139
141
|
// Repoint child rows (suites, runs) of duplicate projects onto the kept
|
|
140
142
|
// project (newest by created_at, tie-break rowid — mirrors the pg
|
|
@@ -455,6 +457,13 @@ export class LocalEvalStore implements EvalStore {
|
|
|
455
457
|
return this.getRunById(tenantId, id);
|
|
456
458
|
}
|
|
457
459
|
|
|
460
|
+
async requestCancel(tenantId: string, id: string): Promise<boolean> {
|
|
461
|
+
const result = this.db.prepare(
|
|
462
|
+
`UPDATE lt_eval_runs SET cancel_requested = 1 WHERE tenant_id = ? AND id = ? AND status = 'running'`,
|
|
463
|
+
).run(tenantId, id);
|
|
464
|
+
return result.changes > 0;
|
|
465
|
+
}
|
|
466
|
+
|
|
458
467
|
async deleteRun(tenantId: string, id: string): Promise<boolean> {
|
|
459
468
|
const result = this.db.prepare(`DELETE FROM lt_eval_runs WHERE tenant_id = ? AND id = ?`).run(tenantId, id);
|
|
460
469
|
return result.changes > 0;
|
|
@@ -612,6 +621,7 @@ export class LocalEvalStore implements EvalStore {
|
|
|
612
621
|
interruptedCases: (row.interrupted_cases as number) ?? 0,
|
|
613
622
|
avgScore: (row.avg_score as number) ?? 0,
|
|
614
623
|
error: row.error as string | undefined,
|
|
624
|
+
cancelRequested: Boolean(row.cancel_requested),
|
|
615
625
|
holdout: row.holdout ? Boolean(row.holdout) : undefined,
|
|
616
626
|
envProjectId: row.env_project_id as string | undefined,
|
|
617
627
|
envWorkspaceId: row.env_workspace_id as string | undefined,
|
|
@@ -200,6 +200,7 @@ export class LocalTaskStore implements TaskStore {
|
|
|
200
200
|
params.push(...statuses);
|
|
201
201
|
}
|
|
202
202
|
if (filter.priority) { conditions.push('priority = ?'); params.push(filter.priority); }
|
|
203
|
+
if (filter.threadId) { conditions.push("json_extract(context, '$.thread_id') = ?"); params.push(filter.threadId); }
|
|
203
204
|
if (filter.workspaceId) { conditions.push('workspace_id = ?'); params.push(filter.workspaceId); }
|
|
204
205
|
if (filter.projectId === null) conditions.push("(project_id IS NULL OR project_id = '' OR project_id = 'default')");
|
|
205
206
|
else if (filter.projectId !== undefined) { conditions.push('project_id = ?'); params.push(filter.projectId); }
|