test(session): align turn-end contract artifacts

This commit is contained in:
_Kerman
2026-08-04 14:09:52 +08:00
parent d4fa26023d
commit e874910a76
186 changed files with 408 additions and 414 deletions

View File

@@ -260,7 +260,7 @@ describe('same-session goal driving', () => {
message: 'Goal round was rejected before entering its step.',
})
expect(test.adapter.requests).toHaveLength(0)
expect(test.agent.session.events.some(event => event.type === 'turn/start')).toBe(false)
expect(test.agent.session.events.some(event => event.type === 'turn/start')).toBe(true)
})
it('does not reserve again when a stopped-goal observer queues cancel-scoped work', async () => {
@@ -744,7 +744,7 @@ describe('same-session goal driving', () => {
await test.agent.whenIdle()
expect(test.adapter.requests).toHaveLength(0)
expect(test.agent.session.events.some(event => event.type === 'turn/start')).toBe(false)
expect(test.agent.session.events.some(event => event.type === 'turn/start')).toBe(true)
})
it('leaves round-zero goal context to the ordinary pre-step chain', async () => {
@@ -1023,7 +1023,7 @@ describe('same-session goal driving', () => {
expect(test.ctx.goals.get(test.agent)).toMatchObject({ phase: 'active', roundsStarted: 0 })
expect(test.adapter.requests).toHaveLength(0)
expect(test.agent.session.events.some(event => event.type === 'turn/start')).toBe(false)
expect(test.agent.session.events.some(event => event.type === 'turn/start')).toBe(true)
})
it('ignores session events without an exact owning agent and retires disposed agent state', async () => {
@@ -1032,7 +1032,7 @@ describe('same-session goal driving', () => {
orphan.append('turn/start', {
turn: 1,
})
orphan.append('turn/end', { turn: 1, step: 0, reason: { kind: 'completed' } })
orphan.append('turn/end', { turn: 1, reason: { kind: 'completed' } })
const handle = await test.ctx.agents.create({
sessionId: SessionId('goal-session-disposed'),

View File

@@ -41,7 +41,7 @@ function appendRound(session: Session, turn: number, content = renderGoalRoundPr
session.append('user/message', createUserMessage({
content, source,
}), { surfaceOp: 'append' })
session.append('turn/end', { turn, step: 0, reason: { kind: 'completed' } })
session.append('turn/end', { turn, reason: { kind: 'completed' } })
}
async function mount(sessionFirst = false): Promise<{ ctx: Context; session: Session }> {
@@ -73,7 +73,7 @@ describe('goal-session prompt invariants', () => {
content: [{ type: 'text', text: 'ordinary human message' }],
source: userSource,
}), { surfaceOp: 'append' })
session.append('turn/end', { turn: 4, step: 0, reason: { kind: 'completed' } })
session.append('turn/end', { turn: 4, reason: { kind: 'completed' } })
const stateSource = {
kind: 'goal', goalId: change.goal.id, revision: change.goal.revision, round: 0,

View File

@@ -74,7 +74,7 @@ function appendRound(session: Session, ref: GoalRef, round: number): void {
session.append('user/message', createUserMessage({
content: [{ type: 'text', text: `round ${round}` }], source,
}), { surfaceOp: 'append' })
session.append('turn/end', { turn, step: 0, reason: { kind: 'completed' } })
session.append('turn/end', { turn, reason: { kind: 'completed' } })
}
describe('GoalService creation and replay', () => {
@@ -582,7 +582,7 @@ describe('goal replay validation', () => {
session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'ordinary' }], source,
}), { surfaceOp: 'append' })
session.append('turn/end', { turn, step: 0, reason: { kind: 'completed' } })
session.append('turn/end', { turn, reason: { kind: 'completed' } })
expect(foldGoal(session.events)).toEqual({ roundsStarted: 0 })
})
@@ -724,7 +724,7 @@ describe('goal replay validation', () => {
session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'missing' }], source,
}), { surfaceOp: 'append' })
session.append('turn/end', { turn, step: 0, reason: { kind: 'completed' } })
session.append('turn/end', { turn, reason: { kind: 'completed' } })
expect(() => foldGoal(session.events)).toThrow('goal message source is invalid')
})

View File

@@ -66,7 +66,7 @@ function openTurn(stub: StubAgent, source: MessageSource, text = 'prompt'): numb
/** Close the currently open test turn. */
function closeTurn(stub: StubAgent, turn: number): void {
stub.session.append('turn/end', { turn, step: 0, reason: { kind: 'completed' } })
stub.session.append('turn/end', { turn, reason: { kind: 'completed' } })
}
async function harness(config: toolGoal.Config = {}) {