diff --git a/packages/api/session-controller/src/history/controller.ts b/packages/api/session-controller/src/history/controller.ts index 15c49c6a4b..d090f0a3f7 100644 --- a/packages/api/session-controller/src/history/controller.ts +++ b/packages/api/session-controller/src/history/controller.ts @@ -30,12 +30,12 @@ export class HistoryController { } /** - * Read a passive history page at an exact event cut. - * @param request - Session identity and optional historical cut and page window. + * Read a passive page of Session events at an exact cut. + * @param request - Session identity and optional cut and page window. * @param signal - read cancellation. * @returns a page at the supplied cut, or the observed log end when omitted. */ - async history(request: SessionPageRequest, signal: AbortSignal): Promise { + async events(request: SessionPageRequest, signal: AbortSignal): Promise { const spec = resolveHistoryRequest(request) try { return await this.usingObservation({ sessionId: addressId(request.address), projection: request.address.kind === 'subagent' }, signal, (observation) => { diff --git a/packages/api/session-controller/src/index.ts b/packages/api/session-controller/src/index.ts index 43d002e9b8..94d08c77e3 100644 --- a/packages/api/session-controller/src/index.ts +++ b/packages/api/session-controller/src/index.ts @@ -527,7 +527,7 @@ export class SessionController extends TypertRemoteService { */ @Remote('page') page(request: SessionPageRequest, signal: AbortSignal): Promise { - return this.historyController.history(request, signal) + return this.historyController.events(request, signal) } /** @@ -538,7 +538,7 @@ export class SessionController extends TypertRemoteService { */ @Remote events(request: SessionPageRequest, signal: AbortSignal): Promise { - return this.historyController.history(request, signal) + return this.historyController.events(request, signal) } /** diff --git a/packages/api/session-controller/tests/history-controller.host.spec.ts b/packages/api/session-controller/tests/history-controller.host.spec.ts index 2f39beb128..e3592ddbad 100644 --- a/packages/api/session-controller/tests/history-controller.host.spec.ts +++ b/packages/api/session-controller/tests/history-controller.host.spec.ts @@ -94,7 +94,7 @@ describe('HistoryController passive reads', () => { message: createMessage({ role: 'assistant', content: [{ type: 'text', text: 'latest' }], source: { kind: 'model', provider: 'p', model: 'm' } }), stream: [], }, { surfaceOp: 'append' }) - const page = await f.history.history({ address: f.address }, f.abort.signal) + const page = await f.history.events({ address: f.address }, f.abort.signal) expect(page.cursor).toBe(f.session.seq - 1) expect(page.records.at(-1)?.event.seq).toBe(f.session.seq - 1) }) @@ -144,7 +144,7 @@ describe('HistoryController passive reads', () => { const f = await fixture() // A cross-realm or opaque source may reject with the code alone; the message falls back. vi.spyOn(f.ctx.sessionQuery, 'observeSession').mockRejectedValue({ code: 'SESSION_QUERY_ABORTED' }) - await expect(f.history.history({ address: f.address }, f.abort.signal)).rejects.toMatchObject({ + await expect(f.history.events({ address: f.address }, f.abort.signal)).rejects.toMatchObject({ code: 'gateway/cancelled', message: 'Session read was cancelled', }) }) diff --git a/packages/api/session-controller/tests/transport.host.spec.ts b/packages/api/session-controller/tests/transport.host.spec.ts index c35d2f7055..66c7bdb606 100644 --- a/packages/api/session-controller/tests/transport.host.spec.ts +++ b/packages/api/session-controller/tests/transport.host.spec.ts @@ -614,7 +614,7 @@ describe('Session history and Web follow', () => { { version: SESSION_FORMAT_VERSION, id: corruptId, createdAt: 1, cwd: '/workspace', isSeeded: false }, [event('fixture/start', SessionSeq(0)), event('fixture/gap', SessionSeq(2))], ) - await expect(corrupt.history.history({ + await expect(corrupt.history.events({ address: { kind: 'session', sessionId: corruptId }, throughSeq: 1, }, signal())).rejects.toMatchObject({ code: 'SESSION_QUERY_CORRUPT_SESSION' }) for (const maxMessages of [0, 0.5]) { @@ -675,7 +675,7 @@ describe('Session history and Web follow', () => { events: [], }), }) as never) - await expect(first.history.history({ address, throughSeq: -1 }, signal())) + await expect(first.history.events({ address, throughSeq: -1 }, signal())) .rejects.toMatchObject({ code: 'session/not-found' }) const second = await setup() @@ -689,7 +689,7 @@ describe('Session history and Web follow', () => { events: [], }), }) as never) - await expect(second.history.history({ address, throughSeq: -1 }, signal())) + await expect(second.history.events({ address, throughSeq: -1 }, signal())) .rejects.toMatchObject({ code: 'session/not-found' }) }) @@ -704,7 +704,7 @@ describe('Session history and Web follow', () => { isSeeded: false, } cold(ordinaryBench.ctx, ordinaryHeader, [event('turn/start', SessionSeq(0), { turn: 1 })]) - await expect(ordinaryBench.history.history({ + await expect(ordinaryBench.history.events({ address: { kind: 'session', sessionId: ordinaryId }, throughSeq: 0, }, signal())).resolves.toMatchObject({ @@ -730,18 +730,18 @@ describe('Session history and Web follow', () => { } const missing = await setup() cold(missing.ctx, childHeader, []) - await expect(missing.history.history({ address: childAddress, throughSeq: -1 }, signal())) + await expect(missing.history.events({ address: childAddress, throughSeq: -1 }, signal())) .rejects.toMatchObject({ code: 'subagent/catalog-diagnostic', details: { reason: 'corrupt' } }) const corrupt = await setup() cold(corrupt.ctx, childHeader, [event('subagent/descriptor', SessionSeq(0), { version: 'bad' })]) - await expect(corrupt.history.history({ address: childAddress, throughSeq: 0 }, signal())) + await expect(corrupt.history.events({ address: childAddress, throughSeq: 0 }, signal())) .rejects.toMatchObject({ code: 'subagent/catalog-diagnostic', details: { reason: 'corrupt' } }) const ordinaryChild = await setup() const { origin: _origin, ...ordinaryChildHeader } = childHeader cold(ordinaryChild.ctx, ordinaryChildHeader, []) - await expect(ordinaryChild.history.history({ address: childAddress, throughSeq: -1 }, signal())) + await expect(ordinaryChild.history.events({ address: childAddress, throughSeq: -1 }, signal())) .rejects.toMatchObject({ code: 'subagent/unauthorized' }) }) @@ -791,7 +791,7 @@ describe('Session history and Web follow', () => { const session = ordinary.ctx.sessions.create(SessionId('projected'), { meta: { cwd: '/workspace' } }) session.append('turn/start', { turn: 1 }) const ordinarySnapshot = vi.spyOn(ordinary.ctx.sessionProjections, 'snapshot') - const ordinaryPage = await ordinary.history.history({ + const ordinaryPage = await ordinary.history.events({ address: { kind: 'session', sessionId: session.id }, throughSeq: 0, }, signal()) @@ -808,7 +808,7 @@ describe('Session history and Web follow', () => { mode: 'continuable', provider: 'test', label: 'child', })) const childSnapshot = vi.spyOn(child.ctx.sessionProjections, 'snapshot') - const page = await child.history.history({ + const page = await child.history.events({ address: { kind: 'subagent', parentSessionId,