mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-09-13 04:03:30 +00:00
chore(session): scope history reader exemptions to tests
This commit is contained in:
@@ -254,13 +254,30 @@ export const longProbe = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 +
|
||||
}
|
||||
}, 90_000)
|
||||
|
||||
it('allows waived Session history reads while rejecting new reads and unrelated deprecations', async () => {
|
||||
it('allows Session history reads only in tests or with existing-call waivers', async () => {
|
||||
const suffix = randomUUID()
|
||||
const configPath = await writeContractConfig(suffix)
|
||||
const path = join(repositoryRoot, 'scripts', `oxlint-contract-${suffix}.ts`)
|
||||
const testPaths = [
|
||||
`packages/core/session/tests/oxlint-contract-${suffix}.ts`,
|
||||
`apps/cli/tests/oxlint-contract-${suffix}.ts`,
|
||||
`scripts/oxlint-contract-${suffix}.spec.ts`,
|
||||
]
|
||||
const productionPaths = [
|
||||
`packages/core/session/src/oxlint-contract-${suffix}.ts`,
|
||||
`scripts/oxlint-contract-${suffix}.ts`,
|
||||
]
|
||||
const paths = [...testPaths, ...productionPaths]
|
||||
const reads = `import { Session, SessionSeq } from '@deepseek-ai/dsh-session'
|
||||
|
||||
export function reads(session: Session): void {
|
||||
session.snapshotEvents()
|
||||
session.eventAt(SessionSeq(0))
|
||||
session.ownEvents()
|
||||
}
|
||||
`
|
||||
const existing = `import { Session, SessionSeq } from '@deepseek-ai/dsh-session'
|
||||
|
||||
export function existingReads(session: Session): void {
|
||||
export function reads(session: Session): void {
|
||||
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
|
||||
session.snapshotEvents()
|
||||
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
|
||||
@@ -269,39 +286,50 @@ export function existingReads(session: Session): void {
|
||||
session.ownEvents()
|
||||
}
|
||||
`
|
||||
const added = `
|
||||
const unrelated = `
|
||||
/** @deprecated Use the replacement API. */
|
||||
function oldApi(): void {}
|
||||
|
||||
export function newReads(session: Session): void {
|
||||
session.snapshotEvents()
|
||||
session.eventAt(SessionSeq(0))
|
||||
session.ownEvents()
|
||||
export function unrelatedRead(): void {
|
||||
oldApi()
|
||||
}
|
||||
`
|
||||
|
||||
try {
|
||||
await writeFile(path, existing)
|
||||
const args = ['--config', relative(repositoryRoot, configPath), '--format', 'unix', relative(repositoryRoot, path)]
|
||||
await Promise.all([
|
||||
...testPaths.map(path => writeFile(join(repositoryRoot, path), reads)),
|
||||
...productionPaths.map(path => writeFile(join(repositoryRoot, path), existing)),
|
||||
])
|
||||
const args = ['--config', relative(repositoryRoot, configPath), '--format', 'unix', ...paths]
|
||||
const allowed = runRepositoryOxlint(args)
|
||||
expect(allowed.error).toBeUndefined()
|
||||
expect(allowed.signal).toBeNull()
|
||||
expect(allowed.status, normalizedOutput(allowed)).toBe(0)
|
||||
|
||||
await writeFile(path, existing + added)
|
||||
await Promise.all([
|
||||
...testPaths.map(path => writeFile(join(repositoryRoot, path), reads + unrelated)),
|
||||
...productionPaths.map(path => writeFile(join(repositoryRoot, path), reads)),
|
||||
])
|
||||
const rejected = runRepositoryOxlint(args)
|
||||
const output = normalizedOutput(rejected)
|
||||
expect(rejected.error).toBeUndefined()
|
||||
expect(rejected.signal).toBeNull()
|
||||
expect(rejected.status, output).toBe(1)
|
||||
expect(output.match(/typescript\(no-deprecated\)/g), output).toHaveLength(4)
|
||||
const diagnostics = output.split('\n').filter(line => line.includes('typescript(no-deprecated)'))
|
||||
for (const path of testPaths) {
|
||||
const reported = diagnostics.filter(line => line.startsWith(`${path}:`))
|
||||
expect(reported, output).toHaveLength(1)
|
||||
expect(reported[0]).toContain('`oldApi` is deprecated')
|
||||
}
|
||||
for (const path of productionPaths) {
|
||||
expect(diagnostics.filter(line => line.startsWith(`${path}:`)), output).toHaveLength(3)
|
||||
}
|
||||
for (const method of ['snapshotEvents', 'eventAt', 'ownEvents', 'oldApi']) {
|
||||
expect(output).toContain(`\`${method}\` is deprecated`)
|
||||
}
|
||||
} finally {
|
||||
await Promise.all([
|
||||
rm(path, { force: true }),
|
||||
...paths.map(path => rm(join(repositoryRoot, path), { force: true })),
|
||||
rm(configPath, { force: true }),
|
||||
])
|
||||
}
|
||||
|
||||
@@ -82,7 +82,6 @@ describe('advanced Python snapshot workflow ordering', () => {
|
||||
const child = await entered.promise
|
||||
expect(child.id).toBe(run.id)
|
||||
expect(adapter.requests).toHaveLength(0)
|
||||
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
|
||||
expect(child.session.snapshotEvents().some(event => event.type === 'subagent/descriptor')).toBe(false)
|
||||
parent.session.append('tool-workflow/agent-start', {
|
||||
runId: WorkflowRunId('run'), seq: 1, label: 'workflow-child', childId: child.id,
|
||||
|
||||
Reference in New Issue
Block a user