dsh-llm-verifier 0.9.2 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/lib/client.js +73 -18
- package/lib/client.js.map +1 -1
- package/lib/types/client.d.ts +20 -3
- package/lib/types/client.d.ts.map +1 -1
- package/lib/types/client.js +31 -6
- package/lib/types/client.js.map +1 -1
- package/package.json +10 -6
- package/src/cache.test.ts +13 -1
- package/src/client.test.ts +21 -3
- package/src/client.tsx +45 -7
- package/src/topic-storage.test.ts +18 -8
|
@@ -1,21 +1,31 @@
|
|
|
1
|
-
import { dirname, join } from 'node:path'
|
|
1
|
+
import { dirname, join, resolve } from 'node:path'
|
|
2
2
|
import { describe, expect, it } from 'vitest'
|
|
3
3
|
import type { SessionHeader } from '@deepseek-ai/dsh-session'
|
|
4
4
|
import { resolveTopicDataDir } from './topic-storage.ts'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// Fixture roots are built with resolve() so they are ABSOLUTE on every
|
|
7
|
+
// platform. A literal 'C:\\Users\\...' is relative on POSIX, where dirname
|
|
8
|
+
// then operates on cwd + that string and the assertion against the
|
|
9
|
+
// implementation fails while the implementation is correct.
|
|
10
|
+
const header = { id: 'session-test', cwd: resolve('workspace'), createdAt: 1 } as unknown as SessionHeader
|
|
11
|
+
const SESSIONS_ROOT = resolve('sessions-root')
|
|
12
|
+
const DATA_ROOT = resolve('data-root')
|
|
7
13
|
|
|
8
14
|
describe('resolveTopicDataDir', () => {
|
|
9
15
|
it('places verifier files beside the session artifact', () => {
|
|
10
|
-
const artifact = join(
|
|
16
|
+
const artifact = join(SESSIONS_ROOT, 'project', 'session-test', 'session.jsonl.zstd')
|
|
11
17
|
const result = resolveTopicDataDir({ locate: () => ({ path: artifact }) }, header, 'verifier')
|
|
12
18
|
expect(result).toBe(join(dirname(artifact), 'verifier'))
|
|
13
19
|
})
|
|
14
20
|
|
|
15
21
|
it('rejects paths that escape the topic directory', () => {
|
|
16
|
-
const locator = { locate: () => ({ path: join(
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
const locator = { locate: () => ({ path: join(DATA_ROOT, 'session-test', 'session.jsonl') }) }
|
|
23
|
+
// Build the escaping path with join() so it is '../shared' on POSIX and
|
|
24
|
+
// '..\shared' on Windows. A literal '..\shared' is one ordinary segment
|
|
25
|
+
// on POSIX (backslash is not a separator), so it never escapes and the
|
|
26
|
+
// assertion failed there while the implementation was correct.
|
|
27
|
+
expect(() => resolveTopicDataDir(locator, header, join('..', 'shared'))).toThrow(/inside the topic directory/u)
|
|
28
|
+
expect(() => resolveTopicDataDir(locator, header, SESSIONS_ROOT)).toThrow(/relative/u)
|
|
19
29
|
})
|
|
20
30
|
|
|
21
31
|
it('fails closed when the backend cannot locate a topic artifact', () => {
|
|
@@ -24,8 +34,8 @@ describe('resolveTopicDataDir', () => {
|
|
|
24
34
|
})
|
|
25
35
|
|
|
26
36
|
it('falls back to root-based path when locate is missing', () => {
|
|
27
|
-
const result = resolveTopicDataDir({ root:
|
|
28
|
-
expect(result).toBe(join(
|
|
37
|
+
const result = resolveTopicDataDir({ root: DATA_ROOT }, header, 'verifier')
|
|
38
|
+
expect(result).toBe(join(DATA_ROOT, 'session-test', 'verifier'))
|
|
29
39
|
})
|
|
30
40
|
})
|
|
31
41
|
|