fix: isolate watcher task runtimes

This commit is contained in:
Eyejoker
2026-03-23 07:16:07 +09:00
parent 867a6a80ef
commit 9def49f7fb
14 changed files with 407 additions and 61 deletions

View File

@@ -7,6 +7,9 @@ import {
isValidGroupFolder,
resolveGroupFolderPath,
resolveGroupIpcPath,
resolveGroupSessionsPath,
resolveTaskRuntimeIpcPath,
resolveTaskSessionsPath,
} from './group-folder.js';
describe('group folder validation', () => {
@@ -33,8 +36,24 @@ describe('group folder validation', () => {
expect(resolved).toBe(path.resolve(DATA_DIR, 'ipc', 'family-chat'));
});
it('resolves safe paths under data sessions directory', () => {
const resolved = resolveGroupSessionsPath('family-chat');
expect(resolved).toBe(path.resolve(DATA_DIR, 'sessions', 'family-chat'));
});
it('resolves task-scoped IPC and session paths under the group namespace', () => {
expect(resolveTaskRuntimeIpcPath('family-chat', 'task-123')).toBe(
path.resolve(DATA_DIR, 'ipc', 'family-chat', 'tasks', 'task-123'),
);
expect(resolveTaskSessionsPath('family-chat', 'task-123')).toBe(
path.resolve(DATA_DIR, 'sessions', 'family-chat', 'tasks', 'task-123'),
);
});
it('throws for unsafe folder names', () => {
expect(() => resolveGroupFolderPath('../../etc')).toThrow();
expect(() => resolveGroupIpcPath('/tmp')).toThrow();
expect(() => resolveTaskRuntimeIpcPath('family-chat', '../../etc')).toThrow();
expect(() => resolveTaskSessionsPath('family-chat', '/tmp')).toThrow();
});
});