fix: redact lineage errors and parse precise times
This commit is contained in:
@@ -97,4 +97,132 @@ describe('tool-session-query with the real SQLite provider', () => {
|
||||
expect(liveEvents.content.map(block => block.type === 'text' ? block.text : '').join('\n'))
|
||||
.toContain('seq 1')
|
||||
})
|
||||
|
||||
it('passes finite fractional epoch-millisecond bounds through SQLite comparisons', async () => {
|
||||
const root = await mkdtemp(join(tmpdir(), 'dsh-tool-session-query-fractional-'))
|
||||
temporaryDirectories.push(root)
|
||||
const ctx = new Context()
|
||||
contexts.push(ctx)
|
||||
await ctx.plugin(SessionStore)
|
||||
await ctx.plugin(SystemPrompt)
|
||||
await ctx.plugin(ToolRegistry)
|
||||
await ctx.plugin(SessionPersistenceJsonl, { root, compression: 'none' })
|
||||
await ctx.plugin(SessionQuerySqlite, { path: join(root, 'session-query.db') })
|
||||
await ctx.plugin(ToolSessionQuery)
|
||||
|
||||
const base = Date.parse('2026-07-24T00:00:00.000Z')
|
||||
const persisted = SessionId('fractional-persisted')
|
||||
await ctx.sessionPersistence.create({
|
||||
version: SESSION_FORMAT_VERSION,
|
||||
id: persisted,
|
||||
createdAt: base,
|
||||
cwd: '/work',
|
||||
})
|
||||
await ctx.sessionPersistence.append(persisted, [
|
||||
{
|
||||
type: 'user/message',
|
||||
seq: 0,
|
||||
time: base + 123,
|
||||
data: {
|
||||
content: [{ type: 'text', text: 'fractional integration needle' }],
|
||||
source: { kind: 'user' },
|
||||
},
|
||||
surfaceOp: 'append',
|
||||
},
|
||||
{
|
||||
type: 'user/message',
|
||||
seq: 1,
|
||||
time: base + 124,
|
||||
data: {
|
||||
content: [{ type: 'text', text: 'fractional integration needle' }],
|
||||
source: { kind: 'user' },
|
||||
},
|
||||
surfaceOp: 'append',
|
||||
},
|
||||
{
|
||||
type: 'user/message',
|
||||
seq: 2,
|
||||
time: -124,
|
||||
data: {
|
||||
content: [{ type: 'text', text: 'pre-epoch fractional needle' }],
|
||||
source: { kind: 'user' },
|
||||
},
|
||||
surfaceOp: 'append',
|
||||
},
|
||||
{
|
||||
type: 'user/message',
|
||||
seq: 3,
|
||||
time: -123,
|
||||
data: {
|
||||
content: [{ type: 'text', text: 'pre-epoch fractional needle' }],
|
||||
source: { kind: 'user' },
|
||||
},
|
||||
surfaceOp: 'append',
|
||||
},
|
||||
])
|
||||
|
||||
const caller = ctx.sessions.create(SessionId('fractional-caller'), {
|
||||
meta: { createdAt: base + 1_000, cwd: '/work' },
|
||||
})
|
||||
let call = 0
|
||||
const execute = (args: unknown) => ctx.tools.execute({
|
||||
name: 'session_event_search',
|
||||
arguments: args,
|
||||
callId: CallId(`fractional-integration-${++call}`),
|
||||
signal: new AbortController().signal,
|
||||
agent: fakeAgent(caller),
|
||||
})
|
||||
|
||||
const lowerBound = await execute({
|
||||
session_id: persisted,
|
||||
query: 'fractional integration needle',
|
||||
time_from: '2026-07-24T00:00:00.12300001Z',
|
||||
})
|
||||
expect(lowerBound.isError).toBe(false)
|
||||
const lowerText = lowerBound.content.map(block => block.type === 'text' ? block.text : '').join('\n')
|
||||
expect(lowerText).toContain('seq 1')
|
||||
expect(lowerText).not.toContain('seq 0')
|
||||
|
||||
const upperBound = await execute({
|
||||
session_id: persisted,
|
||||
query: 'fractional integration needle',
|
||||
time_to: '2026-07-24T08:00:00.1239999+08:00',
|
||||
})
|
||||
expect(upperBound.isError).toBe(false)
|
||||
const upperText = upperBound.content.map(block => block.type === 'text' ? block.text : '').join('\n')
|
||||
expect(upperText).toContain('seq 0')
|
||||
expect(upperText).not.toContain('seq 1')
|
||||
|
||||
const emptySameMillisecond = await execute({
|
||||
session_id: persisted,
|
||||
query: 'fractional integration needle',
|
||||
time_from: '2026-07-24T00:00:00.12300001Z',
|
||||
time_to: '2026-07-24T08:00:00.1239999+08:00',
|
||||
})
|
||||
expect(emptySameMillisecond.isError).toBe(false)
|
||||
expect(emptySameMillisecond.content.map(block => block.type === 'text' ? block.text : '').join('\n'))
|
||||
.toContain('No prior event matches found.')
|
||||
|
||||
const preEpochLower = await execute({
|
||||
session_id: persisted,
|
||||
query: 'pre-epoch fractional needle',
|
||||
time_from: '1969-12-31T23:59:59.87600001Z',
|
||||
})
|
||||
expect(preEpochLower.isError).toBe(false)
|
||||
const preEpochLowerText = preEpochLower.content
|
||||
.map(block => block.type === 'text' ? block.text : '').join('\n')
|
||||
expect(preEpochLowerText).toContain('seq 3')
|
||||
expect(preEpochLowerText).not.toContain('seq 2')
|
||||
|
||||
const preEpochUpper = await execute({
|
||||
session_id: persisted,
|
||||
query: 'pre-epoch fractional needle',
|
||||
time_to: '1969-12-31T19:59:59.8769999-04:00',
|
||||
})
|
||||
expect(preEpochUpper.isError).toBe(false)
|
||||
const preEpochUpperText = preEpochUpper.content
|
||||
.map(block => block.type === 'text' ? block.text : '').join('\n')
|
||||
expect(preEpochUpperText).toContain('seq 2')
|
||||
expect(preEpochUpperText).not.toContain('seq 3')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user