feat(agent): isolate JSONL repository conformance tests

This commit is contained in:
Vegard Stikbakke
2026-08-14 10:48:45 +02:00
parent f43f1ef81d
commit 893d82525f
2 changed files with 43 additions and 41 deletions
@@ -0,0 +1,42 @@
import { describe, it } from "vitest";
import { NodeExecutionEnv } from "../../src/harness/env/nodejs.ts";
import { type JsonlSessionMetadata, JsonlSessionRepo } from "../../src/harness/session/jsonl/index.ts";
import {
type ConformanceCase,
createSessionRepoLifecycleConformance,
createSessionRepoMessageConformance,
} from "../../src/harness/session/testing/index.ts";
import { createTempDir } from "./session-test-utils.ts";
const NOW = 1_700_000_000_000;
const CONFORMANCE_CWD = "/workspace";
function registerConformance(name: string, cases: readonly ConformanceCase[]): void {
describe(name, () => {
for (const group of new Set(cases.map((testCase) => testCase.group))) {
describe(group, () => {
for (const testCase of cases.filter((candidate) => candidate.group === group)) {
it(testCase.name, () => testCase.run());
}
});
}
});
}
let jsonlRepo: JsonlSessionRepo;
async function createConformanceRepo() {
const fileSystem = new NodeExecutionEnv({ cwd: createTempDir() });
jsonlRepo = new JsonlSessionRepo({ fileSystem, sessionsRoot: "sessions", now: () => NOW });
return {
create: (options: { id?: string; parentSessionId?: string }) =>
jsonlRepo.create({ ...options, cwd: CONFORMANCE_CWD }),
open: (metadata: JsonlSessionMetadata) => jsonlRepo.open(metadata),
list: () => jsonlRepo.list({ cwd: CONFORMANCE_CWD }),
delete: (metadata: JsonlSessionMetadata) => jsonlRepo.delete(metadata),
};
}
registerConformance("JsonlSessionRepo conformance", [
...createSessionRepoLifecycleConformance<JsonlSessionMetadata>(createConformanceRepo, () => jsonlRepo.close()),
...createSessionRepoMessageConformance<JsonlSessionMetadata>(createConformanceRepo, () => jsonlRepo.close()),
]);
@@ -1,50 +1,10 @@
import { describe, expect, it } from "vitest";
import { NodeExecutionEnv } from "../../src/harness/env/nodejs.ts";
import {
JSONL_STORAGE_VERSION,
type JsonlSessionMetadata,
JsonlSessionRepo,
} from "../../src/harness/session/jsonl/index.ts";
import {
type ConformanceCase,
createSessionRepoLifecycleConformance,
createSessionRepoMessageConformance,
} from "../../src/harness/session/testing/index.ts";
import { JSONL_STORAGE_VERSION, JsonlSessionRepo } from "../../src/harness/session/jsonl/index.ts";
import { getOrThrow } from "../../src/harness/types.ts";
import { createTempDir } from "./session-test-utils.ts";
const NOW = 1_700_000_000_000;
const CONFORMANCE_CWD = "/workspace";
function registerConformance(name: string, cases: readonly ConformanceCase[]): void {
describe(name, () => {
for (const group of new Set(cases.map((testCase) => testCase.group))) {
describe(group, () => {
for (const testCase of cases.filter((candidate) => candidate.group === group)) {
it(testCase.name, () => testCase.run());
}
});
}
});
}
let jsonlRepo: JsonlSessionRepo;
async function createConformanceRepo() {
const fileSystem = new NodeExecutionEnv({ cwd: createTempDir() });
jsonlRepo = new JsonlSessionRepo({ fileSystem, sessionsRoot: "sessions", now: () => NOW });
return {
create: (options: { id?: string; parentSessionId?: string }) =>
jsonlRepo.create({ ...options, cwd: CONFORMANCE_CWD }),
open: (metadata: JsonlSessionMetadata) => jsonlRepo.open(metadata),
list: () => jsonlRepo.list({ cwd: CONFORMANCE_CWD }),
delete: (metadata: JsonlSessionMetadata) => jsonlRepo.delete(metadata),
};
}
registerConformance("JsonlSessionRepo conformance", [
...createSessionRepoLifecycleConformance<JsonlSessionMetadata>(createConformanceRepo, () => jsonlRepo.close()),
...createSessionRepoMessageConformance<JsonlSessionMetadata>(createConformanceRepo, () => jsonlRepo.close()),
]);
describe("JsonlSessionRepo cwd-scoped lifecycle", () => {
it("persists metadata and filters discovery by cwd", async () => {