import {
	buildN8nObservationLogReflectorPrompt,
	DEFAULT_REFLECTOR_PROMPT,
	DEFAULT_REFLECTOR_THRESHOLD_TOKENS,
} from '../observation-log-reflector';

describe('n8n observation-log reflector policy', () => {
	it('uses the n8n reflector defaults', () => {
		expect(DEFAULT_REFLECTOR_THRESHOLD_TOKENS).toBe(4_000);
		expect(DEFAULT_REFLECTOR_PROMPT).toContain('Return JSON with two arrays');
		expect(DEFAULT_REFLECTOR_PROMPT).toContain('CRITICAL');
	});

	it('builds the reflector prompt from active log and token budget', () => {
		const prompt = buildN8nObservationLogReflectorPrompt({
			observationScopeId: 'thread-1',
			now: new Date('2026-05-12T15:00:00.000Z'),
			activeObservationLog: [],
			renderedObservationLog:
				'* [obs-1] CRITICAL 2026-05-12T14:30:00.000Z User chose observation-log memory.',
			tokenCount: 42,
			tokenBudget: 8_000,
		});

		expect(prompt).toContain('Current timestamp: 2026-05-12T15:00:00.000Z');
		expect(prompt).not.toContain('Scope:');
		expect(prompt).toContain('Active observation log tokens: 42');
		expect(prompt).toContain('Token budget: 8000');
		expect(prompt).toContain('[obs-1] CRITICAL');
	});
});
