diff --git a/src/config/sessions/session-accessor.test.ts b/src/config/sessions/session-accessor.test.ts index c64bdd1b71ea..3b7f93c87e5a 100644 --- a/src/config/sessions/session-accessor.test.ts +++ b/src/config/sessions/session-accessor.test.ts @@ -15,7 +15,6 @@ import { createSessionEntryWithTranscript, listSessionEntries, loadSessionEntry, - loadTranscriptEvents, patchSessionEntry, persistSessionResetLifecycle, persistSessionRolloverLifecycle, @@ -709,7 +708,7 @@ describe("session accessor file-backed seam", () => { expect(fs.existsSync(result.previousSessionTranscript.sessionFile ?? "")).toBe(true); }); - it("loads and appends transcript events through a session scope", async () => { + it("appends transcript events through a session scope", async () => { const scope = { sessionFile: transcriptPath, sessionId: "session-1", @@ -724,10 +723,6 @@ describe("session accessor file-backed seam", () => { await appendTranscriptEvent(scope, { type: "session", sessionId: "session-1" }); await appendTranscriptEvent(scope, event); - await expect(loadTranscriptEvents(scope)).resolves.toEqual([ - { type: "session", sessionId: "session-1" }, - event, - ]); expect(fs.statSync(transcriptPath).mode & 0o777).toBe(0o600); }); @@ -890,7 +885,6 @@ describe("session accessor file-backed seam", () => { await appendTranscriptEvent(scope, event); - await expect(loadTranscriptEvents(scope)).resolves.toEqual([event]); // Explicit-artifact writes never touch entry metadata: no entry appears. expect(listSessionEntries({ storePath })).toEqual([]); }); @@ -1353,44 +1347,6 @@ describe("session accessor file-backed seam", () => { expect(fs.existsSync(transcriptPath)).toBe(false); }); - it("loads transcript events without a session key when the read target is explicit", async () => { - const scope = { - sessionFile: transcriptPath, - sessionId: "session-1", - }; - const event = { - payload: { value: "hello" }, - type: "metadata", - }; - - await appendTranscriptEvent( - { - ...scope, - sessionKey: "agent:main:main", - storePath, - }, - event, - ); - - await expect(loadTranscriptEvents(scope)).resolves.toEqual([event]); - }); - - it("loads transcript events from a generated read target without a session key", async () => { - const event = { - payload: { value: "hello" }, - type: "metadata", - }; - - fs.writeFileSync(path.join(tempDir, "session-1.jsonl"), `${JSON.stringify(event)}\n`, "utf-8"); - - await expect( - loadTranscriptEvents({ - sessionId: "session-1", - storePath, - }), - ).resolves.toEqual([event]); - }); - it("appends messages and publishes updates through a session scope", async () => { const scope = { agentId: "main", @@ -1438,17 +1394,6 @@ describe("session accessor file-backed seam", () => { idempotencyKey: "assistant-once", }), }); - await expect(loadTranscriptEvents(scope)).resolves.toEqual([ - expect.objectContaining({ type: "session" }), - expect.objectContaining({ - id: appended.messageId, - message: expect.objectContaining({ - content: "hello", - idempotencyKey: "assistant-once", - }), - type: "message", - }), - ]); expect(updates).toEqual([ { agentId: "main", @@ -1516,22 +1461,6 @@ describe("session accessor file-backed seam", () => { updatedAt: expect.any(Number), }); expect(loadSessionEntry(scope)?.updatedAt).toBeGreaterThanOrEqual(10); - const events = await loadTranscriptEvents({ ...scope, sessionFile: result.sessionFile }); - expect(events).toEqual([ - expect.objectContaining({ type: "session" }), - expect.objectContaining({ - id: result.messages[0]?.messageId, - message: expect.objectContaining({ role: "user", content: "hello" }), - parentId: null, - type: "message", - }), - expect.objectContaining({ - id: result.messages[1]?.messageId, - message: expect.objectContaining({ role: "assistant", content: "hi there" }), - parentId: result.messages[0]?.messageId, - type: "message", - }), - ]); expect(updates).toEqual([ { lineCount: 3, @@ -1600,19 +1529,7 @@ describe("session accessor file-backed seam", () => { }), ]); expect(completed).toBe(true); - const [turnResult] = await results; - - const events = await loadTranscriptEvents({ ...scope, sessionFile: turnResult.sessionFile }); - expect( - events - .filter( - (event): event is { message?: { content?: unknown }; type?: unknown } => - typeof event === "object" && - event !== null && - (event as { type?: unknown }).type === "message", - ) - .map((event) => event.message?.content), - ).toEqual(["batch reply", "queued prompt"]); + await results; }); it("rejects expected-session transcript turns after a queued session rebind", async () => { @@ -1726,13 +1643,6 @@ describe("session accessor file-backed seam", () => { expect.objectContaining({ kind: "header" }), expect.objectContaining({ kind: "id" }), ]); - await expect(loadTranscriptEvents(scope)).resolves.toEqual([ - expect.objectContaining({ type: "session" }), - expect.objectContaining({ - message: expect.objectContaining({ content: "owned batch" }), - type: "message", - }), - ]); }); it("honors thread fallback paths when resolving transcript scope from the store", async () => { @@ -1759,7 +1669,6 @@ describe("session accessor file-backed seam", () => { expect(fs.realpathSync(loadSessionEntry(scope)?.sessionFile ?? "")).toBe( fs.realpathSync(expectedTranscriptPath), ); - await expect(loadTranscriptEvents(scope)).resolves.toEqual([event]); }); it("resolves runtime transcript targets from scope without caller-owned paths", async () => { diff --git a/src/config/sessions/session-accessor.ts b/src/config/sessions/session-accessor.ts index 4842b458c98a..932b03da4725 100644 --- a/src/config/sessions/session-accessor.ts +++ b/src/config/sessions/session-accessor.ts @@ -835,22 +835,6 @@ export async function persistSessionRolloverLifecycle(params: { }; } -/** Reads parsed transcript records from an explicit or derived transcript target. */ -export async function loadTranscriptEvents( - scope: SessionTranscriptAccessScope, -): Promise { - const transcript = await resolveTranscriptReadAccess(scope); - const events: TranscriptEvent[] = []; - for await (const line of streamSessionTranscriptLines(transcript.sessionFile)) { - try { - events.push(JSON.parse(line) as TranscriptEvent); - } catch { - continue; - } - } - return events; -} - /** * Appends a non-message transcript record such as session or metadata events. * Message records must use appendTranscriptMessage so parent links, idempotency, @@ -1767,32 +1751,6 @@ function resolveAccessStorePath(scope: SessionAccessScope): string { }); } -async function resolveTranscriptReadAccess(scope: SessionTranscriptAccessScope): Promise<{ - sessionFile: string; -}> { - if (scope.sessionFile?.trim()) { - return { sessionFile: scope.sessionFile }; - } - if (scope.sessionKey) { - return await resolveTranscriptAccess({ ...scope, sessionKey: scope.sessionKey }); - } - if (scope.storePath) { - return { - sessionFile: resolveSessionTranscriptPathInDir( - scope.sessionId, - path.dirname(path.resolve(scope.storePath)), - scope.threadId, - ), - }; - } - if (scope.agentId) { - return { - sessionFile: resolveSessionTranscriptPath(scope.sessionId, scope.agentId, scope.threadId), - }; - } - throw new Error(`Cannot resolve transcript read scope without a session target`); -} - async function resolveTranscriptAccess(scope: SessionTranscriptWriteScope): Promise<{ sessionFile: string; }> {