style: clear the lint lane — drop redundant assertions and non-thenable awaits
eslint --fix removed the no-unnecessary-type-assertion hits the review knives introduced; the two await-thenable errors were vi.runAllTicks() awaits in the cache spec, replaced with advanceTimersByTimeAsync(0) (the fake-timer-safe microtask drain). Repo-wide eslint, dual-aggregate tsc, and the focused 100% coverage set all green.
This commit is contained in:
@@ -39,7 +39,7 @@ const marksUnit = (stateVersion = 1): ProjectionDefinition<'cache-test/marks', M
|
|||||||
key: 'cache-test/marks',
|
key: 'cache-test/marks',
|
||||||
schema: z.object({ marks: z.array(z.string()) }),
|
schema: z.object({ marks: z.array(z.string()) }),
|
||||||
init: () => null,
|
init: () => null,
|
||||||
apply: (state, event) => (event.type === 'cache-test/mark' ? (event as SessionEvent<'cache-test/mark'>).data : state),
|
apply: (state, event) => (event.type === 'cache-test/mark' ? (event).data : state),
|
||||||
view: state => state ?? { marks: [] },
|
view: state => state ?? { marks: [] },
|
||||||
stateVersion,
|
stateVersion,
|
||||||
})
|
})
|
||||||
@@ -163,7 +163,7 @@ describe('SessionProjectionCache write policy', () => {
|
|||||||
await vi.advanceTimersByTimeAsync(249)
|
await vi.advanceTimersByTimeAsync(249)
|
||||||
expect(storedRows(pool, session.id)).toBeUndefined()
|
expect(storedRows(pool, session.id)).toBeUndefined()
|
||||||
await vi.advanceTimersByTimeAsync(1)
|
await vi.advanceTimersByTimeAsync(1)
|
||||||
await vi.runAllTicks()
|
await vi.advanceTimersByTimeAsync(0)
|
||||||
expect(storedRows(pool, session.id)?.['cache-test/marks']?.state).toEqual({ marks: ['slow'] })
|
expect(storedRows(pool, session.id)?.['cache-test/marks']?.state).toEqual({ marks: ['slow'] })
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ describe('SessionProjectionCache write policy', () => {
|
|||||||
apply: (state: unknown) => state,
|
apply: (state: unknown) => state,
|
||||||
view: () => null as never,
|
view: () => null as never,
|
||||||
stateVersion: 1,
|
stateVersion: 1,
|
||||||
} as never)
|
})
|
||||||
await expect(ctx.sessionProjectionCache.write(clean)).rejects.toThrow('not losslessly JSON-serializable')
|
await expect(ctx.sessionProjectionCache.write(clean)).rejects.toThrow('not losslessly JSON-serializable')
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@ describe('SessionProjectionCache write policy', () => {
|
|||||||
mark(armed, ['pending']) // timer armed, no write yet
|
mark(armed, ['pending']) // timer armed, no write yet
|
||||||
mark(cleaned, ['done'])
|
mark(cleaned, ['done'])
|
||||||
endTurn(cleaned) // mandatory write; markClean leaves {pending: 0, timer: undefined} in the map
|
endTurn(cleaned) // mandatory write; markClean leaves {pending: 0, timer: undefined} in the map
|
||||||
await vi.runAllTicks()
|
await vi.advanceTimersByTimeAsync(0)
|
||||||
await fiber.dispose()
|
await fiber.dispose()
|
||||||
// The armed timer died with the plugin: advancing time writes nothing.
|
// The armed timer died with the plugin: advancing time writes nothing.
|
||||||
await vi.advanceTimersByTimeAsync(10_000)
|
await vi.advanceTimersByTimeAsync(10_000)
|
||||||
@@ -224,7 +224,7 @@ describe('SessionProjectionCache cold read', () => {
|
|||||||
{ type: 'turn/start', seq: 0, time: 0, data: { turn: 1, trigger: { kind: 'message', source: { kind: 'user' } } } },
|
{ type: 'turn/start', seq: 0, time: 0, data: { turn: 1, trigger: { kind: 'message', source: { kind: 'user' } } } },
|
||||||
]
|
]
|
||||||
for (const m of marks) {
|
for (const m of marks) {
|
||||||
events.push({ type: 'cache-test/mark', seq: events.length, time: events.length, data: { marks: m } } as SessionEvent)
|
events.push({ type: 'cache-test/mark', seq: events.length, time: events.length, data: { marks: m } })
|
||||||
}
|
}
|
||||||
events.push({ type: 'turn/end', seq: events.length, time: events.length, data: { turn: 1, reason: { kind: 'completed' } } })
|
events.push({ type: 'turn/end', seq: events.length, time: events.length, data: { turn: 1, reason: { kind: 'completed' } } })
|
||||||
return events
|
return events
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ export class SessionProjectionRegistry extends Service {
|
|||||||
if (row === undefined || row.stateVersion !== def.stateVersion) continue
|
if (row === undefined || row.stateVersion !== def.stateVersion) continue
|
||||||
values[def.key] = def.schema.parse(def.view(row.state))
|
values[def.key] = def.schema.parse(def.view(row.state))
|
||||||
}
|
}
|
||||||
return values as Partial<SessionProjectionMap>
|
return values
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -352,7 +352,7 @@ export class SessionProjectionRegistry extends Service {
|
|||||||
refreshed[def.key] = { stateVersion: def.stateVersion, observedSeq: endSeq, state }
|
refreshed[def.key] = { stateVersion: def.stateVersion, observedSeq: endSeq, state }
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
snapshot: { asOfSeq: endSeq, values: values as ProjectionSnapshot['values'] },
|
snapshot: { asOfSeq: endSeq, values: values },
|
||||||
checkpoint: refreshed,
|
checkpoint: refreshed,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ describe('SessionProjectionRegistry drive', () => {
|
|||||||
ctx.sessionProjections.register(marksUnit())
|
ctx.sessionProjections.register(marksUnit())
|
||||||
ctx.sessionProjections.register(countUnit())
|
ctx.sessionProjections.register(countUnit())
|
||||||
const tail: SessionEvent[] = [
|
const tail: SessionEvent[] = [
|
||||||
{ type: 'test/mark', seq: 3, time: 3, data: { marks: ['new'] } } as SessionEvent,
|
{ type: 'test/mark', seq: 3, time: 3, data: { marks: ['new'] } },
|
||||||
{ type: 'turn/end', seq: 4, time: 4, data: { turn: 1, reason: { kind: 'completed' } } },
|
{ type: 'turn/end', seq: 4, time: 4, data: { turn: 1, reason: { kind: 'completed' } } },
|
||||||
]
|
]
|
||||||
// marks row usable (watermark 2, tail starts at 3); count row mismatched — but
|
// marks row usable (watermark 2, tail starts at 3); count row mismatched — but
|
||||||
@@ -236,8 +236,8 @@ describe('SessionProjectionRegistry drive', () => {
|
|||||||
// The full-log re-read (baseSeq 0) refolds the mismatched key from init.
|
// The full-log re-read (baseSeq 0) refolds the mismatched key from init.
|
||||||
const full: SessionEvent[] = [
|
const full: SessionEvent[] = [
|
||||||
{ type: 'turn/start', seq: 0, time: 0, data: { turn: 1, trigger: { kind: 'message', source: { kind: 'user' } } } },
|
{ type: 'turn/start', seq: 0, time: 0, data: { turn: 1, trigger: { kind: 'message', source: { kind: 'user' } } } },
|
||||||
{ type: 'test/mark', seq: 1, time: 1, data: { marks: ['old'] } } as SessionEvent,
|
{ type: 'test/mark', seq: 1, time: 1, data: { marks: ['old'] } },
|
||||||
{ type: 'test/mark', seq: 2, time: 2, data: { marks: ['old', '2'] } } as SessionEvent,
|
{ type: 'test/mark', seq: 2, time: 2, data: { marks: ['old', '2'] } },
|
||||||
...tail,
|
...tail,
|
||||||
]
|
]
|
||||||
const { snapshot, checkpoint } = ctx.sessionProjections.restore({
|
const { snapshot, checkpoint } = ctx.sessionProjections.restore({
|
||||||
|
|||||||
Reference in New Issue
Block a user