mirror of
https://github.com/davidkaya/aryx.git
synced 2026-07-24 21:48:36 +02:00
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
94 lines
3.3 KiB
TypeScript
94 lines
3.3 KiB
TypeScript
import { describe, expect, test } from 'bun:test';
|
|
|
|
import { createBuiltinPatterns, validatePatternDefinition } from '@shared/domain/pattern';
|
|
|
|
const BUILTIN_TIMESTAMP = '2026-03-22T00:00:00.000Z';
|
|
|
|
describe('pattern validation', () => {
|
|
test('builtin patterns are valid except explicitly unavailable modes', () => {
|
|
const patterns = createBuiltinPatterns(BUILTIN_TIMESTAMP);
|
|
|
|
const validPatterns = patterns.filter((pattern) => pattern.availability !== 'unavailable');
|
|
|
|
for (const pattern of validPatterns) {
|
|
expect(validatePatternDefinition(pattern)).toEqual([]);
|
|
}
|
|
});
|
|
|
|
test('magentic pattern is marked unavailable', () => {
|
|
const magentic = createBuiltinPatterns(BUILTIN_TIMESTAMP).find(
|
|
(pattern) => pattern.mode === 'magentic',
|
|
);
|
|
|
|
expect(magentic).toBeDefined();
|
|
expect(validatePatternDefinition(magentic!)[0]?.message).toContain('unsupported');
|
|
});
|
|
|
|
test('single-agent mode reports agent count, warning, and model issues together', () => {
|
|
const singlePattern = createBuiltinPatterns(BUILTIN_TIMESTAMP).find(
|
|
(pattern) => pattern.mode === 'single',
|
|
);
|
|
|
|
expect(singlePattern).toBeDefined();
|
|
|
|
const issues = validatePatternDefinition({
|
|
...singlePattern!,
|
|
agents: [
|
|
{
|
|
...singlePattern!.agents[0],
|
|
instructions: ' ',
|
|
},
|
|
{
|
|
...singlePattern!.agents[0],
|
|
id: 'agent-reviewer',
|
|
name: 'Reviewer',
|
|
model: '',
|
|
},
|
|
],
|
|
});
|
|
|
|
expect(issues.find((issue) => issue.field === 'agents')?.message).toBe(
|
|
'Single-agent chat requires exactly one agent.',
|
|
);
|
|
expect(issues.find((issue) => issue.field === 'agents.instructions')?.level).toBe('warning');
|
|
expect(issues.find((issue) => issue.field === 'agents.instructions')?.message).toBe(
|
|
'Agent "Primary Agent" should have instructions.',
|
|
);
|
|
expect(issues.find((issue) => issue.field === 'agents.model')?.message).toBe(
|
|
'Agent "Reviewer" requires a model identifier.',
|
|
);
|
|
});
|
|
|
|
test('multi-agent orchestration modes reject single-agent configurations', () => {
|
|
const patterns = createBuiltinPatterns(BUILTIN_TIMESTAMP);
|
|
const handoff = patterns.find((pattern) => pattern.mode === 'handoff');
|
|
const groupChat = patterns.find((pattern) => pattern.mode === 'group-chat');
|
|
|
|
expect(handoff).toBeDefined();
|
|
expect(groupChat).toBeDefined();
|
|
|
|
expect(
|
|
validatePatternDefinition({
|
|
...handoff!,
|
|
agents: handoff!.agents.slice(0, 1),
|
|
}).find((issue) => issue.field === 'agents')?.message,
|
|
).toBe('Handoff orchestration requires at least two agents.');
|
|
|
|
expect(
|
|
validatePatternDefinition({
|
|
...groupChat!,
|
|
agents: groupChat!.agents.slice(0, 1),
|
|
}).find((issue) => issue.field === 'agents')?.message,
|
|
).toBe('Group chat requires at least two agents.');
|
|
});
|
|
|
|
test('handoff builtin instructions clearly separate triage and specialist ownership', () => {
|
|
const handoff = createBuiltinPatterns(BUILTIN_TIMESTAMP).find((pattern) => pattern.mode === 'handoff');
|
|
|
|
expect(handoff).toBeDefined();
|
|
expect(handoff?.agents[0].instructions).toContain('Do not do the specialist work yourself');
|
|
expect(handoff?.agents[1].instructions).toContain('own the substantive answer');
|
|
expect(handoff?.agents[2].instructions).toContain('own the substantive answer');
|
|
});
|
|
});
|