import { describe, expect, it } from 'vitest';
import { formatSubstrateHandoffPage } from '../src/tier1/substrateHandoff';

describe('SET 94c — substrate handoff packing', () => {
  it('caps the whole page, preserves recent attempts, and discloses elision', () => {
    const page = formatSubstrateHandoffPage({
      classKey: 'assertion|toBe',
      attempts: Array.from({ length: 50 }, (_, i) => ({
        handler: `handler-${i}`,
        status: 'refused',
        reason: `reason ${i} ${'x'.repeat(36)}`,
      })),
      refusals: ['ambiguous site'],
      rejectedCandidates: ['candidate rejected'],
    });

    expect(page.length).toBeLessThanOrEqual(800);
    expect(page).toContain('handler-49');
    expect(page).toContain('elided at cap');
  });
});
