fix(session): validate seeded projection boundary

This commit is contained in:
pku-xht
2026-08-27 05:21:41 +08:00
parent a5330ecf99
commit 57d8a79bfe
2 changed files with 5 additions and 1 deletions
@@ -199,8 +199,8 @@ export class SessionProjectionRegistry extends Service {
constructor(ctx: Context) {
super(ctx, 'sessionProjections')
ctx.on('session/created', (session: Session) => {
if (session.seq !== 0) return
validateSeedLength(session.header, session.seq)
if (session.seq !== 0) return
for (const registration of this.registrations.values()) {
if (registration.cells.has(session)) continue
registration.cells.set(session, {
@@ -152,6 +152,10 @@ describe('SessionProjectionRegistry drive', () => {
expect(() => ctx.sessions.create(undefined, {
meta: { seedLength: 1 },
})).toThrow(/seedLength 1 exceeds observed log length 0/)
expect(() => ctx.sessions.create(undefined, {
seed: [{ type: 'turn/start', seq: 0, time: 0, data: { turn: 1 } }],
meta: { seedLength: 3 },
})).toThrow(/seedLength 3 exceeds observed log length 2/)
})
it('notifies onChanged with the validated view and the causing seq, and skips same-reference applies', async () => {